private void OnPlayerEscapeRoomBounds(int sideEscaped)
    {
        // Exit current Room.
        OnPlayerExitRoom(CurrRoom);
        // Enter next Room.
        WorldData currWorldData = CurrRoom.MyWorldData;
        RoomData  nextLD        = currWorldData.GetRoomAtSide(CurrRoom.MyRoomData, Player.PosLocal, sideEscaped);

        if (nextLD != null)
        {
            int     sideEntering = Sides.GetOpposite(sideEscaped);
            Vector2 posExited    = Player.PosGlobal;

            PlayerData pd = Player.ToData() as PlayerData; // Remember Player's physical properties (e.g. vel) so we can preserve 'em.
            pd.pos = GetPlayerStartingPosFromPrevExitPos(nextLD, sideEntering, posExited);
            if (sideEntering == Sides.B)                   // Entering from bottom?? Give min y-vel to boost us into the room!
            {
                pd.vel = new Vector2(pd.vel.x, Mathf.Max(pd.vel.y, 0.6f));
            }
            StartGameAtRoom(nextLD, pd);
        }
        else
        {
            Debug.LogWarning("Whoa! No room at this side: " + sideEscaped);
        }
    }
Esempio n. 2
0
 public int GetSideBeamExits(int sideEntered)
 {
     if (MyOccupant == null)
     {
         return(Sides.GetOpposite(sideEntered));
     }                                                                // No BoardOccupant? Pass straight through me; simply return the other side.
     return(MyOccupant.SideBeamExits(sideEntered));
 }
Esempio n. 3
0
 //public static int GetOppositeSide (Vector2Int dir) { return GetOppositeSide(GetSide(dir)); }
 //public static int GetOppositeSide (int side) {
 //    switch (side) {
 //        case 0: return 2;
 //        case 1: return 3;
 //        case 2: return 0;
 //        case 3: return 1;
 //        default: throw new UnityException ("Whoa, " + side + " is not a valid side. Try 0, 1, 2, or 3.");
 //    }
 //}
 public static Vector2Int GetOppositeDir(int side)
 {
     return(GetDir(Sides.GetOpposite(side)));
 }
Esempio n. 4
0
 virtual public int SideBeamExits(int sideEntered)
 {
     return(Sides.GetOpposite(sideEntered));
 }
Esempio n. 5
0
 public static int GetOppositeSide(int side)
 {
     return(Sides.GetOpposite(side));
 }