Esempio n. 1
0
    private IEnumerator ParryKnockbackTask(Vector2 dir, float duration, float force)
    {
        if (movementController != null)
        {
            StopBlocking();
            movementController.DashEnd();
            movementController.SetAnimationDirection(dir);
            if (weapon != null)
            {
                weapon.BreakAttack();
                if (weapon.weaponAnimator != null)
                {
                    SNWeapon.SetAnimationDirection(weapon.weaponAnimator, dir);
                    weapon.weaponAnimator.Play("Knockback");
                }
            }
            canAttack = false;
            movementController.canMove = false;
            movementController.PlayAnimation(SNMovementController.AnimationsStates.Knockback, true);
            movementController.Knockback(-dir, force, duration);
            yield return(new WaitForSeconds(duration));

            movementController.UnlockAnimations();
            if ((weapon != null) && (weapon.weaponAnimator != null))
            {
                weapon.weaponAnimator.Play("Idle");
            }
            movementController.canMove = true;
            canAttack = true;
        }
    }
 public void Dash()
 {
     if (canMove && canDash)
     {
         if (dashEnergy > dashEnergyCost)
         {
             dashEnergy   -= dashEnergyCost;
             dashing       = true;
             afterDash     = false;
             canMove       = false;
             dashTime      = dashDuration;
             dashDirection = lastInputMove;
             PlayAnimation(AnimationsStates.Dash, true);
             if (character != null)
             {
                 character.canAttack = false;
                 if (character.weapon != null)
                 {
                     SNWeapon.SetAnimationDirection(character.weapon.weaponAnimator, dashDirection);
                     character.weapon.weaponAnimator.Play("Idle");
                     character.weapon.weaponAnimator.Play(AnimationsStates.Dash.ToString());
                     if (dashDealDamage)
                     {
                         character.weapon.EnableAttack("Dash");
                     }
                 }
             }
             if (dashEffectObject != null)
             {
                 DashTrail trail = dashEffectObject.GetComponent <DashTrail> ();
                 if (trail != null)
                 {
                     trail.Show(Angle(dashDirection));
                     if ((character != null) && (character.spriteRenderer != null))
                     {
                         character.spriteRenderer.enabled = false;
                     }
                 }
             }
             if (dashEffectPrefab != null)
             {
                 GameObject dashEffectAnimObject = Instantiate(dashEffectPrefab);
                 dashEffectAnimObject.transform.position = character.characterTransform.position;
                 Destroy(dashEffectAnimObject, 1);
             }
             if (dashIgnoreCollisions)
             {
                 topDownPhysics.SetCollitionGhostLevel();
             }
             if (dashImmuneDamage)
             {
                 if (hurtbox != null)
                 {
                     hurtbox.SetActive(false);
                 }
             }
         }
     }
 }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        attackStartTime    = 10;
        movementController = GetComponent <SNMovementController> ();
        if ((weapon == null) && (defaultWeaponPrefab != null))
        {
            weapon = Instantiate(defaultWeaponPrefab).GetComponent <SNWeapon> ();
            weapon.transform.SetParent(characterTransform);
            weapon.transform.localPosition = Vector3.zero;
        }
        if (weapon != null)
        {
            weapon.SetOwner(this);
        }

        if ((gun == null) && (defaultGunPrefab != null))
        {
            gun = Instantiate(defaultGunPrefab).GetComponent <SNGun> ();
            gun.transform.SetParent(movementController.armsAnimationController.transform);
            gun.transform.localPosition = localGunPosition;
        }
        if (gun != null)
        {
            gun.SetOwner(this);
            gun.SetHide(true);
        }

        whiteShader  = Shader.Find("GUI/Text Shader");
        normalShader = Shader.Find("Sprites/Default");

        spriteRenderer = this.transform.GetChild(0).GetComponent <SpriteRenderer> ();

        if (healthBar != null)
        {
            healthBar.MaxHealth = health;
        }
    }