コード例 #1
0
    private void FixedUpdate()
    {
        if (myController.IsDisabled())
        {
            return;
        }

        steeringForce = Vector3.zero;

        changeTargetTimer -= Time.fixedDeltaTime;
        attackTimer       -= Time.fixedDeltaTime;

        // Check for a new target
        if (changeTargetTimer < 0.0f)
        {
            targetPlayer      = FindClosestPlayer();
            changeTargetTimer = changeTargetCheck;
        }

        // If we have a target player
        if (targetPlayer)
        {
            // If out of range, seek
            if ((this.transform.position - targetPlayer.transform.position).magnitude > attackDistance)
            {
                steeringForce += Seek(targetPlayer.transform.position);
                myController.SetLook(targetPlayer.transform.position - this.transform.position);
            }
            else if (attackTimer < 0.0f)
            {
                // If not charging or firing, start charging
                if (!myController.IsCharging() && !myController.IsFiring())
                {
                    myController.StartCharging();
                    attackTimer = Random.Range(0.5f, 1.5f);
                }
                // If not firing and are charging, fire
                else if (!myController.IsFiring() && myController.IsCharging())
                {
                    myController.SetLook(targetPlayer.transform.position - this.transform.position);
                    myController.FireProjectile();
                }
            }
            else
            {
                myController.SetLook(targetPlayer.transform.position - this.transform.position);
            }
        }
        else
        {
            myController.SetLook(rigidBody.velocity);
        }

        steeringForce += Containment();

        steeringForce = Vector3.ClampMagnitude(steeringForce, maxSteeringForce);

        currentForce = Vector3.ClampMagnitude(currentForce + steeringForce, maxVelocity);
        myController.Move(currentForce);
    }
コード例 #2
0
ファイル: HumanPlayer.cs プロジェクト: StefTheDev/Prototype4
    private void FixedUpdate()
    {
        if (myController.IsDisabled())
        {
            return;
        }

        float horMove  = Input.GetAxisRaw(horizontalAxes[playerID]);
        float vertMove = Input.GetAxisRaw(verticalAxes[playerID]);

        Vector3 moveVector = new Vector3(horMove, 0.0f, vertMove).normalized;

        myController.Move(moveVector);

        if (moveVector != Vector3.zero)
        {
            this.transform.forward = moveVector;
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (!inputsDisabled)
        {
            moveInputs.x = Input.GetAxisRaw("Horizontal");
            moveInputs.z = Input.GetAxisRaw("Vertical");

            bool camouflageInput = Input.GetButton("Camouflage");
            // bool camouflageInput = (playerRef.HeldCrystalType() == CrystalType.Purple);

            playerController.Move(moveInputs, jumpInput, camouflageInput);
        }

        switch (actionState)
        {
        default:
            break;

        case ActionState.jump:
        {
            jumpInput          = Input.GetButtonDown("Jump");
            actionImage.sprite = jumpImage;
            break;
        }

        case ActionState.talk:
        {
            if (Input.GetButtonDown("Jump"))
            {
                NPCManager.Instance.Next();
            }
            actionImage.sprite = talkImage;
            break;
        }
        }
    }