public void DeleteMap()
    {
        for (int i = 0; i < floors.Length; i++)
        {
            DestroyObjects(floors[i]);
        }
        DestroyObjects(elevators);
        DestroyObjects(passengers);
        DestroyObjects(ceilings);
        DestroyObjects(destRooms);

        currentAction = null;
        Destroy(currentElevatorObject.ElevatorGameObject);
        Destroy(currentPassengerObject.PassengerGameObject);
        currentElevatorObject  = null;
        currentPassengerObject = null;

        foreach (Elevator e in elevatorsObjects)
        {
            Destroy(e.ElevatorGameObject);
        }
        foreach (Passenger p in passengersObjects)
        {
            Destroy(p.PassengerGameObject);
        }
        elevatorsObjects.Clear();
        floorObjects.Clear();
        passengersObjects.Clear();
    }
    /*
     * If the reversed action is MoveAction then the elevator will return to its former postion
     *  i.e the floor the elevator was before the next action occurred
     * If the reversed action is PassengerAction then the passenger will return to its former position immidietly
     * without any animation (so we can distinguish between step forward and step backward)
     */
    private void ReturnToFormerPositions(testElevator.Action reversedAction)
    {
        if (reversedAction is MoveAction)
        {
            string elevName = reversedAction.ExecutorName;
            CalculateAndSetElevatorCost(elevName, ((MoveAction)reversedAction));
            currentElevatorObject = getElevatorByName(elevName);
            Vector3 elevPos = currentElevatorObject.GetGameObjectTransform().position;
            currentElevatorObject.GetGameObjectTransform().position = new Vector3(elevPos.x, ((MoveAction)reversedAction).TargetFloor * stepY, elevPos.z);
        }
        else
        {
            string elevName = ((PassengerAction)reversedAction).ElevatorName;
            currentElevatorObject = getElevatorByName(elevName);

            string passName = ((PassengerAction)reversedAction).ExecutorName;
            currentPassengerObject = getPassengerByName(passName);

            Vector3 elevPos = currentElevatorObject.GetGameObjectTransform().position;
            currentElevatorObject.GetGameObjectTransform().position = new Vector3(elevPos.x, ((PassengerAction)reversedAction).FloorNumber * stepY, elevPos.z);

            // standing
            currentPassengerObject.WalkingOrStandingMovement(false);

            if (((PassengerAction)reversedAction).IsBoard)
            {
                Vector3 incitement     = currentElevatorObject.getNextFreeSpace();
                float   elevDirectionX = currentElevatorObject.GetGameObjectTransform().position.x + incitement.x;
                float   elevDirectionZ = currentElevatorObject.GetGameObjectTransform().position.z + incitement.z;
                currentPassengerObject.InsideElevatorIncitement = incitement;

                currentPassengerObject.GetGameObjectTransform().SetParent(currentElevatorObject.GetGameObjectTransform());
                currentPassengerObject.GetGameObjectTransform().position = new Vector3(elevDirectionX, ((PassengerAction)reversedAction).FloorNumber * stepY, elevDirectionZ);
                currentPassengerObject.RotatePassengerInfo(true);

                currentPassengerObject.LeaveAction = false;
            }
            else
            {
                // Detaching the parent elevtor game object from the passenger game object
                currentPassengerObject.GetGameObjectTransform().SetParent(null);
                currentElevatorObject.freePassengerSpace(currentPassengerObject.InsideElevatorIncitement);

                System.Random rand           = new System.Random();
                float         randDirectionZ = (float)(rand.NextDouble() * 1.9 + 1.1);
                float         randDirectionX = (float)(rand.NextDouble() * ((numOfElevators * stepX) - 4)) + 1;

                currentPassengerObject.GetGameObjectTransform().position = new Vector3(randDirectionX, ((PassengerAction)reversedAction).FloorNumber * stepY, randDirectionZ);
                currentPassengerObject.RotatePassengerInfo(false);

                currentPassengerObject.BoardAction = false;
            }
            currentPassengerObject.rotatePassengerTowardsZ();
            currentPassengerObject.rotatePassengerTowardsZ();
            UpdateElevatorCapacity(elevName, ((PassengerAction)reversedAction).FinalCapacity);
        }
    }
    /*
     * Extracting Action objects each time the next conditions are fulfilled:
     + There are more actions in the list
     + if we in step by step mode each click in the button will take only one Action from the list
     */
    private void IterateActionsList()
    {
        actionNumber.text = actionCounter.ToString();
        if (actionCounter < actions.Count)
        {
            currentAction = actions[actionCounter];
            if (currentAction != null && gameHold == stepFlag)
            {
                //if (stepBackwardFlag && actionCounter >= 0)
                //{
                //    testElevator.Action reversedAction = ReverseActionProperties();
                //    SimulationMovements(reversedAction);
                //}
                //else
                //{
                SimulationMovements(currentAction);
                actionCounter++;
                //}

                if (gameHold && stepFlag)
                {
                    stepFlag = !stepFlag;
                }
            }
            else if (currentAction != null && gameHold == stepBackwardFlag)
            {
                if (actionCounter >= 0)
                {
                    testElevator.Action reversedAction = ReverseActionProperties();
                    ReturnToFormerPositions(reversedAction);// switch to new function of just placing the objects in their former state
                }

                if (gameHold && stepBackwardFlag)
                {
                    stepBackwardFlag = !stepBackwardFlag;
                }
            }
        }
    }
    /*
     * For each Action given in the List<Action> we classify them as 3:
     + MoveAction: Elevator is moving from one floor to another
     + PassengerAction:
     + Type1 - Board: a passenger is getting aboard to an elevator
     + Type2 - Leave: a passenger is leaving the current elevator
     + In each PassengerAction we updating the current state of an elevator: current capacity/ total capacity and the current cost by
     +  the cost dictionary provided in the init files that have been readen by the emssParser
     */
    private void SimulationMovements(testElevator.Action action)
    {
        if (action is MoveAction)
        {
            passengerActionFlag = false;
            elevatorActionFlag  = true;
            string elevName = action.ExecutorName;

            CalculateAndSetElevatorCost(elevName, ((MoveAction)action));

            currentElevatorObject = getElevatorByName(elevName);
            currentDirectionY     = ((MoveAction)action).Direction;
            actionIsOnGoing       = true;

            Vector3 view1UpperCameraPosition = view1Cameras[0].gameObject.transform.position;
            float   desiredY = ((MoveAction)action).DeparuredFloor * stepY + 2.5f;
            view1Cameras[0].gameObject.transform.position = new Vector3(view1UpperCameraPosition.x, desiredY, view1UpperCameraPosition.z);
        }

        if (action is PassengerAction)
        {
            // Placing the view1UpperCamera in the floor that the passenger is moving on
            if (actionCounter == 0)
            {
                int thisFloorNumber = ((PassengerAction)action).FloorNumber;
                PlaceView1UpperCameraInInitFloor(thisFloorNumber);
            }

            elevatorActionFlag  = false;
            passengerActionFlag = true;

            string elevName = ((PassengerAction)action).ElevatorName;
            currentElevatorObject = getElevatorByName(elevName);


            string passName = ((PassengerAction)action).ExecutorName;
            currentPassengerObject = getPassengerByName(passName);

            // start walking
            currentPassengerObject.WalkingOrStandingMovement(true);

            if (((PassengerAction)action).IsBoard)
            {
                Vector3 incitement = currentElevatorObject.getNextFreeSpace();
                currentDirectionX = currentElevatorObject.GetGameObjectTransform().position.x + incitement.x;
                currentDirectionZ = currentElevatorObject.GetGameObjectTransform().position.z + incitement.z;

                currentPassengerObject.BoardAction = true;
                currentPassengerObject.InsideElevatorIncitement = incitement;
                currentPassengerObject.rotatePassengerTowardsX(currentDirectionX);
            }
            else
            {
                // Detaching the parent elevtor game object from the passenger game object
                currentPassengerObject.GetGameObjectTransform().SetParent(null);
                currentPassengerObject.GetGameObjectTransform().position = currentElevatorObject.GetGameObjectTransform().position + currentPassengerObject.InsideElevatorIncitement;
                currentElevatorObject.freePassengerSpace(currentPassengerObject.InsideElevatorIncitement);

                // Sending the Passenger to the destination floor in case it is his target or find him random place in the current floor
                System.Random rand = new System.Random();
                if (currentPassengerObject.Destination.Number == ((PassengerAction)action).FloorNumber + 1 && !stepBackwardFlag)
                {
                    currentDirectionZ = (float)(rand.NextDouble() * 1.5 + 1.1);
                    float maxD = (float)((numOfElevators + 1) * stepX) - 3.7f;
                    float minD = (float)(numOfElevators * stepX) + 0.5f;
                    currentDirectionX = (float)(rand.NextDouble() * (maxD - minD)) + minD;
                }
                // Finding random space in the floor for the passenger
                else
                {
                    currentDirectionZ = (float)(rand.NextDouble() * 1.9 + 1.1);
                    currentDirectionX = (float)(rand.NextDouble() * ((numOfElevators * stepX) - 2)) + 1;
                }

                currentPassengerObject.RotatePassengerInfo(false);

                currentPassengerObject.LeaveAction = true;
            }
            UpdateElevatorCapacity(elevName, ((PassengerAction)action).FinalCapacity);
            actionIsOnGoing = true;
        }
    }