示例#1
0
        public override void EnterState()
        {
            base.EnterState();
            cmd = aiCharacter.lastCmd;
            aiCharacter.blackboard[AIParam.SkillCmd] = new AIEvent()
            {
                cmd = cmd.proto
            };

            var target       = cmd.skillAction.Target;
            var targetPlayer = ObjectManager.objectManager.GetPlayer(target);

            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();

            skillStateMachine     = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, targetPlayer);
            skillStateMachine.cmd = cmd.proto;

            var time    = Util.FrameToFloat(aiCharacter.lastCmd.skillAction.RunFrame);
            var dir     = cmd.skillAction.Dir;
            var physics = aiCharacter.GetAttr().GetComponent <IPhysicCom>();

            physics.TurnToDir(dir);
            holdTime = time;

            var npcConfig = aiCharacter.attribute.npcConfig;
            var actConfig = npcConfig.GetActionBySkillId(cmd.proto.SkillAction.SkillId);

            if (actConfig == null)
            {
                Debug.LogError("NpcSkill:" + MobaUtil.PrintObj(npcConfig) + ":" + cmd.proto);
            }
            var aniName = actConfig.aniName;

            aiCharacter.PlayAniInTime(aniName, time);
        }
示例#2
0
        public override void EnterState()
        {
            base.EnterState();
            cmd         = aiCharacter.lastCmd;
            activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill();
            var target       = cmd.skillAction.Target;
            var targetPlayer = ObjectManager.objectManager.GetPlayer(target);

            skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position, targetPlayer);
            var time = Util.FrameToFloat(aiCharacter.lastCmd.skillAction.RunFrame);
            var dir  = cmd.skillAction.Dir;

            holdTime = time;
        }
示例#3
0
        /// <summary>
        /// 直线移动到目标位置
        /// </summary>
        /// <param name="pos"></param>
        /// <param name=""></param>
        public void MoveTo(ObjectCommand cmd)
        {
            logicFrameId++;
            runTime   = Util.FrameToFloat(cmd.runFrame);
            passTime  = 0.0f;
            curPos    = transform.position;
            targetPos = cmd.targetPos;
            var deltaPos = targetPos - curPos;

            deltaPos.y = 0;
            var dx      = deltaPos.x;
            var dz      = deltaPos.z;
            var moveDir = new Vector2(dx, dz);

            moveDir.Normalize();
            directionTo = new Vector3(moveDir.x, 0, moveDir.y);
            var hval = Vector2.Dot(moveDir, cr);
            var vval = Vector2.Dot(moveDir, cf);

            vcontroller.inputVector.x = hval;
            vcontroller.inputVector.y = vval;
            state = State.InMove;
        }
示例#4
0
        /// <summary>
        /// 只确保在某一帧执行某个命令
        /// 不保证命令状态本身的完整性
        /// linear 插值
        /// step
        /// pulse
        /// </summary>
        /// <param name="cmd"></param>
        void DoLogicCommand(ObjectCommand cmd)
        {
            Log.AI("DoLogicCommad " + cmd.commandID);
            state      = State.InCommand;
            currentCmd = cmd;
            switch (cmd.commandID)
            {
            case ObjectCommand.ENUM_OBJECT_COMMAND.OC_MOVE:
                //简单直线移动
                RunMoveCmd(cmd as MoveCMD);
                break;

            case ObjectCommand.ENUM_OBJECT_COMMAND.OC_USE_SKILL:
                EnterUseSkill(cmd as SkillCMD);
                break;

            default:
                state = State.Idle;
                Debug.LogError("LogicCommand:: UnImplement Command " + cmd.commandID.ToString());
                break;
            }
            //waitTime = currentCmd.runFrame * 1.0f / Util.FramePerSecond;
            waitTime = Util.FrameToFloat(currentCmd.runFrame);
        }