예제 #1
0
 protected UIContext(ClientGame game, LocalPlayer localPlayer, PlayerGameObject playerGameObject)
 {
     this.game = game;
     this.localPlayer = localPlayer;
     this.localPlayer.PushUIContext(this);
     this.playerObject = playerGameObject;
 }
        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();
        }
        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);
            }
        }
예제 #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();
        }
예제 #5
0
 public virtual void OnClientInitialization(ClientGame game) { }
예제 #6
0
 public RootContext(ClientGame game, LocalPlayer localPlayer, PlayerGameObject playerGameObject)
     : base(game, localPlayer, playerGameObject)
 {
 }