public override void Initialize()
 {
     base.Initialize();
     spellName = RemoteControlBomb.REMOTE_CONTROL_BOMB_NAME;
     playerAnim.SetSpell(this, SkillType.RemoteControlBomb);
     status = SpellStatus.BeforeBringout;
 }
Ejemplo n.º 2
0
        public static void StopCastingSpell(bool cancelled)
        {
            if (s_currentCastType != CurrentCastType.Spell)
            {
                Log.Error($"Tried to stop casting a spell while current cast type is {s_currentCastType}", 155, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return;
            }
            if (cancelled)
            {
                FightCastManager.OnUserActionEnd?.Invoke(FightCastState.Cancelled);
            }
            else
            {
                FightCastManager.OnUserActionEnd?.Invoke(FightCastState.DoneCasting);
            }
            HideSpellCostsPreview(cancelled);
            FightMap current = FightMap.current;

            if (null != current)
            {
                FightMap fightMap = current;
                fightMap.onTargetChanged = (Action <Target?, CellObject>)Delegate.Remove(fightMap.onTargetChanged, new Action <Target?, CellObject>(OnSpellTargetChanged));
                FightMap fightMap2 = current;
                fightMap2.onTargetSelected = (Action <Target?>)Delegate.Remove(fightMap2.onTargetSelected, new Action <Target?>(OnSpellTargetSelected));
                RevertFightMapTargetingPhase(current);
            }
            s_currentCastType      = CurrentCastType.None;
            s_playerCasting        = null;
            s_spellBeingCast       = null;
            s_castTargetDefinition = null;
            s_castTargetContext    = null;
        }
Ejemplo n.º 3
0
 public static void GetSpellRange(ref SpellStatus targetSpell)
 {
     if (ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRangeDisplayOverride <= 0)
     {
         if (ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRange <= 0)
         {
             targetSpell.Range =
                 (int)ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRadius;
         }
         else
         {
             if (!targetSpell.IsCharging)
             {
                 targetSpell.Range =
                     (int)ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRange;
             }
             else
             {
                 targetSpell.Range =
                     (int)ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRadius;
             }
         }
     }
     else
     {
         targetSpell.Range =
             (int)ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).SData.CastRangeDisplayOverride;
     }
 }
Ejemplo n.º 4
0
        public static void GetSpellstatus(ref SpellStatus targetSpell, String name)
        {
            targetSpell.Damagetype   = (byte)GetSettingValue_Int(name, "Damagetype", setFile.FullName);
            targetSpell.IsCharging   = GetSettingValue_Bool(name, "IsCharged", setFile.FullName);
            targetSpell.ChargingTime = GetSettingValue_Double(name, "ChargingTime", setFile.FullName);
            targetSpell.IsMissile    = GetSettingValue_Bool(name, "IsMissile", setFile.FullName);
            targetSpell.MissileType  = (byte)GetSettingValue_Int(name, "MissileType", setFile.FullName);
            targetSpell.MissileDelay = GetSettingValue_Int(name, "MissileDelay", setFile.FullName);
            targetSpell.IsBlockable  = GetSettingValue_Bool(name, "IsBlockable", setFile.FullName);
            targetSpell.DmgLv1       = GetSettingValue_Double(name, "DmgLv1", setFile.FullName);
            targetSpell.DmgPer       = GetSettingValue_Double(name, "DmgPer", setFile.FullName);
            targetSpell.totalAD      = GetSettingValue_Double(name, "+totalAD(%)", setFile.FullName);
            targetSpell.addAD        = GetSettingValue_Double(name, "+addAD(%)", setFile.FullName);
            targetSpell.totalAP      = GetSettingValue_Double(name, "+totalAP(%)", setFile.FullName);

            targetSpell.EnemyAP         = GetSettingValue_Double(name, "+EnemyAP(%)", setFile.FullName);
            targetSpell.MaxMana         = GetSettingValue_Double(name, "+MaxMana(%)", setFile.FullName);
            targetSpell.EnemyMaxHP      = GetSettingValue_Double(name, "+EnemyMaxHP(%)", setFile.FullName);
            targetSpell.EnemyCurHP      = GetSettingValue_Double(name, "+EnemyCurHP(%)", setFile.FullName);
            targetSpell.EnemyMissHP     = GetSettingValue_Double(name, "+EnemyMissHP(%)", setFile.FullName);
            targetSpell.Per100AP        = GetSettingValue_Double(name, "+AP(%)Per100AP", setFile.FullName);
            targetSpell.IsNeedCalculate = GetSettingValue_Bool(name, "IsNeedCalculate", setFile.FullName);

            targetSpell.slot     = GetSpellSlotByString(name);
            targetSpell.level    = ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).Level;
            targetSpell.manacost = ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).ManaCost;

            GetSpellRange(ref targetSpell);

            targetSpell.name[0] = ObjectManager.Player.Spellbook.GetSpell(targetSpell.slot).Name.Replace(Player.ChampionName, "");
            targetSpell.name[1] = GetChangeableSpellName(targetSpell.slot);
        }
Ejemplo n.º 5
0
        private void RemoveFightEventListeners(SpellStatus spellStatusToRemove, bool status)
        {
            List <EventCategory> list = new List <EventCategory>();
            Dictionary <EventCategory, List <int> > dictionary = status ? m_spellsPerCategoryInvalidatingStatus : m_spellsPerCategoryInvalidatingView;

            foreach (KeyValuePair <EventCategory, List <int> > item in dictionary)
            {
                for (int num = item.Value.Count - 1; num >= 0; num--)
                {
                    if (item.Value[num] == spellStatusToRemove.instanceId)
                    {
                        item.Value.RemoveAt(num);
                        break;
                    }
                }
                if (item.Value.Count == 0)
                {
                    list.Add(item.Key);
                }
            }
            foreach (EventCategory item2 in list)
            {
                if (status)
                {
                    FightLogicExecutor.RemoveListenerUpdateStatus(spellStatusToRemove.ownerPlayer.fightId, OnCastingValidityUpdated, item2);
                }
                else
                {
                    FightLogicExecutor.RemoveListenerUpdateView(spellStatusToRemove.ownerPlayer.fightId, OnCastingValidityViewUpdated, item2);
                }
                dictionary.Remove(item2);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Begin cast, checking prerequisites before initiating.
        /// </summary>
        public void Cast()
        {
            if (status != SpellStatus.Initiating)
            {
                throw new InvalidOperationException();
            }

            log.Trace($"Spell {parameters.SpellInfo.Entry.Id} has started initating.");

            CastResult result = CheckCast();

            if (result != CastResult.Ok)
            {
                SendSpellCastResult(result);
                return;
            }

            if (caster is Player player)
            {
                if (parameters.SpellInfo.GlobalCooldown != null)
                {
                    player.SpellManager.SetGlobalSpellCooldown(parameters.SpellInfo.GlobalCooldown.CooldownTime / 1000d);
                }
            }

            SendSpellStart();

            // enqueue spell to be executed after cast time
            events.EnqueueEvent(new SpellEvent(parameters.SpellInfo.Entry.CastTime / 1000d, Execute));
            status = SpellStatus.Casting;

            log.Trace($"Spell {parameters.SpellInfo.Entry.Id} has started casting.");
        }
Ejemplo n.º 7
0
 public void Set(SpellStatus status, DynamicValueContext context, int cost)
 {
     m_definition           = status.definition;
     m_tooltipValueProvider = new FightValueProvider(status);
     m_tooltipElementValues = TooltipWindowUtility.GetTooltipElementValues(m_definition, context);
     m_costText.text        = cost.ToString();
     ApplyIllu(status.ownerPlayer.isLocalPlayer);
 }
Ejemplo n.º 8
0
        public static IEnumerator ShowPlayingSpell(SpellStatus spellStatus, CellObject cell)
        {
            PlaySpellCompanionUI playSpellCompanionUI = s_instance.m_playSpellCompanionUI;

            if (null != playSpellCompanionUI)
            {
                yield return(playSpellCompanionUI.ShowPlaying(spellStatus, cell));
            }
        }
Ejemplo n.º 9
0
        public override void UpdateStatus(FightStatus fightStatus)
        {
            if (fightStatus.TryGetEntity(concernedEntity, out PlayerStatus entityStatus))
            {
                bool flag  = fightStatus == FightStatus.local;
                int  count = moves.Count;
                for (int i = 0; i < count; i++)
                {
                    SpellMovement spellMovement = moves[i];
                    if (flag)
                    {
                        FightCastManager.CheckSpellPlayed(spellMovement.Spell.SpellInstanceId);
                    }
                    switch (spellMovement.To)
                    {
                    case Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Nowhere:
                    case Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Deck:
                        if (spellMovement.From == Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Hand)
                        {
                            int spellInstanceId = spellMovement.Spell.SpellInstanceId;
                            entityStatus.RemoveSpell(spellInstanceId);
                            AbstractPlayerUIRework view2 = entityStatus.view;
                            if (null != view2)
                            {
                                view2.RemoveSpellStatus(spellInstanceId, i);
                            }
                        }
                        break;

                    case Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Hand:
                    {
                        SpellInfo   spell       = spellMovement.Spell;
                        SpellStatus spellStatus = SpellStatus.TryCreate(spell, entityStatus);
                        if (spellStatus != null)
                        {
                            entityStatus.AddSpell(spellStatus);
                            AbstractPlayerUIRework view = entityStatus.view;
                            if (null != view)
                            {
                                view.AddSpellStatus(spell, i);
                            }
                        }
                        break;
                    }

                    default:
                        throw new ArgumentOutOfRangeException($"Spell moved to unknown zone: {spellMovement.To}");
                    }
                }
            }
            else
            {
                Log.Error(FightEventErrors.PlayerNotFound(concernedEntity), 75, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\SpellsMovedEvent.cs");
            }
            FightLogicExecutor.FireUpdateStatus(fightStatus.fightId, EventCategory.SpellsMoved);
        }
Ejemplo n.º 10
0
        public void Update(double lastTick)
        {
            events.Update(lastTick);

            if (status == SpellStatus.Executing && !events.HasPendingEvent)
            {
                // spell effects have finished executing
                status = SpellStatus.Finished;
                log.Trace($"Spell {parameters.SpellInfo.Entry.Id} has finished.");
            }
        }
Ejemplo n.º 11
0
 public override void AddSpellStatus(SpellInfo spellInfo, int index)
 {
     if (!(null == m_spellBar))
     {
         SpellStatus spellStatus = SpellStatus.TryCreate(spellInfo, m_playerStatus);
         if (spellStatus != null)
         {
             m_spellBar.AddSpellStatus(spellStatus);
         }
     }
 }
Ejemplo n.º 12
0
 public SpellStatusData?GetSpellStatusData(SpellStatus spellStatus)
 {
     if (spellStatus == null)
     {
         return(null);
     }
     if (m_spellUsabilityInView.TryGetValue(spellStatus.instanceId, out SpellStatusData value))
     {
         return(value);
     }
     return(null);
 }
Ejemplo n.º 13
0
        public Spell(UnitEntity caster, SpellParameters parameters)
        {
            this.caster     = caster;
            this.parameters = parameters;
            CastingId       = GlobalSpellManager.Instance.NextCastingId;
            status          = SpellStatus.Initiating;

            if (parameters.RootSpellInfo == null)
            {
                parameters.RootSpellInfo = parameters.SpellInfo;
            }
        }
Ejemplo n.º 14
0
        public void RemoveSpellStatus(int spellInstanceId)
        {
            int i = 0;

            for (int count = m_spellStatusList.Count; i < count && m_spellStatusList[i].instanceId != spellInstanceId; i++)
            {
            }
            if (i < m_spellStatusList.Count)
            {
                SpellStatus spellStatusToRemove = m_spellStatusList[i];
                RemoveFightEventListeners(spellStatusToRemove, status: true);
            }
        }
Ejemplo n.º 15
0
        public static bool StartCastingSpell(PlayerStatus casterStatus, SpellStatus spellStatus)
        {
            if (s_currentCastType != 0)
            {
                Log.Error($"Tried to start casting a spell while current cast type is {s_currentCastType}", 59, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return(false);
            }
            SpellDefinition definition = spellStatus.definition;

            if (null == definition)
            {
                Log.Error("Tried to start casting a spell without a loaded definition.", 66, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return(false);
            }
            ICastTargetDefinition castTarget = definition.castTarget;

            if (castTarget == null)
            {
                Log.Error("Tried to cast a spell that has no cast target definition.", 73, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return(false);
            }
            CastTargetContext    castTargetContext = castTarget.CreateCastTargetContext(FightStatus.local, casterStatus.id, DynamicValueHolderType.Spell, definition.get_id(), spellStatus.level, spellStatus.instanceId);
            IReadOnlyList <Cost> costs             = definition.costs;
            int count = costs.Count;

            for (int i = 0; i < count; i++)
            {
                if (costs[i].CheckValidity(casterStatus, castTargetContext) != 0)
                {
                    Log.Error("Tried to cast a spell but one cost requirement is not met.", 86, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                    return(false);
                }
            }
            FightMap current = FightMap.current;

            if (null != current)
            {
                FightMap fightMap = current;
                fightMap.onTargetChanged = (Action <Target?, CellObject>)Delegate.Combine(fightMap.onTargetChanged, new Action <Target?, CellObject>(OnSpellTargetChanged));
                FightMap fightMap2 = current;
                fightMap2.onTargetSelected = (Action <Target?>)Delegate.Combine(fightMap2.onTargetSelected, new Action <Target?>(OnSpellTargetSelected));
                current.SetTargetingPhase(castTarget.EnumerateTargets(castTargetContext));
            }
            s_currentCastType      = CurrentCastType.Spell;
            s_playerCasting        = casterStatus;
            s_spellBeingCast       = spellStatus;
            s_castTargetDefinition = castTarget;
            s_castTargetContext    = castTargetContext;
            ShowSpellCostsPreview();
            return(true);
        }
Ejemplo n.º 16
0
        public void Update(double lastTick)
        {
            events.Update(lastTick);

            if (status == SpellStatus.Executing && !events.HasPendingEvent)
            {
                // spell effects have finished executing
                status = SpellStatus.Finished;
                log.Trace($"Spell {parameters.SpellInfo.Entry.Id} has finished.");

                // TODO: add a timer to count down on the Effect before sending the finish - sending the finish will e.g. wear off the buff
                //SendSpellFinish();
            }
        }
Ejemplo n.º 17
0
 public void BombClock()
 {
     if (isBroughtout)
     {
         bombCurTime += Time.deltaTime;
         if (bombCurTime >= bombTotalTme)
         {
             currentBomb.Bomb();
             bombCurTime  = 0f;
             status       = SpellStatus.BeforeBringout;
             isBroughtout = false;
         }
     }
 }
Ejemplo n.º 18
0
        private bool TryGetSpellStatusByInstanceId(int instanceId, out SpellStatus spellStatus)
        {
            spellStatus = null;
            int i = 0;

            for (int count = m_spellStatusList.Count; i < count; i++)
            {
                SpellStatus spellStatus2 = m_spellStatusList[i];
                if (spellStatus2.instanceId == instanceId)
                {
                    spellStatus = spellStatus2;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 19
0
 public override IEnumerator AddSpell(SpellInfo spellInfo, int index)
 {
     if (!(null == m_spellBar))
     {
         float num = (float)index * 0.1f;
         if (num > 0f)
         {
             yield return((object)new WaitForTime(num));
         }
         SpellStatus spellStatus = SpellStatus.TryCreate(spellInfo, m_playerStatus);
         if (spellStatus != null)
         {
             yield return(m_spellBar.AddSpell(spellStatus));
         }
     }
 }
Ejemplo n.º 20
0
        public static void AddSpellSubmenu(Menu menu, String spellslotname, SpellStatus spells)
        {
            if (spellslotname.Length == 1)
            {
                menu.AddItem(SetMenuItem(spellslotname + "_name", "Name : " + spells.name[0]));
            }
            else
            {
                menu.AddItem(SetMenuItem(spellslotname + "_name", "Name : " + spells.name[1]));
            }

            menu.AddItem(SetMenuItem(spellslotname + "_level", "Level : " + spells.level));
            menu.AddItem(SetMenuItem(spellslotname + "_Damagetype", "Damagetype : " + GetStringByDmgtype(spells.Damagetype)));
            menu.AddItem(SetMenuItem(spellslotname + "_Range", "Range : " + spells.Range));
            menu.AddItem(SetMenuItem(spellslotname + "_IsCharging", "IsCharging : " + spells.IsCharging));
            if (spells.IsCharging)
            {
                menu.AddItem(SetMenuItem(spellslotname + "_ChargingTime", "ChargingTime : " + spells.ChargingTime));
            }
            menu.AddItem(SetMenuItem(spellslotname + "_IsMissile", "IsMissile : " + spells.IsMissile));

            if (spells.IsMissile)
            {
                menu.AddItem(SetMenuItem(spellslotname + "_MissileType", "MissileType : " + ComboSpells.GetSStypeByByte(spells.MissileType).ToString().Replace("Skillshot", "")));
                menu.AddItem(SetMenuItem(spellslotname + "_MissileDelay", "MissileDelay  : " + spells.MissileDelay));
            }
            menu.AddItem(SetMenuItem(spellslotname + "_IsBlockable", "IsBlockable : " + spells.IsBlockable));


            SetMenuItem(spellslotname + "_DmgLv1", "DmgLv1 : ", spells.DmgLv1, menu);
            SetMenuItem(spellslotname + "_DmgPer", "DmgPer : ", spells.DmgPer, menu);
            SetMenuItem(spellslotname + "_totalAD", "totalAD : ", spells.totalAD, menu);
            SetMenuItem(spellslotname + "_addAD", "addAD : ", spells.addAD, menu);
            SetMenuItem(spellslotname + "_totalAP", "totalAP : ", spells.totalAP, menu);

            menu.AddItem(SetMenuItem(spellslotname + "noneuse", "----SpeacialList----"));

            SetMenuItem(spellslotname + "_EnemyAP", "EnemyAP : ", spells.totalAP, menu);
            SetMenuItem(spellslotname + "_MaxMana", "MaxMana : ", spells.totalAP, menu);
            SetMenuItem(spellslotname + "_EnemyMaxHP", "EnemyMaxHP : ", spells.EnemyMaxHP, menu);
            SetMenuItem(spellslotname + "_EnemyCurHP", "EnemyCurHP : ", spells.EnemyCurHP, menu);
            SetMenuItem(spellslotname + "_EnemyMissHP", "EnemyMissHP : ", spells.EnemyMissHP, menu);
            SetMenuItem(spellslotname + "_Per100AP", "Per100AP : ", spells.Per100AP, menu);
            menu.AddItem(SetMenuItem(spellslotname + "_IsNeedCalculate", "IsNeedCalculate : " + spells.IsNeedCalculate));
        }
Ejemplo n.º 21
0
 public static void RecomputeSpellCost(SpellStatus spellStatus, ref SpellStatusData data)
 {
     if (spellStatus.ownerPlayer != null)
     {
         int?baseCost = spellStatus.baseCost;
         if (!baseCost.HasValue)
         {
             data.apCost   = null;
             data.baseCost = null;
             return;
         }
         SpellDefinition   definition = spellStatus.definition;
         CastTargetContext context    = spellStatus.CreateCastTargetContext();
         int cost = spellStatus.definition.GetCost(context) ?? 0;
         data.apCost   = SpellCostModification.ApplyCostModification(spellStatus.ownerPlayer.spellCostModifiers, cost, definition, context);
         data.baseCost = baseCost.Value;
     }
 }
Ejemplo n.º 22
0
        private void Execute()
        {
            status = SpellStatus.Executing;
            log.Trace($"Spell {parameters.SpellInfo.Entry.Id} has started executing.");

            if (caster is Player player)
            {
                if (parameters.SpellInfo.Entry.SpellCoolDown != 0u)
                {
                    player.SpellManager.SetSpellCooldown(parameters.SpellInfo.Entry.Id, parameters.SpellInfo.Entry.SpellCoolDown / 1000d);
                }
            }

            SelectTargets();
            ExecuteEffects();

            SendSpellGo();
        }
Ejemplo n.º 23
0
        private static bool HasSpellValidTargets(PlayerStatus casterStatus, SpellStatus spellStatus)
        {
            SpellDefinition definition = spellStatus.definition;

            if (null == definition)
            {
                return(false);
            }
            ICastTargetDefinition castTarget = definition.castTarget;

            if (castTarget == null)
            {
                return(false);
            }
            CastTargetContext castTargetContext = castTarget.CreateCastTargetContext(FightStatus.local, casterStatus.id, DynamicValueHolderType.Spell, definition.get_id(), spellStatus.level, spellStatus.instanceId);

            return(castTarget.EnumerateTargets(castTargetContext).GetEnumerator().MoveNext());
        }
Ejemplo n.º 24
0
        public IEnumerator AddSpell(SpellStatus spellStatus)
        {
            DequeueSpellStatusEvent(spellStatus.instanceId, andUpdate: false);
            m_spellStatusList.Add(spellStatus);
            m_spellList.Insert(m_spellStatusList.Count - 1, spellStatus);
            HashSet <EventCategory> hashSet = new HashSet <EventCategory>();

            foreach (EventCategory item in spellStatus.definition.eventsInvalidatingCost)
            {
                hashSet.Add(item);
            }
            foreach (EventCategory item2 in spellStatus.definition.eventsInvalidatingCasting)
            {
                hashSet.Add(item2);
            }
            AddFightEventListeners(spellStatus, hashSet, status: false);
            yield break;
        }
Ejemplo n.º 25
0
        public void RefreshUsability(PlayerStatus status, bool recomputeCosts)
        {
            List <int> list = new List <int>();
            IEnumerator <SpellStatus> spellStatusEnumerator = status.GetSpellStatusEnumerator();

            while (spellStatusEnumerator.MoveNext())
            {
                SpellStatus current = spellStatusEnumerator.Current;
                if (current != null)
                {
                    SpellStatusData data = default(SpellStatusData);
                    CastValidityHelper.RecomputeSpellCastValidity(current.ownerPlayer, current, ref data);
                    CastValidityHelper.RecomputeSpellCost(current, ref data);
                    EnqueueSpellStatusData(current.instanceId, data);
                    list.Add(current.instanceId);
                }
            }
            m_refreshUsabilityQueue.Enqueue(list);
        }
Ejemplo n.º 26
0
        public void AddSpellStatus(SpellStatus spellStatus)
        {
            SpellStatusData data = default(SpellStatusData);

            CastValidityHelper.RecomputeSpellCastValidity(spellStatus.ownerPlayer, spellStatus, ref data);
            CastValidityHelper.RecomputeSpellCost(spellStatus, ref data);
            EnqueueSpellStatusData(spellStatus.instanceId, data);
            HashSet <EventCategory> hashSet = new HashSet <EventCategory>();

            foreach (EventCategory item in spellStatus.definition.eventsInvalidatingCost)
            {
                hashSet.Add(item);
            }
            foreach (EventCategory item2 in spellStatus.definition.eventsInvalidatingCasting)
            {
                hashSet.Add(item2);
            }
            AddFightEventListeners(spellStatus, hashSet, status: true);
        }
Ejemplo n.º 27
0
        public static CastValidity ComputeSpellCostCastValidity(PlayerStatus owner, SpellStatus spellStatus)
        {
            if (owner.HasProperty(PropertyId.PlaySpellForbidden))
            {
                return(CastValidity.NOT_ALLOW_TO_PLAY_SPELLS);
            }
            CastTargetContext    castTargetContext = spellStatus.CreateCastTargetContext();
            IReadOnlyList <Cost> costs             = spellStatus.definition.costs;

            for (int i = 0; i < costs.Count; i++)
            {
                CastValidity castValidity = costs[i].CheckValidity(owner, castTargetContext);
                if (castValidity != 0)
                {
                    return(castValidity);
                }
            }
            return(CastValidity.SUCCESS);
        }
Ejemplo n.º 28
0
        public IEnumerator RemoveSpell(int spellInstanceId)
        {
            while (m_spellsInDoneCasting.Count != 0)
            {
                yield return(null);
            }
            int i = 0;

            for (int count = m_spellStatusList.Count; i < count && m_spellStatusList[i].instanceId != spellInstanceId; i++)
            {
            }
            if (i < m_spellStatusList.Count)
            {
                SpellStatus spellStatusToRemove = m_spellStatusList[i];
                RemoveFightEventListeners(spellStatusToRemove, status: false);
                m_spellStatusList.RemoveAt(i);
                m_spellList.RemoveAt(i);
                m_spellUsabilityInView.Remove(spellInstanceId);
            }
        }
Ejemplo n.º 29
0
        public bool IsValidDrag(object value)
        {
            if (FightCastManager.currentCastType != 0)
            {
                return(false);
            }
            SpellStatus spellStatus = (SpellStatus)value;

            if (CastValidityHelper.ComputeSpellCostCastValidity(m_playerStatus, spellStatus) != 0)
            {
                return(false);
            }
            CastValidity castValidity = CastValidityHelper.ComputeSpellCastValidity(m_playerStatus, spellStatus);

            if (castValidity != 0)
            {
                NotificationWindowManager.DisplayNotification(TextCollectionUtility.GetFormattedText(castValidity));
            }
            return(castValidity == CastValidity.SUCCESS);
        }
        public IEnumerable <(Spell Id, MagicSpell Info)> FindSpells(SpellRoutine routine, SpellTargeting targeting,
                                                                    SpellElement element     = SpellElement.Any,
                                                                    SpellStatus status       = SpellStatus.Any,
                                                                    OOBSpellRoutine oobSpell = OOBSpellRoutine.None
                                                                    )
        {
            IEnumerable <MagicSpell> foundSpells;

            if (routine == SpellRoutine.Life)
            {
                foundSpells = SpellInfos.Where(s =>
                                               (s.routine == SpellRoutine.CureAilment) &&
                                               (s.targeting == targeting || targeting == SpellTargeting.Any) &&
                                               (s.effect == (byte)SpellStatus.Death));
            }
            else if (routine == SpellRoutine.Smoke)
            {
                foundSpells = SpellInfos.Where(s =>
                                               (s.routine == SpellRoutine.CureAilment) &&
                                               (s.targeting == targeting || targeting == SpellTargeting.Any) &&
                                               (s.effect == 0));
            }
            else if (routine == SpellRoutine.InflictStatus || routine == SpellRoutine.PowerWord || routine == SpellRoutine.CureAilment)
            {
                foundSpells = SpellInfos.Where(s =>
                                               (s.routine == routine) &&
                                               (s.targeting == targeting || targeting == SpellTargeting.Any) &&
                                               (s.elem == element || element == SpellElement.Any) &&
                                               (s.effect == (byte)status || status == SpellStatus.Any));
            }
            else
            {
                foundSpells = SpellInfos.Where(s =>
                                               (s.routine == routine) &&
                                               (s.targeting == targeting || targeting == SpellTargeting.Any) &&
                                               (s.elem == element || element == SpellElement.Any) &&
                                               (s.oobSpellRoutine == oobSpell || oobSpell == OOBSpellRoutine.None));
            }

            return(foundSpells.Select(s => ((Spell)Convert.ToByte((int)Spell.CURE + s.Index), s)).ToList());
        }