Ejemplo n.º 1
0
        /// <summary>
        /// 每1/45秒向服务器发送己方小兵位置
        /// </summary>
        private void SendSoldierPosition()
        {
            var handle = new mmopb.sendSoldierPos_req();
            var dic    = new Dictionary <int, mmopb.p_SoldierPosInfo>();

            foreach (var pair in DataMgr.Instance.SoldierDic)
            {
                if (pair.Value.playerId == LocalUser.Instance.PlayerId)
                {
                    SoldierCtrl soldier = pair.Value;
                    var         info    = new mmopb.p_SoldierPosInfo();
                    info.x          = soldier.transform.position.x;
                    info.y          = soldier.transform.position.y;
                    info.z          = soldier.transform.position.z;
                    info.xQuternion = soldier.transform.rotation.x;
                    info.yQuternion = soldier.transform.rotation.y;
                    info.zQuternion = soldier.transform.rotation.z;
                    info.wQuternion = soldier.transform.rotation.w;
                    dic.Add(soldier.id, info);
                }
            }
            handle.soldierPosInfoList = dic;
            ClientNet.Instance.Send(ProtoBuf.ProtoHelper.EncodeWithName(handle));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 服务器同步小兵位置
 /// </summary>
 /// <param name="Info"></param>
 public void UpdatePos(mmopb.p_SoldierPosInfo Info)
 {
     transform.position = new Vector3(Info.x, Info.y, Info.z);
     transform.rotation = new Quaternion(Info.xQuternion, Info.yQuternion, Info.zQuternion, Info.wQuternion);
 }