public void Update()
        {
            if (Started)
            {
                if (SendPositionInterval.ElapsedMilliseconds > 100)
                {
                    foreach (UserSession spawnPlayer in Room.RoomMember)
                    {
                        ((InMatchState)spawnPlayer.UserGameState).SendMovePacket();
                    }
                    SendPositionInterval.Reset();
                    SendPositionInterval.Start();
                }

                if (GameTimeInterval.ElapsedMilliseconds > 16)
                {
                    foreach (UserSession spawnPlayer in Room.RoomMember)
                    {
                        ((InMatchState)spawnPlayer.UserGameState).Update();
                        // Map.MapPath[0].FloorPolygon.IsCollide(spawnPlayer.CollisionObject);
                    }

                    GameTimeInterval.Reset();
                    GameTimeInterval.Start();
                }
            }
        }
Beispiel #2
0
        public void Start()
        {
            StreamReader MapWriter = new StreamReader("pasta\\Map0.json");
            Map          objectMap = Map.LoadMapFromJson(MapWriter.ReadToEnd());

            MapWriter.Close();
            Map = objectMap;
            foreach (UserSession user in Room.RoomMembers)
            {
                user.UserGameState = new InMatchState(user, this);

                foreach (UserSession spawnPlayer in Room.RoomMembers)
                {
                    IMapElement sp = objectMap.GetMapElementByName <IMapElement>("sp");
                    spawnPlayer.position = sp.Position;
                    NetOutgoingMessage SendAllPlayersPositionToCurrentSession = user.Connection.Peer.CreateMessage();
                    SendAllPlayersPositionToCurrentSession.Write(SpawnPacket.OpCode);
                    SendAllPlayersPositionToCurrentSession.Write(spawnPlayer.ID);
                    user.Connection.SendMessage(SendAllPlayersPositionToCurrentSession, NetDeliveryMethod.UnreliableSequenced, SendAllPlayersPositionToCurrentSession.LengthBytes);
                }
            }
            SendPositionInterval.Start();
            GameTimeInterval.Start();
            Started = true;
        }