Ejemplo n.º 1
0
    public virtual void Die()
    {
        for (int i = 0; i < Drops.Length; i++)
        {
            if (Drops[i].WantsToSpawn)
            {
                for (int a = 0; a < Drops[i].Amount; a++)
                {
                    EntitySpawnManager.Spawn(Drops[i].Next().poolName, transform.position, Quaternion.identity, queue: true);
                }
            }
        }

        EntitySpawnManager.Despawn(poolName, gameObject, true);
        GameEventHandler.TriggerEntityDied(this);
    }
Ejemplo n.º 2
0
    public void Explode()
    {
        HitAbleInfo[] HitAblesInRange = EntitySpawnManager.Instance.GetHitAbleInCircles(transform.position, HitAbleHitMask, ExplosionRange, true);
        //HitAbleInfo[] collider = EntitySpawnManager.Instance.GetHitAbleInCircles(transform.position, HitAbleHitMask, distance, true, false);
        for (int i = 0; i < HitAblesInRange.Length; i++)
        {
            HitAbleInfo item = HitAblesInRange[i];

            if (item == null || item.hitAble == null)
            {
                continue;
            }

            float distance = 0f;
            distance = item.distance;

            float damageMult = (ExplosionRange - distance);

            item.hitAble.Damage(new Damage()
            {
                type              = DamageType.EXPLOSION,
                amount            = damageMult * damage,
                DamageFromAPlayer = true,
                player            = player,
                other             = player.transform
            });
            item.hitAble.Hit(item.ColliderCenter, (item.ColliderCenter - transform.position), force);

            /*
             * Debug.Log("Distance: " + HitAblesInRange[i].distance);
             * HitAblesInRange[i].hitAble.Damage(new Damage()
             * {
             *  DamageFromAPlayer = true,
             *  player = player,
             *  amount = Mathf.Min(distance - HitAblesInRange[i].distance, 0.0f),
             *  type = DamageType.EXPLOSION,
             *  other = player.transform
             * });
             * HitAblesInRange[i].hitAble.Hit(HitAblesInRange[i].ColliderCenter, (HitAblesInRange[i].ColliderCenter - transform.position), force);
             * */
        }

        AudioEffectController.Instance.PlayOneShot(explosion, transform.position);
        EntitySpawnManager.Spawn(hitEffektPoolName, transform.position, Quaternion.identity, forceDirectSpawn: true, countEntity: false);

        EntitySpawnManager.Despawn(poolName, gameObject, false);
    }
Ejemplo n.º 3
0
    private void Hit(GameObject other, Vector3 position)
    {
        if (other && other.GetComponent <HitAble>())
        {
            if (gameObjectHitted.Contains(other))
            {
                return;
            }

            HitAble target = other.GetComponent <HitAble>();
            target.Damage(new Damage()
            {
                DamageFromAPlayer = true,
                player            = player,
                amount            = damage,
                type  = DamageType.RANGED,
                other = player.transform
            });
            target.Hit(position, rigidbody2D.velocity * Time.fixedDeltaTime, force);

            gameObjectHitted.Add(other);

            AudioEffectController.Instance.PlayOneShot(HitEffect, transform.position);
        }
        else
        {
            EntitySpawnManager.InstantSpawn(hitEffektPoolName, position, Quaternion.identity, countEntity: false);

            EntitySpawnManager.Despawn(poolName, gameObject, false);
            return;
        }


        EntitySpawnManager.InstantSpawn(hitEffektPoolName, position, Quaternion.identity, countEntity: false);

        if (pierceCount >= pierceAmount)
        {
            rigidbody2D.velocity = Vector2.zero;
            GameObjectPool.Instance.Despawn(poolName, gameObject);
        }
        else
        {
            pierceCount++;
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;
        if (timer <= 0)
        {
            EntitySpawnManager.Despawn(poolName, gameObject, false);
            //GameObjectPool.Instance.Despawn(poolName, gameObject);
        }

        /*timer = Mathf.Clamp(timer + Time.deltaTime, 0f, time);
         *
         * float size = startSize + endSize * (timer / time);
         * transform.localScale = new Vector3(size, size, size);
         *
         * if (timer > time * 0.8f)
         * {
         *  GetComponent<SpriteRenderer>().color = new Color(1,1,1,time - timer);
         * }
         *
         * if (timer == time)
         * {
         *  GameObjectPool.Instance.Despawn(poolName, gameObject);
         * }*/
    }
Ejemplo n.º 5
0
 void OnTriggerEnter2D(Collider2D other)
 {
     TriggerHit(other);
     EntitySpawnManager.Despawn(poolName, gameObject, true);
 }