public void Run(MapInfoComponent map, uint client) { var state = world.GetComponent <StateComponent>(client); state.state = StateDefine.Mapping; state.map = map.entity.id; map.Add(client); System.Console.WriteLine("AddPlayer::Run"); }
private bool isAllOver(MapInfoComponent map) { foreach (var item in map.players) { var s = world.GetComponent <StateComponent>(item); if (s == null) { continue; } if (s.state != StateDefine.Over) { return(false); } } return(true); }
public void Run(MapInfoComponent map) { System.Console.WriteLine("MapInit::Run"); int seed = world.GetBehavior <RandomBhr>().random(); GameInitMessage message = new GameInitMessage() { seed = seed }; message.pid.AddRange(map.players); foreach (var item in map.players) { world.GetComponent <StateComponent>(item).state = StateDefine.Readying; world.Get <Entity>(item).AddComponent <InputComponenet>(); } world.GetBehavior <Notify>().Run(map.players, message); map.entity.AddComponent <WaitCounterComponent>(); map.entity.AddComponent <FrameComponent>(); }
public async void Run(MapInfoComponent info) { foreach (var item in info.players) { world.GetComponent <StateComponent>(item).state = StateDefine.Gaming; } var fr = info.Slibing <FrameComponent>(); var pull = world.GetBehavior <InputPull>(); var notify = world.GetBehavior <Notify>(); while (true) { try { if (isAllOver(info)) { notify.Run(info.players, new GameOverMessage()); info.Clear(); fr.frame = 0; foreach (var item in info.players) { world.GetComponent <StateComponent>(item).Clear(); world.GetComponent <InputComponenet>(item).data = null; } return; } var message = pull.Run(info.players, fr.frame); notify.Run(info.players, message); await Task.Delay((int)(1000f / fr.hz)); fr.frame++; } catch (System.Exception e) { System.Console.WriteLine("RunGame::Error " + e); } } }
public void Run(MapInfoComponent mapInfo) { foreach (var item in mapInfo.players) { } }
public void SetCmps(Entity entity) { //this.entity = entity; wait = entity.GetComponent <WaitCounterComponent>(); info = entity.GetComponent <MapInfoComponent>(); }