示例#1
0
        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);
        }
示例#2
0
        public void HandleUseItem(string rid)
        {
            Champion entity = this._entityManager.GetChampion(rid);
            bool     result = entity.UseItem();

            SyncEvent.UseItem(rid, result);
        }
示例#3
0
        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;
                }
            }
        }
示例#4
0
        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()}");
        }
示例#5
0
        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);
        }
示例#7
0
        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();
                }
            }
        }
示例#8
0
        private void HandleBuffTriggered(BaseEvent baseEvent)
        {
            SyncEvent e    = ( SyncEvent )baseEvent;
            VBuff     buff = this.GetBuff(e.buffId);

            buff.HandleTriggered(e.triggerIndex);
        }
示例#9
0
        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;
            }
        }
示例#10
0
 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);
        }
示例#12
0
        public static void DestroyBattle()
        {
            SyncEvent e = SyncEvent.Get();

            e.type = SyncEventType.BATTLE_DESTROIED;
            e.BeginInvoke();
        }
示例#13
0
        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);
     }
 }
示例#16
0
        private void HandleMissileComplete(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            VMissile missile = this.GetMissile(e.missileId);

            missile.HandleComplete(e.position.ToVector3(), e.direction.ToVector3());
        }
示例#17
0
        private void HandleRelive(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            VBio bio = this.GetBio(e.targetId);

            bio.HandleRelive(e.position.ToVector3(), e.direction.ToVector3());
        }
示例#18
0
 public void OnTrigger(Entity entity)
 {
     if ((( Champion )entity).PickItem(this.rid))
     {
         SyncEvent.PickItem(entity.rid, this.rid);
         this.MarkToDestroy();
     }
 }
示例#19
0
        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);
        }
示例#20
0
        private void HandleExitBuff(BaseEvent baseEvent)
        {
            SyncEvent e      = ( SyncEvent )baseEvent;
            VBuff     buff   = this.GetBuff(e.buffId);
            VBio      target = this.GetBio(e.targetId);

            target.HandleExitBuff(buff);
        }
示例#21
0
        private void HandleEntityStateChanged(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            IFSMOwner entity = this.GetBio(e.targetId);

            entity.HandleEntityStateChanged(e.stateType, e.forceChange, e.stateParam);
        }
示例#22
0
        public static void DespawnBuff(string buffId)
        {
            SyncEvent e = SyncEvent.Get();

            e.type   = SyncEventType.DESPAWN_BUFF;
            e.buffId = buffId;
            e.BeginInvoke();
        }
示例#23
0
        private void HandleBuffStateRemoved(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            VBio bio = this.GetBio(e.targetId);

            bio.HandleBuffStateRemoved(e.buffStateId);
        }
示例#24
0
        private void HandleBuffStateTriggered(BaseEvent baseEvent)
        {
            SyncEvent e = ( SyncEvent )baseEvent;

            VBio bio = this.GetBio(e.targetId);

            bio.HandleBuffStateTriggered(e.buffStateId, e.triggerIndex);
        }
示例#25
0
        public static void BuffAttrInitialized(string buffId)
        {
            SyncEvent e = SyncEvent.Get();

            e.type   = SyncEventType.BUFF_ATTR_INITIALIZED;
            e.buffId = buffId;
            e.BeginInvoke();
        }
示例#26
0
 public void Dispose()
 {
     this._startCountDown.Dispose();
     this._buffManager.Dispose();
     this._entityManager.Dispose();
     this._maze.Dispose();
     SyncEvent.DestroyBattle();
 }
示例#27
0
        public static void EntityAttrInitialized(string entityId)
        {
            SyncEvent e = SyncEvent.Get();

            e.type     = SyncEventType.ENTITY_ATTR_INITIALIZED;
            e.targetId = entityId;
            e.BeginInvoke();
        }
示例#28
0
        public static void DespawnEntity(string entityId)
        {
            SyncEvent e = SyncEvent.Get();

            e.type     = SyncEventType.DESPAWN_ENTITY;
            e.targetId = entityId;
            e.BeginInvoke();
        }
示例#29
0
        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();
        }
示例#30
0
        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
 }