Ejemplo n.º 1
0
 protected UIContext(ClientGame game, LocalPlayer localPlayer, PlayerGameObject playerGameObject)
 {
     this.game = game;
     this.localPlayer = localPlayer;
     this.localPlayer.PushUIContext(this);
     this.playerObject = playerGameObject;
 }
Ejemplo n.º 2
0
        public void Apply(ClientGame game, GameTime gameTime)
        {
            GameObjectField.SetModeSimulation();

            this.ResetReader();
            Type typeFromMessage = GameObjectTypes.GetType(this.ReadInt());
            int idFromMessage = this.ReadInt();
            bool isDesroyedFromMessage = this.ReadBoolean();

            GameObjectCollection collection = game.GameObjectCollection;

            GameObject obj;
            if (collection.Contains(idFromMessage))
            {
                obj = collection.Get<GameObject>(idFromMessage);
                if (obj.LastMessageTimeStamp > this.TimeStamp)
                {
                    return;
                }

                if (!(obj.GetType() == typeFromMessage && obj.ID == idFromMessage))
                {
                    throw new Exception("this message does not belong to this object");
                }

                obj.IsDestroyed = isDesroyedFromMessage;
                foreach (GameObjectField field in obj.Fields)
                {
                    field.ApplyMessage(this);
                }
                this.AssertMessageEnd();
            }
            else
            {
                if (isDesroyedFromMessage)
                {
                    return;
                }
                obj = GameObject.Construct(typeFromMessage, game.GameObjectCollection, idFromMessage);

                if (!(obj.GetType() == typeFromMessage && obj.ID == idFromMessage))
                {
                    throw new Exception("this message does not belong to this object");
                }

                obj.IsDestroyed = isDesroyedFromMessage;
                foreach (GameObjectField field in obj.Fields)
                {
                    field.ApplyMessage(this);
                }
                this.AssertMessageEnd();

                obj.OnClientInitialization(game);
            }

            obj.LatencyAdjustment(gameTime, this.TimeStamp);
            GameObjectField.SetModeDraw();
        }
Ejemplo n.º 3
0
        public override void OnClientInitialization(ClientGame game)
        {
            base.OnClientInitialization(game);
            this.clientGame = game;

            if (this.clientGame.LocalPlayer.Id == this.playerID.Value)
            {
                this.localPlayer = this.clientGame.LocalPlayer;
                this.clientGame.LocalPlayer.SetPlayerGameObject(this);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void ClientMain()
        {
            string serverIP = Microsoft.VisualBasic.Interaction.InputBox("Enter Server IP Address", "Server IP Address", "127.0.0.1");

            IPAddress address;
            try
            {
                address = IPAddress.Parse(serverIP);
            }
            catch (System.FormatException)
            {
                return;
            }

            ClientGame game = new ClientGame(address);
            game.Run();
        }
Ejemplo n.º 5
0
 public virtual void OnClientInitialization(ClientGame game) { }
Ejemplo n.º 6
0
 public RootContext(ClientGame game, LocalPlayer localPlayer, PlayerGameObject playerGameObject)
     : base(game, localPlayer, playerGameObject)
 {
 }