Пример #1
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;
        }
Пример #2
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);
        }
Пример #3
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());
        }
Пример #4
0
        public override void PopulateFromJson(JObject jsonObject)
        {
            this.PopulateFromJson(jsonObject);
            m_eventsInvalidatingCost    = Serialization.JsonArrayAsList <EventCategory>(jsonObject, "eventsInvalidatingCost");
            m_eventsInvalidatingCasting = Serialization.JsonArrayAsList <EventCategory>(jsonObject, "eventsInvalidatingCasting");
            m_precomputedData           = PrecomputedData.FromJsonProperty(jsonObject, "precomputedData");
            m_spellType = (SpellType)Serialization.JsonTokenValue <int>(jsonObject, "spellType", 1);
            m_god       = (God)Serialization.JsonTokenValue <int>(jsonObject, "god", 0);
            m_element   = (Element)Serialization.JsonTokenValue <int>(jsonObject, "element", 0);
            m_tags      = Serialization.JsonArrayAsList <SpellTag>(jsonObject, "tags");
            JArray val = Serialization.JsonArray(jsonObject, "gaugeToModifyOnSpellPlay");

            m_gaugeToModifyOnSpellPlay = new List <GaugeValue>((val != null) ? val.get_Count() : 0);
            if (val != null)
            {
                foreach (JToken item in val)
                {
                    m_gaugeToModifyOnSpellPlay.Add(GaugeValue.FromJsonToken(item));
                }
            }
            JArray val2 = Serialization.JsonArray(jsonObject, "costs");

            m_costs = new List <Cost>((val2 != null) ? val2.get_Count() : 0);
            if (val2 != null)
            {
                foreach (JToken item2 in val2)
                {
                    m_costs.Add(Cost.FromJsonToken(item2));
                }
            }
            m_castTarget = ICastTargetDefinitionUtils.FromJsonProperty(jsonObject, "castTarget");
            JArray val3 = Serialization.JsonArray(jsonObject, "spellEffectData");

            m_spellEffectData = new List <SpellEffectInstantiationData>((val3 != null) ? val3.get_Count() : 0);
            if (val3 != null)
            {
                foreach (JToken item3 in val3)
                {
                    m_spellEffectData.Add(SpellEffectInstantiationData.FromJsonToken(item3));
                }
            }
        }
        public static ICastTargetDefinition FromJsonProperty(JObject jsonObject, string propertyName, ICastTargetDefinition defaultValue = null)
        {
            //IL_0011: Unknown result type (might be due to invalid IL or missing references)
            //IL_0018: Invalid comparison between Unknown and I4
            JProperty val = jsonObject.Property(propertyName);

            if (val == null || (int)val.get_Value().get_Type() == 10)
            {
                return(defaultValue);
            }
            return(FromJsonToken(val.get_Value()));
        }
Пример #6
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            if (fightStatus.TryGetEntity(concernedEntity, out PlayerStatus playerStatus))
            {
                if (playerStatus.TryGetSpell(spellInstanceId, out SpellStatus spellStatus))
                {
                    SpellDefinition definition = spellStatus.definition;
                    if (!(null != definition))
                    {
                        yield break;
                    }
                    yield return(definition.LoadResources());

                    ICastTargetDefinition castTarget        = definition.castTarget;
                    CastTargetContext     castTargetContext = castTarget.CreateCastTargetContext(fightStatus, concernedEntity, DynamicValueHolderType.Spell, spellDefId, spellLevel, 0);
                    int count = targets.Count;
                    for (int j = 0; j < count; j++)
                    {
                        castTargetContext.SelectTarget(targets[j].ToTarget(fightStatus));
                    }
                    if (count > 0 && !playerStatus.isLocalPlayer)
                    {
                        CellObject targetedCell = GetTargetedCell(fightStatus, targets[0]);
                        yield return(FightUIRework.ShowPlayingSpell(spellStatus, targetedCell));
                    }
                    List <SpellEffectInstantiationData> spellEffectData = (List <SpellEffectInstantiationData>)definition.spellEffectData;
                    int spellEffectCount = spellEffectData.Count;
                    if (spellEffectCount > 0)
                    {
                        List <IEnumerator> routineList = ListPool <IEnumerator> .Get();

                        int num;
                        for (int i = 0; i < spellEffectCount; i = num)
                        {
                            SpellEffect spellEffect = definition.GetSpellEffect(i);
                            if (!(null == spellEffect))
                            {
                                SpellEffectInstantiationData spellEffectInstantiationData = spellEffectData[i];
                                spellEffectInstantiationData.PreComputeDelayOverDistance(castTargetContext);
                                foreach (Vector2Int item3 in spellEffectInstantiationData.EnumerateInstantiationPositions(castTargetContext))
                                {
                                    IEnumerator item = FightSpellEffectFactory.PlaySpellEffect(spellEffect, item3, spellEffectInstantiationData, castTargetContext);
                                    routineList.Add(item);
                                }
                                foreach (IsoObject item4 in spellEffectInstantiationData.EnumerateInstantiationObjectTargets(castTargetContext))
                                {
                                    IEnumerator item2 = FightSpellEffectFactory.PlaySpellEffect(spellEffect, item4, spellEffectInstantiationData, castTargetContext);
                                    routineList.Add(item2);
                                }
                                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(routineList.ToArray()));

                                routineList.Clear();
                            }
                            num = i + 1;
                        }
                        ListPool <IEnumerator> .Release(routineList);
                    }
                    FightSpellEffectFactory.SetupSpellEffectOverrides(definition, fightStatus.fightId, eventId);
                }
                else
                {
                    Log.Error($"Could not find spell with instance id {spellInstanceId} for player with id {concernedEntity}.", 128, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PlaySpellEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.PlayerNotFound(concernedEntity), 133, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PlaySpellEvent.cs");
            }
        }