示例#1
0
    // Update is called once per frame
    void Update()
    {
        //We first call super class function
        base.Update();

        bool moved = false;         //moved indicates that the user has attempted to move

        //We are only allowed to move if there are no holds on the player
        if (!isHeld())
        {
            moved = true;
            //Here we check for the arrow keys inputs and WASD inputs for movement, the turn based controller is then prompted after the movement
            if ((Input.GetKeyDown(KeyCode.UpArrow)) || (Input.GetKeyDown(KeyCode.W)))
            {
                moveSightWise(1);
                TurnBasedController.advanceTurn();
            }
            else if ((Input.GetKeyDown(KeyCode.DownArrow)) || (Input.GetKeyDown(KeyCode.S)))
            {
                moveSightWise(-1);
                TurnBasedController.advanceTurn();
            }
            else if ((Input.GetKeyDown(KeyCode.LeftArrow)) || (Input.GetKeyDown(KeyCode.A)))
            {
                moveSideWays(1);
                TurnBasedController.advanceTurn();
            }
            else if ((Input.GetKeyDown(KeyCode.RightArrow)) || (Input.GetKeyDown(KeyCode.D)))
            {
                moveSideWays(-1);
                TurnBasedController.advanceTurn();
            }
            //If the user preses space it indicates that they are waiting and the enviroment will advance a turn
            else if (Input.GetKeyDown(KeyCode.Space))
            {
                TurnBasedController.advanceTurn();
            }
            //If no movement commands are issues then we mark it as false
            else
            {
                moved = false;
            }
        }
        //Q and E rotate the camera, Q by 90 degrees and E by 270 degrees (equal to -90 degrees)
        //The camera offset which is used to ensure the movement keys are relative also have to be changed here
        if (Input.GetKeyDown(KeyCode.Q))
        {
            rotateClockwise();
            if (++offSet > 7)
            {
                offSet -= 8;
            }
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            rotateAntiClockwise();
            if (--offSet < 0)
            {
                offSet += 8;
            }
        }
        //Empty else-if statement for tab is used here so the disableGUI() function is called which is the only function needed for Tab
        else if (Input.GetKeyDown(KeyCode.Tab))
        {
            ;
        }
        //Escape loads the main menu level
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("MainMenu");
        }
        //R loads the same level we're on
        else if (Input.GetKeyDown(KeyCode.R))
        {
            Application.LoadLevel(Application.loadedLevelName);
        }
        //If we haven't moved we return to avoid calling disableGUI()
        else if (!moved)
        {
            return;
        }
        //If any control has been pressed the GUI is disabled to prevent positioning issues and inconsistency issues
        LevelGUI.disableGUI();
    }
示例#2
0
 void Start()
 {
     //It registers itself in the turn based controller
     TurnBasedController.addTurnBasedElement(this);
 }
示例#3
0
 //Frezes the mob from moving
 public void freezeMob()
 {
     //To freeze the mob we simply remove the mob from the turn based controller
     TurnBasedController.removeTurnBasedElement(turnBasedElement);
 }