Exemple #1
0
    public void Interact(RaycastHit hit)
    {
        switch (state)
        {
        case InnerState.Placing:

            // If it can not be placed simply break
            if (canPlace == false)
            {
                break;
            }

            // otherwise set the state to the next state and save the MousePosition for the rotation
            state = InnerState.Rotating;
            rotateAroundMosPos = Input.mousePosition;

            break;

        case InnerState.Rotating:

            // If the building can not be placed then simply break
            if (canPlace == false)
            {
                break;
            }

            // Add it to the town. If there are not enough resources then delete the building
            Town town = TownDict.Instance.Towns[0];     // TODO: Replace if multiple towns are allowed
            if (town.Supplies.AdjustAmount(Cost) == false)
            {
                UIManager.Instance.DisplayEvent(ToyEvent.NotEnoughResources);
                DeSelect();
                return;
            }
            town.AddBuilding(building);

            // Set the state to the placed state
            state = InnerState.Placed;

            // Deselect the building from the camera controller
            if (CameraController.Instance.DeSelect(this) == false)
            {
                DeSelect();
            }

            // Reenable all colliders
            for (int i = 0; i < colliders.Count; i++)
            {
                colliders[i].enabled = true;
            }

            buildingsSelectable = GetComponent <IBuildingsSelectable>();
            SetOutlineColor(0);

            building.OnBuildingPlaced();

            break;
        }
    }
Exemple #2
0
        public Building(Town town, Sprite sprite, bool inConstruction = true)
            : base()
        {
            town.AddBuilding(this);

            _mutex = new Semaphore(1, 1);

            IsSolid        = true;
            IsBig          = true;
            ObjectSprite   = sprite;
            InConstruction = inConstruction;
            ResourcesSpent = !inConstruction;
            Progress       = 0;
            //LastGameTime = new TimeSpan();
            //BuildTime = new TimeSpan(0, 0, 5);
        }
Exemple #3
0
        public static void Main()
        {
            //IO
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter(Constants.ConsoleHeight, Constants.ConsoleWidth);

            //player
            IPlayer player = new Player("Pesho")
            {
                Inventory = new List <IItem>
                {
                    new Axe(1, "Cepeni4kata", 99, Rarity.Common),
                    new Hammer(2, "Za dinozavrite", 15, Rarity.Epic),
                    new Sword(3, "Me4a na Ahil", 15, Rarity.Epic),
                    new Booklet(4, "Priklu4eniq", 15, Rarity.Epic),
                    new Sneaker(5, "Adidas", 15, Rarity.Epic),
                    new Sneaker(6, "Nike", 15, Rarity.Epic),
                    new Sneaker(7, "Reebok", 15, Rarity.Epic),
                    new Sneaker(8, "Puma", 15, Rarity.Epic),
                    new Sneaker(9, "Guma", 15, Rarity.Epic)
                }
            };

            //MANAGERS AND UTILITIES
            IRandomNumberGenerator   randomNumberGenerator = new RandomNumberGenerator();
            ICustomEventHandler      handler                 = new CustomEventHandler(writer);
            IPlayerManager           playerManager           = new PlayerManager(player);
            ITownsManager            townsManager            = new TownsManager();
            IRandomEncountersManager randomEncountersManager =
                new RandomEncountersManager(playerManager, reader, writer);
            IPlayerActionFactory playerActionFactory =
                new PlayerActionFactory(townsManager, playerManager, reader, writer);

            //SOFIA
            IMap  sofiaMap = new Map(player, writer);
            ITown sofia    = new Town("Sofia", sofiaMap, writer);

            sofia.AddBuilding(new Banicharnitsa(1, "Banicharnica", "Topli zakuski", 10, 50, playerManager));
            sofia.AddBuilding(new PoliceOffice(townsManager, playerManager, randomNumberGenerator, 1, "Police Station",
                                               "Just a police station", 30, 15, handler));
            IBuilding mall = new MallShop(playerManager, 1, "Mall of Sofia", null, 30, 50)
            {
                Inventory = new List <IItem>
                {
                    new Primer(10, "Primer", 55, Rarity.Epic),
                    new Overshoe(11, "Obushta", 60, Rarity.Epic)
                }
            };

            sofia.AddBuilding(mall);
            foreach (var building in Initializer.InitializeBuildings())
            {
                sofia.AddBuilding(building);
            }
            townsManager.AddTown(sofia);
            townsManager.SetCurrentTown(sofia);

            //MONTANA
            IMap  montanaMap = new Map(player, writer);
            ITown montana    = new Town("Montana", montanaMap, writer);

            montana.AddBuilding(new BasicBuilding(10, 10, 3));
            townsManager.AddTown(montana);

            //ENGINE
            IEngine engine = new Engine(playerManager, townsManager, reader, writer, playerActionFactory,
                                        randomEncountersManager, randomNumberGenerator);

            engine.Run();
        }