Exemplo n.º 1
0
        public static ScriptRuntime.Vector3 GetCenter(ScriptRuntime.Vector3 fvPos1, ScriptRuntime.Vector3 fvPos2)
        {
            ScriptRuntime.Vector3 fvRet = new ScriptRuntime.Vector3();

              fvRet.X = (fvPos1.X + fvPos2.X) / 2.0f;
              fvRet.Y = (fvPos1.Y + fvPos2.Y) / 2.0f;
              fvRet.Z = (fvPos1.Z + fvPos2.Z) / 2.0f;

              return fvRet;
        }
Exemplo n.º 2
0
        public void Reset()
        {
            m_StateStack.Clear();
            m_AiDatas.Clear();
            if (null != m_AiStoryInstanceInfo) {
                m_AiStoryInstanceInfo.Recycle();
                m_AiStoryInstanceInfo = null;
            }
            m_IsInited = false;

            m_AiLogic = 0;
            m_AiParam = new string[c_MaxAiParamNum];
            m_AiStoryInstanceInfo = null;
            m_Time = 0;
            m_IsInited = false;
            m_leaderID = 0;
            m_HomePos = Vector3.Zero;
            m_Target = 0;
            m_HateTarget = 0;
            m_IsExternalTarget = false;
            m_LastChangeTargetTime = 0;
        }
        internal static void Execute(object msg, User user)
        {
            Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos;
            if (move_msg == null)
                return;
            EntityInfo charactor = user.Info;
            if (charactor == null) {
                LogSys.Log(LOG_TYPE.DEBUG, "charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name);
                return;
            }
            ///
            if (charactor.GetAIEnable()) {
                float tx, tz;
                ProtoHelper.DecodePosition2D(move_msg.target_pos, out tx, out tz);
                ScriptRuntime.Vector3 pos = new ScriptRuntime.Vector3(tx, 0, tz);

                MovementStateInfo msi = charactor.GetMovementStateInfo();
                msi.IsMoving = true;
                msi.TargetPosition = pos;
                float dir = Geometry.GetYRadian(msi.GetPosition3D(), pos);
                msi.SetFaceDir(dir);
                msi.SetMoveDir(dir);

                Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(charactor);
                if (null != npcMoveBuilder) {
                    Scene scene = user.OwnRoom.ActiveScene;
                    if (null != scene) {
                        scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcMove, npcMoveBuilder);
                    }
                }
            }
        }