Exemplo n.º 1
0
    protected void ExplodeOnHit(Character hitChr, Damage damage)
    {
        Velocity = Vector2.zero;
        fanim.ChangeAnimation(explode_anim);

        fanim.AnimationOver += DestroyAfterAnimation;
    }
Exemplo n.º 2
0
    void Awake()
    {
        spawnTriggerCollider = GetComponent <Collider2D>();
        anim = GetComponent <FrameAnimator>();
        anim.Init();

        anim.ChangeAnimation("beforeSpawn");

        anim.AnimationOver += Remove;
    }
Exemplo n.º 3
0
    protected void Awake()
    {
        fanim = GetComponent <FrameAnimator>();
        spr   = GetComponent <SpriteRenderer>();
        hibMn = GetComponent <HitboxManager>();
        col   = GetComponent <CircleCollider2D>();

        counter = 0;

        fanim.ChangeAnimation(fly_anim);
    }
Exemplo n.º 4
0
    protected void FixedUpdate()
    {
        if (flipX)
        {
            if (Velocity.x < 0)
            {
                spr.flipX = true;
            }
            else
            {
                spr.flipX = false;
            }
        }

        if (flipY)
        {
            if (Velocity.y > 0)
            {
                spr.flipY = true;
            }
            else
            {
                spr.flipY = false;
            }
        }

        if (destroyAfterTime != 0)
        {
            timer++;
        }

        if (Velocity.magnitude * 60 >= damagingSpeed)
        {
            int colNr = col.Cast(Vector2.zero, filter, collisions);

            if (colNr > 0)
            {
                for (int i = 0; i < collisions.Length; i++)
                {
                    Character chr = collisions[0].transform.GetComponentInParent <Character>();

                    if (chr != Owner)
                    {
                        damage.knockBackDirection = Velocity;
                        if (chr != null)
                        {
                            chr.GetHit(damage);
                        }

                        if (destroyIfGrounded)
                        {
                            Destroy(gameObject);
                        }
                    }
                }
            }
        }

        if (destroyIfGrounded)
        {
            if (ctr.grounded)
            {
                FrameAnimator anim = GetComponent <FrameAnimator>();

                if (anim != null)
                {
                    anim.ChangeAnimation("die");
                }
                else
                {
                    Destroy(gameObject);
                }
            }
        }

        if (destroyOnCollision)
        {
            if (ctr.collision)
            {
                FrameAnimator anim = GetComponent <FrameAnimator>();

                if (anim != null)
                {
                    anim.ChangeAnimation("die");
                }
                else
                {
                    Destroy(gameObject);
                }
            }
        }

        if (destroyOnCharacterHit)
        {
            if (ctr.characterHit)
            {
                FrameAnimator anim = GetComponent <FrameAnimator>();

                if (anim != null)
                {
                    anim.ChangeAnimation("die");
                }
                else
                {
                    Destroy(gameObject);
                }
            }
        }

        if (timer > destroyAfterTime)
        {
            FrameAnimator anim = GetComponent <FrameAnimator>();

            if (anim != null)
            {
                anim.ChangeAnimation("die");
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 5
0
    private void SpawnEnemy()
    {
        enemySpawned = true;

        anim.ChangeAnimation("spawn");
    }