Ejemplo n.º 1
0
    protected override void FireEffect()
    {
        Debug.Log("PTrap FireEffect() called");
        //aoe adds bullet range
        if (aoe > 0f)
        {
            bulletRange = aoe;
        }
        //split adds # of bullets
        //ie if split is 1, it'll spawn 1 bullet, and so on
        bulletCount = split;
        //charge adds size of explosion, both for trap and for radial bullets
        if (charge > 0f)
        {
            bulletCharge = charge;
            GameObject splashCircle = Instantiate(Resources.Load("Prefabs/MainCanvas/SplashCircle")) as GameObject;
            splashCircle.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
            splashCircle.transform.SetParent(Dial.spawnLayer.transform, false);
            AoE ac = splashCircle.GetComponent <AoE>();
            ac.scale     = charge;
            ac.aoeDamage = dmg;
            ac.parent    = "Trap";
        }
        //attraction adds homing on bullets
        if (attraction > 0f)
        {
            bulletHoming = attraction;
        }

        SpawnRadialBullets(bulletCount);
    }
Ejemplo n.º 2
0
 //actions for this bullet to take upon hitting something
 public void Collide()
 {
     if (charge > 0)
     {
         GameObject splashCircle = Instantiate(Resources.Load("Prefabs/MainCanvas/SplashCircle")) as GameObject;
         splashCircle.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
         splashCircle.transform.SetParent(Dial.spawnLayer.transform, false);
         AoE   ac         = splashCircle.GetComponent <AoE>();
         float chargeSize = charge * chargePercent;
         if (chargeSize < 1.2f)
         {
             chargeSize = 1.2f;
         }
         ac.scale = chargeSize;
         Debug.Log(chargeSize);
         ac.parent    = "Bullet";
         ac.aoeDamage = this.chargeDamage;
     }
     if (penetrationsLeft > 0)
     {
         penetrationsLeft--;
         return;
     }
     GameObject.Destroy(gameObject);
 }
Ejemplo n.º 3
0
    public void updateAOE(GUN spell)//bool activate)
    {
        AoE.gameObject.SetActive(true);
        Color _newColor = Color.clear;

        switch (currentGun)
        {
        case GUN.SHOOT:
            AoE.gameObject.SetActive(false);
            break;

        case GUN.EXPLOSIVE:
            _newColor = Color.red;
            break;

        case GUN.MAGNETIC:
            _newColor = Color.yellow;
            break;

        case GUN.FREEZING:
            _newColor = Color.cyan;
            break;
        }
        _newColor.a = 0.7f;
        AoE.GetComponent <Renderer>().material.color = _newColor;
        //AoE.GetComponent<checkValidSpot>().canPlant = activate;
        //AoE.GetComponent<checkValidSpot>().setColor();
    }
Ejemplo n.º 4
0
 protected virtual void FireEffect()
 {
     if (aoe > 0f)
     {
         GameObject splashCircle = Instantiate(Resources.Load("Prefabs/MainCanvas/SplashCircle")) as GameObject;
         splashCircle.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
         splashCircle.transform.SetParent(Dial.spawnLayer.transform, false);
         AoE ac = splashCircle.GetComponent <AoE>();
         ac.scale     = aoe;
         ac.aoeDamage = dmg;
         ac.parent    = "Trap";
     }
     if (field > 0f)
     {
         GameObject damageField = Instantiate(Resources.Load("Prefabs/MainCanvas/DamageField")) as GameObject;
         damageField.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
         damageField.transform.SetParent(Dial.spawnLayer.transform, false);
         DamageField df = damageField.GetComponent <DamageField>();
         if (aoe > 0f)
         {
             df.aoeSize = aoe;
         }
         else
         {
             df.aoeSize = 1f;
         }
         df.damagePerTick = dmg * 0.1f;
         df.maxTime       = field;
     }
 }
Ejemplo n.º 5
0
    protected override void Attack()
    {
        AoE aoe = projectile.Instantiate <AoE>();

        aoe.SetSize(expansionVector);
        aoe.gameObject.transform.position = projectileStart.position;
        aoe.SetDieTime(bulletSpeed);
        aoe.SetDamage(damage);
    }
Ejemplo n.º 6
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?
 }
Ejemplo n.º 7
0
    void Explode()
    {
        GameObject splashCircle = Instantiate(Resources.Load("Prefabs/MainCanvas/SplashCircle")) as GameObject;

        splashCircle.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
        splashCircle.transform.SetParent(Dial.spawnLayer.transform, false);
        AoE ac = splashCircle.GetComponent <AoE>();

        ac.scale         = sabotageAoeScale;
        ac.aoeDamage     = sabotageAoeDamage;
        ac.parent        = "PieceDrop";
        ac.canDamageDial = true;
        Destroy(gameObject);
    }
Ejemplo n.º 8
0
    public void Fire(AoE spell)
    {
        Debug.Log("Casting AoE: " + spell.name);
        Vector3?targetPos = GetTargetPosition();

        if (targetPos != null)
        {
            Vector3 targetPosition = (Vector3)targetPos;

            //Instantiate a copy of our spellPrefab
            GameObject spellClone = Instantiate(spell.spellPrefab, targetPosition + (Vector3.up * 10), transform.rotation);
            spellClone.GetComponent <AoEObject>().spell    = spell;
            spellClone.GetComponent <Rigidbody>().velocity = Vector3.up * -20f;
        }
    }
Ejemplo n.º 9
0
    public void CastSpell(string ownerTag, Transform loc, Transform playerLoc)
    {
        OnCoolDown = true;
        Debug.Log("CastSpell ::" + Ability.Name);

        playerLoc.rotation = GameFuncs.RotateTowardsMouse(playerLoc);

        Vector3 pos = Ability.Effect == GameConsts.EFFECT.PROJECTILE ? loc.position : loc.position;

        GameObject go = GameObject.Instantiate(Ability.Prefab, pos, loc.rotation);

        Projectile projectile = (Projectile)go.GetComponent(typeof(Projectile));

        switch (Ability.Effect)
        {
        case GameConsts.EFFECT.PROJECTILE:
        {
            Projectile proj = go.GetComponent <Projectile>();
            proj.Ability  = Ability;
            proj.OwnerTag = ownerTag;
            break;
        }

        case GameConsts.EFFECT.AOE:
        {
            AoE aoe = go.GetComponent <AoE>();
            aoe.Ability  = Ability;
            aoe.OwnerTag = ownerTag;

            //Size of AOE
            float scale = Ability.Range.x * 0.2f;
            go.transform.GetChild(0).localScale = new Vector3(scale, 0.1f, scale);
            break;
        }

        case GameConsts.EFFECT.CLICK:
        {
            break;
        }
        }
    }
Ejemplo n.º 10
0
        public static async Task <bool> Combat()
        {
            //Only stop doing damage when in party
            if (Globals.InParty && Utilities.Combat.Enemies.Count > SageSettings.Instance.StopDamageWhenMoreThanEnemies)
            {
                return(false);
            }

            if (Globals.InParty && !SageSettings.Instance.DoDamage)
            {
                return(true);
            }

            if (!GameSettingsManager.FaceTargetOnAction &&
                !Core.Me.CurrentTarget.InView())
            {
                return(false);
            }

            if (BotManager.Current.IsAutonomous)
            {
                if (Core.Me.HasTarget)
                {
                    Movement.NavigateToUnitLos(Core.Me.CurrentTarget, 20 + Core.Me.CurrentTarget.CombatReach);
                }
            }

            if (!Core.Me.HasTarget ||
                !Core.Me.CurrentTarget.ThoroughCanAttack())
            {
                return(false);
            }

            if (Globals.OnPvpMap)
            {
                return(false);
            }

            if (SageRoutine.CanWeave())
            {
                if (await Buff.Kardia())
                {
                    return(true);
                }
                if (await Buff.Soteria())
                {
                    return(true);
                }
            }

            if (Core.Me.CurrentManaPercent < SageSettings.Instance.MinimumManaPercentToDoDamage &&
                Core.Target.CombatTimeLeft() > SageSettings.Instance.DoDamageIfTimeLeftLessThan)
            {
                if (await AoE.Toxikon())
                {
                    return(true);
                }
                return(true);
            }

            if (await AoE.Toxikon())
            {
                return(true);
            }
            if (await AoE.Phlegma())
            {
                return(true);
            }
            if (await AoE.Pneuma())
            {
                return(true);
            }
            if (await SingleTarget.EukrasianDosis())
            {
                return(true);
            }
            if (await SingleTarget.DotMultipleTargets())
            {
                return(true);
            }
            if (await AoE.Dyskrasia())
            {
                return(true);
            }
            return(await SingleTarget.Dosis());
        }
Ejemplo n.º 11
0
    public List <Character> setTargets(AoE area, Squad squad, SquadPosition target)
    {
        List <Character> targets = new List <Character>();

        switch (area)
        {
        case AoE.SINGLE:
            targets.Add(squad.getCharacterAtPosition(target));
            break;

        case AoE.SINGLE_PENETRATING:
            targets.Add(
                squad.getCharacterAtPosition(target)
                );

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(target)
                    ));
            break;

        case AoE.DOUBLE:
            targets.Add(
                squad.getCharacterAtPosition(target)
                );

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(target)
                    ));
            break;

        case AoE.DOUBLE_PENETRATING:
            targets.Add(
                squad.getCharacterAtPosition(target)
                );

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(target)
                    ));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(target)
                    ));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(
                        squad.getCharacterNextToPosition(target)
                        )));
            break;

        case AoE.TRIPLE:
            targets.Add(
                squad.getCharacterAtPosition(target)
                );

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(target)
                    ));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(
                        squad.getCharacterNextToPosition(target)
                        )));
            break;

        case AoE.TRIPLE_PENETRATING:
            targets.Add(
                squad.getCharacterAtPosition(target)
                );

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(target)
                    ));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(target)
                    ));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(
                        squad.getCharacterNextToPosition(target)
                        )));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterNextToPosition(
                        squad.getCharacterNextToPosition(target)
                        )));

            targets.Add(
                squad.getCharacterAtPosition(
                    squad.getCharacterBehindPosition(
                        squad.getCharacterNextToPosition(
                            squad.getCharacterNextToPosition(target
                                                             )))));
            break;

        case AoE.ALL:
            targets.Add(squad.getCharacterAtPosition(SquadPosition.FRONT_LEFT));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.FRONT_MIDDLE));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.FRONT_RIGHT));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.BACK_LEFT));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.BACK_MIDDLE));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.BACK_RIGHT));
            targets.Add(squad.getCharacterAtPosition(SquadPosition.UTILITY));
            break;

        default:
            break;
        }
        return(targets);
    }
Ejemplo n.º 12
0
 public void GetStatused(AoE aoe)
 {
 }
Ejemplo n.º 13
0
        public static async Task <bool> Combat()
        {
            if (Core.Me.IsCasting)
            {
                return(true);
            }

            if (await Casting.TrackSpellCast())
            {
                return(true);
            }

            await Casting.CheckForSuccessfulCast();

            Utilities.Routines.Reaper.RefreshVars();

            if (!Core.Me.HasTarget || !Core.Me.CurrentTarget.ThoroughCanAttack())
            {
                if (await Utility.Soulsow())
                {
                    return(true);
                }
                return(false);
            }

            if (await CustomOpenerLogic.Opener())
            {
                return(true);
            }


            if (BotManager.Current.IsAutonomous)
            {
                if (Core.Me.HasTarget)
                {
                    Movement.NavigateToUnitLos(Core.Me.CurrentTarget, 3 + Core.Me.CurrentTarget.CombatReach);
                }
            }

            if (await Buff.FightLogic_ArcaneCrest())
            {
                return(true);
            }
            if (await Buff.FightLogic_Feint())
            {
                return(true);
            }

            if (Core.Me.HasAura(Auras.Enshrouded)) //Enshroud Mode
            {
                if (ReaperRoutine.GlobalCooldown.CanWeave(1))
                {
                    if (await Enshroud.AoE.LemuresScythe())
                    {
                        return(true);
                    }
                    if (await Enshroud.SingleTarget.LemuresSlice())
                    {
                        return(true);
                    }
                }

                if (await Enshroud.AoE.Communio())
                {
                    return(true);
                }
                if (await Enshroud.AoE.GrimReaping())
                {
                    return(true);
                }
                if (await Enshroud.SingleTarget.VoidReaping())
                {
                    return(true);
                }
                if (await Enshroud.SingleTarget.CrossReaping())
                {
                    return(true);
                }
                if (await Enshroud.SingleTarget.LemuresSliceOfFWeave())
                {
                    return(true);
                }
            }
            else
            {
                if (ReaperRoutine.GlobalCooldown.CanWeave())
                {
                    if (await PhysicalDps.Interrupt(ReaperSettings.Instance))
                    {
                        return(true);
                    }
                    if (await PhysicalDps.SecondWind(ReaperSettings.Instance))
                    {
                        return(true);
                    }
                    if (await PhysicalDps.Bloodbath(ReaperSettings.Instance))
                    {
                        return(true);
                    }
                    if (await Cooldown.ArcaneCircle())
                    {
                        return(true);
                    }
                    if (await Cooldown.Enshroud())
                    {
                        return(true);
                    }
                    if (await Cooldown.Gluttony())
                    {
                        return(true);
                    }
                    if (await AoE.GrimSwathe())
                    {
                        return(true);
                    }
                    if (await SingleTarget.BloodStalk())
                    {
                        return(true);
                    }
                    if (await Utility.TrueNorth())
                    {
                        return(true);
                    }
                }

                if (await Utility.Soulsow())
                {
                    return(true);
                }
                if (await AoE.WhorlofDeath())
                {
                    return(true);
                }
                if (await SingleTarget.ShadowOfDeath())
                {
                    return(true);
                }
                if (await AoE.HarvestMoon())
                {
                    return(true);
                }
                if (await AoE.PlentifulHarvest())
                {
                    return(true);
                }
                if (await AoE.Guillotine())
                {
                    return(true);
                }
                if (await SingleTarget.GibbetAndGallows())
                {
                    return(true);
                }
                if (await AoE.SoulScythe())
                {
                    return(true);
                }
                if (await SingleTarget.SoulSlice())
                {
                    return(true);
                }

                if (await AoE.NightmareScythe())
                {
                    return(true);
                }
                if (await SingleTarget.InfernalSlice())
                {
                    return(true);
                }
                if (await SingleTarget.WaxingSlice())
                {
                    return(true);
                }
                if (await AoE.WhorlofDeathIdle())
                {
                    return(true);
                }
                if (await AoE.SpinningScythe())
                {
                    return(true);
                }
                if (await SingleTarget.ShadowOfDeathIdle())
                {
                    return(true);
                }
                if (await SingleTarget.Slice())
                {
                    return(true);
                }
                if (await SingleTarget.HarvestMoon())
                {
                    return(true);
                }
                return(await SingleTarget.EnhancedHarpe());
            }

            return(false);
        }
Ejemplo n.º 14
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?
 }
Ejemplo n.º 15
0
    public AoE GetAOESpell(XElement spell)
    {
        XElement Spell = spell;

        AoE AOEspell = new AoE();
        AOEspell.m_DamageType = (Ability.DamageType)Enum.Parse(typeof(Ability.DamageType), Spell.Element("damagetype").Value.ToString());
        AOEspell.m_iDamage = int.Parse(Spell.Element("damage").Value);
        AOEspell.m_iDoT = int.Parse(Spell.Element("dot").Value);
        AOEspell.m_iHoT = int.Parse(Spell.Element("heal").Value);
        AOEspell.m_iCastTime = int.Parse(Spell.Element("casttime").Value);
        AOEspell.m_iCoolDown = int.Parse(Spell.Element("cooldown").Value);
        AOEspell.m_iSlowPercent = int.Parse(Spell.Element("slow").Value);
        AOEspell.m_iManaCost = int.Parse(Spell.Element("mana").Value);
        AOEspell.m_iRadius = int.Parse(Spell.Element("radius").Value);
        AOEspell.m_sDescription = Spell.Element("desc").Value;
        AOEspell.m_sName = Spell.Element("name").Value;

        return AOEspell;
    }
Ejemplo n.º 16
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?
    }
Ejemplo n.º 17
0
 public void GetStatused(AoE aoe)
 {
 }
Ejemplo n.º 18
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?
    }