Exemple #1
0
    // Use this for initialization
    void Start()
    {
        GameObject manager = GameObject.Find("MovementManager");

        playerSelector = manager.GetComponent <PlayerSelector>();
        playerSelector.SetSelectable(false);

        index       = 0;
        turnManager = GetComponentInParent <TurnManager>();

        StartCoroutine("FadeIn");
    }
    void Update()
    {
        navAgent.SamplePathPosition(-1, 0.0f, out navHit); //when player is moving

        //check the areas the player hit
        if (navHit.mask == 8)              //NavMeshArea Mud
        {
            navAgent.speed = speed * 0.5f; //set speed to half the speed
        }
        else
        {
            navAgent.speed = speed;
        }


        if (selected)
        {
            if (Input.GetMouseButtonDown(0))                                //if left mouse button is pressed
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition); //get mouse position
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit)) //if raycast hits something
                {
                    //TO DO...
                    //so you can select another player instead
                    //or so you can select multiple players

                    selector.SetSelectable(false); //not possible to select other players

                    cameraManager.ChangeMovable(); //make the camera able to follow the player
                    cameraManager.StartCoroutine("FollowPlayer", gameObject);

                    StartCoroutine("MovePlayer", hit.point); //begin movement
                }
            }
        }
    }
Exemple #3
0
    public IEnumerator PlayerTurn()
    {
        if (!gameOver)
        {
            gameRound++;
            playerSelector.SetSelectable(false);
            turnText.text    = "Player turn";
            turnText.enabled = true;

            yield return(new WaitForSeconds(2));

            turnText.enabled = false;
            playerSelector.SetSelectable(true);

            foreach (GameObject player in players)
            {
                if (player != null)
                {
                    player.GetComponent <PlayerScript>().TurnBegin();
                }
            }
        }
    }