Exemplo n.º 1
0
 public void ClearBuildingSelection()
 {
     if (SelectedBuilding != null)
     {
         SelectedBuilding.Holder.GetComponent <SpriteRenderer>().sprite
             = Sprites.Current.UsualPlain;
         SelectedBuilding = null;
     }
 }
Exemplo n.º 2
0
        public void SelectBuilding(Vector position)
        {
            ClearBuildingSelection();

            SelectedBuilding = this[position];

            SelectedBuilding.Holder.GetComponent <SpriteRenderer>().sprite
                = Sprites.Current.SelectedPlain;
        }
Exemplo n.º 3
0
        public void ShowArea(Vector areaPosition, BuildingAreaDto[,] buildings)
        {
            foreach (
                var childTransform
                in GameObjects.Current.BuildingsContainer.transform
                .GetComponentsInChildren <Transform>()
                .Where(c => c.gameObject != GameObjects.Current.BuildingsContainer))
            {
                Destroy(childTransform.gameObject);
            }

            for (var x = 0; x < buildings.GetLength(0); x++)
            {
                for (var y = 0; y < buildings.GetLength(1); y++)
                {
                    var b = buildings[x, y];

                    var buildingAbsolutePosition = areaPosition * AreaWidth + new Vector(x, y);

                    Debug.Log("World width: " + Buildings.GetLength(0) + ", Position: " + buildingAbsolutePosition);

                    var image
                          = this[buildingAbsolutePosition]
                          = new BuildingImage
                        {
                        Holder = Instantiate(
                            Prefabs.Current.Holder,
                            new Vector3(0, 0, -1),
                            new Quaternion(),
                            GameObjects.Current.BuildingsContainer.transform),
                        Position = buildingAbsolutePosition,
                        Name     = b.Name,
                        };

                    image.Flag = Instantiate(
                        Prefabs.Current.Flag,
                        Vector3.zero,
                        new Quaternion())
                                 .GetComponent <SpriteRenderer>();

                    SetBuilding(buildingAbsolutePosition, b.Name, b.OwnerName);

                    image.Flag.transform.SetParent(image.Building.transform, false);

                    image.Indicator =
                        Instantiate(
                            Prefabs.Current.BuildingTimer,
                            image.Building.transform.position
                            + new Vector3(0, -0.15f * image.Building.transform.localScale.y, -1),
                            new Quaternion(),
                            image.Building.transform)
                        .GetComponent <Indicator>();

                    if (b.BuildingTime > TimeSpan.Zero)
                    {
                        image.Indicator.Manager = new Timer(b.BuildingTime);
                    }

                    image.Indicator.Hunger = b.ArePeopleHungry;

                    if (b.IsThereArmy)
                    {
                        SetArmy(buildingAbsolutePosition);
                    }

                    image.Holder
                    .GetComponent <IsometricController>()
                    .IsometricPosition = buildingAbsolutePosition.ToVector2();
                }
            }
        }