Ejemplo n.º 1
0
    private void TransitionToNewRoom(GameObject exitDoor)
    {
        if (exitDoor.CompareTag("DoorNextFloor") || exitDoor.CompareTag("DoorVillage"))
        {
            InstantiateNewLevel();
        }
        else
        {
            //set the current room inactive
            DungeonFloorScript.MyInstance.GetCurrentNode().ActivateRoom(false);

            ItemsManagerScript.MyInstance.RemovePotionEffect();

            //get the next room direction
            FloorNode.directionEnum direction = FloorNode.directionEnum.north;
            string spawnPointName             = "SpawnDown";

            if (exitDoor.CompareTag("DoorRight"))
            {
                direction      = FloorNode.directionEnum.east;
                spawnPointName = "SpawnLeft";
            }
            else if (exitDoor.CompareTag("DoorDown"))
            {
                direction      = FloorNode.directionEnum.south;
                spawnPointName = "SpawnUp";
            }
            else if (exitDoor.CompareTag("DoorLeft"))
            {
                direction      = FloorNode.directionEnum.west;
                spawnPointName = "SpawnRight";
            }

            //print("current room : " + DungeonFloorScript.MyInstance.GetCurrentNode().GetRoomName());
            //print("next room : " + DungeonFloorScript.MyInstance.GetCurrentNode().GetNeighbourNode(direction).GetRoomName());

            //get the next room node
            FloorNode nextNode = DungeonFloorScript.MyInstance.GetCurrentNode().GetNeighbourNode(direction);

            //change the current room node as the next room node we picked
            DungeonFloorScript.MyInstance.SetCurrentNode(nextNode);

            //activate the room
            DungeonFloorScript.MyInstance.GetCurrentNode().ActivateRoom(true);

            //update the mini map
            MinimapScript.MyInstance.AddRoom(DungeonFloorScript.MyInstance.GetCurrentNode(), false);
            MinimapScript.MyInstance.UpdateCurrentRoomDisplay(DungeonFloorScript.MyInstance.GetCurrentNode());

            //reposition the player to the correct place of the room where he should spawn
            UpdatePlayerPosition(spawnPointName);

            //reset the room doors to get the doors of the new room
            GameManager.MyInstance.ResetRoomDoors();

            AstarPath.active.Scan();

            DestroyAllProjectiles();
        }
    }
Ejemplo n.º 2
0
    private FloorNode.directionEnum GetOppositeDirection(FloorNode.directionEnum direction)
    {
        //return the opposite direction of a given direction
        int newDirection = ((int)direction + 2) % 4;

        return((FloorNode.directionEnum)newDirection);
    }
Ejemplo n.º 3
0
    public void CreateLinkBetweenNodes(FloorNode a, FloorNode b, FloorNode.directionEnum directionFromAToB)
    {
        //if both nodes have no neighbour at the chosen direction
        if (a.GetNeighbourNode(directionFromAToB) == null && b.GetNeighbourNode(GetOppositeDirection(directionFromAToB)) == null)
        {
            //add the new room as a neighbour of the existing room
            a.SetNeighbourNode(directionFromAToB, b);

            //add the existing room as a neighbour of the new room
            b.SetNeighbourNode(GetOppositeDirection(directionFromAToB), a);
        }
    }