Example #1
0
        protected override IEnumerator Unload()
        {
            while (FightLogicExecutor.isValid)
            {
                yield return(null);
            }
            FightMap current = FightMap.current;

            if (null != current)
            {
                current.Release();
                FightMap.current = null;
            }
            if (FightSpellEffectFactory.isReady)
            {
                yield return(FightSpellEffectFactory.Unload());
            }
            if (FightObjectFactory.isReady)
            {
                yield return(FightObjectFactory.Unload());
            }
            if (FightUIFactory.isReady)
            {
                yield return(FightUIFactory.Unload());
            }
            VisualEffectFactory.Dispose();
            yield return(RuntimeData.UnloadTextCollectionAsync("Fight"));

            yield return(_003C_003En__0());

            DragNDropListener.instance.CancelSnapDrag();
            instance = null;
        }
 private static IEnumerator RemovePropertyFromView(ICharacterObject characterObject, PropertyId property)
 {
     if (FightSpellEffectFactory.isReady && FightSpellEffectFactory.TryGetPropertyEffect(property, out AttachableEffect attachableEffect))
     {
         yield return(characterObject.RemovePropertyEffect(attachableEffect, property));
     }
 }
Example #3
0
 public void ClearFloatingCounterEffect()
 {
     if (null != m_currentFloatingCounterFeedback)
     {
         FightSpellEffectFactory.DestroyFloatingCounterFeedback(m_currentFloatingCounterFeedback);
         m_currentFloatingCounterFeedback = null;
     }
 }
        private static IEnumerator AddPropertyToView(ICharacterObject characterObject, PropertyId property)
        {
            AttachableEffect attachableEffect;

            if (FightSpellEffectFactory.isReady && FightSpellEffectFactory.TryGetPropertyEffect(property, out attachableEffect) && null != attachableEffect)
            {
                yield return(characterObject.AddPropertyEffect(attachableEffect, property));
            }
        }
Example #5
0
        public IEnumerator InitializeFloatingCounterEffect(FloatingCounterEffect floatingCounterEffect, int value)
        {
            if (null != m_currentFloatingCounterFeedback)
            {
                Log.Warning("InitializeFloatingCounterEffect called on " + base.GetType().Name + " named " + this.get_name() + " but a floating counter feedback is already attached.", 662, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs");
            }
            FloatingCounterFeedback floatingCounterFeedback = FightSpellEffectFactory.InstantiateFloatingCounterFeedback(m_attachableEffectsContainer);

            if (!(null == floatingCounterFeedback))
            {
                m_currentFloatingCounterFeedback = floatingCounterFeedback;
                yield return(floatingCounterFeedback.Launch(this, floatingCounterEffect, value));
            }
        }
Example #6
0
 public override IEnumerator UpdateView(FightStatus fightStatus)
 {
     if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithBoardPresence entityStatus))
     {
         IObjectWithCounterEffects objectWithCounterEffects;
         IObjectWithCounterEffects isoObject = objectWithCounterEffects = (entityStatus.view as IObjectWithCounterEffects);
         if (objectWithCounterEffects != null)
         {
             if (counterReplaced.HasValue)
             {
                 yield return(isoObject.RemoveFloatingCounterEffect());
             }
             CaracId floatingCounterType = (CaracId)this.floatingCounterType;
             if (!FightSpellEffectFactory.TryGetFloatingCounterEffect(floatingCounterType, (PropertyId?)sightProperty, out FloatingCounterEffect effect))
             {
                 yield break;
             }
             if (null != effect)
             {
                 if (valueBefore == 0 || counterReplaced.HasValue)
                 {
                     yield return(isoObject.InitializeFloatingCounterEffect(effect, valueAfter));
                 }
                 else
                 {
                     FloatingCounterFeedback currentFloatingCounterFeedback = isoObject.GetCurrentFloatingCounterFeedback();
                     currentFloatingCounterFeedback.ChangeVisual(effect);
                     yield return(currentFloatingCounterFeedback.SetCount(valueAfter));
                 }
                 if (parentEventId.HasValue)
                 {
                     FightSpellEffectFactory.SetupSpellEffectOverrides(effect, fightStatus.fightId, parentEventId.Value);
                 }
             }
             else
             {
                 Log.Error(string.Format("No prefab defined for {0} {1}.", "FloatingCounterEffect", floatingCounterType), 68, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloatingCounterValueChangedEvent.cs");
             }
         }
         else
         {
             Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithCounterEffects>(entityStatus), 74, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloatingCounterValueChangedEvent.cs");
         }
     }
     else
     {
         Log.Error(FightEventErrors.EntityNotFound <IEntityWithBoardPresence>(concernedEntity), 79, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloatingCounterValueChangedEvent.cs");
     }
 }
        private static IEnumerator TryChangeSightVisual(ICharacterObject characterObject, PropertyId?property)
        {
            IObjectWithCounterEffects objectWithCounterEffects;

            if ((objectWithCounterEffects = (characterObject as IObjectWithCounterEffects)) != null)
            {
                if (FightSpellEffectFactory.isReady && FightSpellEffectFactory.TryGetFloatingCounterEffect(CaracId.FloatingCounterSight, property, out FloatingCounterEffect floatingEffectCounter))
                {
                    yield return(objectWithCounterEffects.ChangeFloatingCounterEffect(floatingEffectCounter));
                }
            }
            else
            {
                Log.Warning(string.Format("Try to set a {0} on {1}, which is not a {2}", "SightPropertyId", characterObject, "IObjectWithCounterEffects"), 209, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PropertyChangedEvent.cs");
            }
        }
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithBoardPresence entityStatus))
            {
                IsoObject view = entityStatus.view;
                if (null != view)
                {
                    IObjectWithAction objectWithAction;
                    if ((objectWithAction = (view as IObjectWithAction)) != null)
                    {
                        objectWithAction.SetPhysicalDamageBoost(valueAfter);
                    }
                    else
                    {
                        Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithAction>(entityStatus), 37, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PhysicalDamageModifierChangedEvent.cs");
                    }
                    CellObject cellObject = view.cellObject;
                    if (null != cellObject)
                    {
                        if (valueAfter > valueBefore)
                        {
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.PhysicalDamageGain, fightStatus.fightId, parentEventId, view, fightStatus.context));

                            ValueChangedFeedback.Launch(valueAfter - valueBefore, ValueChangedFeedback.Type.Action, cellObject.get_transform());
                        }
                        else
                        {
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.PhysicalDamageLoss, fightStatus.fightId, parentEventId, view, fightStatus.context));

                            ValueChangedFeedback.Launch(valueAfter - valueBefore, ValueChangedFeedback.Type.Action, cellObject.get_transform());
                        }
                    }
                    else
                    {
                        Log.Warning("Tried to apply a damage modifier on target named " + view.get_name() + " (" + ((object)view).GetType().Name + ") but the target is no longer on the board.", 56, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PhysicalDamageModifierChangedEvent.cs");
                    }
                }
                else
                {
                    Log.Error(FightEventErrors.EntityHasNoView(entityStatus), 61, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PhysicalDamageModifierChangedEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.EntityNotFound <IEntityWithBoardPresence>(concernedEntity), 66, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PhysicalDamageModifierChangedEvent.cs");
            }
        }
Example #9
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            int fightId = fightStatus.fightId;

            if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithMovement entityStatus))
            {
                IsoObject isoObject = entityStatus.view;
                if (null != isoObject)
                {
                    IObjectWithMovement objectWithMovement;
                    if ((objectWithMovement = (isoObject as IObjectWithMovement)) != null)
                    {
                        objectWithMovement.SetMovementPoints(valueAfter);
                    }
                    else
                    {
                        Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithMovement>(entityStatus), 46, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MovementPointsChangedEvent.cs");
                    }
                    if (valueAfter > valueBefore)
                    {
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.MovementPointGain, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(valueAfter - valueBefore, ValueChangedFeedback.Type.Movement, isoObject.cellObject.get_transform());
                    }
                    else
                    {
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.MovementPointLoss, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(valueAfter - valueBefore, ValueChangedFeedback.Type.Movement, isoObject.cellObject.get_transform());
                    }
                }
                else
                {
                    Log.Error(FightEventErrors.EntityHasNoView(entityStatus), 62, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MovementPointsChangedEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.EntityNotFound <IEntityWithMovement>(concernedEntity), 67, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MovementPointsChangedEvent.cs");
            }
            FightLogicExecutor.FireUpdateView(fightId, EventCategory.MovementPointsChanged);
        }
Example #10
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            FightMap current = FightMap.current;

            if (!(null != current))
            {
                yield break;
            }
            if (current.TryGetCellObject(center.X, center.Y, out CellObject cellObject))
            {
                if (FightSpellEffectFactory.TryGetSpellEffect(SpellEffectKey.Explosion, fightStatus.fightId, parentEventId, out SpellEffect spellEffect))
                {
                    CameraHandler current2 = CameraHandler.current;
                    yield return(FightSpellEffectFactory.PlaySpellEffect(rotation: (!(null != current2)) ? Quaternion.get_identity() : current2.mapRotation.GetInverseRotation(), spellEffect: spellEffect, transform: cellObject.get_transform(), scale: Vector3.get_one(), delay: 0f, fightContext: fightStatus.context, contextProvider: null));
                }
            }
            else
            {
                Log.Error(FightEventErrors.InvalidPosition(center), 38, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\ExplosionEvent.cs");
            }
        }
Example #11
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            int fightId = fightStatus.fightId;

            if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithBoardPresence entity))
            {
                IsoObject isoObject = entity.view;
                if (null != isoObject)
                {
                    switch (movementType)
                    {
                    case 1:
                    {
                        IObjectWithMovement objectWithMovement6;
                        if ((objectWithMovement6 = (isoObject as IObjectWithMovement)) != null)
                        {
                            yield return(objectWithMovement6.Move(GetPath()));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithMovement>(entity), 71, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    case 3:
                    {
                        IMovableObject movableObject;
                        IMovableObject objectWithMovement3 = movableObject = (isoObject as IMovableObject);
                        if (movableObject != null)
                        {
                            FightContext fightContext = fightStatus.context;
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.TeleportationStart, fightId, parentEventId, isoObject, fightContext));

                            objectWithMovement3.Teleport(GetDestination());
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.TeleportationEnd, fightId, parentEventId, isoObject, fightContext));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithMovement>(entity), 88, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    case 6:
                    {
                        IMovableObject movableObject;
                        IMovableObject objectWithMovement3 = movableObject = (isoObject as IMovableObject);
                        if (movableObject != null)
                        {
                            Vector2Int[]             path2            = GetPath();
                            Quaternion               pathRotation2    = GetPathRotation(path2);
                            Transform                transform2       = isoObject.cellObject.get_transform();
                            ITimelineContextProvider contextProvider2 = isoObject as ITimelineContextProvider;
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.Push, fightId, parentEventId, transform2, pathRotation2, Vector3.get_one(), fightStatus.context, contextProvider2));

                            yield return(objectWithMovement3.Push(path2));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IMovableObject>(entity), 108, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    case 7:
                    {
                        IMovableObject movableObject;
                        IMovableObject objectWithMovement3 = movableObject = (isoObject as IMovableObject);
                        if (movableObject != null)
                        {
                            Vector2Int[]             path2           = GetPath();
                            Quaternion               pathRotation    = GetPathRotation(path2);
                            Transform                transform       = isoObject.cellObject.get_transform();
                            ITimelineContextProvider contextProvider = isoObject as ITimelineContextProvider;
                            yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.Pull, fightId, parentEventId, transform, pathRotation, Vector3.get_one(), fightStatus.context, contextProvider));

                            yield return(objectWithMovement3.Pull(path2));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IMovableObject>(entity), 128, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    case 2:
                    case 4:
                    {
                        IObjectWithMovement objectWithMovement5;
                        if ((objectWithMovement5 = (isoObject as IObjectWithMovement)) != null)
                        {
                            Direction direction2 = (Direction)this.direction;
                            yield return(objectWithMovement5.MoveToAction(GetPath(), direction2));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithMovement>(entity), 143, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    case 8:
                    {
                        IObjectWithMovement objectWithMovement4;
                        if ((objectWithMovement4 = (isoObject as IObjectWithMovement)) != null)
                        {
                            Direction direction = (Direction)this.direction;
                            yield return(objectWithMovement4.MoveToAction(GetPath(), direction, hasFollowUpAnimation: false));
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithMovement>(entity), 157, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                        break;
                    }

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    if (IsMovementAction())
                    {
                        IObjectWithAction objectWithAction;
                        if ((objectWithAction = (isoObject as IObjectWithAction)) != null)
                        {
                            objectWithAction.SetActionUsed(actionUsed: true, turnEnded: false);
                        }
                        else
                        {
                            Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithAction>(entity), 174, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                        }
                    }
                    ICharacterObject characterObject;
                    if ((characterObject = (isoObject as ICharacterObject)) != null)
                    {
                        characterObject.CheckParentCellIndicator();
                    }
                }
                else
                {
                    Log.Error(FightEventErrors.EntityHasNoView(entity), 185, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.EntityNotFound <IEntityWithBoardPresence>(concernedEntity), 190, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\EntityAreaMovedEvent.cs");
            }
            FightLogicExecutor.FireUpdateView(fightId, EventCategory.EntityMoved);
        }
Example #12
0
        public IEnumerator LoadResources()
        {
            switch (m_resourceLoadingState)
            {
            case ResourceLoadingState.Loaded:
                break;

            case ResourceLoadingState.Loading:
                do
                {
                    yield return(null);
                }while (m_resourceLoadingState == ResourceLoadingState.Loading);
                break;

            default:
                throw new ArgumentOutOfRangeException();

            case ResourceLoadingState.None:
            {
                if (!FightSpellEffectFactory.isReady)
                {
                    break;
                }
                m_resourceLoadingState = ResourceLoadingState.Loading;
                int spellEffectReferenceCount = m_spellEffectData.Count;
                int count = ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Count;
                int num   = spellEffectReferenceCount + count;
                AssetLoadRequest <SpellEffect>[] loadRequests = new AssetLoadRequest <SpellEffect> [num];
                IEnumerator[] spellEffectLoadRequests         = new IEnumerator[num];
                int           i;
                for (i = 0; i < spellEffectReferenceCount; i++)
                {
                    string spellEffect = m_spellEffectData[i].spellEffect;
                    if (spellEffect.Length > 0)
                    {
                        loadRequests[i] = AssetManager.LoadAssetAsync <SpellEffect>(spellEffect, "core/spells/effects");
                        continue;
                    }
                    Log.Warning($"Spell named '{this.get_displayName()}' has an unassigned spell effect at index {i}.", 118, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                    loadRequests[i] = null;
                }
                foreach (AssetReference value in ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Values)
                {
                    AssetReference current = value;
                    if (current.get_hasValue())
                    {
                        loadRequests[i] = current.LoadFromAssetBundleAsync <SpellEffect>("core/spells/effects");
                    }
                    else
                    {
                        loadRequests[i] = null;
                    }
                    i++;
                }
                yield return(EnumeratorUtility.ParallelRecursiveSafeExecution((IEnumerator[])loadRequests));

                SpellEffect[] spellEffects = new SpellEffect[spellEffectReferenceCount];
                for (i = 0; i < spellEffectReferenceCount; i++)
                {
                    AssetLoadRequest <SpellEffect> val = loadRequests[i];
                    if (val == null)
                    {
                        spellEffects[i] = null;
                        continue;
                    }
                    if (AssetManagerError.op_Implicit(val.get_error()) == 0)
                    {
                        spellEffectLoadRequests[i] = (spellEffects[i] = val.get_asset()).Load();
                        continue;
                    }
                    spellEffects[i] = null;
                    Log.Error($"Could not load spell effect for spell {this.get_name()}: {val.get_error()}", 159, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                }
                Dictionary <SpellEffectKey, SpellEffect> spellEffectOverrides = new Dictionary <SpellEffectKey, SpellEffect>(((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Count, SpellEffectKeyComparer.instance);
                foreach (SpellEffectKey key in ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Keys)
                {
                    AssetLoadRequest <SpellEffect> val2 = loadRequests[i];
                    if (val2 == null)
                    {
                        spellEffectOverrides.Add(key, null);
                    }
                    else if (AssetManagerError.op_Implicit(val2.get_error()) == 0)
                    {
                        SpellEffect asset = val2.get_asset();
                        spellEffectOverrides.Add(key, asset);
                        spellEffectLoadRequests[i] = asset.Load();
                    }
                    else
                    {
                        spellEffectOverrides.Add(key, null);
                        Log.Error($"Could not load spell effect override for key {key} for spell {this.get_name()}: {val2.get_error()}", 183, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                    }
                    i++;
                }
                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(spellEffectLoadRequests));

                m_spellEffects         = spellEffects;
                m_spellEffectOverrides = spellEffectOverrides;
                m_resourceLoadingState = ResourceLoadingState.Loaded;
                FightSpellEffectFactory.NotifySpellDefinitionLoaded(this);
                break;
            }
            }
        }
Example #13
0
        protected override IEnumerator Load()
        {
            if (m_concurrentFightsCount == 1)
            {
                RuntimeData.currentKeywordContext = KeywordContext.FightSolo;
            }
            else
            {
                RuntimeData.currentKeywordContext = KeywordContext.FightMulti;
            }
            instance = this;
            int fightCount = m_concurrentFightsCount;

            if (!RuntimeData.fightDefinitions.TryGetValue(m_fightDefId, out m_fightDefinition))
            {
                Log.Error(string.Format("Could not find {0} with id {1}.", "FightDefinition", m_fightDefId), 78, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            yield return(RuntimeData.LoadTextCollectionAsync("Fight"));

            yield return(LoadSceneAndBundleRequest("FightMapWrapper", "core/scenes/maps/fight_maps"));

            Scene sceneByName = SceneManager.GetSceneByName("FightMapWrapper");

            if (!sceneByName.get_isLoaded())
            {
                Log.Error("Could not load scene named 'FightMapWrapper' from bundle 'core/scenes/maps/fight_maps'.", 93, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            yield return(LoadFightMap());

            FightMap current = FightMap.current;

            if (null == current)
            {
                Log.Error("Failed to load fight map.", 104, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\FightState.cs");
                yield break;
            }
            FightLogicExecutor.Initialize(fightCount);
            FightMapDefinition definition = current.definition;

            FightStatus[] array = new FightStatus[fightCount];
            for (int i = 0; i < fightCount; i++)
            {
                FightMapStatus mapStatus   = definition.CreateFightMapStatus(i);
                FightStatus    fightStatus = new FightStatus(i, mapStatus);
                if (fightStatus.fightId == m_ownFightId)
                {
                    FightStatus.local = fightStatus;
                }
                FightLogicExecutor.AddFightStatus(fightStatus);
                array[i] = fightStatus;
            }
            GameStatus.Initialize((FightType)m_fightInfo.FightType, m_fightDefinition, array);
            yield return(current.Initialize());

            VisualEffectFactory.Initialize();
            yield return(FightObjectFactory.Load());

            if (!FightObjectFactory.isReady)
            {
                yield break;
            }
            yield return(FightSpellEffectFactory.Load(fightCount));

            if (!FightSpellEffectFactory.isReady)
            {
                yield break;
            }
            yield return(FightUIFactory.Load());

            if (!FightUIFactory.isReady)
            {
                yield break;
            }
            UILoader <FightUIRework> loaderRework = new UILoader <FightUIRework>(this, "FightUIRework", "core/scenes/ui/fight");

            yield return(loaderRework.Load());

            m_uiRework = loaderRework.ui;
            m_uiRework.Init(GameStatus.fightType, m_fightDefinition);
            frame = new FightFrame
            {
                onOtherPlayerLeftFight = OnOtherPlayerLeftFight
            };
            if (m_hardResumed)
            {
                FightSnapshot snapshot = null;
                frame.onFightSnapshot = delegate(FightSnapshot fightSnapshot)
                {
                    snapshot = fightSnapshot;
                };
                frame.SendFightSnapshotRequest();
                while (snapshot == null)
                {
                    yield return(null);
                }
                frame.onFightSnapshot = null;
                yield return(ApplyFightSnapshot(snapshot));
            }
            frame.SendPlayerReady();
            while (!FightLogicExecutor.fightInitialized)
            {
                yield return(null);
            }
            yield return(uiRework.Load());
        }
Example #14
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");
            }
        }
Example #15
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            int fightId = fightStatus.fightId;

            if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithBoardPresence entityStatus))
            {
                int change = 0;
                int num    = 0;
                int num2   = 0;
                LifeModificationType lifeModificationType = LifeModificationType.Undefined;
                if (armorAfter.HasValue)
                {
                    num = armorAfter.Value;
                    if (armorBefore.HasValue)
                    {
                        int value = armorBefore.Value;
                        change += num - value;
                        if (value > num)
                        {
                            lifeModificationType = LifeModificationType.Damage;
                        }
                        else if (value < num)
                        {
                            lifeModificationType = LifeModificationType.ArmorGain;
                        }
                    }
                }
                if (lifeAfter.HasValue)
                {
                    num2 = lifeAfter.Value;
                    if (lifeBefore.HasValue)
                    {
                        int value2 = lifeBefore.Value;
                        change += num2 - value2;
                        if (value2 > num2)
                        {
                            lifeModificationType = ((num2 > 0) ? LifeModificationType.Damage : LifeModificationType.Death);
                        }
                        else if (value2 < num2)
                        {
                            lifeModificationType = ((entityStatus.type == EntityType.ObjectMechanism) ? LifeModificationType.ArmorGain : LifeModificationType.Heal);
                        }
                    }
                }
                if (lifeAfter.HasValue && entityStatus.type == EntityType.Hero)
                {
                    HeroStatus heroStatus = (HeroStatus)entityStatus;
                    if (heroStatus.ownerId == fightStatus.localPlayerId)
                    {
                        FightMap current = FightMap.current;
                        if (null != current)
                        {
                            current.SetLocalPlayerHeroLife(num2, heroStatus.baseLife);
                        }
                    }
                    if (fightStatus.TryGetEntity(heroStatus.ownerId, out PlayerStatus entityStatus2))
                    {
                        AbstractPlayerUIRework view = entityStatus2.view;
                        if (null != view)
                        {
                            view.ChangeHeroLifePoints(num2);
                        }
                        TryDrawLowLifeMessage(num2, entityStatus2);
                    }
                }
                IsoObject isoObject = entityStatus.view;
                if (null != isoObject)
                {
                    IObjectWithArmoredLife objectWithArmoredLife2;
                    IObjectWithArmoredLife objectWithArmoredLife = objectWithArmoredLife2 = (isoObject as IObjectWithArmoredLife);
                    if (objectWithArmoredLife2 != null)
                    {
                        int life  = lifeAfter.HasValue ? num2 : objectWithArmoredLife.life;
                        int armor = armorAfter.HasValue ? num : objectWithArmoredLife.armor;
                        objectWithArmoredLife.SetArmoredLife(life, armor);
                    }
                    else
                    {
                        Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithArmoredLife>(entityStatus), 151, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\ArmoredLifeChangedEvent.cs");
                        objectWithArmoredLife = null;
                    }
                    switch (lifeModificationType)
                    {
                    case LifeModificationType.ArmorGain:
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.ArmorGain, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(change, ValueChangedFeedback.Type.Heal, isoObject.cellObject.get_transform());
                        break;

                    case LifeModificationType.Damage:
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.Damage, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(change, ValueChangedFeedback.Type.Damage, isoObject.cellObject.get_transform());
                        if (objectWithArmoredLife != null)
                        {
                            yield return(objectWithArmoredLife.Hit(isoObject.area.refCoord));
                        }
                        break;

                    case LifeModificationType.Heal:
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.Heal, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(change, ValueChangedFeedback.Type.Heal, isoObject.cellObject.get_transform());
                        break;

                    case LifeModificationType.Death:
                        yield return(FightSpellEffectFactory.PlayGenericEffect(SpellEffectKey.Damage, fightId, parentEventId, isoObject, fightStatus.context));

                        ValueChangedFeedback.Launch(change, ValueChangedFeedback.Type.Damage, isoObject.cellObject.get_transform());
                        objectWithArmoredLife?.LethalHit(isoObject.area.refCoord);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();

                    case LifeModificationType.Undefined:
                        break;
                    }
                }
                else
                {
                    Log.Error(FightEventErrors.EntityHasNoView(entityStatus), 197, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\ArmoredLifeChangedEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.EntityNotFound <IEntityWithBoardPresence>(concernedEntity), 202, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\ArmoredLifeChangedEvent.cs");
            }
            FightLogicExecutor.FireUpdateView(fightId, EventCategory.LifeArmorChanged);
        }