Esempio n. 1
0
        /// <summary>
        /// 移动到世界的某地图的某个点
        /// </summary>
        /// <param name="newLocation"></param>
        /// <param name="map"></param>
        public bool MoveToWorld(Point3D newLocation, BaseMap newMap)
        {
            BaseMap tempMap = m_Map; // 副本防止多线程置空

            if (m_Deleted == true || tempMap == null || newMap == null)
            {
                return(false);
            }

            MoveToWorldEventArgs eventArgs = GlobalEvent.BaseCharacter.InvokeMoveToWorld(newLocation, newMap, this);

            if (eventArgs != null)
            {
                if (eventArgs.Blocked == true)
                {
                    return(false);
                }
            }

            if (tempMap == newMap)
            {
                return(MoveTo(newLocation));
            }
            else
            {
                BaseMap oldMap      = tempMap;
                Point3D oldLocation = (Point3D)m_Location;

                if (m_GameEntityState != null)
                {
                    if (m_GameEntityState.OnMovingToWorld(newLocation, newMap, this) == true)
                    {
                        return(false);
                    }
                }

                this.Map      = newMap;      // 间接设置
                this.Location = newLocation; // 间接设置

                oldMap.OnLeave(this);
                tempMap.OnEnter(this);
                m_GameEntityState.IsMoveToWorldCall = true;

                if (m_GameEntityState != null)
                {
                    m_GameEntityState.OnMovedToWorld(oldLocation, oldMap, this);
                }

                return(true);
            }
        }