Exemplo n.º 1
0
 public void Init()
 {
     tm         = TileMapInterfacer.Instance.TileMap;
     FogObjects = new GameObject[tm.size_x, tm.size_z];
 }
        static Vector2[] GetRandomGoldTiles(int amount)
        {
            //The general algorithm is to split the gold into 5 different parts.
            //Each player gets amount / 5 gold at his sector, with the last odd one out
            //splitting up to everyone.

            //Vector2[] goldTiles = new Vector2[amount];
            List <Vector2> goldTiles  = new List <Vector2>();
            TileMap        theTileMap = TileMapInterfacer.Instance.TileMap;

            //Player 1 amount
            for (int i = 0; i < amount / 5; i++)
            {
                Vector2 temp;
                do
                {
                    temp = new Vector2(Random.Range(1, theTileMap.size_x / 2), Random.Range(1, theTileMap.size_z / 2));
                }while (goldTiles.Contains(temp) || (theTileMap.theMap.GetTileAt(temp) is Noblock));

                goldTiles.Add(temp);
            }
            for (int i = 0; i < amount / 5; i++)
            {
                Vector2 temp;
                do
                {
                    temp = new Vector2(Random.Range(1, theTileMap.size_x / 2), Random.Range(theTileMap.size_z / 2, theTileMap.size_z - 2));
                }while (goldTiles.Contains(temp) || (theTileMap.theMap.GetTileAt(temp) is Noblock));

                goldTiles.Add(temp);
            }
            for (int i = 0; i < amount / 5; i++)
            {
                Vector2 temp;
                do
                {
                    temp = new Vector2(Random.Range(theTileMap.size_x / 2, theTileMap.size_x - 2), Random.Range(1, theTileMap.size_z / 2));
                }while (goldTiles.Contains(temp) || (theTileMap.theMap.GetTileAt(temp) is Noblock));

                goldTiles.Add(temp);
            }
            for (int i = 0; i < amount / 5; i++)
            {
                Vector2 temp;
                do
                {
                    temp = new Vector2(Random.Range(theTileMap.size_x / 2, theTileMap.size_x - 2), Random.Range(theTileMap.size_z / 2, theTileMap.size_z - 2));
                }while (goldTiles.Contains(temp) || (theTileMap.theMap.GetTileAt(temp) is Noblock));

                goldTiles.Add(temp);
            }
            for (int i = 0; i < amount / 5; i++)
            {
                Vector2 temp;
                do
                {
                    temp = new Vector2(Random.Range(1, theTileMap.size_x - 1), Random.Range(1, theTileMap.size_z - 2));
                }while (goldTiles.Contains(temp) || (theTileMap.theMap.GetTileAt(temp) is Noblock));

                goldTiles.Add(temp);
            }

            return(goldTiles.ToArray());
        }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     theMeshRenderer = GetComponent <MeshRenderer>();
     _tileMap        = GetComponent <TileMap>();
     theCollider     = GetComponent <Collider>();
 }