Пример #1
0
        public void ReceiveLatestData(PlayerSyncData sync)
        {
            updated = true;

            previous  = init.sync;
            init.sync = sync;

            ManageDiff();
        }
Пример #2
0
        public void Push(NetConnection connection, PushData data)
        {
            PlayerSyncData sync = players[connection].sync;

            sync.xpos       = data.xpos;
            sync.ypos       = data.ypos;
            sync.zpos       = data.zpos;
            sync.xrot       = data.xrot;
            sync.yrot       = data.yrot;
            sync.animestate = data.animestate;
        }
        public void Interpolation(PlayerSyncData latest, float delta)
        {
            Vector3 latestPos = new Vector3(latest.xpos, latest.ypos, latest.zpos);

            transform.position = Vector3.Lerp(transform.position, latestPos, delta * 10.0f);

            transform.localEulerAngles = new Vector3(0, Mathf.LerpAngle(transform.localEulerAngles.y, latest.yrot, delta * 10.0f), 0);
            latest_xrot = latest.xrot;

            if (this.animeState != latest.animestate)
            {
                this.animeState = latest.animestate;
                SetAnime();
            }
        }
Пример #4
0
 public PlayerBase(PlayerInitData init)
 {
     this.init = init;
     previous  = init.sync;
 }
Пример #5
0
        public void CheckBattleStart()
        {
            if (players.Count == 0)
            {
                return;
            }

            Player not_ready_player = players.FirstOrDefault(x => x.Value.ready == false).Value;

            if (not_ready_player != null)
            {
                return;
            }

            PlayerInitDatas datas = new PlayerInitDatas();

            foreach (Player player in players.Values)
            {
                if (player.faction == 0)
                {
                    PlayerSyncData sync = new PlayerSyncData
                    {
                        userid     = player.userid,
                        xpos       = 16.0f,
                        ypos       = 17.0f,
                        zpos       = 1.0f,
                        xrot       = 0.0f,
                        yrot       = 0.0f,
                        animestate = 0,
                        hp         = 100
                    };
                    player.sync = sync;
                }
                else
                {
                    PlayerSyncData sync = new PlayerSyncData
                    {
                        userid     = player.userid,
                        xpos       = 16.0f,
                        ypos       = 17.0f,
                        zpos       = 63.0f,
                        xrot       = 0.0f,
                        yrot       = 180.0f,
                        animestate = 0,
                        hp         = 100
                    };
                    player.sync = sync;
                }

                player.ResetRespawnTimer();

                datas.datas.Add(new PlayerInitData {
                    username = player.username, faction = player.faction, sync = player.sync
                });
            }

            foreach (Player player in players.Values)
            {
                GSrv.Send(MessageType.BattleStart, GSrv.Serialize <PlayerInitDatas>(datas), player.connection, NetDeliveryMethod.ReliableOrdered);
            }

            roomstate = 1;
        }