public void ReachTerminus(Champion champion) { if (champion.mazeResult != Champion.MazeResult.Nan) { return; } champion.BeginMove(FVec3.zero); SyncEvent.Terminus(champion.rid); champion.mazeResult = Champion.MazeResult.Win; int count = this._entityManager.championCount; for (int i = 0; i < count; i++) { Champion other = this._entityManager.GetChampionAt(i); if (other.team == champion.team && other.mazeResult != Champion.MazeResult.Win) { return; } } for (int i = 0; i < count; i++) { Champion other = this._entityManager.GetChampionAt(i); if (other.team != champion.team) { other.mazeResult = Champion.MazeResult.Lose; } } this.Win(champion.team); }
public void HandleUseItem(string rid) { Champion entity = this._entityManager.GetChampion(rid); bool result = entity.UseItem(); SyncEvent.UseItem(rid, result); }
private static void HandleAction(_DTO_frame_info dto) { int count = dto.actions.Length; for (int i = 0; i < count; i++) { _DTO_action_info action = dto.actions[i]; if (action.sender == CPlayer.instance.rid) { SyncEvent.HandleFrameAction(); } FrameActionType type = ( FrameActionType )action.type; switch (type) { case FrameActionType.Move: { lBattle.HandleBeginMove(action.sender, new FVec3(action.x, action.y, action.z)); } break; case FrameActionType.UseItem: { lBattle.HandleUseItem(action.sender); } break; } } }
private NodeStatsEventType GetSyncEventType(SyncEvent syncEvent) { switch (syncEvent) { case SyncEvent.InitCompleted: return(NodeStatsEventType.SyncInitCompleted); case SyncEvent.InitCancelled: return(NodeStatsEventType.SyncInitCancelled); case SyncEvent.InitFailed: return(NodeStatsEventType.SyncInitFailed); case SyncEvent.Started: return(NodeStatsEventType.SyncStarted); case SyncEvent.Completed: return(NodeStatsEventType.SyncCompleted); case SyncEvent.Failed: return(NodeStatsEventType.SyncFailed); case SyncEvent.Cancelled: return(NodeStatsEventType.SyncCancelled); } throw new Exception($"SyncStatus not supported: {syncEvent.ToString()}"); }
public T Create <T>(EntityParam param) where T : Entity, new() { T entity = this._gPool.Pop <T>(); this._idToEntity[param.rid] = entity; this._entities.Add(entity); System.Type t = typeof(T); if (typeof(Collider).IsAssignableFrom(t)) { Collider collider = entity as Collider; this._colliders.Add(collider); } if (typeof(ITrigger).IsAssignableFrom(t)) { ITrigger trigger = entity as ITrigger; this._triggers.Add(trigger); } if (typeof(Item).IsAssignableFrom(t)) { Item item = entity as Item; this._idToItem[param.rid] = item; this._items.Add(item); } if (typeof(Champion).IsAssignableFrom(t)) { Champion champion = entity as Champion; this._idToChampion[param.rid] = champion; this._champions.Add(champion); } SyncEvent.CreateEntity(entity.GetType().Name, param); entity.OnAddedToBattle(this._battle, param); return(entity); }
private void HandleCountDown(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; UIEvent.CountDown(e.i0, e.i1); this._battle.HandleCountDown(e.i0, e.i1); }
private async void Notify(ConnectionEndpoint endpoint, NetworkEvent networkEvent) { lock (this) { pendingCount++; if (pendingCount == 1) { Trace("Queue started"); syncPendingSent = new SyncEvent(); } } await Task.Delay(Parameters.CallLatency); endpoint.Notify(networkEvent); lock (this) { pendingCount--; if (pendingCount == 0) { Trace("Queue empty"); syncPendingSent.SetComplete(); } } }
private void HandleBuffTriggered(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBuff buff = this.GetBuff(e.buffId); buff.HandleTriggered(e.triggerIndex); }
private void HandleSpawnEntity(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; EntityParam param = e.entityParam; switch (e.entityType) { case "Bio": VEntity entity = CUser.id == param.uid ? this._entityManager.CreatePlayer(param) : this._entityManager.CreateBio(param); if (entity == VPlayer.instance) { //hero.fsm.enableDebug = true; this.camera.target = entity; } break; case "Missile": this._entityManager.CreateMissile(param); break; case "FoxFire": this._entityManager.CreateBio <VFoxFire>(param); break; } }
protected virtual void OnShowAllColorsChanged(EventArgs e) { ClearCache(); Invalidate(); SelectedColorIndex = SelectedColorIndex; SyncEvent.Invoke(ShowAllColorsChanged, this, e); }
private void HandleWin(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; UIEvent.Win(e.i0); this._battle.HandleWin(e.i0); }
public static void DestroyBattle() { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.BATTLE_DESTROIED; e.BeginInvoke(); }
protected override async Task Dispatch( PeerInfo bestPeer, BlocksRequest?blocksRequest, CancellationToken cancellation) { if (blocksRequest == null) { if (Logger.IsWarn) { Logger.Warn($"NULL received for dispatch in {nameof(BlockDownloader)}"); } return; } if (!_blockTree.CanAcceptNewBlocks) { return; } CancellationTokenSource linkedCancellation = CancellationTokenSource.CreateLinkedTokenSource( cancellation, _allocationWithCancellation.Cancellation.Token); try { SyncEvent?.Invoke(this, new SyncEventArgs(bestPeer.SyncPeer, Synchronization.SyncEvent.Started)); if ((blocksRequest.Options & DownloaderOptions.WithBodies) == DownloaderOptions.WithBodies) { if (Logger.IsDebug) { Logger.Debug("Downloading bodies"); } await DownloadBlocks(bestPeer, blocksRequest, linkedCancellation.Token).ContinueWith(t => HandleSyncRequestResult(t, bestPeer)); if (Logger.IsDebug) { Logger.Debug("Finished downloading bodies"); } } else { if (Logger.IsDebug) { Logger.Debug("Downloading headers"); } await DownloadHeaders(bestPeer, blocksRequest, linkedCancellation.Token).ContinueWith(t => HandleSyncRequestResult(t, bestPeer)); if (Logger.IsDebug) { Logger.Debug("Finished downloading headers"); } } } finally { _allocationWithCancellation.Dispose(); linkedCancellation.Dispose(); } }
private void InvokeSyncEvent(SynchronizationState state) { SyncState = state; if (SyncEvent != null) { SyncEvent.Invoke(this, new SynchEventArgs(state)); } }
private void ThreadFunctionSync() { while (running) { action(); SyncEvent.WaitOne(100); } }
private void HandleMissileComplete(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VMissile missile = this.GetMissile(e.missileId); missile.HandleComplete(e.position.ToVector3(), e.direction.ToVector3()); }
private void HandleRelive(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBio bio = this.GetBio(e.targetId); bio.HandleRelive(e.position.ToVector3(), e.direction.ToVector3()); }
public void OnTrigger(Entity entity) { if ((( Champion )entity).PickItem(this.rid)) { SyncEvent.PickItem(entity.rid, this.rid); this.MarkToDestroy(); } }
private void HandleTriggerTarget(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBuff buff = this.GetBuff(e.buffId); VBio target = this.GetBio(e.targetId); target.HandleTrigger(buff, e.triggerIndex); }
private void HandleExitBuff(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBuff buff = this.GetBuff(e.buffId); VBio target = this.GetBio(e.targetId); target.HandleExitBuff(buff); }
private void HandleEntityStateChanged(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; IFSMOwner entity = this.GetBio(e.targetId); entity.HandleEntityStateChanged(e.stateType, e.forceChange, e.stateParam); }
public static void DespawnBuff(string buffId) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.DESPAWN_BUFF; e.buffId = buffId; e.BeginInvoke(); }
private void HandleBuffStateRemoved(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBio bio = this.GetBio(e.targetId); bio.HandleBuffStateRemoved(e.buffStateId); }
private void HandleBuffStateTriggered(BaseEvent baseEvent) { SyncEvent e = ( SyncEvent )baseEvent; VBio bio = this.GetBio(e.targetId); bio.HandleBuffStateTriggered(e.buffStateId, e.triggerIndex); }
public static void BuffAttrInitialized(string buffId) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.BUFF_ATTR_INITIALIZED; e.buffId = buffId; e.BeginInvoke(); }
public void Dispose() { this._startCountDown.Dispose(); this._buffManager.Dispose(); this._entityManager.Dispose(); this._maze.Dispose(); SyncEvent.DestroyBattle(); }
public static void EntityAttrInitialized(string entityId) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.ENTITY_ATTR_INITIALIZED; e.targetId = entityId; e.BeginInvoke(); }
public static void DespawnEntity(string entityId) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.DESPAWN_ENTITY; e.targetId = entityId; e.BeginInvoke(); }
public static void SpawnEntity(string type, EntityParam param) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.SPAWN_ENTITY; e.entityType = type; e.entityParam = param; e.BeginInvoke(); }
public static void BuffStateRemoved(string targetId, string id) { SyncEvent e = SyncEvent.Get(); e.type = SyncEventType.BUFF_STATE_REMOVED; e.targetId = targetId; e.buffStateId = id; e.BeginInvoke(); }
//Sync Event handler (client and server) public override void OnEvent(SyncEvent evnt) { Debug.Log("Sync event recieved"); StartTime = evnt.StartTime; if (evnt.StartTime < BoltNetwork.serverTime) { if (!BoltNetwork.isServer) { BoltNetwork.server.Disconnect(new DisconnectReason("Sync Failure", "Failed to synchronize with the server in time")); } else { Debug.LogWarning("Server recieved sync message that is before the current time?"); } } DebugHUD.setValue("load state", "Synch message recieved"); running = true; //hide loading screen }