Ejemplo n.º 1
0
        /// <summary>
        /// Take the new state update from the server (i.e. its correction) and store it, so
        /// that we can apply it on our next frame.
        /// </summary>
        public override void AuthoritativeChangePosition(StateUpdateData data, double time)
        {
            base.AuthoritativeChangePosition(data, time);
            Animation  = data.Animation;
            FacingLeft = data.FacingLeft;

            ServerPosition = data.Position;
            Corrections.Add(new CorrectionInfo(time, data.Position, data.Velocity, PreviousLastAck));
            Corrected = true;

            // Remove corrections that are too old
            double limit = Client.Instance.GetTime().TotalSeconds - CORRECTIONS_TIME_KEPT.TotalSeconds;
            int    i     = 0;

            for (; i < Corrections.Count &&
                 Corrections[i].Time < limit; ++i)
            {
            }
            Corrections.RemoveRange(0, i);

            // Remove actions that are most certainly acknowledged
            if (Corrections.Count > 0)
            {
                for (i = 0; i < RecentActions.Count &&
                     RecentActions[i].ID <= Corrections[0].LastAcknowledgedActionId; ++i)
                {
                }
                RecentActions.RemoveRange(0, i);
            }
        }
Ejemplo n.º 2
0
        private void ProcessStateUpdateData(StateUpdateData data)    // метод обработки сообщений с данными состояния игры
        {
            if (data.State.CurrentTurn == 0)
            {
                State = GameClientState.WaitingForTurn;
                GameStarted(this, EventArgs.Empty);
            }

            PlayerInfo = data.State.Players.First(player => player.Id == PlayerId);
            if (PlayerInfo.Alive == false)                                                       // если игрок мерт он просто наблюдает
            {
                State = GameClientState.Spectating;
            }

            GameSession.UpdateState(data.State);            // обновляем состояния



            if (data.TurnAllowed)   // проверка  нашего хода можем идти или нет
            {
                State = GameClientState.WaitingForInput;
                MapUpdated(this, new MapUpdatedEventArgs(data.State.Map));
                TurnReceived(this, EventArgs.Empty);  // получили ход
            }
            else
            {
                MapUpdated(this, new MapUpdatedEventArgs(data.State.Map));      // если нет то ходит другой а карту обновляем
            }
        }
Ejemplo n.º 3
0
		public override void AuthoritativeChangePosition(StateUpdateData data, double time)
		{
			ServerPosition = data.Position;
			StateHistory.AddSnapshot(
				data,
				GetCurrentTimeSeconds());
		}
Ejemplo n.º 4
0
 public override void AuthoritativeChangePosition(StateUpdateData data, double time)
 {
     ServerPosition = data.Position;
     StateHistory.AddSnapshot(
         data,
         GetCurrentTimeSeconds());
 }
Ejemplo n.º 5
0
 // конструктор сообщения в котором содерждатся данные о типе сообщения, данных инициализации, действиях игрока, обновлениях состояния, результатх игры
 public Message(
     MessageType type,
     InitializationData initializationData = null,
     PlayerActionData playerActionData     = null,
     StateUpdateData stateUpdateData       = null,
     GameResultsData gameResultsData       = null)
 {
     Type = type;
     InitializationData = initializationData;
     PlayerActionData   = playerActionData;
     StateUpdateData    = stateUpdateData;
     GameResultsData    = gameResultsData;
 }
Ejemplo n.º 6
0
		/// <summary>
		/// Called when an authority (i.e. the server) indicates a new position.
		/// Depending on who the champion is (the local player or a remote client),
		/// we'll act differently.
		/// </summary>
		public virtual void AuthoritativeChangePosition(StateUpdateData data, double time)
		{
			Position = data.Position;
		}
Ejemplo n.º 7
0
 /// <summary>
 /// Called when an authority (i.e. the server) indicates a new position.
 /// Depending on who the champion is (the local player or a remote client),
 /// we'll act differently.
 /// </summary>
 public virtual void AuthoritativeChangePosition(StateUpdateData data, double time)
 {
     Position = data.Position;
 }
Ejemplo n.º 8
0
        private void TwitterClientFactory_ClientUpdated(long id, StateUpdateData data)
        {
            try
            {
                if (this.m_invoker.InvokeRequired)
                {
                    this.m_invoker.Invoke(new Action <long, StateUpdateData>(this.TwitterClientFactory_ClientUpdated), id, data);
                }
                else
                {
                    lock (this.m_clients)
                    {
                        if (!data.IsRemoved && !this.m_clients.ContainsKey(id))
                        {
                            this.m_clients.Add(id, this.NewClientToolStripItems(id, data.ScreenName));
                        }

                        var cts = this.m_clients[id];

                        if (data.IsRemoved)
                        {
                            this.m_contextMenuStrip.Items.Remove(cts.RootItem);

                            foreach (ToolStripMenuItem subItem in cts.RootItem.DropDownItems)
                            {
                                subItem.Dispose();
                            }
                            cts.RootItem.Dispose();

                            this.m_clients.Remove(id);
                        }
                        else
                        {
                            if (data.ScreenName != null)
                            {
                                cts.RootItem.Text = data.ScreenName;
                            }
                            if (data.Connected.HasValue)
                            {
                                cts.RootItem.Checked = data.Connected.Value;

                                if (!data.Connected.Value)
                                {
                                    cts.TlHome.Text     = "-";
                                    cts.TlAbountMe.Text = "-";
                                    cts.TlDm.Text       = "-";
                                }
                            }

                            if (data.WaitTimeHome.HasValue)
                            {
                                cts.TlHome.Text = FormatWaitTime(data.WaitTimeHome.Value);
                            }
                            if (data.WaitTimeAboutMe.HasValue)
                            {
                                cts.TlAbountMe.Text = FormatWaitTime(data.WaitTimeAboutMe.Value);
                            }
                            if (data.WaitTimeDm.HasValue)
                            {
                                cts.TlDm.Text = FormatWaitTime(data.WaitTimeDm.Value);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SentrySdk.CaptureException(ex);
            }
        }
Ejemplo n.º 9
0
		/// <summary>
		/// Take the new state update from the server (i.e. its correction) and store it, so
		/// that we can apply it on our next frame.
		/// </summary>
		public override void AuthoritativeChangePosition(StateUpdateData data, double time)
		{
			base.AuthoritativeChangePosition(data, time);
			Animation = data.Animation;
			FacingLeft = data.FacingLeft;

			ServerPosition = data.Position;
			Corrections.Add(new CorrectionInfo(time, data.Position, data.Velocity, PreviousLastAck));
			Corrected = true;

            // Remove corrections that are too old
            double limit = Client.Instance.GetTime().TotalSeconds - CORRECTIONS_TIME_KEPT.TotalSeconds;
			int i = 0;
			for (; i < Corrections.Count &&
                   Corrections[i].Time < limit; ++i) { }
            Corrections.RemoveRange(0, i);

			// Remove actions that are most certainly acknowledged
			if (Corrections.Count > 0) {
				for (i = 0; i < RecentActions.Count &&
				     RecentActions[i].ID <= Corrections[0].LastAcknowledgedActionId; ++i) { }
				RecentActions.RemoveRange(0, i);
			}
		}