Esempio n. 1
0
 public void SetForce(float force)
 {
     if (transform.localScale.x < 0)
     {
         RgbChar.AddForce(new Vector2(force * -1, 0));
     }
     else
     {
         RgbChar.AddForce(new Vector2(force, 0));
     }
 }
Esempio n. 2
0
 public void GetDamage(float damage, Vector2 posEnemie)
 {
     base.GetDamage(damage);
     spriteEffect.CancelEffect();
     spriteEffect.StartInvunerable();
     playerController.StartCoroutine(TimeDesactiveControlls(0.4f));
     RgbChar.velocity = Vector2.zero;
     animChar.SetInteger("AnimState", 0);
     if (posEnemie.x >= transform.position.x)
     {
         RgbChar.AddForce(new Vector2(-directionKnowBack.x, directionKnowBack.y) * forceKnowBack);
     }
     else
     {
         RgbChar.AddForce(new Vector2(directionKnowBack.x, directionKnowBack.y) * forceKnowBack);
     }
 }
Esempio n. 3
0
    public IEnumerator GetKnowBack(float forceKnowBack, Vector3 posPlayer)
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        RgbChar.velocity = new Vector2(0, RgbChar.velocity.y);
        if (posPlayer.x >= transform.position.x)
        {
            RgbChar.AddForce(new Vector2(-directionKnowBack.x, directionKnowBack.y) * forceKnowBack);
        }
        else
        {
            RgbChar.AddForce(new Vector2(directionKnowBack.x, directionKnowBack.y) * forceKnowBack);
        }
        yield return(new WaitForSeconds(0.05f));

        RgbChar.velocity = new Vector2(0, RgbChar.velocity.y);
    }
Esempio n. 4
0
 private void Jump()
 {
     if (isGround && !isAttacking())
     {
         RgbChar.AddForce(new Vector2(0, forceJump));
     }
     else if (!isGround && isWall)
     {
         if (transform.localScale.x < 0)
         {
             RgbChar.velocity = Vector2.zero;
             RgbChar.AddForce(new Vector2(500, forceJump));
         }
         else
         {
             RgbChar.velocity = Vector2.zero;
             RgbChar.AddForce(new Vector2(-500, forceJump));
         }
     }
 }