예제 #1
0
        public override void Step(float deltaTime)
        {
            base.Step(deltaTime);

            server.Service();

            lobbyTimer -= deltaTime;
            if (lobbyTimer <= 0)
            {
                lobbyTimer = 1.0f;
                SendLobby(PacketFlags.Reliable);
            }

            if (state == NetworkState.Lobby)
            {
                if (testMode)
                {
                    SetBattle();
                }
                else
                {
                    if (peers.Count > 0 && peers.Values.All(x => x.Ready))
                    {
                        state = NetworkState.Countdown;
                        timer = 5.0f;
                    }
                }
            }
            else if (state == NetworkState.Countdown)
            {
                timer -= deltaTime;
                if (peers.Values.Any(x => !x.Ready))
                {
                    state = NetworkState.Lobby;
                }
                else
                {
                    if (timer <= 0)
                    {
                        SetBattle();
                    }
                }
            }
            else
            {
                if (!testMode && peers.Where(x => x.Value.Ready).Count() == 0)
                {
                    SetLobby();
                }
                else
                {
                    SendSnapshot();

                    foreach (Unit unit in Root.GetChild <WorldEntity>().GetChildren <Unit>())
                    {
                        if (unit.GetChild <Transform>() != null)
                        {
                            unit.GetChild <Transform>().ResetWarped();
                        }
                    }
                }
            }
        }
 public override void Step(float deltaTime)
 {
     server.Service();
 }