private static void UpdateAudioContext(PlayerStatus ownerStatus, int life)
 {
     if (ownerStatus.isLocalPlayer)
     {
         FightMap current = FightMap.current;
         if (null != current)
         {
             current.SetLocalPlayerHeroLife(life, life);
         }
     }
 }
 public override IEnumerator UpdateView(FightStatus fightStatus)
 {
     if (fightStatus.TryGetEntity(concernedEntity, out IEntityWithBoardPresence entityStatus))
     {
         IObjectWithArmoredLife objectWithArmoredLife;
         if ((objectWithArmoredLife = (entityStatus.view as IObjectWithArmoredLife)) != null)
         {
             objectWithArmoredLife.SetBaseLife(maxLifeAfter);
         }
         else
         {
             Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithArmoredLife>(entityStatus), 37, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MaxLifeChangedEvent.cs");
         }
         if (entityStatus.type == EntityType.Hero)
         {
             HeroStatus heroStatus = (HeroStatus)entityStatus;
             if (heroStatus.ownerId == fightStatus.localPlayerId)
             {
                 FightMap current = FightMap.current;
                 if (null != current)
                 {
                     current.SetLocalPlayerHeroLife(heroStatus.life, maxLifeAfter);
                 }
             }
             if (fightStatus.TryGetEntity(heroStatus.ownerId, out PlayerStatus entityStatus2))
             {
                 AbstractPlayerUIRework view = entityStatus2.view;
                 if (null != view)
                 {
                     view.ChangeHeroBaseLifePoints(maxLifeAfter);
                 }
             }
             else
             {
                 Log.Error(FightEventErrors.PlayerNotFound(heroStatus.ownerId), 62, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MaxLifeChangedEvent.cs");
             }
         }
     }
     else
     {
         Log.Error(FightEventErrors.EntityNotFound <IEntityWithBoardPresence>(concernedEntity), 68, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\MaxLifeChangedEvent.cs");
     }
     FightLogicExecutor.FireUpdateView(fightStatus.fightId, EventCategory.LifeArmorChanged);
     yield break;
 }
Beispiel #3
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);
        }