// Use this for initialization
 void Start()
 {
     thisPlayerBack = GetComponent <MoveBackwards>();
     rectTransform  = GetComponent <RectTransform>();
     thisPlayerMove = GetComponent <MoveOneTile>();
     thisPlayerMove.OnEndMoveEvent += ReactToEndMove;
     thisPlayerBack.OnEndMoveEvent += ReactToEndMove;
 }
 private void Start()
 {
     // Get components for moving and teleporting
     PMC = PlayerGameObject.GetComponent <MovementComponent>();
     PTC = PlayerGameObject.GetComponent <TeleportComponent>();
     // bind Command to Class
     buttonW     = new MoveForward(PMC);
     buttonS     = new MoveBackwards(PMC);
     buttonShift = new Teleport(PTC);
     nothing     = new DoNothing(PMC);
 }
Example #3
0
 private void Awake()
 {
     CheckPlayerCollision.OnPlayersDidntCollide += CheckForTurn;
     CheckPlayerCollision.OnPlayersCollided     += CheckForOtherHit;
     playerDice     = GetComponent <PlayerDiceHolding>();
     playermove     = GetComponent <MoveOneTile>();
     moveSync       = GetComponent <PlayerMoveSync>();
     playerMoveBack = GetComponent <MoveBackwards>();
     MoveBackwards.OnGamestateChanged += CheckAfterMoveBack;
     if (GetComponent <PlayerMoveSync>() != null)
     {
         playerID = GetComponent <PlayerMoveSync>().playerID;
         PlayerMoveSync.OnTalismanDiceRolled += ActivateTalism;
         isMulti = true;
     }
     else
     {
         DiceMechanism.OnTalismanDiceRolled += ActivateTalism;
         CheckForTurn(0);
     }
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        // Continuously applies a force to the Player object in the positive Z direction using the forwardForce float
        if (Input.GetKey("w"))
        {
            Command MoveForward = new MoveForward(rb, forwardForce);
            //rb.AddForce(0, 0, forwardForce * Time.deltaTime);

            Invoker invoker = new Invoker();
            invoker.SetCommand(MoveForward);
            invoker.ExecuteCommmand();
        }

        // Constantly checks to see if the player presses the "d" key
        if (Input.GetKey("d"))
        {
            Command MoveRight = new MoveRight(rb, sideForce);
            // A force is added to the Player object in the positive X direction using the sideForce float
            //rb.AddForce(sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);

            Invoker invoker = new Invoker();
            invoker.SetCommand(MoveRight);
            invoker.ExecuteCommmand();
        }

        // Constantly checks to see if the player presses the "a" key
        if (Input.GetKey("a"))
        {
            // A force is added to the Player object in the negative X direction using the sideForce float
            Command MoveLeft = new MoveLeft(rb, sideForce);
            //MoveLeft.Execute();
            //rb.AddForce(-sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);

            Invoker invoker = new Invoker();
            invoker.SetCommand(MoveLeft);
            invoker.ExecuteCommmand();
        }

        // Constantly checks to see if the player presses the "s" key
        if (Input.GetKey("s"))
        {
            Command MoveBackwards = new MoveBackwards(rb, forwardForce);
            // A force is added to the Player object in the negative Z direction using the forwardForce float
            //rb.AddForce(0, 0, -forwardForce * Time.deltaTime);

            Invoker invoker = new Invoker();
            invoker.SetCommand(MoveBackwards);
            invoker.ExecuteCommmand();
        }

        // Constantly checks to see if the player has pressed the spacebar and that the jumpsRemaining float is greater than 0
        //if (Input.GetKeyDown("space") && canDoubleJump == false)
        //{

        //    // Calls the Jumping function
        //    Jumping();

        //    // Sets the canDoubleJump boolean to true
        //    canDoubleJump = true;

        //}

        //// Constantly checks to see if the player has released the spacebar
        //if (Input.GetKeyUp("space"))
        //{

        //    // Sets the canDoubleJump boolean to false
        //    canDoubleJump = false;

        //}


        // Constantly checks to see if the Player object has fallen below -1 on the Y axis
        if (rb.position.y < -5f)
        {
            // Calls the EndGame function from the Game_Manager script
            FindObjectOfType <Game_Manager>().EndGame();
        }
    }