Ejemplo n.º 1
0
    public virtual void OnHit(Enemy e)
    {
        if (vampIsOn)
        {
            if (e.GetHP() < vampDrain)
            {
                dial.ChangeHealth(e.GetHP());
            }
            else
            {
                dial.ChangeHealth(vampDrain);
            }
        }

        e.TakeDamage(dmg);
        if (frequency > 0)
        {
            float mult = 1.0f - (0.15f * frequency);
            e.Slow(mult, frequency);
        }
        if (penetration > 0)
        {
            float shredAmount = penetration * 5f;
            e.ShredShield(shredAmount);
            Debug.Log("we're shreddin': " + shredAmount);
        }
    }
Ejemplo n.º 2
0
 //called once each tick
 protected virtual void ForEachTarget(CircleCollider2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         Enemy e = coll.GetComponent <Enemy>();
         if (e != null)
         {
             if (vampIsOn)
             {
                 if (e.GetHP() < damagePerTick)
                 {
                     dial.ChangeHealth(e.GetHP());
                 }
                 else
                 {
                     dial.ChangeHealth(damagePerTick);
                 }
             }
             e.TakeDamage(damagePerTick);
         }
     }
     else if (coll.gameObject.tag == "EnemyShield")
     {
         EnemyShield es = coll.GetComponent <EnemyShield>();
         if (es != null)
         {
             es.TakeDamage(damagePerTick);
         }
     }
 }
Ejemplo n.º 3
0
    //apply damage and effects to all enemies in This zone
    void Blast()
    {
        dial = GameObject.Find("Dial").GetComponent <Dial>();
        List <Enemy> enemyList = Dial.GetAllEnemiesInZone(zoneID);

        for (int i = 0; i < enemyList.Count; i++)
        {
            if (PlayerPrefsInfo.Int2Bool(PlayerPrefs.GetInt(PlayerPrefsInfo.s_vampire)))
            {
                float ehp = enemyList[i].GetHP();
                if (ehp < damage * vampDrain)
                {
                    dial.ChangeHealth(ehp);
                }
                else
                {
                    dial.ChangeHealth(damage * vampDrain);
                }
            }
            enemyList[i].TakeDamage(damage);
            if (parentShield != null && enemyList[i] != null)
            {
                enemyList[i].ShieldInflictedStatus(parentShield);
            }
        }
    }
Ejemplo n.º 4
0
 public virtual void OnHit(Enemy e, float unreducedDamage, float unreducedHP)
 {
     if (reflect > 0f)
     {
         float dealtBack = reflect * unreducedDamage;
         e.TakeDamage(dealtBack);
     }
     if (tempDisplace > 0f)
     {
         RectTransform ert = e.GetComponent <RectTransform>();
         Vector2       dir = (Vector2.zero - ert.anchoredPosition).normalized;
         dir *= ((Dial.TRACK_LENGTH - 15f) * tempDisplace); //15 is because it shouldn't knock back the whole exact track length
         ert.anchoredPosition -= dir;
     }
     if (absorb > 0f)
     {
         Debug.Log("max hp: " + shieldDurability + " -> " + (shieldDurability + absorb));
         shieldDurability += absorb;
         UpdateHPMeter();
     }
     if (vampDrain > 0f)
     {
         //Vampire drain
         //Debug.Log("vampdrain is on on shield");
         float amt = e.GetHP();
         dial.ChangeHealth(vampDrain * amt * .4f);
         e.TakeDamage(vampDrain * amt * .8f);
         //Debug.Log("new dial health is " + dial.health);
     }
 }
Ejemplo n.º 5
0
 protected override void ForEachTarget(CircleCollider2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         //Debug.Log("Here's an enemy in ShieldTrapField");
         Enemy e = coll.GetComponent <Enemy>();
         if (e != null)
         {
             //Drain
             if (drainPerTick > 0f)
             {
                 //Debug.Log("doing drain in ShieldTrapField");
                 if (e.GetHP() < drainPerTick)
                 {
                     dial.ChangeHealth(e.GetHP()); //multiplier applied in SetUp()
                 }
                 else
                 {
                     dial.ChangeHealth(drainPerTick); //multiplier applied in SetUp()
                 }
                 e.TakeDamage(drainPerTick);
             }
             if (coolPerTick > 0f)
             {
                 ReduceCooldown(coolPerTick); //multiplier applied in SetUp()
             }
         }
     }
     else if (coll.gameObject.tag == "EnemyShield")
     {
         EnemyShield es = coll.GetComponent <EnemyShield>();
         if (es != null)
         {
             //es.TakeDamage(damagePerTick);
             //Drain
             if (drainPerTick > 0f)
             {
             }
         }
     }
 }
Ejemplo n.º 6
0
 //when it hits an enemy
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Enemy")
     {
         Enemy ec = other.gameObject.GetComponent <Enemy>();
         if (vampIsOn)
         {
             float ehp = ec.GetHP();
             if (ehp < damage * vampDrain)
             {
                 dial.ChangeHealth(ehp);
             }
             else
             {
                 dial.ChangeHealth(damage * vampDrain);
             }
         }
         ec.TakeDamage(damage);
         Debug.Log("inflicting zone wave statuses");
         ec.ZoneWaveInflictedStatus(this);
     }
 }
Ejemplo n.º 7
0
    public virtual void OnHit(Enemy e, float unreducedDamage)
    {
        float pulseDamage = dmg;

        if (reflect > 0f)
        {
            pulseDamage += reflect * unreducedDamage;
        }
        int pulseTimes = 1;

        if (continuousStrength > 0)
        {
            pulseTimes += (int)(continuousStrength - 1);
        }
        for (int i = 0; i < pulseTimes; i++)
        {
            GameObject pulse = Instantiate(Resources.Load("Prefabs/MainCanvas/ShieldPulseMask")) as GameObject;
            pulse.transform.SetParent(Dial.underLayer, false);
            ShieldPulse sp = pulse.transform.Find("ShieldPulse").GetComponent <ShieldPulse>();
            sp.dial = dial;
            sp.dmg  = pulseDamage;
            if (vampDrain > 0f)
            {
                sp.vampDrain = vampDrain;
                sp.vampIsOn  = true;
            }
            sp.frequency   = frequency;
            sp.penetration = penetration;
            sp.ConfigurePulse(GetCurrentLaneID(), i * 0.3f);
        }
        if (vampDrain > 0f)
        {
            //Vampire drain
            //Debug.Log("vampdrain is on on shield");
            float amt = e.GetHP();
            dial.ChangeHealth(vampDrain * amt * .4f);
            e.TakeDamage(vampDrain * amt * .8f);
            //Debug.Log("new dial health is " + dial.health);
        }
    }
Ejemplo n.º 8
0
    public void HandleEvent(GameEvent ge)
    {
        CanvasSpinner cSpin = GameObject.Find("Dial").GetComponent <CanvasSpinner>();

        //various conditions under which bullet shouldn't fire
        if ((int)ge.args [0] != gunID)
        {
            //Debug.Log ("not tower " + gunID);
            return;
        }
        if (cooldown > 0)
        {
            //Debug.Log ("cooldown > 0");
            return;
        }
        if (cSpin.IsSpinning())
        {
            Debug.Log("dial is spinning");
            return;
        }
        if (transform.gameObject.activeSelf != true)
        {
            Debug.Log("we're not active");
            return;
        }
        if (useLockIsOn && useLockHasFired)
        {
            Debug.Log("uselock is on and this gun has already fired!");
            return;
        }

        if (useLockIsOn)
        {
            useLockHasFired           = true;
            waitingForOtherGunsToFire = true;
        }

        //unlock dial spinner if it was rot-locked before
        cSpin.rotLockIsLocked = false;

        //self-repair chance
        if (selfRepairRate > 0f)
        {
            float rando = UnityEngine.Random.value * 100f;
            if (rando <= selfRepairRate)
            {
                Debug.Log("gun did self-repair");
                dial.ChangeHealth(selfRepairAmt);
            }
        }

        cooltimer.Restart();
        cooldown             = maxcool; //start cooldown
        chargeImg.fillAmount = 0f;
        chargeImg.color      = new Color(1f, 1f, 1f);

        //Decide what to do based on tower type ("Bullet", "Trap", "Shield", "BulletTrap", "BulletShield", "TrapShield")
        switch (towerType)
        {
        case "Bullet":
            if (continuousStrength <= 0)
            {
                if (split == 1)
                {
                    SpawnBulletI();
                }
                else
                {
                    SpawnSplitFirer(split);
                }
            }
            break;

        case "Trap":
            SpawnTrap();
            break;

        case "Shield":
            SpawnShield();
            break;

        case "BulletTrap":
            //BulletTrap behavior
            SpawnProjectileTrap();
            break;

        case "BulletShield":
            //BulletShield behavior
            SpawnProjectileShield();
            break;

        case "TrapShield":
            //TrapShield behavior
            SpawnAllShieldTraps();
            break;

        default:
            print("Uh oh, I didn't receive a valid towerType string value!");
            Debug.Log("value is: " + towerType);
            break;
        }
    }
Ejemplo n.º 9
0
    public virtual void OnTriggerEnter2D(Collider2D coll)
    {
        if (frozen)
        {
            return;                                         //invincible while boss is moving it
        }
        if (coll != null && coll.gameObject.tag == "Enemy") //handled before anything that cares about shields
        {
            if (knockChained)
            {
                Debug.Log("we hit something with knockchain");
                float timeEstimate = 1.3f; //how long stuff presumably gets knocked back for
                                           //it's an estimate since we can't see it directly (without writing a script to measure it)
                float duration      = knockbackTimer.TimeElapsedSecs();
                float remainingTime = timeEstimate - duration;
                if (remainingTime > 0)
                {
                    float power = (remainingTime / timeEstimate) * knockbackPower;
                    coll.GetComponent <Enemy>().SelfKnockback(power);
                    coll.GetComponent <Enemy>().SelfStun(stunDuration);
                    Debug.Log("we're calling selfknockback on something");
                }
            }
        }
        if (shield != null)
        {
            if (shield.hitThisFrame)//the shield handled collision for us this time
            {
                return;
            }
            else  //the shield was either missed or hasn't been handled by collision yet
            {
                if (secondaryCollisionTicket)
                {
                    //let execution through to actually handle the collision- we're calling this function manually
                    secondaryCollisionTicket = false; //punch the ticket
                }
                else                                  //skip colliding- wait until update to check if the shield got it for us
                {
                    collidedThisFrame = true;
                    heldCollision     = coll; //store the collision so we can handle it if/when we call this manually
                    return;
                }
            }
        }
        if (coll == null)
        {
            Debug.Log("bullet's gone");
            return;
        }
        //Debug.Log ("!!! we made it through to our own collision");
        if (coll.gameObject.tag == "Bullet") //if it's a bullet
        {
            Debug.Log("we got hit by a bullet");
            Bullet bc = coll.gameObject.GetComponent <Bullet>();
            if (bc != null)
            {
                if (bc.CheckActive()) //if we get a Yes, this bullet/trap/shield is active
                {
                    bc.enemyHit = this.gameObject;
                    GetStatused(bc);
                    //StartCoroutine (StatusEffectsBullet (bc));
                    //Vamp-Drain
                    if (bc.vampDrain > 0f)
                    {
                        //if this enemy's hp is about to drop to 0
                        if (hp < bc.dmg * bc.vampDrain)
                        {
                            dialCon.ChangeHealth(hp);
                        }
                        else
                        {
                            dialCon.ChangeHealth(bc.dmg * bc.vampDrain);
                        }
                    }
                    hp -= bc.dmg;

                    timesShot++;
                    bc.Collide();

                    if (hp <= 0)
                    {
                        hp = 0;
                        Die();
                    }
                }
            }
        }
        else if (coll.gameObject.tag == "BulletRadial") //if it's a radial bullet from a BulletTrap
        {
            Debug.Log("we got hit by a radialBullet");
            BulletRadial bc = coll.gameObject.GetComponent <BulletRadial>();
            if (bc != null)
            {
                if (bc.CheckActive())
                {
                    Debug.Log("this bulletRadial that hit an enemy IS active");
                    //bulletRadials ignore the enemy that tripped the PTrap to begin with
                    if (this.gameObject != bc.ignoredEnemy)
                    {
                        Debug.Log(this.gameObject.ToString() + "equals " + bc.ignoredEnemy.ToString());
                        bc.enemyHit = this.gameObject;
                        GetStatused(bc);
                        //StartCoroutine (StatusEffectsBullet (bc));
                        //Vamp-Drain
                        if (bc.vampDrain > 0f)
                        {
                            //if this enemy's hp is about to drop to 0
                            if (hp < bc.dmg * bc.vampDrain)
                            {
                                dialCon.ChangeHealth(hp);
                            }
                            else
                            {
                                dialCon.ChangeHealth(bc.dmg * bc.vampDrain);
                            }
                        }
                        hp -= bc.dmg;
                        timesShot++;
                        bc.Collide();

                        if (hp <= 0)
                        {
                            hp = 0;
                            Die();
                        }
                    }
                }
            }
        }
        else if (coll.gameObject.tag == "Trap")         //if it's a trap
        {
            if (tripsTraps)
            {
                Trap tc = coll.gameObject.GetComponent <Trap>();
                if (tc != null)
                {
                    if (tc.CheckActive())                     //if we get a Yes, this bullet/trap/shield is active
                    {
                        tc.enemyHit = this.gameObject;
                        //Vamp-Drain
                        if (tc.vampDrain > 0f)
                        {
                            //if this enemy's hp is about to drop to 0
                            if (hp < tc.dmg * tc.vampDrain)
                            {
                                dialCon.ChangeHealth(hp);
                            }
                            else
                            {
                                dialCon.ChangeHealth(tc.dmg * tc.vampDrain);
                            }
                        }
                        if (tc.aoe == 0f)
                        {
                            hp -= tc.dmg;
                        }
                        tc.Collide();
                        if (hp <= 0)
                        {
                            Die();
                        }
                    }
                }
            }
        }
        else if (coll.gameObject.tag == "ProjectileTrap") //if it's a projectiletrap
        {
            //Debug.Log("enemy collided with projectiletrap");
            if (tripsTraps)
            {
                //Debug.Log("enemy which collided with PTrap DOES trip traps");
                ProjectileTrap tc = coll.gameObject.GetComponent <ProjectileTrap>();
                if (tc != null)
                {
                    //Debug.Log("PTrap isn't null");
                    if (tc.CheckActive())
                    {
                        tc.enemyHit = this.gameObject;
                        //Vamp-Drain
                        if (tc.vampDrain > 0f)
                        {
                            //if this enemy's hp is about to drop to 0
                            if (hp < tc.dmg * tc.vampDrain)
                            {
                                dialCon.ChangeHealth(hp);
                            }
                            else
                            {
                                dialCon.ChangeHealth(tc.dmg * tc.vampDrain);
                            }
                        }
                        hp -= tc.dmg;
                        //Debug.Log("calling Collide() on projectiletrap");
                        tc.Collide();
                        if (hp <= 0)
                        {
                            Die();
                        }
                    }
                }
            }
        }
        else if (coll.gameObject.tag == "Shield")         //if it's a shield
        {
            //all handled by the shield collision now
        }
        else if (coll.gameObject.tag == "AoE")
        {
            //Debug.Log ("enemy collided with AoE");
            GameObject obj = coll.gameObject;
            AoE        ac  = obj.GetComponent <AoE>();
            if (ac.parent == "Bullet")
            {
                //StartCoroutine (StatusEffectsBullet (bc));
                if (ac.vampIsOn)
                {
                    if (hp < ac.vampDrain)
                    {
                        dialCon.ChangeHealth(hp);
                    }
                    else
                    {
                        dialCon.ChangeHealth(ac.vampDrain);
                    }
                }
                hp -= ac.aoeDamage;
                Debug.Log("damage taken: " + ac.aoeDamage);
                //timesShot++;
                if (hp <= 0)
                {
                    Die();
                }
            }
            else if (ac.parent == "Trap")
            {
                hp -= ac.aoeDamage;
                if (hp <= 0)
                {
                    Die();
                }
            }
        }
        //other types of collision?
    }