public Player(PlayerSyncData sync) : base(sync)
        {
            prefab = (GameObject)GameObject.Instantiate(Resources.Load("Player"));
            prefab.GetComponent <PlayerScript>().Init(sync);

            Camera.main.GetComponent <CameraScript>().SetTarget(prefab.transform);
        }
Example #2
0
        public void ReceiveLatestData(PlayerSyncData sync)
        {
            updated = true;

            previous = latest;
            latest   = sync;
        }
        public void Init(PlayerSyncData sync)
        {
            rgd   = GetComponent <Rigidbody>();
            anime = GetComponent <Animator>();

            transform.position         = new Vector3(sync.xpos, sync.ypos, sync.zpos);
            transform.localEulerAngles = new Vector3(0, sync.yrot, 0);
        }
        public void Init(PlayerSyncData sync)
        {
            anime = GetComponent <Animator>();

            transform.position         = new Vector3(sync.xpos, sync.ypos, sync.zpos);
            transform.localEulerAngles = new Vector3(0, sync.yrot, 0);

            state = sync.anime;

            SetAnime();
        }
        public static PlayerSyncData GeneratePlayer(NetConnection connection)
        {
            int            userid = userCount++;
            PlayerSyncData sync   = new PlayerSyncData {
                userid = userid, xpos = 10.0f, ypos = 0.0f, zpos = 10.0f, yrot = 0, anime = 0
            };

            players.Add(connection, sync);

            return(sync);
        }
Example #6
0
        static public void ConnectHandler(NetConnection connection, object data)
        {
            PlayerSyncData sync = Players.GeneratePlayer(connection);
            BMPInitData    bmps = World.GetBMP();

            InitData init = new InitData()
            {
                sync = sync, bmps = bmps
            };

            GSrv.Send(MessageType.ConnectSuccess, GSrv.Serialize <InitData>(init), connection, NetDeliveryMethod.ReliableOrdered);
        }
 public static void Push(NetConnection connection, PushData push)
 {
     if (players.ContainsKey(connection))
     {
         PlayerSyncData sync = players[connection];
         sync.xpos  = push.xpos;
         sync.ypos  = push.ypos;
         sync.zpos  = push.zpos;
         sync.yrot  = push.yrot;
         sync.anime = push.anime;
     }
 }
        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);

            if (this.state != latest.anime)
            {
                this.state = latest.anime;
                SetAnime();
            }
        }
Example #9
0
        InitData GetDummyInitData()
        {
            PlayerSyncData sync = new PlayerSyncData {
                userid = 1, xpos = 10.0f, ypos = 0, zpos = 10.0f, yrot = 0, anime = 0
            };
            BMPInitData bmps = new BMPInitData();

            int[,] bot_blocks = new int[Env.TotalPixels, Env.TotalPixels];
            bmps.botbmp.AddRange(bot_blocks.Cast <int>());
            bmps.frontbmp.AddRange(bot_blocks.Cast <int>());

            return(new InitData {
                sync = sync, bmps = bmps
            });
        }
Example #10
0
 public PlayerBase(PlayerSyncData sync)
 {
     latest   = sync;
     previous = sync;
 }
 public static void SetPlayer(PlayerSyncData sync)
 {
     userid = sync.userid;
     player = new Player(sync);
 }
 public OtherPlayer(PlayerSyncData sync) : base(sync)
 {
     prefab = (GameObject)GameObject.Instantiate(Resources.Load("OtherPlayer"));
     prefab.GetComponent <OtherPlayerScript>().Init(sync);
 }