コード例 #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 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;
     }
 }
コード例 #5
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);
        }
コード例 #6
0
        public static bool StartInvokingCompanion(PlayerStatus casterStatus, ReserveCompanionStatus companionStatus)
        {
            if (s_currentCastType != 0)
            {
                Log.Error($"Tried to start invoking a companion while current cast type is {s_currentCastType}", 208, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return(false);
            }
            CompanionDefinition definition = companionStatus.definition;

            if (null == definition)
            {
                Log.Error("Tried to start invoking a companion without a loaded definition.", 215, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                return(false);
            }
            OneCastTargetContext castTargetContext = new OneCastTargetContext(FightStatus.local, casterStatus.id, DynamicValueHolderType.Companion, definition.get_id(), companionStatus.level, 0);
            FightMap             current           = FightMap.current;

            if (null != current)
            {
                ICoordSelector spawnLocation = definition.spawnLocation;
                if (spawnLocation == null)
                {
                    Log.Error("Tried to start invoking a companion that has no spawn location.", 227, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightCastManager.cs");
                    return(false);
                }
                FightMap fightMap = current;
                fightMap.onTargetChanged = (Action <Target?, CellObject>)Delegate.Combine(fightMap.onTargetChanged, new Action <Target?, CellObject>(OnCompanionInvocationLocationChanged));
                FightMap fightMap2 = current;
                fightMap2.onTargetSelected = (Action <Target?>)Delegate.Combine(fightMap2.onTargetSelected, new Action <Target?>(OnCompanionInvocationLocationSelected));
                current.SetTargetingPhase(EnumerateCompanionAvailableLocations(spawnLocation, castTargetContext));
            }
            s_currentCastType       = CurrentCastType.Companion;
            s_playerCasting         = casterStatus;
            s_companionBeingInvoked = companionStatus;
            s_castTargetContext     = castTargetContext;
            ShowCompanionCostsPreview();
            return(true);
        }
コード例 #7
0
        public static int ApplyCostModification(List <SpellCostModification> modifications, int cost, SpellDefinition spellDefinition, CastTargetContext context)
        {
            int count = modifications.Count;

            for (int i = 0; i < count; i++)
            {
                SpellCostModification spellCostModification = modifications[i];
                if (spellCostModification.Accept(context.instanceId, spellDefinition))
                {
                    cost += spellCostModification.modificationValue;
                }
            }
            return(Math.Max(0, cost));
        }
コード例 #8
0
        public static IEnumerator PlaySpellEffect([NotNull] SpellEffect spellEffect, [NotNull] IsoObject view, [NotNull] SpellEffectInstantiationData instantiationData, [NotNull] CastTargetContext castTargetContext)
        {
            CellObject cellObject = view.cellObject;

            if (null == cellObject)
            {
                Log.Warning("Tried to play spell effect " + spellEffect.get_name() + " on target named " + view.get_name() + " (" + ((object)view).GetType().Name + ") but the target is no longer on the board.", 449, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs");
                yield break;
            }
            Transform                transform = cellObject.get_transform();
            FightContext             context   = castTargetContext.fightStatus.context;
            ITimelineContextProvider timelineContextProvider = view as ITimelineContextProvider;
            Quaternion               rotation = Quaternion.get_identity();
            Vector3 scale = Vector3.get_one();

            switch (spellEffect.orientationMethod)
            {
            case SpellEffect.OrientationMethod.None:
            {
                CameraHandler current = CameraHandler.current;
                if (null != current)
                {
                    rotation = current.mapRotation.GetInverseRotation();
                }
                break;
            }

            case SpellEffect.OrientationMethod.Context:
            {
                VisualEffectContext visualEffectContext;
                if (timelineContextProvider != null && (visualEffectContext = (timelineContextProvider.GetTimelineContext() as VisualEffectContext)) != null)
                {
                    visualEffectContext.GetVisualEffectTransformation(out rotation, out scale);
                }
                break;
            }

            case SpellEffect.OrientationMethod.SpellEffectTarget:
                rotation = instantiationData.GetOrientation(cellObject.coords, castTargetContext);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            float delayOverDistance = instantiationData.GetDelayOverDistance(cellObject.coords);

            yield return(PlaySpellEffect(spellEffect, transform, rotation, scale, delayOverDistance, context, timelineContextProvider));
        }
コード例 #9
0
        public static IEnumerator PlaySpellEffect([NotNull] SpellEffect spellEffect, Vector2Int coords, [NotNull] SpellEffectInstantiationData instantiationData, [NotNull] CastTargetContext castTargetContext)
        {
            //IL_000e: Unknown result type (might be due to invalid IL or missing references)
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            if (!FightMap.current.TryGetCellObject(coords.get_x(), coords.get_y(), out CellObject cellObject))
            {
                yield break;
            }
            Transform                transform = cellObject.get_transform();
            FightContext             context   = castTargetContext.fightStatus.context;
            ITimelineContextProvider timelineContextProvider = null;
            Quaternion               rotation = Quaternion.get_identity();
            Vector3 scale = Vector3.get_one();

            switch (spellEffect.orientationMethod)
            {
            case SpellEffect.OrientationMethod.None:
            {
                CameraHandler current = CameraHandler.current;
                if (null != current)
                {
                    rotation = current.mapRotation.GetInverseRotation();
                }
                break;
            }

            case SpellEffect.OrientationMethod.Context:
                if (cellObject.TryGetIsoObject(out CharacterObject isoObject))
                {
                    timelineContextProvider = isoObject;
                    VisualEffectContext visualEffectContext;
                    if ((visualEffectContext = (timelineContextProvider.GetTimelineContext() as VisualEffectContext)) != null)
                    {
                        visualEffectContext.GetVisualEffectTransformation(out rotation, out scale);
                    }
                }
                else
                {
                    Log.Warning($"Spell effect named '{spellEffect.get_name()}' orientation method is {SpellEffect.OrientationMethod.Context} but context provider could not be found.", 426, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs");
                }
                break;

            case SpellEffect.OrientationMethod.SpellEffectTarget:
                rotation = instantiationData.GetOrientation(coords, castTargetContext);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            float delayOverDistance = instantiationData.GetDelayOverDistance(coords);

            yield return(PlaySpellEffect(spellEffect, transform, rotation, scale, delayOverDistance, context, timelineContextProvider));
        }
コード例 #10
0
        private static void ShowSpellCostsPreview()
        {
            CastTargetContext context = s_spellBeingCast.CreateCastTargetContext();

            PreviewCosts(s_spellBeingCast.definition.costs, context);
        }
コード例 #11
0
 private static IEnumerable <Target> EnumerateCompanionAvailableLocations(ICoordSelector spawnLocation, CastTargetContext castTargetContext)
 {
     foreach (Coord item in spawnLocation.EnumerateCoords(castTargetContext))
     {
         yield return(new Target(item));
     }
 }
コード例 #12
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");
            }
        }