Exemplo n.º 1
0
        private void UserInterfaceManagerOnPurchasableItemPlaced(object sender, PurchasableItemPlacedEventArgs e)
        {
            // place equipment active only if we have been in this state for more than a second to prevent super fast action being taken
            if (!IsUserInterfaceStateChangeDelayPassed)
            {
                return;
            }

            if (e.PurchasableItem is SodaMachine)
            {
                var agentToAdd = agentFactory.CreateSodaMachine(SimulationManager.SimulationTime, new Vector(e.HoveredMapCells[0].WorldPosition.X, e.HoveredMapCells[0].WorldPosition.Y));
                AddEquipmentToGame(agentToAdd, e.HoveredMapCells[0]);
            }
            else if (e.PurchasableItem is SnackMachine)
            {
                var agentToAdd = agentFactory.CreateSnackMachine(SimulationManager.SimulationTime, new Vector(e.HoveredMapCells[0].WorldPosition.X, e.HoveredMapCells[0].WorldPosition.Y));
                AddEquipmentToGame(agentToAdd, e.HoveredMapCells[0]);
            }
            else if (e.PurchasableItem is OfficeDesk)
            {
                var agentToAdd = agentFactory.CreateOfficeDesk(SimulationManager.SimulationTime, new Vector(e.HoveredMapCells[0].WorldPosition.X, e.HoveredMapCells[0].WorldPosition.Y));
                AddEquipmentToGame(agentToAdd, e.HoveredMapCells[0]);
            }
            else if (e.PurchasableItem is Library)
            {
                var agentToAdd = roomFactory.CreateLibrary(agentFactory);
                AddRoomToGame(agentToAdd, e.HoveredMapCells);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a reference to an equipment agent based on the map object passed. Will assign the map cells position to the created agent.
        /// </summary>
        /// <param name="mapObject"></param>
        /// <param name="mapCell"></param>
        /// <returns></returns>
        private Equipment CreateEquipmentFromEquipmentObjectSubtype(MapObject mapObject, MapCell mapCell)
        {
            if (mapObject == null)
            {
                throw new ArgumentNullException("mapObject");
            }
            if (mapCell == null)
            {
                throw new ArgumentNullException("mapCell");
            }

            Equipment       equipment       = null;
            EquipmentObject equipmentObject = (EquipmentObject)mapObject;

            switch (equipmentObject.Subtype)
            {
            case EquipmentObjectType.SnackMachine:
                equipment = agentFactory.CreateSnackMachine(TimeSpan.Zero, mapCell.WorldPosition);
                break;

            case EquipmentObjectType.SodaMachine:
                equipment = agentFactory.CreateSodaMachine(TimeSpan.Zero, mapCell.WorldPosition);
                break;

            case EquipmentObjectType.OfficeDesk:
                equipment = agentFactory.CreateOfficeDesk(TimeSpan.Zero, mapCell.WorldPosition);
                break;

            case EquipmentObjectType.WaterFountain:
                equipment = agentFactory.CreateWaterFountain(TimeSpan.Zero, mapCell.WorldPosition);
                break;
            }

            return(equipment);
        }