示例#1
0
    void TransitionToNextLevel()
    {
        if (levelIndex == levelTexts.Length - 1)
        {
            victoryText = string.Format("Thanks for playing!\nYou won in {0} {1}.\nYou caused {2} {3}.\nHold Esc to quit.",
                                        clickTally, clickTally == 1 ? "click" : "clicks",
                                        crashTally, crashTally == 1 ? "crash" : "crashes");
            return;
        }
        levelIndex++;
        lastLevel = level;
        lastRoot  = root;
        Restart(false);
        // Place the newly constructed level.
        List <LevelExitDirection> possibleDirections = new List <LevelExitDirection>(Enum.GetValues(typeof(LevelExitDirection)) as LevelExitDirection[]);

        possibleDirections.Remove(lastLevel.exitDirection);
        possibleDirections.Remove(Util.GetOppositeDirection(level.exitDirection));
        LevelExitDirection direction = possibleDirections[UnityEngine.Random.Range(0, possibleDirections.Count)];

        transitionT  = 0;
        transitionTo = root.transform.localPosition;
        root.transform.localPosition += Util.GetDirectionVector(direction, TRANSITION_DISTANCE);
        transitionFrom = root.transform.localPosition;
    }
示例#2
0
 public static Vector3 GetDirectionVector(LevelExitDirection direction, float magnitude)
 {
     if (direction == LevelExitDirection.Down)
     {
         return(new Vector3(0, 0, -magnitude));
     }
     if (direction == LevelExitDirection.Left)
     {
         return(new Vector3(-magnitude, 0, 0));
     }
     if (direction == LevelExitDirection.Right)
     {
         return(new Vector3(magnitude, 0, 0));
     }
     return(new Vector3(0, 0, magnitude));
 }
示例#3
0
 public static LevelExitDirection GetOppositeDirection(LevelExitDirection direction)
 {
     if (direction == LevelExitDirection.Down)
     {
         return(LevelExitDirection.Up);
     }
     if (direction == LevelExitDirection.Left)
     {
         return(LevelExitDirection.Right);
     }
     if (direction == LevelExitDirection.Right)
     {
         return(LevelExitDirection.Left);
     }
     return(LevelExitDirection.Down);
 }