Esempio n. 1
0
    void Move()
    {
        //gets movement in x and z axis by wasd
        Vector3 movement = inputManager.GetMovementInput();

        if (movement != Vector3.zero)
        {
            RaycastHit hitInfo;
            if (Physics.Raycast(transform.position, movement, out hitInfo, 1.1f)) //check if player is going to move into wall or another player - if not, move him
            {
                if (hitInfo.collider.tag == "Wall")                               //if player moves into a wall, don't accept input
                {
                    paused = true;
                    StartCoroutine(Unpause());
                    return;
                }
            }
            else
            {
                transform.Translate(movement);
            }

            //if within attack range after moving, attack another player
            if (Physics.Raycast(transform.position, movement, out hitInfo, stats.attackRange))
            {
                if (hitInfo.collider.tag == "Player")
                {
                    CmdCombat(hitInfo.collider.gameObject);
                    isTurn = false;
                    paused = true;
                    StartCoroutine(Unpause());
                    return;
                }
            }

            isTurn = false;
            paused = true;
            CmdSetNextPlayerTurn();
            StartCoroutine(Unpause());
        }
    }