Beispiel #1
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }

            GCli.Receive();

            frameSpan += Time.deltaTime;
            if (frameSpan >= 0.1f)
            {
                frameSpan = 0;

                PushData push = Players.GetPushData();
                if (push != null)
                {
                    GCli.Send(MessageType.Push, GCli.Serialize <PushData>(push), NetDeliveryMethod.UnreliableSequenced);
                }
            }

            /*if(firstFrame)
             * {
             *  firstFrame = false;
             *  InitData init = GetDummyInitData();
             *  GameObject.Find("Canvas").GetComponent<UIScript>().SetInitData(init.bmps);
             * }*/
        }
 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 PushData GetPushData()
        {
            PushData data = new PushData();

            data.xpos  = transform.position.x;
            data.ypos  = transform.position.y;
            data.zpos  = transform.position.z;
            data.yrot  = transform.localEulerAngles.y;
            data.anime = walk ? 1 : 0;

            return(data);
        }
Beispiel #4
0
        static public void PushHandler(NetConnection connection, object data)
        {
            PushData push = GSrv.Deserialize <PushData>((byte[])data);

            Players.Push(connection, push);
        }