コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     _currState = _playerBH.State;
     if (AllowRotation)
     {
         RotateCamera();
     }
     RaiseCamera();
 }
コード例 #2
0
ファイル: FollowPlayer.cs プロジェクト: Tibauvdb/PlatDev-Exam
    void Update()
    {
        #region Previous
        //First check if player is in visionDistance
        _currState = _player.gameObject.GetComponent <PlayerBehaviour>().State;

        if (Vector3.Distance(this.gameObject.transform.position, _player.position) <= _visionDistance)
        {
            //If Player is in VisionDistance -> Check if nothing is blocking LOS
            RaycastHit hit;
            if (Physics.Linecast(this.gameObject.transform.position, _player.position, out hit, _layerMask) || _currState == PlayerBehaviour.States.Sitting || _currState == PlayerBehaviour.States.KnockedOut)
            {
                //If the lineCast returns true, something is in between the player & AI
                if (this.gameObject.name.Contains("Type01"))
                {
                    if (_aiBehaviour.IsAIFollowing)
                    {
                        _aiBehaviour.ResetAgent();
                    }
                }
                _aiBehaviour.IsAIFollowing = false;
                if (this.gameObject.name.Contains("Type02"))
                {
                    //Doesn't happen
                    _aiBehaviour.IsAILooking = false;;
                }
                //Reset Agent
            }
            else
            {
                //Check if following or looking type
                if (this.gameObject.name.Contains("Type01"))
                {
                    _aiBehaviour.IsAIFollowing = true;
                }
                if (this.gameObject.name.Contains("Type02"))
                {
                    _aiBehaviour.IsAILooking = true;
                }

                _aiBehaviour.PlayerPosition = _player.position;
            }
        }
        else
        {
            if (this.gameObject.name.Contains("Type01"))
            {
                _aiBehaviour.IsAIFollowing = false;
            }
            if (this.gameObject.name.Contains("Type02"))
            {
                _aiBehaviour.IsAILooking = false;
            }
        }
        #endregion
    }
コード例 #3
0
ファイル: AllowPickup.cs プロジェクト: Tibauvdb/PlatDev-Exam
    private void CheckIfPlayerCanPickUp(GameObject player)
    {
        PlayerBehaviour.States state = player.GetComponent <PlayerBehaviour>().State;

        //Allow player to pick up object
        if (Input.GetButtonDown(_input.A) && state != PlayerBehaviour.States.WalkingWithPickup)
        {
            player.GetComponent <PlayerBehaviour>().PickUpObject(this.gameObject);
            this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
        }
    }
コード例 #4
0
    void Update()
    {
        currentState = GetComponent <PlayerBehaviour>().currentState;
        //to-do make sure colliders are for solid objects

        if (currentState != PlayerBehaviour.States.flinching && currentState != PlayerBehaviour.States.dying)
        {
            AirborneOrIdle();
            if (GameInput.Left())
            {
                if (currentState != PlayerBehaviour.States.airborne)
                {
                    currentState = PlayerBehaviour.States.walking;
                }
                Move(-Speed, null);
                anim.SetBool("Moving", true);
            }
            else if (GameInput.Right())
            {
                if (currentState != PlayerBehaviour.States.airborne)
                {
                    currentState = PlayerBehaviour.States.walking;
                }
                Move(Speed, null);
                anim.SetBool("Moving", true);
            }
            else
            {
                if (currentState != PlayerBehaviour.States.airborne)
                {
                    currentState = PlayerBehaviour.States.idle;
                }
                PlayerRigidbody.velocity = new Vector2(0, PlayerRigidbody.velocity.y);

                anim.SetBool("Moving", false);
            }
            if (GameInput.Jump())
            {
                if (currentState != PlayerBehaviour.States.airborne)
                {
                    Move(null, JumpPower);
                }
            }
        }
        else if (currentState == PlayerBehaviour.States.flinching)
        {
            Flinch();
        }
    }
コード例 #5
0
    private void CheckPlayerStates(GameObject player)
    {
        PlayerBehaviour.States state = player.GetComponent <PlayerBehaviour>().State;

        //Preparing throw, as soon as trigger gets released, object will be thrown
        if (state == PlayerBehaviour.States.WalkingWithPickup && Input.GetAxis(_input.Triggers) != 0)
        {
            StartThrow();
        }

        //Throw object
        if (_isThrowing == true && Input.GetAxis(_input.Triggers) == 0)
        {
            Throw();
        }
    }
コード例 #6
0
ファイル: BoxBehaviour.cs プロジェクト: Tibauvdb/PlatDev-Exam
    private void CheckPlayerState(GameObject player)
    {
        PlayerBehaviour.States state = player.GetComponent <PlayerBehaviour>().State;

        if (Input.GetButtonDown(_input.A))
        {
            if (state == PlayerBehaviour.States.Walking)
            {
                WalkingToPushBox(player);
            }
            else if (state == PlayerBehaviour.States.PushingBox)
            {
                PushBoxToWalking(player);
            }
        }
    }
コード例 #7
0
    private bool CheckLineOfSight(bool allowReset)
    {
        _currentState = _player.GetComponent <PlayerBehaviour>().State;
        RaycastHit hit;

        if (Physics.Linecast(this.gameObject.transform.position, _player.transform.position, out hit, _layerMask) || _currentState == PlayerBehaviour.States.Sitting || _currentState == PlayerBehaviour.States.KnockedOut)
        {
            //Something in between player & AI
            if (allowReset && _aiBehaviour.IsAIFollowing)
            {
                _aiBehaviour.ResetAgent();
            }
            return(false);
        }
        else
        {
            _aiBehaviour.PlayerPosition = _player.transform.position;
            return(true);
        }
    }