Example #1
0
 public void HandleShieldedCollision(Collider2D coll)
 {
     if (coll.gameObject.tag == "Bullet")         //if it's 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;
                 ShieldAgainstBullet(bc);
                 bc.Collide();
             }
         }
     }
     else if (coll.gameObject.tag == "Trap")         //if it's a trap
     {
         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;
                 if (tc.aoe == 0)
                 {
                     ShieldAgainstTrap(tc.dmg);
                 }
                 tc.Collide();
             }
         }
     }
     else if (coll.gameObject.tag == "Shield")         //if it's a shield
     {
     }
     else if (coll.gameObject.tag == "AoE")
     {
         Debug.Log("shield collided with AoE");
         GameObject obj = coll.gameObject;
         AoE        ac  = obj.GetComponent <AoE>();
         if (ac.parent == "Bullet")
         {
             //Debug.Log ("parent is bullet@");
             ShieldAgainstAoE(ac.aoeDamage);
         }
         else if (ac.parent == "Trap")
         {
             ShieldAgainstTrap(ac.aoeDamage);
         }
     }
     //other types of collision?
 }
Example #2
0
 public virtual void OnTriggerEnter2D(Collider2D coll)      //this is said system.
 //Debug.Log ("a collision happened!");
 {
     if (coll.gameObject.tag == "Bullet")         //if it's 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;
                 TakeDamage(bc.dmg);
                 bc.Collide();
             }
         }
     }
     else if (coll.gameObject.tag == "Trap")         //if it's a trap
     {
         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;
                 if (tc.aoe == 0f)
                 {
                     hp -= tc.dmg;
                 }
                 tc.Collide();
                 if (hp <= 0)
                 {
                     Die();
                 }
             }
         }
     }
     else if (coll.gameObject.tag == "Shield")         //if it's a shield
     {
         //shield actions are handled in Dial
     }
     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));
             hp -= ac.aoeDamage;
             //timesShot++;
             if (hp <= 0)
             {
                 Die();
             }
         }
         else if (ac.parent == "Trap")
         {
             hp -= ac.aoeDamage;
             if (hp <= 0)
             {
                 Die();
             }
         }
     }
     //other types of collision?
 }
Example #3
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?
    }
Example #4
0
    public virtual void OnTriggerEnter2D(Collider2D coll)
    {
        if (frozen)
        {
            return;
        }

        /*if(coll.gameObject.tag == "Enemy"){ //handled before anything that cares about shields
         *      if(knockChained){
         *              Enemy e = coll.GetComponent<Enemy>();
         *              float progressGap = progress-e.GetProgress();
         *              carrySpacing = progressGap;
         *              CarryEnemy(e);
         *      }
         * }*/
        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
        {
            Bullet bc = coll.gameObject.GetComponent <Bullet> ();
            if (bc != null)
            {
                if (bc.CheckActive())                 //if we get a Yes, this bullet/trap/shield is active
                {
                    //dude, the timer on split bullets is to keep it from colliding with itself, not enemies

                    bc.enemyHit = this.gameObject;
                    GetStatused(bc);
                    //StartCoroutine (StatusEffectsBullet (bc));
                    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;
                        //StartCoroutine (StatusEffectsTrap (tc));
                        hp -= tc.dmg;
                        tc.Collide();
                        if (hp <= 0)
                        {
                            Die();
                        }
                    }
                }
            }
        }
        else if (coll.gameObject.tag == "Shield")         //if it's a shield
        {
            //shield actions are handled in DialController
        }
        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")
            {
                // if (ac.aoeBulletCon.enemyHit != this.gameObject) //if this isn't the enemy originally hit
                // {
                //  //Debug.Log ("parent is bullet@");
                //  Bullet bc = ac.aoeBulletCon;
                //  GetStatused(bc);
                //  //StartCoroutine (StatusEffectsBullet (bc));
                //  hp -= bc.dmg;
                //  Debug.Log ("damage taken: " + bc.dmg);
                //  //timesShot++;
                //  if(hp <= 0){
                //      Die ();
                //  }
                // }
            }
            else if (ac.parent == "Trap")
            {
                // if (ac.aoeTrapCon.enemyHit != this.gameObject) //if this isn't the enemy originally hit
                // {
                //  Trap tc = ac.aoeTrapCon;
                //  //StartCoroutine (StatusEffectsTrap (tc));
                //  hp -= tc.dmg;
                //  if(hp <= 0){
                //      Die ();
                //  }
                // }
            }
        }
        //other types of collision?
    }