Exemplo n.º 1
0
    public void damageTarget(UnitLife unit)
    {
        Transform exp = ParticleSpawner.instance.getReusable(smallExplosion).transform;

        exp.position = (unit.transform.position + transform.position) * .5f;
        unit.ApplyDamage(3);
    }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        UnitLife life = collision.GetComponentInParent <UnitLife>();

        if (life)
        {
            if (!unitsHit.ContainsKey(collision.GetInstanceID()))
            {
                unitsHit.Add(collision.GetInstanceID(), life);
            }

            if (!collidedObjects.Contains(life))
            {
                collidedObjects.Add(life);
                life.onUnitsCollision(this.life);
                Transform exp = ParticleSpawner.instance.getReusable(exploshion).transform;
                exp.position = transform.position + Vector3.one * Random.Range(0, 0.1f);
            }

            //PlayerController.gold += goldDrop;
            //life.ApplyDamage(fireSystem.damage);
            if (suicider)
            {
                life.ApplyDamage(fireSystem.damage * 2);
                destroySelf();
            }
        }
    }
Exemplo n.º 3
0
 protected virtual void onHitShip(UnitLife unit, Collider2D collision)
 {
     dead = true;
     if (target == null)
     {
         target = collision.transform;
     }
     collidedUnits.Add(unit);
 }
Exemplo n.º 4
0
 protected override void onHitShip(UnitLife unit, Collider2D collision)
 {
     expelUnits.Add(collision, unit);
     if (collidedUnits.Contains(unit))
     {
         return;
     }
     collidedUnits.Add(unit);
     damageTarget(unit);
     StartCoroutine(referesh(unit, collision));
 }
Exemplo n.º 5
0
    IEnumerator referesh(UnitLife unit, Collider2D collider)
    {
        yield return(new WaitForSeconds(0.35f));

        if (!expelUnits.ContainsKey(collider))
        {
            collidedUnits.Remove(unit);
            yield break;
        }
        else
        {
            damageTarget(unit);
            yield return(referesh(unit, collider));
        }
    }
Exemplo n.º 6
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (dead)
        {
            return;
        }

        UnitLife unit = collision.GetComponentInParent <UnitLife>();

        if (unit)
        {
            onHitShip(unit, collision);
        }
        else
        {
            Missle missle = collision.GetComponentInParent <Missle>();
            if (missle)
            {
                if (missle.GetType() == typeof(Meteor))
                {
                    clife = 0;
                }
                clife -= missle.damage;
            }
            else
            {
                clife -= 1f;
            }

            if (clife < 0)
            {
                dead = true;
            }
            else
            {
                OnCollision();
            }
        }
    }
Exemplo n.º 7
0
 public UnitAttribute()
 {
     m_HpMinMax      = new UnitLife();
     m_AttackDamgage = 10;
     m_magicGage     = 10;
 }
Exemplo n.º 8
0
 public UnitAttribute()
 {
     m_HpMinMax = new UnitLife ();
     m_AttackDamgage = 10;
     m_magicGage = 10;
 }
Exemplo n.º 9
0
    void Start()
    {
        Enemies++;
        life       = GetComponent <UnitLife>();
        target     = PlayerController.player;
        fireSystem = GetComponent <FireSystem>();

        float maxPowerLevel = RandomEnemies.maxDifficulty;
        float powerLevel    = maxPowerLevel;

        if (Random.value < RandomEnemies.BossChance)
        {
            powerLevel *= 10f;
            RandomEnemies.BossChance = 0;
            isBoss = true;
            //AudioManager.playOnce(AudioManager.instance.bossIsCommingClip);
            AudioManager.playRepeatedEffect(AudioManager.instance.bossIsCommingClip, 6, 2, 1);
        }
        else
        {
            powerLevel = maxPowerLevel * (Random.value + 2) * 0.05f;
            float reducePower = maxPowerLevel * (Random.value + 2) * 0.05f;
            if (powerLevel > reducePower)
            {
                powerLevel = reducePower;
            }
        }

        repositionChance = Random.value * 0.1f;

        camRatio            = Random.value * 0.5f;
        fireSystem.camRatio = camRatio;

        difficulty = fireSystem.RandomValues(powerLevel);

        float vv = (difficulty / RandomEnemies.maxDifficulty);
        float Rv = 0.75f + .15f * vv;

        life.life = (difficulty * 2) + 35;
        life.life = Mathf.Clamp(life.life, RandomEnemies.maxDifficulty + 35, RandomEnemies.maxDifficulty * 20);
        maxLife   = life.life;

        float scale = Rv < 2.5f ? Rv : 2.5f;

        transform.localScale = scale * Vector3.one;

        goldDrop = difficulty * 3 + 5;
        if (goldDrop > RandomEnemies.maxDifficulty * 10)
        {
            goldDrop *= 0.25f + Random.value * 0.75f;
        }

        rotationSpeed = 2;
        behaviorType  = 1;
        Range         = 0;
        fleeRange     = 0;



        speed = Random.value * 4f + 1;

        if (vv < 1 || Random.value > 0.85)
        {
            if (Random.value > 0.7)
            {
                behaviorType = 0;
                Range        = Random.Range(6f, 12f);
                AdRange      = Range * .05f + 1f;
                shootRange   = Random.Range(Range * 1.5f, Range * 2.5f);
                fleeRange    = Range * 0.5f * Random.value;
            }
            else
            {
                suicider = Random.value > vv * 4f ? true : false;
                if (suicider)
                {
                    if (Random.value > .5f)
                    {
                        difficulty *= .5f;

                        Range = 0;
                        speed = 3.25f / Rv;
                        speed = Mathf.Clamp(speed, 2.5f, 5f);

                        StartCoroutine(DestroySelf(7.5f));

                        rotationSpeed = 6f;
                        life.life    *= 0.75f;
                        camRatio      = 0;
                    }
                }
            }
        }

        StartCoroutine(damageColliding());

        stayPos = CameraFlow.randomScreenPos();
        RandomEnemies.liveDifficulty += difficulty;

        StartCoroutine(CheckDestroy());

        life.onGetHitCallback += onGethit;
    }