Example #1
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("NPC"))
     {
         NpcController NPCAI = other.GetComponent <NpcController>();
         NPCAI.GetComponent <NavMeshAgent>().speed /= speedFactor;
         SlowedNPC.Remove(NPCAI);
     }
 }
Example #2
0
 public override void Run(NpcController c)
 {
     WaitTime -= Time.deltaTime;
     if (WaitTime < 0)
     {
         c._renderer.flipX = false;
         Physics2D.IgnoreCollision(PlayerController.Singleton.GetComponent <Collider2D>(),
                                   c.GetComponent <Collider2D>());
         c._animator.SetBool("Cry", true);
         c.rb.velocity = new Vector2(
             Mathf.Lerp(Mathf.Abs(c.rb.velocity.x), c.WalkSpeed * 1.5f, Time.deltaTime * 4f),
             c.rb.velocity.y);
     }
 }
Example #3
0
    public void CastSpell(NPC casterNPC, NPC targetNPC, Ability abilityToCast, float CasterSpellPower, float CasterAttackPower)
    {
        if (abilityToCast == Ability.NOTHING || casterNPC == null || targetNPC == null)
        {
            return;
        }
        else if (casterNPC != null)
        {
            casterNPC.TryPlayAttackAnimation();
            casterNPC.CONCENTRATION = 0;
        }

        if (abilityToCast == Ability.Fireball)
        {
            GameObject   go        = (GameObject)Instantiate(Resources.Load("Fireball"), this.transform.position, Quaternion.identity);
            DamageReport dmgReport = targetNPC.CalculateDamageTaken(2 * CasterSpellPower, casterNPC, DamageSource.Magical_Ability);
            go.GetComponentInChildren <AbilityFireball>().dmgReport   = dmgReport;
            go.GetComponentInChildren <AbilityFireball>().destination = dmgReport.damageReceiverNPC.transform.position;
            casterNPC.combatReport_DamageDoneThisRound += dmgReport.primaryDamageDealt;
        }

        else if (abilityToCast == Ability.AP_UP_Self)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("AP_PowerUp"), this.transform.position, Quaternion.identity);
            go.transform.SetParent(casterNPC.transform);
            float boostValue    = CasterAttackPower * (0.1f + (casterNPC.TIER * 0.05f));
            float boostDuration = 5 + (1 * casterNPC.TIER);
            casterNPC.ATTACKPOWER += boostValue;
            if (casterNPC.PowerChangeParticleSystem != null)
            {
                casterNPC.PowerChangeParticleSystem.PowerUpObject.SetActive(true);
            }
            StartCoroutine(AP_SubstractBonusAfterSeconds(casterNPC, boostDuration, boostValue, go));
        }

        else if (abilityToCast == Ability.Armor_UP_Self)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("ARMOR_PowerUp"), this.transform.position, Quaternion.identity);
            go.transform.SetParent(casterNPC.transform);
            float boostValue    = 7;
            float boostDuration = 5 + (1 * casterNPC.TIER);
            casterNPC.ARMOR += boostValue;
            if (casterNPC.PowerChangeParticleSystem != null)
            {
                casterNPC.PowerChangeParticleSystem.PowerUpObject.SetActive(true);
            }
            StartCoroutine(ARMOR_SubstractBonusAfterSeconds(casterNPC, boostDuration, boostValue, go));
        }
        else if (abilityToCast == Ability.MaxHP_Up_Self)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("MAXHP_PowerUp"), this.transform.position, Quaternion.identity);
            go.transform.SetParent(casterNPC.transform);
            float boostValue    = casterNPC.BASE_MAXHP * 0.25f;
            float boostDuration = 5 + (1 * casterNPC.TIER);
            casterNPC.MAXHP += boostValue;
            casterNPC.HP    += boostValue;
            if (casterNPC.PowerChangeParticleSystem != null)
            {
                casterNPC.PowerChangeParticleSystem.PowerUpObject.SetActive(true);
            }
            StartCoroutine(MAXHP_SubstractBonusAfterSeconds(casterNPC, boostDuration, boostValue, go));
        }
        else if (abilityToCast == Ability.Retaliation_UP_Self)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("RETALIATION_PowerUp"), this.transform.position, Quaternion.identity);
            go.transform.SetParent(casterNPC.transform);
            float boostValue    = 7;
            float boostDuration = 5 + (1 * casterNPC.TIER);
            casterNPC.RETALIATION += boostValue;
            if (casterNPC.PowerChangeParticleSystem != null)
            {
                casterNPC.PowerChangeParticleSystem.PowerUpObject.SetActive(true);
            }
            StartCoroutine(RETALIATION_SubstractBonusAfterSeconds(casterNPC, boostDuration, boostValue, go));
        }
        else if (abilityToCast == Ability.HeroicStrike)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("HeroicStrike Animation"), this.transform.position, Quaternion.identity);
            go.transform.LookAt(targetNPC.transform);
            go.transform.SetParent(casterNPC.transform);
            DamageReport dmgReport = targetNPC.CalculateDamageTaken(1.9f * CasterAttackPower, casterNPC, DamageSource.Physical_Ability);
            uiController.SpawnFloatingCombatText(dmgReport.damageReceiverNPC, dmgReport, DisplayMode.AbilityDamage);
            targetNPC.TakePureDamage(dmgReport);
            casterNPC.combatReport_DamageDoneThisRound += dmgReport.primaryDamageDealt;
            GameObject.Destroy(go, 4);
        }
        else if (abilityToCast == Ability.Stab)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("Stab Animation"), this.transform.position, Quaternion.identity);
            go.transform.LookAt(targetNPC.transform);
            go.transform.SetParent(casterNPC.transform);
            DamageReport dmgReport = targetNPC.CalculateDamageTaken(1.4f * CasterAttackPower, casterNPC, DamageSource.Physical_Ability);
            uiController.SpawnFloatingCombatText(dmgReport.damageReceiverNPC, dmgReport, DisplayMode.AbilityDamage);
            targetNPC.TakePureDamage(dmgReport);
            casterNPC.combatReport_DamageDoneThisRound += dmgReport.primaryDamageDealt;
            GameObject.Destroy(go, 3);
        }
        else if (abilityToCast == Ability.AP_DOWN_OTHER)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("AP_PowerDown"), targetNPC.transform.position, Quaternion.identity);
            go.transform.LookAt(targetNPC.transform);
            go.transform.SetParent(targetNPC.transform);
            float boostValue    = targetNPC.BASE_ATTACKPOWER * (0.1f + (casterNPC.TIER * 0.05f));
            float boostDuration = 6;
            targetNPC.ReduceAttackPower(boostValue);
            if (targetNPC.PowerChangeParticleSystem != null)
            {
                targetNPC.PowerChangeParticleSystem.PowerDownObject.SetActive(true);
            }
            StartCoroutine(AP_AddBonusAfterSeconds(targetNPC, boostDuration, boostValue, go));
        }

        else if (abilityToCast == Ability.ARMOR_DOWN_OTHER)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load("ARMOR_PowerDown"), targetNPC.transform.position, Quaternion.identity);
            go.transform.SetParent(targetNPC.transform);
            float boostValue    = 7;
            float boostDuration = 6;
            targetNPC.ReduceArmor(boostValue);
            if (targetNPC.PowerChangeParticleSystem != null)
            {
                targetNPC.PowerChangeParticleSystem.PowerDownObject.SetActive(true);
            }
            StartCoroutine(ARMOR_AddBonusAfterSeconds(targetNPC, boostDuration, boostValue, go));
        }
        else if (abilityToCast == Ability.FrostBall)
        {
            GameObject   go        = (GameObject)Instantiate(Resources.Load("FrostBall"), this.transform.position, Quaternion.identity);
            DamageReport dmgReport = targetNPC.CalculateDamageTaken(1.5f * CasterSpellPower, casterNPC, DamageSource.Magical_Ability);
            go.GetComponentInChildren <AbilityFrostBall>().dmgReport   = dmgReport;
            go.GetComponentInChildren <AbilityFrostBall>().destination = dmgReport.damageReceiverNPC.transform.position;
            casterNPC.combatReport_DamageDoneThisRound += dmgReport.primaryDamageDealt;
        }
        else if (abilityToCast == Ability.Stun)
        {
            float stunDuration = 3;
            DoStunCycle(stunDuration, targetNPC, casterNPC);
        }
        else if (abilityToCast == Ability.HealFriend)
        {
            float amountToHeal     = CasterSpellPower;
            NPC[] casters_AllyList = null;

            if (casterNPC.isEnemy == false)
            {
                casters_AllyList = npcController.deployedAllyList.ToArray();
            }
            else
            {
                casters_AllyList = npcController.GetComponent <NpcController>().enemyList.ToArray();
            }
            targetNPC = casters_AllyList[0];
            float maximumHPDeficit = 0;

            foreach (NPC nPC in casters_AllyList)
            {
                float HPDeficit = nPC.MAXHP - nPC.HP;

                if (HPDeficit >= maximumHPDeficit)
                {
                    maximumHPDeficit = nPC.MAXHP - nPC.HP;
                    targetNPC        = nPC;
                }
            }

            DamageReport dmgReport = ScriptableObject.CreateInstance <DamageReport>();
            dmgReport.damageReceiverNPC  = targetNPC;
            dmgReport.damageSourceNPC    = casterNPC;
            dmgReport.primaryDamageDealt = amountToHeal;
            dmgReport.wasCriticalStrike  = false;
            dmgReport.wasDampenedMiss    = false;
            dmgReport.wasMiss            = false;
            uiController.SpawnFloatingCombatText(targetNPC, dmgReport, DisplayMode.Heal);
            GameObject anim = (GameObject)Instantiate(Resources.Load("Heal Animation"), targetNPC.transform.position, Quaternion.identity);
            anim.transform.SetParent(targetNPC.transform);
            targetNPC.GainHP(amountToHeal, HealSource.Heal);
            Object.Destroy(anim, 1);
        }
    }