Exemple #1
0
        public void RemoveConstruction(Vector2Int position)
        {
            var room = Rooms[position];

            if (room != null && room.Type == RoomTypes.Construction)
            {
                Rooms.RemoveAt(position);
                Rooms.Add(new BuildingSpotData {
                    Position = position
                });
            }

            OnNestRebuilt?.Invoke();
        }
Exemple #2
0
        public void SetUpgradeRoom(AbNestRoomData room, bool value)
        {
            if (room.CanUpgrade && value)
            {
                room.IsUpgrading = true;

                OnNestRebuilt?.Invoke();
            }
            else if (!value)
            {
                room.IsUpgrading = false;

                OnNestRebuilt?.Invoke();
            }
        }
Exemple #3
0
        public bool AddConstruction(RoomTypes type, Vector2Int position)
        {
            if (!CanBuild(type, position))
            {
                return(false);
            }

            Rooms.RemoveAt(position);
            Rooms.Add(new ConstructionData {
                Position = position, TargetType = type
            });

            OnNestRebuilt?.Invoke();

            return(true);
        }
Exemple #4
0
        public void Build(RoomTypes type, Vector2Int position)
        {
            if (type == RoomTypes.Construction)
            {
                return;
            }

            var room = Rooms[position];

            if (room == null || room.Type != RoomTypes.Construction || (room as ConstructionData).TargetType != type)
            {
                return;
            }

            Rooms.RemoveAt(position);
            switch (type)
            {
            case RoomTypes.Entrance:
                Rooms.Add(new EntranceData {
                    Position = position
                });
                break;

            case RoomTypes.BuildingSpot:
                Rooms.Add(new BuildingSpotData {
                    Position = position
                });
                break;

            case RoomTypes.Warehause:
                Rooms.Add(new WarehouseData {
                    Position = position
                });
                break;

            case RoomTypes.Nursery:
                Rooms.Add(new NurseryData {
                    Position = position
                });
                break;

            case RoomTypes.Armory:
                Rooms.Add(new ArmoryData {
                    Position = position
                });
                break;

            default:
                break;
            }

            for (int y = 0; y <= 1; y++)
            {
                for (int x = -1; x <= 1; x++)
                {
                    if (Mathf.Abs(x) == Mathf.Abs(y))
                    {
                        continue;
                    }

                    var pos = position + new Vector2Int(x, y);

                    if (Rooms[pos] == null && Rooms.ContainsLocation(pos))
                    {
                        Rooms.Add(new BuildingSpotData {
                            Position = pos
                        });
                    }
                }
            }

            OnNestRebuilt?.Invoke();
        }