private void AddFloorsConnectionSection()
        {
            var node = new StairsNode(CurrentFloor, ContextMenuPosition);

            CurrentFloor.AddObject(node);
            node.IsFloorsConnected = true;
        }
Beispiel #2
0
        /// <summary>
        /// Goes to next floor in queue.
        /// <br>If nothing in queue, elevator won't move.</br>
        /// </summary>
        /// <returns>Floor that the elevator moved to (the next in queue)</returns>
        public Floor MoveToNextFloorInQueue()
        {
            // Remove person from spawned floor if carrying person to new floor
            if (personInElevator != null)
            {
                personInElevator.SpawnFloor.RemovePersonFromFloor(personInElevator);
            }
            // Make sure that Floor queue is not empty so it has a reason to move
            if (_queue.Count > 0)
            {
                // TODO: Rethink if floor calls can stack or not. For now, only one call per floor, no queueing
                if (CurrentFloor != null)
                {
                    CurrentFloor.UnCallElevator();
                }
                // Set target floor to the first in queue
                TargetFloor = _queue[0];
                Console.WriteLine("[Elevator]: Elevator is moving to " + TargetFloor.floorName + "... (1sec)");
                Thread.Sleep(1000);

                ArrivedAtFloor();
                return(CurrentFloor);
            }
            else
            {
                Console.WriteLine("[Elevator]: No floors in queue");
                return(null);
            }
        }
    internal void ReplaceDepNode(DepNode depNode)
    {
        if (depNode == null)
        {
            Debug.LogError("MapBuilding.ReplaceDepNode depNode == null");
            return;
        }
        //if (Node == null)
        //{
        //    Debug.LogError("MapBuilding.ReplaceDepNode Node == null : BuildingName :" + BuildingName);
        //    //return;
        //}
        if (BuildingId == depNode.NodeID)
        {
            //Node = depNode;
            SetNode(depNode);

            foreach (var item in FloorList)
            {
                item.ReplaceDepNode(depNode.ChildNodes);
            }
            if (CurrentFloor)
            {
                CurrentFloor.ReplaceDepNode(depNode.ChildNodes);
            }
        }
        else
        {
            Debug.LogWarning(string.Format("MapBuilding.ReplaceDepNode BuildingId != depNode.NodeID Id1={0},Name1={1};ID2={2},Name2={3}", BuildingId, BuildingName, depNode.NodeID, depNode.NodeName));
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        PowerOn       = true;
        LocationTotal = 80;
        floor         = CurrentFloor.NONE;

        StartLocationLights();
    }
Beispiel #5
0
 private void AddVisualEntity(VisualEntity entry)
 {
     if (CurrentFloor == null)
     {
         return;
     }
     CurrentFloor.AddVisualEntity(entry);
 }
Beispiel #6
0
 public void AddFloor()
 {
     CurrentFloor -= DataBase.Direction;
     if (DataBase.CurrentId == Id)
     {
         UpdateCurrentFloor?.Invoke(CurrentFloor.ToString());
     }
 }
        /// <summary>
        /// Creates and returns a list of stringified state data for this GameController.
        /// List begins with a header ("GameController") in index 0, and then serializes each property in turn
        /// </summary>
        /// <returns>list of game state information to be saved</returns>
        public List <string> Serialize()
        {
            List <string> data = new List <string>();

            data.Add("GameController");
            data.Add(CurrentFloor.ToString());
            data.Add(Setting.ToString());
            data.Add(Score.ToString());

            return(data);
        }
    //Instantiates money and tries to place it. Might not actually get the input spot if the input spot is taken.
    public void SpawnMoneyOnTile(Vector2Int spawnLoc, int amount)
    {
        Vector2Int adjustedSpawnLoc = CurrentFloor.FindSpotForItem(spawnLoc, 2); // It might bounce.

        if (adjustedSpawnLoc.x == -1 && adjustedSpawnLoc.y == -1)
        {
            return; // money was lost to the void.
        }
        GameObject   moneyObj           = ItemSpawner.SpawnMoney(adjustedSpawnLoc);
        DroppedMoney newMoneyBloodMoney = moneyObj.GetComponent <DroppedMoney>();

        newMoneyBloodMoney.Initialize(amount); // Set how much this is worth
        newMoneyBloodMoney.xPos = spawnLoc.x;
        newMoneyBloodMoney.zPos = spawnLoc.y;
        map[adjustedSpawnLoc.x, adjustedSpawnLoc.y].SetItemOnTile(newMoneyBloodMoney);
    }
        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </summary>
        /// <param name="other">An object to compare with this instance.</param>
        /// <returns>
        /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name="other" /> in the sort order.  Zero This instance occurs in the same position in the sort order as <paramref name="other" />. Greater than zero This instance follows <paramref name="other" /> in the sort order.
        /// </returns>
        public int CompareTo(ElevatorRequest other)
        {
            var result = 0;

            switch (this.Direction)
            {
            case Status.Up:
                result = CurrentFloor.CompareTo(other.CurrentFloor);
                break;

            case Status.Down:
                result = CurrentFloor.CompareTo(other.CurrentFloor) * -1;
                break;
            }

            return(result);
        }
Beispiel #10
0
        public IList <BuildingState> SafeFloorRearrangements()
        {
            var validForElevator = CurrentFloor.SafeChipGeneratorCombinations();
            var safeToRelease    = validForElevator.Where(a => CurrentFloor.Release(a).IsSafe()).ToList();

            var safeRearrangements = new List <BuildingState>();

            if (CanMoveDown)
            {
                var safeToReceive = safeToRelease.Where(a => LowerFloor.Merge(a).IsSafe());

                foreach (var assembly in safeToReceive)
                {
                    var newBuildingFloors = Floors.Select(a => a.Copy()).ToList();

                    var newThis  = CurrentFloor.Release(assembly);
                    var newLower = LowerFloor.Merge(assembly);

                    newBuildingFloors[Elevator]     = newThis;
                    newBuildingFloors[Elevator - 1] = newLower;

                    safeRearrangements.Add(new BuildingState(Elevator - 1, newBuildingFloors, StateDepth + 1));
                }
            }

            if (CanMoveUp)
            {
                var safeToReceive = safeToRelease.Where(a => UpperFloor.Merge(a).IsSafe());

                foreach (var assembly in safeToReceive)
                {
                    var newBuildingFloors = Floors.Select(a => a.Copy()).ToList();

                    var newThis  = CurrentFloor.Release(assembly);
                    var newUpper = UpperFloor.Merge(assembly);

                    newBuildingFloors[Elevator]     = newThis;
                    newBuildingFloors[Elevator + 1] = newUpper;

                    safeRearrangements.Add(new BuildingState(Elevator + 1, newBuildingFloors, StateDepth + 1));
                }
            }

            return(safeRearrangements);
        }
        private void RemoveSelectedEntity()
        {
            Mode = ActionMode.Remove;
            if (SelectedEntity == null)
            {
                return;
            }

            if (SelectedEntity is Building)
            {
                var index = Buildings.IndexOf(SelectedEntity as Building);
                Buildings.Remove(SelectedEntity as Building);

                if (index >= Buildings.Count - 1)
                {
                    CurrentBuilding = Buildings.LastOrDefault();
                }
                else
                {
                    CurrentBuilding = Buildings[index];
                }

                SelectedEntity = CurrentBuilding;
                return;
            }

            if (SelectedEntity is Floor)
            {
                CurrentBuilding.RemoveFloor(SelectedEntity as Floor);
                CurrentFloor   = CurrentBuilding.CurrentFloor;
                SelectedEntity = CurrentFloor;
                return;
            }

            CurrentFloor.RemoveObject(SelectedEntity);
            SelectedEntity = CurrentFloor.Objects.FirstOrDefault();
            if (SelectedEntity == null)
            {
                SelectedEntity = CurrentFloor;
            }
        }
        private void Stop()
        {
            Console.WriteLine($"E{Number} on F{CurrentFloor.Number} opens");

            RidersCanExitEvents[CurrentFloor].Set();
            WaitRiders();
            RidersCanExitEvents[CurrentFloor].Reset();

            CurrentFloor.ElevatorComes(this, Direction.Value);
            WaitRiders();
            CurrentFloor.ElevatorLeaves(this, Direction.Value);

            Console.WriteLine($"E{Number} on F{CurrentFloor.Number} closes");

            lock (floorsToStop)
            {
                floorsToStop[CurrentFloor] = false;
            }

            State = ElevatorState.Move;
        }
Beispiel #13
0
        public static void TurnOver(int entity)
        {
            //Log.Message("Turn over for " + DescriptionSystem.GetNameWithID(entity));
            var health = EntityManager.GetComponent <HealthComponent>(entity);

            // entity dead, don't do anything
            if (health.Amount <= 0)
            {
                return;
            }

            TurnOverEvent?.Invoke(entity);

            if (entity == PlayerID)
            {
                CurrentFloor.CalculateTileVisibility();
                LocationSystem.UpdateDistanceMap(PlayerID);
                PlayerTurnOver = true;
                TurnCount++;
            }
        }
Beispiel #14
0
        private void SetScale()
        {
            if (!(SelectedActionMode == ActionMode.SetScale) || !IsCreatingLine)
            {
                return;
            }

            var length = CreatingLineInf.Length;

            if (length > 0)
            {
                var win = new ScaleWindow(length, CurrentFloor.Model.Scale);
                if (win.ShowDialog() == true)
                {
                    CurrentFloor.Model.Scale = win.Scale;
                    CurrentFloor.ApplyScale();
                    DrawingScale();
                }
            }

            IsCreatingLine = false;
        }
Beispiel #15
0
        protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
        {
            if (IsCreatingLine)
            {
                IsCreatingLine = false;
                e.Handled      = true;
            }

            if (SelectedActionMode != ActionMode.Move)
            {
                contextMenuHandled = true;
            }
            else
            {
                var entity = CurrentFloor.GetVisualEntity(GetAbsolutePosition(e.GetPosition(this)));
                if (entity != null)
                {
                    contextMenuHandled = true;
                }
            }

            base.OnMouseRightButtonDown(e);
        }
Beispiel #16
0
 public string GetCurrentImageUrl()
 {
     return("../" + CurrentFloor.ToString() + CurrentBei + ".jpg");
 }
Beispiel #17
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (CurrentFloor == null)
            {
                return;
            }

            e.Handled = true;
            var position = GetAbsolutePosition(e.GetPosition(this));

            try
            {
                switch (SelectedActionMode)
                {
                case ActionMode.AddStart:
                {
                    var start = new StartNode(CurrentFloor.Model, position);
                    AddVisualEntity(new VisualStartNode(start, CurrentFloor)); break;
                }

                case ActionMode.AddExit:
                {
                    var exit = new ExitNode(CurrentFloor.Model, position);
                    AddVisualEntity(new VisualExitNode(exit, CurrentFloor)); break;
                }

                case ActionMode.AddEntry:
                {
                    var entry = new EntryNode(CurrentFloor.Model, position);
                    AddVisualEntity(new VisualEntryNode(entry, CurrentFloor)); break;
                }

                case ActionMode.AddStairs:
                case ActionMode.AddRoad:
                {
                    CreatingSection(position);
                    break;
                }

                case ActionMode.Move:
                {
                    var entity = CurrentFloor.GetVisualEntity(position);
                    if (entity != null)
                    {
                        moveInformation         = new MoveInformation(entity.GetUnit(position), position);
                        entity.Model.IsSelected = true;
                    }
                    else if (Shell != null)
                    {
                        moveInformation = new MoveInformation(Shell, e.GetPosition(this), true);
                        e.Handled       = false;
                    }
                    e.Handled = true;
                    break;
                }

                case ActionMode.Remove:
                {
                    var entity = CurrentFloor.GetVisualEntity(position);
                    CurrentFloor.RemoveVisualEntity(entity);
                    break;
                }

                case ActionMode.SetScale:
                {
                    if (IsCreatingLine)
                    {
                        CreatingLineInf.LastPosition = position;
                        SetScale();
                    }
                    else
                    {
                        CreatingLineInf = new CreatingLineInformation(new VisualThumb(position));
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #18
0
        private void CreatingSection(Point position)
        {
            var        entity = CurrentFloor.GetVisualEntity(position);
            VisualNode node   = null;

            if (entity is VisualNode)
            {
                node = entity as VisualNode;
            }
            else
            {
                switch (SelectedActionMode)
                {
                case ActionMode.AddStairs:
                    node = new VisualStairsNode(new StairsNode(CurrentFloor.Model, position), CurrentFloor); break;

                case ActionMode.AddRoad:
                    node = new VisualNode(new RoadNode(CurrentFloor.Model, position), CurrentFloor); break;
                }
                AddVisualEntity(node);
            }

            if (IsCreatingLine)
            {
                if (!node.NodeModel.IncomingSectionsAllowed)
                {
                    return;
                }
                if (CreatingLineInf.FirstUnit == node || !(CreatingLineInf.FirstUnit is VisualNode))
                {
                    return;
                }

                VisualRoadSection section = null;
                Section           model   = null;
                switch (SelectedActionMode)
                {
                case ActionMode.AddStairs:
                    model = new StairsSection(CreatingLineInf.FirstNode.NodeModel, node.NodeModel, CurrentFloor.Model); break;

                case ActionMode.AddRoad:
                    model = new RoadSection(CreatingLineInf.FirstNode.NodeModel, node.NodeModel, CurrentFloor.Model); break;
                }

                // по каким-то причинам (образовывается петля) нет возможности добавить данный участок
                if (!CurrentFloor.Model.CanAddSection(model))
                {
                    return;
                }

                switch (SelectedActionMode)
                {
                case ActionMode.AddStairs:
                    section = new VisualStairsSection(CreatingLineInf.FirstNode, node, model as StairsSection, CurrentFloor); break;

                case ActionMode.AddRoad:
                    section = new VisualRoadSection(CreatingLineInf.FirstNode, node, model as RoadSection, CurrentFloor); break;
                }

                AddVisualEntity(section);
            }

            CreatingLineInf = new CreatingLineInformation(node);

            if (!CreatingLineInf.FirstNode.NodeModel.OutgoingSectionsAllowed)
            {
                IsCreatingLine = false;
            }
        }
 // Moves the given object from wherever it is to the given location on the battlegrid.
 public void MoveObjectTo(Vector2Int tar, TileEntity obj)
 {
     CurrentFloor.MoveObjectTo(tar, obj);
 }
Beispiel #20
0
    void Start()
    {
        player = GameObject.Find("Player").GetComponent <PlayerScript>();


        scene = SceneManager.GetActiveScene();

        if (scene.buildIndex == 0)
        {
            floor = CurrentFloor.NONE;
        }
        else if (scene.buildIndex == 4)
        {
            Debug.Log("CURRENT LOCATION SHOULD BE 1");
            floor            = CurrentFloor.LOBBY;
            player.PlayerLoc = 4;
        }
        else if (scene.buildIndex == 6)
        {
            // THIS IS THE SAFE ROOM FLOOR
            floor            = CurrentFloor.FLOOR2;
            player.PlayerLoc = 6;
        }
        else if (scene.buildIndex == 5) // elevator
        {
            player.PlayerLoc = 5;
        }
        else if (scene.buildIndex == 7)
        {
            floor            = CurrentFloor.FLOOR1;
            player.PlayerLoc = 7;
        }
        else if (scene.buildIndex == 8)
        {
            floor            = CurrentFloor.FLOOR2;
            player.PlayerLoc = 8;
        }
        else if (scene.buildIndex == 9)
        {
            floor            = CurrentFloor.FLOOR3;
            player.PlayerLoc = 9;
        }

        /*
         *      else if (scene.buildIndex == 10)
         *      {
         *          floor = CurrentFloor.BASEMENT;
         *          player.PlayerLoc = 10;
         *      }
         *      else if (scene.buildIndex == 11)
         *      {
         *          floor = CurrentFloor.ROOF;
         *      }
         */
        else if (scene.buildIndex == 2)
        {
            floor = CurrentFloor.NONE;
        }
        else if (scene.buildIndex == 3)
        {
            floor = CurrentFloor.NONE;
        }
    }
Beispiel #21
0
 public override int GetHashCode()
 {
     return(CurrentFloor.GetHashCode() + ResultFloor.GetHashCode());
 }