Пример #1
0
        public void OnLaunchSpell(CharacterSpell spell, long target)
        {
            if (spell.LevelModel.TurnNumber > 0)
            {
                if (myCooldown.ContainsKey(spell.ID))
                    myCooldown[spell.ID].Cooldown = spell.LevelModel.TurnNumber;
                else
                    myCooldown.Add(spell.ID, new SpellCooldown(spell.LevelModel.TurnNumber));
            }

            if (spell.LevelModel.MaxPerTurn > 0 || spell.LevelModel.MaxPerPlayer > 0)
            {
                if (myTargets.ContainsKey(spell.ID))
                    myTargets[spell.ID].Add(new SpellTarget(target));
                else
                    myTargets.Add(spell.ID, new List<SpellTarget> { new SpellTarget(target) });
            }
        }
Пример #2
0
        public bool CanLaunchSpell(CharacterSpell spell, long target)
        {
            if (spell.LevelModel.TurnNumber > 0)
            {
                if (myCooldown.ContainsKey(spell.ID) && myCooldown[spell.ID].Cooldown > 0)
                    return false;
            }

            if (spell.LevelModel.MaxPerTurn > 0)
            {
                if (myTargets.ContainsKey(spell.ID) && myTargets[spell.ID].Count >= spell.LevelModel.MaxPerTurn)
                    return false;
            }

            if (spell.LevelModel.MaxPerPlayer > 0)
            {
                if (myTargets.ContainsKey(spell.ID) && myTargets[spell.ID].Count(x => x.Target == target) >= spell.LevelModel.MaxPerPlayer)
                    return false;
            }

            return true;
        }
Пример #3
0
        public void LaunchSpell(Fighter fighter, CharacterSpell spell, int cellID)
        {
            if (myState != FightState.PLAYING)
                return;

            Fighter firstTarget = GetAliveFighters().FirstOrDefault(x => x.Cell == cellID);
            int targetID = firstTarget == null ? -1 : firstTarget.ID;

            if (!CanLaunchSpell(fighter, spell, cellID, targetID))
                return;

            fighter.AP -= spell.LevelModel.Cost;

            bool isEchec = false;

            if (spell.LevelModel.EC != 0)
            {
                int echecRate = spell.LevelModel.EC - fighter.Stats.GetStat(StatEnum.EchecCritic).Total;

                if (echecRate < 2)
                    echecRate = 2;

                if (Basic.Rand(1, echecRate) == 1)
                    isEchec = true;
            }

            if (isEchec)
            {
                Send("GA;302;" + fighter.ID + ';' + spell.ID);
            }
            else
            {
                fighter.SpellController.OnLaunchSpell(spell, targetID);

                Send("GA;300;" + fighter.ID + ';' + spell.ID + ',' + cellID + ',' + spell.Model.Sprite + ',' + spell.Level + ',' + spell.Model.SpriteInfos);

                bool isCritic = false;

                if (spell.LevelModel.CC != 0 & spell.LevelModel.CriticalEffects.Count > 0)
                {
                    int criticRate = spell.LevelModel.CC - fighter.Stats.GetStat(StatEnum.DamageCritic).Total;

                    if (criticRate < 2)
                        criticRate = 2;

                    if (Basic.Rand(1, criticRate) == 1)
                        isCritic = true;
                }

                if (isCritic)
                    Send("GA;301;" + fighter.ID + ';' + spell.ID);

                List<EffectSpell> effects = isCritic ? spell.LevelModel.CriticalEffects : spell.LevelModel.Effects;
                List<Fighter> targets = new List<Fighter>();

                foreach (int cell in CellZone.GetCells(myMap, cellID, fighter.Cell, spell.LevelModel.Type))
                {
                    Fighter target = GetAliveFighters().FirstOrDefault(x => x.Cell == cell);

                    if (target != null)
                        targets.Add(target);
                }

                int actualChance = 0;

                foreach (EffectSpell effect in effects)
                {
                    if (effect.Chance > 0)
                    {
                        if (Basic.Rand(1, 100) > effect.Chance + actualChance)
                        {
                            actualChance += effect.Chance;
                            continue;
                        }

                        actualChance -= 100;
                    }

                    targets.RemoveAll(x => x.Dead);

                    EffectProcessor.ApplyEffect(new EffectCast
                        ((EffectEnum)effect.ID, spell.ID, cellID, effect.Value, effect.Value2, effect.Value3, effect.Chance, effect.Round, (spell.LevelModel.MinRP == 1 & spell.LevelModel.MaxRP == 1), fighter, effect.Target.RemixTargets(fighter, targets)));
                }
            }

            Send("GA;102;" + fighter.ID + ';' + fighter.ID + ",-" + spell.LevelModel.Cost);

            if (GetWinners() != null)
                FightEnd(GetWinners(), GetEnnemyTeam(GetWinners()));
            else if (isEchec & spell.LevelModel.isECEndTurn)
                TurnEnd();
        }
Пример #4
0
        public bool CanLaunchSpell(Fighter fighter, CharacterSpell spell, int spellCell, long target)
        {
            if (fighter != myCurrentFighter)
                return false;

            //if (!myMap.RushablesCells.Contains(spellCell))
            //    return false;

            if (fighter.AP < spell.LevelModel.Cost)
                return false;

            int distance = Pathfinding.GetDistanceBetween(myMap, fighter.Cell, spellCell);
            int maxPO = spell.LevelModel.MaxRP + (spell.LevelModel.isAlterablePO ? fighter.Stats.GetStat(StatEnum.PO).Total : 0);

            if (maxPO < spell.LevelModel.MinRP)
                maxPO = spell.LevelModel.MinRP;

            if (distance > maxPO || distance < spell.LevelModel.MinRP)
                return false;

            return fighter.SpellController.CanLaunchSpell(spell, target);
        }