Esempio n. 1
0
    public void changeSelection(InputAction.CallbackContext context)
    {
        if (cooldown != 0 || hasSelected)
        {
            return;
        }

        Vector2 leftStickPos    = (Vector2)context.ReadValueAsObject();
        int     newSiblingIndex = playerSelect.transform.parent.GetSiblingIndex();
        int     newXOffset      = 0;
        int     newYOffset      = 0;

        if (leftStickPos.x > 0.0f)
        {
            newXOffset      += 100;
            newSiblingIndex += 1;
            if (newSiblingIndex % 4 == 0 && newSiblingIndex != 0)
            {
                newXOffset      -= 400;
                newSiblingIndex -= 4;
            }
        }
        else if (leftStickPos.x < 0.0f)
        {
            newXOffset      -= 100;
            newSiblingIndex -= 1;

            if (newSiblingIndex < 0 || newSiblingIndex % 4 == 3)
            {
                newXOffset      += 400;
                newSiblingIndex += 4;
            }
        }

        if (leftStickPos.y > 0.0f)
        {
            newYOffset      += 100;
            newSiblingIndex -= 4;
            if (newSiblingIndex < 0)
            {
                newYOffset      -= 200;
                newSiblingIndex += 8;
            }
        }
        else if (leftStickPos.y < 0.0f)
        {
            newYOffset      -= 100;
            newSiblingIndex += 4;
            if (newSiblingIndex > 7)
            {
                newYOffset      += 200;
                newSiblingIndex -= 8;
            }
        }

        playerSelect.transform.position = new Vector2(playerSelect.transform.position.x + newXOffset, playerSelect.transform.position.y + newYOffset);
        playerSelect.transform.SetParent(options[newSiblingIndex].transform);
        cooldown = 2;
    }
Esempio n. 2
0
    public void OnJump(InputAction.CallbackContext context)
    {
        float jump = (float)context.ReadValueAsObject();

        if (jump == 1)
        {
            jumpEvent.Raise();
        }
    }
    public void Look(InputAction.CallbackContext context)
    {
        Vector2 rightStickPos = (Vector2)context.ReadValueAsObject();
        float   h             = rightStickPos.x * Time.deltaTime * rotation_speed;
        float   v             = rightStickPos.y * Time.deltaTime * rotation_speed;
        float   aim_angle     = Mathf.Atan2(v, -h) * Mathf.Rad2Deg;

        head.transform.rotation = Quaternion.AngleAxis(-aim_angle, Vector3.forward);
    }
 private void PI_onActionTriggered(InputAction.CallbackContext obj)
 {
     if (obj.performed && obj.action.type == InputActionType.Button)
     {
         var i = Convert.ToInt32((float)obj.ReadValueAsObject());
         foreach (var x in Subscribers)
         {
             x.SendMessage("On" + obj.action.name, i, SendMessageOptions.DontRequireReceiver);
         }
     }
 }
Esempio n. 5
0
    public void OnAbsorb(InputAction.CallbackContext context)
    {
        float absorb = (float)context.ReadValueAsObject();

        if (absorb == 1)
        {
            // if we are pressing down and simultaneously pressing absorb, we want to remove the skill
            if (movement.y == -1)
            {
                removeSkillEvent.Raise();
            }
            else
            {
                grabEvent.Raise();
                absorbEvent.Raise();
            }
        }
    }
    public void Move(InputAction.CallbackContext context)
    {
        if (!block)
        {
            Vector2 leftStickPos = (Vector2)context.ReadValueAsObject();
            float   h            = leftStickPos.x * movement_speed;
            float   v            = leftStickPos.y * movement_speed;

            moveDir = new Vector2(h, v);

            rb.velocity = moveDir * Time.deltaTime;

            float aim_angle = Mathf.Atan2(v, h) * Mathf.Rad2Deg;
            body.transform.rotation = Quaternion.AngleAxis(aim_angle, Vector3.forward);
        }
        else
        {
            rb.velocity = Vector3.zero;
        }
    }
Esempio n. 7
0
 void DebugEvent(InputAction.CallbackContext context)
 {
     Debug.Log(context.phase + " " + context.ReadValueAsObject());
 }
Esempio n. 8
0
 public void MoveTrunkEnd(InputAction.CallbackContext context)
 {
     endAxis = (float)context.ReadValueAsObject();
 }