Esempio n. 1
0
        public GameObject CreateDecor(Main main)
        {
            GameObject parent = new GameObject ("Decor");
            int count = UnityEngine.Random.Range(minCount, maxCount + 1);
            LocationTiles tempTiles = new LocationTiles (main.Tiles);

            for (int i = 0; i < count; i++) {
                Point<int> point = tempTiles.GetFreeRandomPoint (1, 1, 0, 0, 0);
                if (point == null) {
                    Debug.Log("no more place for decor");
                    break;
                }

                Sprite sprite = Sprites[UnityEngine.Random.Range(0, Sprites.Length)];
                GameObject decor = new GameObject("Decor " + sprite.name);

                float scale = main.SourceGraphicsScale;
                decor.AddComponent<SpriteRenderer>().sprite = sprite;
                decor.transform.SetParent(parent.transform, true);
                decor.transform.localScale = new Vector3(scale* (UnityEngine.Random.value > 0.5f ? 1 : -1), scale, 1);
                decor.transform.localPosition = new Vector3(point.x * main.TileSize + main.TileSize / 2, point.y * main.TileSize + main.TileSize / 2 + scale * sprite.bounds.size.y / 2, 0);
                decor.GetComponent<SpriteRenderer>().sortingOrder = LocationSortOrders.GetLocationObjectSortOrder(point.y * main.TileSize + main.TileSize / 2);
                tempTiles.Set(point.x, point.y, TileType.Forbidden);
            }
            return parent;
        }
Esempio n. 2
0
        public GameObject CreateDecor(Main main)
        {
            GameObject    parent    = new GameObject("Decor");
            int           count     = UnityEngine.Random.Range(minCount, maxCount + 1);
            LocationTiles tempTiles = new LocationTiles(main.Tiles);

            for (int i = 0; i < count; i++)
            {
                Point <int> point = tempTiles.GetFreeRandomPoint(1, 1, 0, 0, 0);
                if (point == null)
                {
                    Debug.Log("no more place for decor");
                    break;
                }

                Sprite     sprite = Sprites[UnityEngine.Random.Range(0, Sprites.Length)];
                GameObject decor  = new GameObject("Decor " + sprite.name);

                float scale = main.SourceGraphicsScale;
                decor.AddComponent <SpriteRenderer>().sprite = sprite;
                decor.transform.SetParent(parent.transform, true);
                decor.transform.localScale    = new Vector3(scale * (UnityEngine.Random.value > 0.5f ? 1 : -1), scale, 1);
                decor.transform.localPosition = new Vector3(point.x * main.TileSize + main.TileSize / 2, point.y * main.TileSize + main.TileSize / 2 + scale * sprite.bounds.size.y / 2, 0);
                decor.GetComponent <SpriteRenderer>().sortingOrder = LocationSortOrders.GetLocationObjectSortOrder(point.y * main.TileSize + main.TileSize / 2);
                tempTiles.Set(point.x, point.y, TileType.Forbidden);
            }
            return(parent);
        }
Esempio n. 3
0
 void Awake()
 {
     TileSize            = 2;
     SourceGraphicsScale = TileSize / 0.4f;
     Tiles = new LocationTiles(UnityEngine.Random.Range(7, 12), UnityEngine.Random.Range(5, 10));
     LocationWidthInMeters  = Tiles.Width * TileSize;
     LocationHeightInMeters = Tiles.Height * TileSize;
 }
Esempio n. 4
0
 void Awake()
 {
     TileSize = 2;
     SourceGraphicsScale = TileSize / 0.4f;
     Tiles = new LocationTiles (UnityEngine.Random.Range(7, 12), UnityEngine.Random.Range(5, 10));
     LocationWidthInMeters = Tiles.Width * TileSize;
     LocationHeightInMeters = Tiles.Height * TileSize;
 }
Esempio n. 5
0
 public LocationTiles(LocationTiles other)
 {
     this.Width = other.Width;
     this.Height = other.Height;
     for (int i = 0; i < Width; i++) {
         tiles[i] = new Dictionary<int, TileType>();
         for (int j = 0; j < Height; j++) {
             tiles[i][j] = other.tiles[i][j];
         }
     }
 }
Esempio n. 6
0
 public LocationTiles(LocationTiles other)
 {
     this.Width  = other.Width;
     this.Height = other.Height;
     for (int i = 0; i < Width; i++)
     {
         tiles[i] = new Dictionary <int, TileType>();
         for (int j = 0; j < Height; j++)
         {
             tiles[i][j] = other.tiles[i][j];
         }
     }
 }