Exemple #1
0
        void LateUpdate()
        {
            if (!photonView.IsMine)
            {
                return;
            }

            if (/*!character.isBusy &&*/ Dialog.conversationTarget == null)
            {
                // Jumping

                /*if (buttonQueue.Consume("Cross")) {
                 *  motor.Jump();
                 * }*/

                if (Input.GetKeyDown(KeyCode.F))
                {
                    motor.AddForce(transform.forward * 500f);
                }

                if (Input.GetKeyDown(KeyCode.R))
                {
                    character.inCombat = !character.inCombat;
                }

                // Attacking
                if (!character.isAttacking && buttonQueue.Consume("R1"))
                {
                    character.Attack(AttackType.Light);
                }

                if (!character.isAttacking && buttonQueue.Consume("R2"))
                {
                    character.Attack(AttackType.Heavy);
                }

                // Blocking
                if (Input.GetButton("L1"))
                {
                    character.Block(true);
                }
                else
                {
                    character.Block(false);
                }

                // Evading
                if (buttonQueue.Consume("Circle"))
                {
                    character.Evade(GetInputDirection());
                }

                // Heal
                if (buttonQueue.Consume("Square"))
                {
                    character.Heal();
                }

                // Interact
                if (Input.GetButtonDown("Cross"))
                {
                    character.Interact();
                }
            }

            // Targeting
            if (Input.GetButtonDown("R3"))
            {
                if (character.target == null)
                {
                    List <Target> targetables = new List <Target>(FindObjectsOfType <Target>());
                    targetables.Sort(delegate(Target x, Target y) {
                        return(Vector3.Distance(this.transform.position, x.transform.position).CompareTo(Vector3.Distance(this.transform.position, y.transform.position)));
                    });

                    targetables = targetables.FindAll(delegate(Target target) {
                        return(Vector3.Distance(transform.position, target.transform.position) <= minTargetDistance && target.gameObject != gameObject);
                    });

                    if (targetables.Count > 0)
                    {
                        character.target = targetables[0];
                    }
                }
                else
                {
                    character.target = null;
                }
            }

            if (transform.position.y < -50f)
            {
                character.Kill();
            }

            // Position camera socket when the CharacterMotor is disabled
            if (motor.enabled == false)
            {
                PositionSocket();
            }
        }