Esempio n. 1
0
        public virtual void SetServerPosition(Vector2 position)
        {
            Vector3 clientPosition = ServerPositionConverter.ConvertToClientPosition(position);

            clientPosition.y = pathFinder.GetTerrainHeight(clientPosition.x, clientPosition.z);
            // transform.position = clientPosition;

            BaseTool.SetPosition(transform, clientPosition);

            status = MoveStatus.Stopped;

            //Debug.LogWarning(string.Format("name : {0} ,pos({1} ,{2})", gameObject.name, clientPosition.x, clientPosition.z));
        }
Esempio n. 2
0
        private void SendMoveTo(Vector3 srcPos, Vector3 destPos)
        {
            //if (Time.time - lastSendMoveTime >= SyncPeriod)
            {
                Vector3 srcServerPos  = ServerPositionConverter.ConvertToServerPosition(srcPos);
                Vector3 destServerPos = ServerPositionConverter.ConvertToServerPosition(destPos);

                NetLogicGame.Instance.SendReqMoveTo((int)srcServerPos.x, (int)srcServerPos.y, (int)destServerPos.x, (int)destServerPos.y);

                //SyncCount++;
                lastSendMoveTime = Time.time;
            }
        }
Esempio n. 3
0
        public override void Stop()
        {
            base.Stop();

            pointList.Clear();

            Vector2 serverPos = ServerPositionConverter.ConvertToServerPosition(transform.position);

            //NetLogicGame.Instance.SendReqMoveStop((int)serverPos.x, (int)serverPos.y, (int)(transform.eulerAngles.y * ServerPositionConverter.ServerScale));
            //float rad = (float)(transform.eulerAngles.y * Math.PI / 180.0f);
            //rad -= (float)Math.PI * 0.5f;
            //Vector3 dir = new Vector3((float)Math.Sin(rad), 0, (float)Math.Cos(rad));
            //Debug.Log(string.Format("stop direction ({0} ,{1} ,{2})",dir.x ,dir.y ,dir.z));
            NetLogicGame.Instance.SendReqMoveStop((int)serverPos.x, (int)serverPos.y, (int)(ServerPositionConverter.ConvertToServerRotation(transform.rotation)));
        }
Esempio n. 4
0
        private void OnDispatchMonsterMoveTo(GameEvent ge, EventParameter parameter)
        {
            MsgData_sMonsterMoveTo msg = parameter.msgParameter as MsgData_sMonsterMoveTo;

            if (null == msg)
            {
                return;
            }

            IMoveHandler handler;

            if (mMoveHandlerDict.TryGetValue(msg.RoleID, out handler))
            {
                Vector2 to = ServerPositionConverter.ConvertToClientPositionVector2(new Vector2(msg.DestX, msg.DestY));
                handler.OnMonsterMoveTo(to);
            }
        }
Esempio n. 5
0
        private void OnDispatchMoveStop(GameEvent ge, EventParameter parameter)
        {
            MsgData_sOtherMoveStop msg = parameter.msgParameter as MsgData_sOtherMoveStop;

            if (null == msg)
            {
                return;
            }

            IMoveHandler handler;

            if (mMoveHandlerDict.TryGetValue(msg.RoleID, out handler))
            {
                Vector2 pos = ServerPositionConverter.ConvertToClientPositionVector2(new Vector2(msg.StopX, msg.StopY));

                handler.OnMoveStop(pos, msg.Dir * 0.001f);
            }

            CoreEntry.gSceneObjMgr.UpdateObjMove(msg.RoleID, msg.StopX, msg.StopY, msg.Dir);
        }
Esempio n. 6
0
 public void GetServerPositionAndRotation(ref Vector2 position, ref float rotation)
 {
     position = ServerPositionConverter.ConvertToServerPosition(transform.position);
     rotation = ServerPositionConverter.ConvertToServerRotation(transform.rotation);
 }
Esempio n. 7
0
 public float GetServerRotation()
 {
     return(ServerPositionConverter.ConvertToServerRotation(transform.rotation));
 }
Esempio n. 8
0
 public Vector2 GetServerPosition()
 {
     return(ServerPositionConverter.ConvertToServerPosition(transform.position));
 }
Esempio n. 9
0
 public void SetServerRotation(float rotation)
 {
     transform.rotation = ServerPositionConverter.ConvertToClientRotation(rotation, transform.rotation);
 }