Skip to content

Commit

Permalink
Manual blanch merging
Browse files Browse the repository at this point in the history
  • Loading branch information
dpeter99 committed Aug 3, 2015
1 parent affd329 commit de00270
Show file tree
Hide file tree
Showing 58 changed files with 298 additions and 480 deletions.
54 changes: 46 additions & 8 deletions Assets/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,69 @@ public class GameController : MonoBehaviour
{

public Map map;
public Player playerclass;

//map Load
public Sprite[] sprites;
public GameObject mapPiece;
public float tileSize;
public Vector2 posMultiplyer;


//Ore gen
public float orePercent;
public float oreReducer;

//UI
public GUIHandler guiHandler;
//Base GUI
public GameObject load;
public GameObject menu;
public Text bar;
public float loadProgress;


public bool MapLoaded = false;
public bool gameIsOn = false;

void Awake()
{
DontDestroyOnLoad(transform.gameObject);
}

void OnLevelWasLoaded(int level)
{
if (level == 1)
{
guiHandler = GameObject.Find("_GUIHandler").GetComponent<GUIHandler>();
playerclass = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
}

}

public void Update()
{
if (Application.loadedLevelName == "Main" && !MapLoaded)
if (Application.loadedLevelName == "Main" && !gameIsOn)
{

Debug.Log("Jeej!");

sprites = Resources.LoadAll<Sprite>("Texturas");

Tile[,] t = TerrainGen.Generate(orePercent, oreReducer, 1245);
Tile[,] t = TerrainGen.Generate(orePercent, oreReducer, 666421, 2);



map = new Map(t);
Debug.Log(t.Length == null);
Debug.Log(map.mapArray == null);

MapLoad.MapDraw(map, mapPiece, sprites, tileSize);

MapLoaded = true;
gameIsOn = true;

Camera.main.GetComponent<CameraChase>().MapLoaded();
}
}


public void StartGame()
{

Expand All @@ -72,8 +89,8 @@ public IEnumerator LoadLevel(string a)

//while (!async.isDone)
//{
loadProgress = async.progress * 100;
bar.text = loadProgress + "!!";
loadProgress = async.progress * 100;
bar.text = loadProgress + "!!";

yield return async;
//}
Expand All @@ -82,5 +99,26 @@ public IEnumerator LoadLevel(string a)

}

public void TogleInventory()
{
if (!(guiHandler.inventoryOn))
{
Debug.Log("Opening");
guiHandler.actionGroup.SetActive(false);
guiHandler.InventoryDisplay.gameObject.SetActive(true);
playerclass.gameObject.GetComponent<Rigidbody2D>().isKinematic = true;
guiHandler.inventoryOn = true;
return;
}
else
{
Debug.Log("Closing");
guiHandler.actionGroup.SetActive(true);
guiHandler.InventoryDisplay.gameObject.SetActive(false);
playerclass.gameObject.GetComponent<Rigidbody2D>().isKinematic = false;
guiHandler.inventoryOn = false;
return;
}
}

}
Binary file removed Assets/Main.unity
Binary file not shown.
4 changes: 2 additions & 2 deletions Assets/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class Map

public Map(Tile[,] inmap)
{
mapHeight = (int)Math.Sqrt(inmap.Length);
this.mapHeight = (int)Math.Sqrt(inmap.Length);

mapArray = new Tile[mapHeight, mapHeight, 2];
this.mapArray = new Tile[mapHeight, mapHeight, 2];

for (int i = 0; i < mapHeight; i++)
{
Expand Down
15 changes: 13 additions & 2 deletions Assets/MapLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static void MapDraw(Map map, GameObject mapPiece, Sprite[] sprites, float

//Debug.Log(xPos + "," + yPos);

GameObject go = GameObject.Instantiate(mapPiece);

GameObject go = GameObject.Instantiate(mapPiece);
go.name = "Tile_" + xPos + "_" + yPos;
SpriteRenderer curr = go.GetComponent<SpriteRenderer>();

curr.sprite = sprites[((int)map.mapArray[xPos, yPos, 0].type)];
Expand All @@ -58,4 +58,15 @@ public static void MapDraw(Map map, GameObject mapPiece, Sprite[] sprites, float
}
}


public static void MapUpdate(int x, int y, Map map)
{
Sprite[] sprites = Resources.LoadAll<Sprite>("Texturas");

GameObject go = GameObject.Find("Tile_" + x + "_" + y);
SpriteRenderer curr = go.GetComponent<SpriteRenderer>();

curr.sprite = sprites[((int)map.mapArray[x, y, 0].type)];

}
}
79 changes: 0 additions & 79 deletions Assets/Ore.cs

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Assets/Resources/Texturas/1.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/SandOre.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class SandOre : Ore
{
}
File renamed without changes.
Binary file renamed Assets/Start.unity → Assets/Scenes/Start.unity
Binary file not shown.
File renamed without changes.
11 changes: 6 additions & 5 deletions Assets/TerrainGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ public class TerrainGen{



public static Tile[,] Generate(float h, float reduce , int seed)
public static Tile[,] Generate(float h, float reduce , int seed,int maxOre)
{

FileStream file = new FileStream("./file.txt", FileMode.Create);
StreamWriter wf = new StreamWriter(file);


int gen = 50;
float[,] h2 = new float[,] { {3f, 15f}, {2f,20f}, {1f,22f}, {0.2f,30f}, {0.1f,40f}, {0.001f,45}};
System.Random rand = new System.Random(5000);
System.Random rand = new System.Random(seed);

Tile[,] map = new Tile[50, 50];
Tile initial;
Expand All @@ -26,22 +27,22 @@ public class TerrainGen{
{
for (int j = 0; j < gen; j++)
{
map[i, j] = new Tile(OreType.Surface, i, j);
map[i, j] = new Tile(i, j);
}
}

for (int i = 0; i < gen; i++)
{
for (int j = 0; j < gen; j++)
{
initial = new Ore(rand, i, j);
initial = new OreTile(rand, i, j, maxOre);
h = h2[(int)initial.type,0];
reduce = h2[(int)initial.type, 1];
if (rand.Next(0, 100) <= h && !t)
{
map[i, j] = initial;

map = ((Ore)map[i, j]).Spread(map, h, rand, reduce);
map = ((OreTile)map[i, j]).Spread(map, h, rand, reduce, rand.Next(1,maxOre));

t = false;
}
Expand Down
Loading

0 comments on commit de00270

Please sign in to comment.