示例#1
0
        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");
        }
示例#2
0
 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);
 }
示例#3
0
        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>();
        }
示例#4
0
        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);
                }
            }
        }
示例#5
0
 public void Run(MapInfoComponent mapInfo)
 {
     foreach (var item in mapInfo.players)
     {
     }
 }
示例#6
0
 public void SetCmps(Entity entity)
 {
     //this.entity = entity;
     wait = entity.GetComponent <WaitCounterComponent>();
     info = entity.GetComponent <MapInfoComponent>();
 }