コード例 #1
0
    public override void Think(Thinker thinker)
    {
        DrakeController    drake     = thinker.Remember <DrakeController>("drake");
        MovementController mc        = thinker.Remember <MovementController>("movement");
        AttackController   at        = thinker.Remember <AttackController>("attack");
        Vector2            moveInput = thinker.Remember <Vector2>("moveInput");

        if (!mc.IsGrounded)
        {
            return;
        }

        if (moveInput.sqrMagnitude <= 0)
        {
            moveInput = new Vector2(1, 0);
        }
        else if (mc.IsAtWall() || mc.IsAtEdge())
        {
            moveInput.x *= -1;
        }

        thinker.Remember("moveInput", moveInput);
        drake.Walk(moveInput);

        if (target.Value != null && at.AttackCollider.bounds.Intersects(target.Value.bounds))
        {
            drake.Attack();
        }
    }
コード例 #2
0
    public override void Think(Thinker thinker)
    {
        DrakeController drake     = thinker.GetComponent <DrakeController>();
        Vector2         moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

        drake.Walk(moveInput);
        if (Input.GetButtonDown("Jump") || moveInput.y > 0)
        {
            drake.Jump();
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            drake.Attack();
        }
    }