Ejemplo n.º 1
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos;

            if (move_msg == null)
            {
                return;
            }
            UserInfo charactor = user.Info;

            if (charactor == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "charactor {0} not exist", user.RoleId);
                return;
            }
            ///
            if (charactor.GetAIEnable())
            {
                MovementStateInfo msi = charactor.GetMovementStateInfo();
                msi.PositionX = move_msg.cur_pos_x;
                msi.PositionZ = move_msg.cur_pos_z;

                UserAiStateInfo asi = charactor.GetAiStateInfo();
                Vector3         pos = new Vector3(move_msg.target_pos_x, 0, move_msg.target_pos_z);
                asi.TargetPos          = pos;
                asi.IsTargetPosChanged = true;
                asi.ChangeToState((int)(AiStateId.Move));
            }
        }
Ejemplo n.º 2
0
 private void PushSkill(UserInfo playerself, Vector3 targetpos, float attackrange)
 {
     if (null != playerself && Vector3.Zero != targetpos)
     {
         UserAiStateInfo info = playerself.GetAiStateInfo();
         RevokeSkill(playerself, info);
         info.Time        = 0;
         info.TargetPos   = targetpos;
         info.AttackRange = attackrange;
         info.IsAttacked  = false;
         info.ChangeToState((int)AiStateId.Combat);
     }
 }
Ejemplo n.º 3
0
 private void RevokeSkill(UserInfo playerself, UserAiStateInfo aiInfo)
 {
     if (null == playerself || null == aiInfo)
     {
         return;
     }
     StopFindPath(playerself, aiInfo);
     aiInfo.Target      = 0;
     aiInfo.IsAttacked  = false;
     aiInfo.Time        = 0;
     aiInfo.TargetPos   = Vector3.Zero;
     aiInfo.AttackRange = 0;
     aiInfo.ChangeToState((int)AiStateId.Idle);
 }
Ejemplo n.º 4
0
        private void Combat(UserInfo playerself, int targetId, float attackrange)
        {
            if (null != playerself && m_lastSelectObjId != targetId)
            {
                UserAiStateInfo info = playerself.GetAiStateInfo();
                if ((int)AiStateId.Move == info.CurState)
                {
                    StopFindPath(playerself, info);
                }
                info.Time        = 0;
                info.Target      = targetId;
                info.IsAttacked  = false;
                info.AttackRange = attackrange;

                info.ChangeToState((int)AiStateId.Combat);
            }
        }
Ejemplo n.º 5
0
        private void StopFindPath(UserInfo playerself, UserAiStateInfo aiInfo)
        {
            if (null == playerself || null == aiInfo)
            {
                return;
            }
            AiData_UserSelf_General data = playerself.GetAiStateInfo().AiDatas.GetData <AiData_UserSelf_General>();

            if (null == data)
            {
                data = new AiData_UserSelf_General();
                playerself.GetAiStateInfo().AiDatas.AddData(data);
            }
            playerself.GetMovementStateInfo().IsMoving = false;
            aiInfo.Time = 0;
            data.Time   = 0;
            data.FoundPath.Clear();
            aiInfo.ChangeToState((int)AiStateId.Idle);
        }
Ejemplo n.º 6
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_UserMoveToAttack attack_msg = msg as Msg_CR_UserMoveToAttack;

            if (attack_msg == null)
            {
                return;
            }
            UserInfo charactor = user.Info;

            if (charactor == null)
            {
                LogSys.Log(LOG_TYPE.ERROR, "charactor {0} not exist", user.RoleId);
                return;
            }
            ///
            if (charactor.GetAIEnable())
            {
                MovementStateInfo msi = charactor.GetMovementStateInfo();
                msi.PositionX = attack_msg.cur_pos_x;
                msi.PositionZ = attack_msg.cur_pos_z;

                UserAiStateInfo aiInfo = charactor.GetAiStateInfo();

                AiData_UserSelf_General data = charactor.GetAiStateInfo().AiDatas.GetData <AiData_UserSelf_General>();
                if (null == data)
                {
                    data = new AiData_UserSelf_General();
                    charactor.GetAiStateInfo().AiDatas.AddData(data);
                }
                charactor.GetMovementStateInfo().IsMoving = false;
                data.FoundPath.Clear();
                aiInfo.Time        = 0;
                aiInfo.Target      = attack_msg.target_id;
                aiInfo.IsAttacked  = false;
                aiInfo.AttackRange = attack_msg.attack_range;

                aiInfo.ChangeToState((int)AiStateId.Combat);
            }
        }