Ejemplo n.º 1
0
    protected override void Execute(InputState actions)
    {
        if (actions.CheckAction(waypointMovement))
        {
            if (currentPath == null)
            {
                currentPath = seek.StartPath(transform.position, actions.target.position);
                currentNode = 0;
            }
            else
            {
                Vector3 targetPoint = currentPath.vectorPath[currentNode];

                Vector3    direction = targetPoint - transform.position;
                Quaternion rot       = Quaternion.LookRotation(direction.normalized, transform.up);
                rot = Quaternion.Euler(0, rot.eulerAngles.y, 0);
                transform.rotation = Quaternion.Slerp(transform.rotation, rot, accuracy);

                Vector3 move = transform.forward * speed;

                move.y         = rigid.velocity.y;
                rigid.velocity = Vector3.Lerp(rigid.velocity, move, acceleration);

                if (Vector3.Distance(transform.position, targetPoint) <= nodeRange)
                {
                    currentNode++;
                    if (currentNode >= currentPath.vectorPath.Count)
                    {
                        currentPath = null;
                    }
                }
            }
        }
        else if (actions.CheckAction(directMovement))
        {
            Vector3    direction = actions.target.position - transform.position;
            Quaternion rot       = Quaternion.LookRotation(direction.normalized, transform.up);
            rot = Quaternion.Euler(0, rot.eulerAngles.y, 0);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, accuracy);

            Vector3 move = transform.forward * speed;

            move.y         = rigid.velocity.y;
            rigid.velocity = Vector3.Lerp(rigid.velocity, move, acceleration);
        }
        else if (actions.CheckAction(rotateOnly))
        {
            Vector3    direction = actions.target.position - transform.position;
            Quaternion rot       = Quaternion.LookRotation(direction.normalized, transform.up);
            rot = Quaternion.Euler(0, rot.eulerAngles.y, 0);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, accuracy);
        }
        else
        {
            rigid.velocity = Vector3.zero;
            currentPath    = null;
        }
    }
Ejemplo n.º 2
0
    protected override void Execute(InputState actions)
    {
        Quaternion def = Quaternion.Euler(Vector3.zero);

        if ((!actions.CheckAction(leftActionAssignment) && !actions.CheckAction(rightActionAssignment)) ||
            (actions.CheckAction(leftActionAssignment) && actions.CheckAction(rightActionAssignment)))
        {
            leanTarget.localRotation = Quaternion.Slerp(leanTarget.localRotation, def, leanSpeed);
        }
        else if (actions.CheckAction(leftActionAssignment))
        {
            if (!actions.CheckAction(rightActionAssignment))
            {
                Quaternion targetRot = Quaternion.Euler(0, 0, leanAmount);
                leanTarget.localRotation = Quaternion.Slerp(leanTarget.localRotation, targetRot, leanSpeed);
            }
        }
        else if (actions.CheckAction(rightActionAssignment))
        {
            if (!actions.CheckAction(leftActionAssignment))
            {
                Quaternion targetRot = Quaternion.Euler(0, 0, -leanAmount);
                leanTarget.localRotation = Quaternion.Slerp(leanTarget.localRotation, targetRot, leanSpeed);
            }
        }
    }
Ejemplo n.º 3
0
 protected override void Execute(InputState actions)
 {
     if (actions.CheckAction(assignedAction) && currentCooldown <= 0)
     {
         Vector3 dir = actions.target.position - transform.position;
         dir.y = 0;
         rigid.AddForce(dir * strength, ForceMode.Impulse);
         currentCooldown = cooldown;
     }
 }
Ejemplo n.º 4
0
    protected override void Execute(InputState actions)
    {
        for (int i = 0; i < toolInputs.Count; i++)
        {
            if (currentSequence.Count < sequenceLength && actions.CheckAction(toolInputs[i]))
            {
                currentSequence.Add((Input)i);
                HudController.instance.DisplayCharacter((Input)i);
                Debug.Log((Input)i);
            }
        }

        if (actions.CheckAction(InputState.Actions.Action0))
        {
            CheckSequence();
        }

        if (actions.CheckAction(InputState.Actions.Action9))
        {
            currentSequence = new List <Input>();
        }
    }