Example #1
0
        public override void OnTriggerEnter2D(Collider2D col)
        {
//			triggered = !triggered;

//			if (!isTrapOn) {
//				return;
//			}


            SoundManager.Instance.PlayAudioClip("MapEffects/" + audioClipName);

            BattleAgentController ba = col.GetComponent <BattleAgentController> ();

            if (ba is BattlePlayerController)
            {
                ba.InitFightTextDirectionTowards(transform.position);
            }

            if (lifeLoseCoroutine != null)
            {
                StopCoroutine(lifeLoseCoroutine);
            }

            lifeLoseCoroutine = LoseLifeContinous(ba);

            StartCoroutine(lifeLoseCoroutine);
        }
Example #2
0
        protected void SetEffectAnims(TriggerInfo triggerInfo, BattleAgentController self, BattleAgentController enemy)
        {
            // 播放技能对应的己方(释放技能方)技能特效动画
            switch (triggerInfo.triggerSource)
            {
            case SkillEffectTarget.Self:            //如果被动逻辑由自己执行
                if (selfEffectAnimName != string.Empty)
                {
                    self.SetEffectAnim(selfEffectAnimName);
                }
                if (enemyEffectAnimName != string.Empty)
                {
                    enemy.SetEffectAnim(enemyEffectAnimName);
                }
                break;

            // 播放技能对应的敌方(技能目标方)的技能特效动画
            case SkillEffectTarget.Enemy:            // 如果被动逻辑由对方执行
                if (selfEffectAnimName != string.Empty)
                {
                    enemy.SetEffectAnim(selfEffectAnimName);
                }
                if (enemyEffectAnimName != string.Empty)
                {
                    self.SetEffectAnim(enemyEffectAnimName);
                }
                break;
            }
        }
        protected override void BeAttackedTriggerCallBack(BattleAgentController self, BattleAgentController enemy)
        {
            int manaDecrease = skillLevel * manaDecreaseBase;

            if (self.agent.mana < manaDecrease)
            {
                return;
            }

            float triggerProbability = fixTriggerProbability + skillLevel * triggerProbabilityBase;

            if (!isEffective(triggerProbability))
            {
                return;
            }

            int healthIncrease = skillLevel * healthIncreaseBase + self.agent.healthRecovery;

            self.agent.mana -= manaDecrease;

            self.AddHealthGainAndShow(healthIncrease);

            self.SetEffectAnim(selfEffectAnimName);

            //self.UpdateStatusPlane();
        }
Example #4
0
        /// <summary>
        /// 包围盒检测到trigger进入
        /// </summary>
        /// <param name="col">Col.</param>
        public void OnTriggerEnter2D(Collider2D col)
        {
            BattleAgentController ba = col.GetComponent <BattleAgentController> ();


            if (!(ba is BattlePlayerController))
            {
                return;
            }

            //Debug.Log("detect player");

            BattlePlayerController bp = ba as BattlePlayerController;

            if (bp.isInEvent)
            {
                return;
            }

            //Debug.Log("player is not in event");

            if (bp.isInFight)
            {
                return;
            }

            //Debug.Log("player is not in figth");

            MapMonster mm = mapMonster as MapMonster;

            mm.isReadyToFight = true;

            mm.DetectPlayer(bp);
        }
Example #5
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int magicResistCal = enemy.agent.magicResist - self.agent.magicResistDecrease / 2;

            if (magicResistCal < -50)
            {
                magicResistCal = -50;
            }

            int acutalHurt = Mathf.RoundToInt(hurt / (magicResistCal / 100f + 1));

            enemy.AddHurtAndShow(acutalHurt, HurtType.Magical, self.towards);

            //enemy.UpdateStatusPlane();

            if (selfEffectAnimName != string.Empty)
            {
                self.SetEffectAnim(selfEffectAnimName);
            }

            if (enemyEffectAnimName != string.Empty)
            {
                enemy.SetEffectAnim(enemyEffectAnimName);
            }

            enemy.PlayShakeAnim();
        }
Example #6
0
        private IEnumerator Poison(BattleAgentController self, BattleAgentController enemy)
        {
            int count = 0;

            //int hurt = poisonBase * skillLevel + self.agent.extraPoisonHurt;

            while (count < poisonDuration)
            {
                if (enemy != null && !enemy.isDead)
                {
                    enemy.AddHurtAndShow(poisonHurt, HurtType.Physical, self.towards);

                    bool fightEnd = enemy.CheckFightEnd();

                    enemy.UpdateStatusPlane();

                    if (fightEnd)
                    {
                        yield break;
                    }

                    yield return(new WaitForSeconds(1.0f));
                }

                count++;
            }
        }
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int armorCal = enemy.agent.armor - self.agent.armorDecrease / 2;

            if (armorCal < -50)
            {
                armorCal = -50;
            }


            int actualHurt = Mathf.RoundToInt(hurt / (armorCal / 100f + 1));

            enemy.AddHurtAndShow(actualHurt, HurtType.Physical, self.towards);

            enemy.SetEffectAnim(enemyEffectAnimName);

            if (!hasTriggered)
            {
                enemy.agent.attack += -attackDecrease;

                enemy.agent.attackChangeFromSkill += -attackDecrease;

                hasTriggered = true;

                enemy.AddTintTextToQueue("攻击\n降低");
            }

            enemy.PlayShakeAnim();
        }
        protected override void ExcuteTriggeredSkillLogic(TriggerInfo triggerInfo, BattleAgentController self, BattleAgentController enemy)
        {
            // 判断被动是否生效
            if (!isEffective(triggeredProbability))
            {
                return;
            }

            SetEffectAnims(triggerInfo, self, enemy);

            // 如果没有状态名称,则默认不是触发状态,直接执行技能
            if (statusName == "")
            {
                Excute();
                return;
            }

            List <TriggeredSkill> sameStatusSkills = affectedAgent.propertyCalculator.GetTriggeredSkillsWithSameStatus(statusName);

            // 如果技能效果不可叠加,则被影响人身上原有的同种状态技能效果全部取消,并从战斗结算器中移除这些技能
            if (!canOverlay)
            {
                for (int i = 0; i < sameStatusSkills.Count; i++)
                {
                    TriggeredSkill ts = sameStatusSkills [i];
                    ts.CancelSkillEffect(ts == this);
                }
            }

            Excute();
        }
Example #9
0
        private IEnumerator DurativeHurt(BattleAgentController self, BattleAgentController enemy)
        {
            int count = 0;

            while (count < healthLoseDuration)
            {
                if (enemy != null && !enemy.isDead)
                {
                    enemy.AddHurtAndShow(healthLoseBase, HurtType.Physical, self.towards);

                    bool fightEnd = enemy.CheckFightEnd();

                    enemy.UpdateStatusPlane();

                    if (fightEnd)
                    {
                        yield break;
                    }

                    yield return(new WaitForSeconds(1.0f));
                }


                count++;
            }
        }
Example #10
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int armorCal = enemy.agent.armor - self.agent.armorDecrease / 2;

            if (armorCal < -50)
            {
                armorCal = -50;
            }

            int actualHurt = Mathf.RoundToInt(hurt / (armorCal / 100f + 1));

            enemy.AddHurtAndShow(actualHurt, HurtType.Physical, self.towards);

            enemy.PlayShakeAnim();

            if (enemyEffectAnimName != string.Empty)
            {
                enemy.SetEffectAnim(enemyEffectAnimName);
            }

            enemy.SetEffectAnim(continuousEffectAnimName, null, 0, healthLoseDuration);

            if (healthDurativeLoseCoroutine != null)
            {
                StopCoroutine(healthDurativeLoseCoroutine);
            }

            healthDurativeLoseCoroutine = DurativeHurt(self, enemy);

            StartCoroutine(healthDurativeLoseCoroutine);
        }
 protected override void FightEndTriggerCallBack(BattleAgentController self, BattleAgentController enemy)
 {
     if (poisonCoroutine != null)
     {
         StopCoroutine(poisonCoroutine);
     }
 }
//		private List<IEnumerator> effectCoroutines = new List<IEnumerator>();

//		private SkillState state;

//		void Awake ()
//		{
//			originalProperty = 0;
//		}


        protected override void ExcuteNoneTriggeredSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            propertyChange = 0;
            // 首次触发前记录受影响者
            if (beforeFightTriggerInfo.triggered)
            {
                affectedAgent = GetAffectedBattleAgent(beforeFightTriggerInfo, self, enemy);
            }
            else if (attackTriggerInfo.triggered)
            {
                affectedAgent = GetAffectedBattleAgent(attackTriggerInfo, self, enemy);
            }
            else if (hitTriggerInfo.triggered)
            {
                affectedAgent = GetAffectedBattleAgent(hitTriggerInfo, self, enemy);
            }
            else if (beAttackedTriggerInfo.triggered)
            {
                affectedAgent = GetAffectedBattleAgent(beAttackedTriggerInfo, self, enemy);
            }
            else if (beHitTriggerInfo.triggered)
            {
                affectedAgent = GetAffectedBattleAgent(beHitTriggerInfo, self, enemy);
            }
//			originalProperty = affectedAgent.propertyCalculator.GetAgentPropertyWithType (propertyType);
        }
Example #13
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            // 原始魔法伤害
            int hurt = self.agent.magicAttack + hurtBase * skillLevel + fixHurt;

            int magicResistCal = enemy.agent.magicResist - self.agent.magicResistDecrease / 2;

            if (magicResistCal < -50)
            {
                magicResistCal = -50;
            }

            // 结算抗性和抗性穿透之后的实际伤害
            hurt = Mathf.RoundToInt(hurt / (magicResistCal / 100f + 1));

            if (hurt < 0)
            {
                hurt = 0;
            }

            // 伤害生效并显示
            enemy.AddHurtAndShow(hurt, HurtType.Magical, self.towards);

            // 敌方被击中后退
            enemy.PlayShakeAnim();

            // 播放技能特效
            enemy.SetEffectAnim(enemyEffectAnimName);
        }
Example #14
0
        protected override void ExcuteNoneTriggeredSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            // 先记录增长前的属性状态
            propertyChange = 0;

            ExcuteConsumablesSkillLogic(self);
        }
Example #15
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.GetComponent <Launcher> () != null)
            {
                return;
            }

            Debug.Log("子弹碰到物体");

            StopCoroutine(bulletMoveCoroutine);

            bc2d.enabled = false;

            BattleAgentController ba = other.GetComponent <BattleAgentController> ();

            if (ba != null)
            {
                ba.InitFightTextDirectionTowards(this.transform.position);
                ba.propertyCalculator.InstantPropertyChange(ba, PropertyType.Health, -hurt, false);
                Debug.Log("子弹命中");
            }

            bulletAnimator.SetBool("Play", true);

            StartCoroutine("ColletBulletAfterExplosion");
        }
Example #16
0
        private IEnumerator NormalTrapTriggerEffect(BattleAgentController ba)
        {
            float timer = 0;

            float agentBackDuration = 0.1f;

            Vector3 backgroundBackVector = (ba.transform.position - agentOriPos) * 0.3f;

            while (timer < agentBackDuration)
            {
                Vector3 agentBackVector = new Vector3(
                    (agentOriPos.x - ba.transform.position.x) / agentBackDuration,
                    (agentOriPos.y - ba.transform.position.y) / agentBackDuration, 0) * Time.deltaTime;

                ba.transform.position += agentBackVector;
                timer += Time.deltaTime;
                yield return(null);
            }

            ba.transform.position = agentOriPos;

            Camera.main.transform.Find("Background").position += backgroundBackVector;

            Debug.Log(Camera.main.transform.Find("Background").position);
        }
Example #17
0
        protected override void ExcuteTriggeredSkillLogic(TriggerInfo triggerInfo, BattleAgentController self, BattleAgentController enemy)
        {
            if (isEffective(triggeredProbability))
            {
                List <TriggeredSkill> fizzySkills = enemy.propertyCalculator.GetTriggeredSkillsWithSameStatus(statusName);

                affectedAgent = GetAffectedBattleAgent(triggerInfo, self, enemy);

                if (fizzySkills.Count > 0)
                {
                    for (int i = 0; i < fizzySkills.Count; i++)
                    {
                        TriggeredSkill ts = fizzySkills [i];
                        ts.CancelSkillEffect(ts != this);
                    }
                }
                else
                {
                    affectedAgent.propertyCalculator.SkillTriggered <TriggeredSkill> (this);
                }


                affectedAgent.PlayRoleAnim("stun", 0, null);
                affectedAgent.isAttackActionFinish = false;

                fizzyCoroutine = StartCoroutine("FizzyForDuration", affectedAgent);

                SetEffectAnims(triggerInfo, self, enemy);
            }
        }
Example #18
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int hurt = fixHurt + hurtBase * skillLevel;

            enemy.AddHurtAndShow(hurt, HurtType.Physical, self.towards);


            enemy.PlayShakeAnim();

            enemy.SetEffectAnim(enemyEffectAnimName);


            float roleAnimScaler = enemy.GetRoleAnimTimeScaler();

            roleAnimScaler *= (1 - attackSpeedDecreaseScalerBase);

            if (roleAnimScaler < 0.6f)
            {
                return;
            }
            else
            {
                // 敌方行动速度减慢
                enemy.SetRoleAnimTimeScale(roleAnimScaler);
                enemy.SetEffectAnim(CommonData.paralyzedEffectName, null, 0, 0);
            }
        }
Example #19
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int armorCal = enemy.agent.armor - self.agent.armorDecrease / 2;

            if (armorCal < -50)
            {
                armorCal = -50;
            }

            int actualHurt = Mathf.RoundToInt(hurt / (armorCal / 100f + 1));

            enemy.AddHurtAndShow(actualHurt, HurtType.Physical, self.towards);

            enemy.PlayShakeAnim();


            if (triggeredCount < maxOverlayCount)
            {
                triggeredCount++;

                enemy.agent.armor += -armorChange;
                enemy.agent.armorChangeFromSkill += -armorChange;

                enemy.agent.magicResist += -magicResistChange;
                enemy.agent.magicResistChangeFromSkill += -magicResistChange;

                enemy.SetEffectAnim(enemyEffectAnimName);

                enemy.AddTintTextToQueue("护甲\n降低");
                enemy.AddTintTextToQueue("抗性\n降低");
            }

            //enemy.UpdateStatusPlane();
        }
        private IEnumerator DurativePoison(BattleAgentController self, BattleAgentController enemy)
        {
            int count = 0;

            int hurt = durativeHurtBase * skillLevel + extraHurtBase;

            while (count < duration)
            {
                if (enemy != null && !enemy.isDead)
                {
                    SetEffectAnims(self, enemy);

                    enemy.AddHurtAndShow(hurt, HurtType.Physical, self.towards);

                    bool fightEnd = enemy.CheckFightEnd();

                    enemy.UpdateStatusPlane();

                    if (fightEnd)
                    {
                        yield break;
                    }

                    yield return(new WaitForSeconds(1f));
                }

                count++;
            }
        }
Example #21
0
        protected override void ExcuteConsumablesSkillLogic(BattleAgentController self)
        {
            if (selfEffectAnimName != string.Empty)
            {
                self.SetEffectAnim(selfEffectAnimName, null);
            }

            // 如果没有状态名称,则默认不是触发状态,直接执行技能
            if (statusName == "")
            {
                Excute(self);
                return;
            }

            List <TriggeredSkill> sameStatusSkills = self.propertyCalculator.GetTriggeredSkillsWithSameStatus(statusName);

            // 如果技能效果不可叠加,则被影响人身上原有的同种状态技能效果全部取消,并从战斗结算器中移除这些技能
            if (!canOverlay)
            {
                for (int i = 0; i < sameStatusSkills.Count; i++)
                {
                    TriggeredSkill ts = sameStatusSkills [i];
                    ts.CancelSkillEffect(ts != this);
                }
            }

            // 执行技能
            Excute(self);
        }
        protected override void BeAttackedTriggerCallBack(BattleAgentController self, BattleAgentController enemy)
        {
            if (!isEffective(triggerProbability))
            {
                return;
            }

            float scaler = 1f;

            int healthDecrease = skillLevel * healthDecreaseBase;

            if (self.agent.health <= healthDecrease)
            {
                scaler         = (self.agent.health - 1) / healthDecrease;
                healthDecrease = self.agent.health - 1;
            }

            int armorIncrease       = Mathf.RoundToInt(scaler * skillLevel * attackIncreaseBase);
            int magicResistIncrease = Mathf.RoundToInt(scaler * skillLevel * attackIncreaseBase);

            self.agent.health -= healthDecrease;

            self.agent.attack += armorIncrease;
            self.agent.attackChangeFromSkill += armorIncrease;

            string tint = "攻击\n提升";

            self.AddTintTextToQueue(tint);

            SetEffectAnims(self, enemy);
        }
 protected void SetEffectAnims(BattleAgentController self)
 {
     // 播放技能对应的己方(释放技能方)技能特效动画
     if (selfEffectAnimName != string.Empty)
     {
         self.SetEffectAnim(selfEffectAnimName);
     }
 }
Example #24
0
        private IEnumerator FizzyForDuration(BattleAgentController affectedAgent)
        {
            yield return(new WaitForSeconds(duration));

            affectedAgent.isAttackActionFinish = true;
            affectedAgent.propertyCalculator.RemoveAttachedSkill <TriggeredSkill> (this);
            affectedAgent.Fight();
        }
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int healthGain = (int)(skillLevel * self.agent.armor * healthGainScaler + fixHealthGain + self.agent.healthRecovery);

            self.AddHealthGainAndShow(healthGain);

            self.SetEffectAnim(selfEffectAnimName);
        }
Example #26
0
        protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy)
        {
            int manaGain = (int)(skillLevel * manaRecoveryScaler * self.agent.magicAttack + fixManaRecovery + self.agent.magicRecovery);

            self.AddManaGainAndShow(manaGain);

            self.SetEffectAnim(selfEffectAnimName);
        }
Example #27
0
        protected override void HitTriggerCallBack(BattleAgentController self, BattleAgentController enemy)
        {
            int hurt = Mathf.RoundToInt(skillLevel * hurtBase);

            enemy.AddHurtAndShow(hurt, HurtType.Physical, self.towards);

            //enemy.UpdateStatusPlane ();
        }
 /// <summary>
 /// 执行被攻击时被动技能回调
 /// </summary>
 /// <param name="enemy">Enemy.</param>
 public void ExcuteBeAttackedSkillCallBacks(BattleAgentController enemy)
 {
     for (int i = 0; i < beAttackedTriggerExcutors.Count; i++)
     {
         SkillCallBack cb = beAttackedTriggerExcutors [i].triggeredCallback;
         cb(this, enemy);
     }
 }
 /// <summary>
 /// 执行战斗结束时被动技能回调
 /// </summary>
 /// <param name="enemy">Enemy.</param>
 public void ExcuteFightEndCallBacks(BattleAgentController enemy)
 {
     for (int i = 0; i < fightEndTriggerExcutors.Count; i++)
     {
         SkillCallBack cb = fightEndTriggerExcutors [i].triggeredCallback;
         cb(this, enemy);
     }
 }
Example #30
0
        /// <summary>
        /// 时效结束时重置人物相应属性
        /// </summary>
        /// <returns>The property when time out.</returns>
        /// <param name="affectedAgent">Affected agent.</param>
        /// <param name="propertyType">Property type.</param>
        /// <param name="duration">Duration.</param>
        private IEnumerator ResetPropertyWhenTimeOut(BattleAgentController affectedAgent, PropertyType propertyType, float duration)
        {
            yield return(new WaitForSeconds(duration));

            affectedAgent.propertyCalculator.InstantPropertyChange(affectedAgent, propertyType, -skillSourceValue);
            affectedAgent.propertyCalculator.RemoveAttachedSkill <TriggeredSkill> (this);
            affectedAgent = null;
        }