public Task <HandlerResponse> Handle(Message message) { if (message.RequestType != MessageType.StartRound) { return(Task.FromResult(NextHandler?.Handle(message).Result)); } if (!FightContext.CanStartNewRound()) { return(Task.FromResult(new HandlerResponse { ResponseType = ResponseType.Skip })); } FightContext.StartRound(); var roundId = FightContext.GetRoundNumber(); return(Task.FromResult(new HandlerResponse { ResponseType = ResponseType.ToAll, Message = new Message { RequestType = message.RequestType, Data = roundId.ToString() } })); }
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)); }
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)); }
public Contexts() { fight = new FightContext(); game = new GameContext(); input = new InputContext(); var postConstructors = System.Linq.Enumerable.Where( GetType().GetMethods(), method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute)) ); foreach (var postConstructor in postConstructors) { postConstructor.Invoke(this, null); } }
public Task <HandlerResponse> Handle(Message message) { if (message.RequestType != MessageType.EndRound) { return(Task.FromResult(NextHandler?.Handle(message).Result)); } FightContext.EndRound(); return(Task.FromResult(new HandlerResponse { ResponseType = ResponseType.ToAll, Message = new Message { RequestType = message.RequestType, Data = null } })); }
private async Task SavePoints(string data) { try { Context.BeginTransaction(); var points = data.Deserialize <FightPoint>(); FightContext.RegisterPoints(points); Context.FightPoints.Add(points); await Context.SaveChangesAsync(); Context.CommitTransaction(); } catch { Context.RollbackTransaction(); throw; } }
public IMessageHandler CreateMessageHandlerChain() { var context = new ApplicationDbContextFactory().CreateDbContext(new string[] { }); var fightContext = new FightContext(context); var endFightHandler = new EndFightHandler(null, fightContext, context); var startRoundHandler = new StartRoundHandler(endFightHandler, fightContext, context); var sendPointsHandler = new SendPointsHandler(startRoundHandler, fightContext, context); var prematureEndHandler = new PrematureEndHandler(sendPointsHandler, fightContext, context); var showPrematureEndPanel = new ShowPrematureEndPanelHandler(prematureEndHandler, fightContext, context); var juryConnectedHandler = new JuryConnectedHandler(showPrematureEndPanel, fightContext, context); var connectHandler = new LoadStateHandler(juryConnectedHandler, fightContext, context); var endRoundHandler = new EndRoundHandler(connectHandler, fightContext, context); var pauseFightHandler = new PauseRoundHandler(endRoundHandler, fightContext, context); var resumeFightHandler = new ResumeRoundHandler(pauseFightHandler, fightContext, context); return(new AcceptPointsHandler(resumeFightHandler, fightContext, context)); }
public async Task <HandlerResponse> Handle(Message message) { if (message.RequestType != MessageType.EndFight) { return(NextHandler?.Handle(message).Result); } FightContext.ResetState(); await SaveWinner(message.Data); return(new HandlerResponse { ResponseType = ResponseType.ToAll, Message = new Message { RequestType = message.RequestType } }); }
public void EndRound_ShouldEndRound() { var context = new Mocks().GetDefaultDatabaseContext(); var fightEntity = new Fight { Id = 1, BlueAthleteId = "abcd", RedAthleteId = "efgh", Structure = new FightStructure() { Round = new Round() { BreakDuration = 1000, Duration = 3000, RoundsCount = 3 } } }; context.Fights.Add(fightEntity); context.SaveChanges(); var fightContext = new FightContext(context); fightContext.InitState(1); fightContext.EndRound(); Thread.SpinWait(1000); var state = fightContext.GetFightState(); Assert.Equal(state.Id, 1); Assert.Equal(state.Paused, false); Assert.Equal(state.Started, false); Assert.True(state.RemainingTime < 1000); Assert.Equal(state.Round, 1); Assert.Equal(state.RedFighter.Id, "efgh"); Assert.Equal(state.BlueFighter.Id, "abcd"); }
public Task <HandlerResponse> Handle(Message message) { if (message.RequestType != MessageType.PersisedState) { return(Task.FromResult(NextHandler?.Handle(message).Result)); } if (FightContext.GetFightId() == 0) { var fightId = message.Data.ToInt(); FightContext.InitState(fightId); } var serializedState = FightContext.GetFightState().Serialize(); return(Task.FromResult(new HandlerResponse { ResponseType = ResponseType.ToSelf, Message = new Message { RequestType = MessageType.PersisedState, Data = serializedState } })); }
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); }
public static IEnumerator PlaySpellEffect([NotNull] SpellEffect spellEffect, [NotNull] Transform transform, Quaternion rotation, Vector3 scale, float delay, [CanBeNull] FightContext fightContext, [CanBeNull] ITimelineContextProvider contextProvider) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (delay > 0f) { yield return((object)new WaitForTime(delay)); } Component instance = spellEffect.Instantiate(transform, rotation, scale, fightContext, contextProvider); if (!(null != instance)) { yield break; } switch (spellEffect.waitMethod) { case SpellEffect.WaitMethod.None: { MonoBehaviour current2 = FightMap.current; if (null != current2) { current2.StartCoroutine(spellEffect.DestroyWhenFinished(instance)); } break; } case SpellEffect.WaitMethod.Delay: yield return((object)new WaitForTime(spellEffect.waitDelay)); if (null != instance) { MonoBehaviour current = FightMap.current; if (null != current) { current.StartCoroutine(spellEffect.DestroyWhenFinished(instance)); } } break; case SpellEffect.WaitMethod.Destruction: yield return(spellEffect.DestroyWhenFinished(instance)); break; default: throw new ArgumentOutOfRangeException(); } }
public static IEnumerator PlayGenericEffect(SpellEffectKey key, int fightId, int?parentEventId, [NotNull] IsoObject target, [CanBeNull] FightContext fightContext) { if (s_spellEffectCache == null || s_currentSpellEffectOverrideData == null) { Log.Error("PlayGenericEffect called while the factory is not ready.", 290, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs"); } else { if (((!parentEventId.HasValue || !s_currentSpellEffectOverrideData[fightId].TryGetSpellEffectOverride(key, parentEventId.Value, out SpellEffect value)) && !s_spellEffectCache.TryGetValue(key, out value)) || null == value) { yield break; } CellObject cellObject = target.cellObject; if (null == cellObject) { Log.Warning($"Tried to play generic effect {key} on target named {target.get_name()} ({((object)target).GetType().Name}) but the target is no longer on the board.", 313, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs"); yield break; } Transform transform = cellObject.get_transform(); Quaternion rotation = Quaternion.get_identity(); Vector3 scale = Vector3.get_one(); ITimelineContextProvider timelineContextProvider = target as ITimelineContextProvider; switch (value.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: Log.Warning($"Spell effect named '{value.get_name()}' orientation method is {SpellEffect.OrientationMethod.SpellEffectTarget} but is not played from a spell.", 346, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs"); break; default: throw new ArgumentOutOfRangeException(); } yield return(PlaySpellEffect(value, transform, rotation, scale, 0f, fightContext, timelineContextProvider)); } }
public static System.Collections.Generic.HashSet <FightEntity> GetEntitiesWithRolePos(this FightContext context, UnityEngine.Vector2 pos) { return(((Entitas.EntityIndex <FightEntity, UnityEngine.Vector2>)context.GetEntityIndex(Contexts.RolePos)).GetEntities(pos)); }
public static IEnumerator PlayGenericEffect(SpellEffectKey key, int fightId, int?parentEventId, [NotNull] Transform parent, Quaternion rotation, Vector3 scale, [CanBeNull] FightContext fightContext, [CanBeNull] ITimelineContextProvider contextProvider) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) SpellEffect spellEffect; if (s_spellEffectCache == null || s_currentSpellEffectOverrideData == null) { Log.Error("PlayGenericEffect called while the factory is not ready.", 361, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs"); } else if (((parentEventId.HasValue && s_currentSpellEffectOverrideData[fightId].TryGetSpellEffectOverride(key, parentEventId.Value, out spellEffect)) || s_spellEffectCache.TryGetValue(key, out spellEffect)) && !(null == spellEffect)) { yield return(PlaySpellEffect(spellEffect, parent, rotation, scale, 0f, fightContext, contextProvider)); } }
public abstract Component Instantiate([NotNull] Transform parent, Quaternion rotation, Vector3 scale, [CanBeNull] FightContext fightContext, [CanBeNull] ITimelineContextProvider contextProvider);
public FightStatus(int fightId, FightMapStatus mapStatus) { this.fightId = fightId; this.mapStatus = mapStatus; context = FightContext.Create(fightId); }
public static PlayableDirector CreateTimelineAssetEffectInstance([NotNull] TimelineAsset timelineAsset, [NotNull] Transform parent, Quaternion rotation, Vector3 scale, [CanBeNull] FightContext fightContext, [CanBeNull] ITimelineContextProvider contextProvider) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (null == timelineAsset) { throw new NullReferenceException(); } if (null == s_instance) { Log.Error("CreateTimelineAssetEffectInstance called while the factory is not ready.", 412, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightObjectFactory.cs"); return(null); } GameObject obj = s_timelineAssetEffectPool.Instantiate(parent.get_position(), rotation, parent); Vector3 localScale = obj.get_transform().get_localScale(); localScale.Scale(scale); obj.get_transform().set_localScale(localScale); PlayableDirector component = obj.GetComponent <PlayableDirector>(); if (null != fightContext) { TimelineContextUtility.SetFightContext(component, fightContext); } if (contextProvider != null) { TimelineContextUtility.SetContextProvider(component, contextProvider); } component.Play(timelineAsset, 2); return(component); }
public override Component Instantiate(Transform parent, Quaternion rotation, Vector3 scale, FightContext fightContext, ITimelineContextProvider contextProvider) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (null == m_timelineAsset) { Log.Warning("Tried to instantiate timeline asset spell effect named '" + this.get_name() + "' without a timeline asset setup.", 42, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Animations\\TimelineAssetSpellEffect.cs"); return(null); } return(FightObjectFactory.CreateTimelineAssetEffectInstance(m_timelineAsset, parent, rotation, scale, fightContext, contextProvider)); }
public override Component Instantiate(Transform parent, Quaternion rotation, Vector3 scale, FightContext fightContext, ITimelineContextProvider contextProvider) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (null == m_visualEffect) { Log.Warning("Tried to instantiate visual character effect named '" + this.get_name() + "' without a visual effect setup.", 84, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Animations\\VisualSpellEffect.cs"); return(null); } Vector3 position = parent.get_position() + m_positionOffset; if (m_sound.get_isValid()) { AudioManager.PlayOneShot(m_sound, parent); } VisualEffect visualEffect = VisualEffectFactory.Instantiate(m_visualEffect, position, rotation, scale, parent); visualEffect.destructionOverride = OnInstanceDestructionRequest; return(visualEffect); }
void Awake() { //DontDestroyOnLoad(gameObject); context = new FightContext(this); }