Example #1
0
 /// <summary>
 /// Reenables mvoement after knockback if still alive
 /// </summary>
 void ReEnableMovement()
 {
     if (HP.health > 0)
     {
         PlayerMovementLocal pm = GetComponent <PlayerMovementLocal>();
         pm.SetMove();
     }
 }
Example #2
0
    /// <summary>
    /// Tells this specific player to apply knockback
    /// Other players will get the update via transform sync
    /// </summary>
    /// <param name="con">Connection to target</param>
    /// <param name="angle">Angle to launch</param>
    void TargetLaunch(float angle)
    {
        //if player isn't dead, apply knockback
        if (HP.health > 0)
        {
            //disable movement
            PlayerMovementLocal pm = GetComponent <PlayerMovementLocal>();
            pm.DisableMove();
            pm.ToggleFlex(false);
            //apply knockback
            Vector2 force = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad)) * knockback;
            print(force);
            rb.AddForce(force, ForceMode2D.Impulse);

            Invoke("ReEnableMovement", knockbackStunTime);
        }
    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     mvr = GetComponent <PlayerMovement>();
     if (!mvr)
     {
         lmvr = GetComponent <PlayerMovementLocal>();
     }
     slash = GetComponent <Slasher>();
     if (!slash)
     {
         lslash = GetComponent <SlasherLocal>();
     }
     colHand = GetComponent <CollisionHandler>();
     if (!colHand)
     {
         lcolHand = GetComponent <CollisionHandlerLocal>();
     }
     rb           = GetComponent <Rigidbody2D>();
     anim         = GetComponent <Animator>();
     achievements = AcheivementScript.Instance;
 }
Example #4
0
    /// <summary>
    /// Toggles collision and movement logic for pits
    /// </summary>
    public void ToggleInteractivity(bool toggle)
    {
        //toggle movement
        PlayerMovementLocal lm = GetComponent <PlayerMovementLocal>();

        if (toggle)
        {
            lm.SetMove();
        }
        else
        {
            lm.DisableMove();
        }
        //toggle all triggers/hitboxes in system, toggle weapons off but never on
        foreach (BoxCollider2D col in GetComponentsInChildren <BoxCollider2D>())
        {
            if (!col.gameObject.CompareTag("Weapons") || !toggle)
            {
                col.enabled = toggle;
            }
        }
        GetComponent <BoxCollider2D>().enabled = toggle;
        //toggle velocity
        if (!toggle)
        {
            rb.constraints = RigidbodyConstraints2D.FreezeAll;
        }
        else
        {
            rb.constraints = RigidbodyConstraints2D.FreezeRotation;
        }

        SlasherLocal sl = GetComponent <SlasherLocal>();

        if (sl.isSwinging)
        {
            sl.EndSlash();
        }
    }
Example #5
0
 // Start is called before the first frame update
 void Start()
 {
     mvr        = GetComponent <PlayerMovementLocal>();
     anim       = GetComponent <Animator>();
     isSwinging = false;
 }