Esempio n. 1
0
 public Workshop()
 {
     Type     = BuildingType.Workshop;
     Recipe   = Recipes.GetRecipe("None");
     Width    = 2;
     Height   = 2;
     Entrance = new BuildingEntrance(this, (0, 1), (0, 2), PathType.Driveway);
 }
Esempio n. 2
0
 public Core(Map map)
 {
     Input    = new GlobalResourceInput(map);
     Width    = 4;
     Height   = 4;
     Entrance = new BuildingEntrance(this, (1, 3), (1, 4), PathType.Driveway);
     Type     = BuildingType.Core;
 }
Esempio n. 3
0
 public TestProducer()
 {
     Width    = 3;
     Height   = 3;
     Output   = new InfiniteDirectOutput(Item.Wood);
     Entrance = new BuildingEntrance(this, (1, 2), (1, 3), PathType.Driveway);
     Type     = BuildingType.TestProducer;
 }
Esempio n. 4
0
 public TestConsumer()
 {
     Width    = 2;
     Height   = 2;
     Input    = new InfiniteDirectInput();
     Entrance = new BuildingEntrance(this, (0, 1), (0, 2), PathType.Driveway);
     Type     = BuildingType.TestConsumer;
 }
Esempio n. 5
0
 public Smelter()
 {
     Type           = BuildingType.Smelter;
     Input          = new ItemDecider(SetItem);
     ProcessingTime = 2;
     Width          = 2;
     Height         = 2;
     Entrance       = new BuildingEntrance(this, (1, 1), (1, 2), PathType.Driveway);
 }
Esempio n. 6
0
 public TrainStation(Map map)
 {
     _map     = map;
     Width    = 2;
     Height   = 4;
     Input    = new InfiniteDirectInput();
     Output   = new InfiniteDirectOutput(Item.Wood);
     Type     = BuildingType.TrainStation;
     Entrance = new BuildingEntrance(this, (2, 0), (2, 3), PathType.Rail);
 }
Esempio n. 7
0
        public Lumbermill(Map map, IntVector pos)
        {
            Type     = BuildingType.Lumbermill;
            Width    = 2;
            Height   = 2;
            Consumer = new ResourceInput(map, this, (-2, -2), 6, Item.Wood);
            var producer = new DirectProducer(5, 1, Item.Wood);

            Producer       = producer;
            Output         = producer;
            ProcessingTime = 1;
            Entrance       = new BuildingEntrance(this, (0, 1), (0, 2), PathType.Driveway);
        }
Esempio n. 8
0
        public Mine(Map map, IntVector pos)
        {
            var item = map.GetNearestResource(pos + (Width / 2, Height / 2), 2, Item.Stone, Item.IronOre, Item.CopperOre);

            Type     = BuildingType.Mine;
            Consumer = new ResourceInput(map, this, (-1, -1), 4, item);
            var output = new DirectProducer(5, 1, item);

            Output         = output;
            Producer       = output;
            ProcessingTime = 2;
            Width          = 2;
            Height         = 2;
            Entrance       = new BuildingEntrance(this, (0, 1), (0, 2), PathType.Driveway);
        }
Esempio n. 9
0
 public void AddMultipleFloors(BuildingEntrance entrance, int floors)
 {
     for (int i = 0; i < floors; i++)
     {
         AddFloor(entrance, i.ToString());
     }
 }
Esempio n. 10
0
        public async Task <BuildingEntranceAddViewModel> Post([FromBody] BuildingEntranceAddViewModel buildingEntrance)
        {
            var building = _unitOfWork.Buildings.Get(buildingEntrance.BuildingId);
            var owner    = await _accountManager.GetUserByIdAsync(buildingEntrance.CreatorId);

            if (building == null || owner == null)
            {
                return(buildingEntrance);
            }

            var newEntrance = new BuildingEntrance
            {
                name            = buildingEntrance.Name,
                CurrentBuilding = building,
                Apartaments     = new List <Apartament>(),
                manager         = owner
            };

            _unitOfWork.BuildingEntrance.Add(newEntrance);
            _unitOfWork.SaveChanges();

            buildingEntrance.Id = newEntrance.id;

            return(buildingEntrance);
        }
Esempio n. 11
0
        public void AddFloor(BuildingEntrance entrance, string floorName = "")
        {
            var floor = new BuildingFloor();

            floor.buildingEntrance = entrance;
            floor.Name             = $"Етаж {floorName}";

            _unitOfWork.BuildingFloor.Add(floor);
            _unitOfWork.SaveChanges();
        }
Esempio n. 12
0
        public void AddEntrance(Building building)
        {
            for (int i = 0; i < building.Entrances; i++)
            {
                var newEntrance = new BuildingEntrance();
                newEntrance.name = $"Вход {i}";
                _unitOfWork.BuildingEntrance.Add(newEntrance);
            }

            _unitOfWork.SaveChanges();
        }
Esempio n. 13
0
        public void AddEntranceCascade(Building building)
        {
            for (int i = 0; i < building.Entrances; i++)
            {
                var newEntrance = new BuildingEntrance();
                newEntrance.name            = $"Вход {i}";
                newEntrance.CurrentBuilding = building;

                _unitOfWork.BuildingEntrance.Add(newEntrance);
                _buildingFloorServices.AddMultipleFloors(newEntrance, building.Floors);
            }
        }
Esempio n. 14
0
    public void Close(bool machineClose)
    {
        if (!IsOpen)
        {
            return;
        }
        if (IsMachine && !machineClose)
        {
            return;
        }


        IsOpen = false;
        if (DoorSound != null)
        {
            if (Type == DoorType.Sliding)
            {
                DoorSound.Play();
            }
            else if (Type == DoorType.Rotating)
            {
                if (SoundType == ContainerSoundType.Wood)
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("WoodDoorClose");
                    DoorSound.PlayOneShot(clip, 0.8f);
                }
                else
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("MetalDoorClose");
                    DoorSound.PlayOneShot(clip, 0.6f);
                }

                //also set navmesh obstacle to non-carve
                NavMeshObstacle obstacle = DoorPanel.GetComponent <NavMeshObstacle>();
                obstacle.carving = false;
            }
        }

        BuildingEntrance entrance = GetComponent <BuildingEntrance>();

        if (entrance != null)
        {
            entrance.IsActive = false;
        }
    }
Esempio n. 15
0
    public void Open(Transform opener, bool machineOpen)
    {
        if (IsOpen)
        {
            return;
        }

        if (IsMachine && !machineOpen)
        {
            return;
        }

        //check if it's locked
        if (IsLocked)
        {
            //here check if player has key
            int keyCount = GameManager.Inst.PlayerControl.SelectedPC.Inventory.CountItemsInBackpack(KeyItemID);
            if (keyCount > 0)
            {
                //play unlock key sound
                IsLocked = false;
            }
            else
            {
                //play locked door sound
                if (SoundType == ContainerSoundType.Wood)
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("WoodDoorLocked");
                    DoorSound.PlayOneShot(clip, 0.6f);
                }
                else
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("MetalDoorLocked");
                    DoorSound.PlayOneShot(clip, 0.6f);
                }

                return;
            }
        }

        IsOpen = true;
        if (DoorSound != null)
        {
            if (Type == DoorType.Sliding)
            {
                DoorSound.Play();
            }
            else if (Type == DoorType.Rotating)
            {
                if (SoundType == ContainerSoundType.Wood)
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("WoodDoorOpen");
                    DoorSound.PlayOneShot(clip, 0.8f);
                }
                else
                {
                    AudioClip clip = GameManager.Inst.SoundManager.GetClip("MetalDoorOpen");
                    DoorSound.PlayOneShot(clip, 0.6f);
                }
            }
        }

        if (Type == DoorType.Rotating)
        {
            //calculate the angle between opener-door and door-up
            Vector3 openerDoorLine = opener.position - transform.position;
            float   angle          = Vector3.Angle(openerDoorLine, transform.up);
            if (angle < 90)
            {
                _rotateTarget = OpenTarget1;
            }
            else
            {
                _rotateTarget = OpenTarget2;
            }

            //also set navmesh obstacle to carve
            NavMeshObstacle obstacle = DoorPanel.GetComponent <NavMeshObstacle>();
            obstacle.carving = true;
        }

        BuildingEntrance entrance = GetComponent <BuildingEntrance>();

        if (entrance != null)
        {
            entrance.IsActive = true;
        }
    }
Esempio n. 16
0
 public void Put(int id, [FromBody] BuildingEntrance buildingEntrance)
 {
     _unitOfWork.BuildingEntrance.Update(buildingEntrance);
     _unitOfWork.SaveChanges();
 }