Exemple #1
0
    public override void Update()
    {
        Actor.Cmd cmd = Owner.CurrentCmd;
        if (cmd != null)
        {
            switch (cmd.m_type)
            {
            case Actor.ENCmdType.enMove:
            {
                if (ActionMoveTo(cmd.m_moveTargetPos, true, false, cmd.IsSyncPosValidate, cmd.m_syncPos))
                {
                    Owner.CurrentCmd = null;
                }
            }
            break;

            case Actor.ENCmdType.enSkill:
            {
                Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID);
                //ActionForwardTo(cmd.m_targetID);
                if (ActionTryAttack(cmd.m_skillID, Owner.CurrentTarget, cmd.IsSyncPosValidate, cmd.m_syncPos))
                {
                    Owner.CurrentCmd = null;
                }
                else
                {
                    ActionForwardTo(cmd.m_targetID);
                }
            }
            break;

            case Actor.ENCmdType.enRoll:
            {
                RollAction rollAction = Owner.ActionControl.AddAction(ActorAction.ENType.enRollAction) as RollAction;
                if (rollAction != null)
                {
                    rollAction.Init(Owner.CurrentCmd.m_syncPos, cmd.m_moveTargetPos);
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enActorEnter:
            {
                Player player = Owner as Player;
                if (player != null)
                {
                    if (player.SwitchActorEnter(cmd.m_syncPos, cmd.m_forward))
                    {
                        Owner.CurrentCmd = null;
                    }
                }
                else
                {
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enActorExit:
            {
                Owner.IsActorExit = true;
                ActorExitAction actorExitAction = Owner.ActionControl.AddAction(ActorAction.ENType.enActorExitAction) as ActorExitAction;
                if (actorExitAction != null)
                {
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enInteruptAction:
            {
                Owner.ActionControl.InterruptAction((ActorAction.ENType)cmd.m_interruptedActionType);
                Owner.CurrentCmd = null;
                break;
            }

            case Actor.ENCmdType.enBeHitAction:
            {
                BeAttackAction beAttackAction = Owner.ActionControl.AddAction(ActorAction.ENType.enBeAttackAction) as BeAttackAction;
                if (beAttackAction != null)
                {
                    Actor srcActor = ActorManager.Singleton.Lookup(cmd.m_srcActorID);
                    beAttackAction.Init(srcActor, cmd.m_isBack, cmd.m_isFly);
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enJumpInAction:
            {
                Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID);
                JumpinAction jumpInAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpinAction) as JumpinAction;
                if (jumpInAction != null)
                {
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enJumpOutAction:
            {
                JumpoutAction jumpOutAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpoutAction) as JumpoutAction;
                if (jumpOutAction != null)
                {
                    Owner.CurrentCmd = null;
                }
                break;
            }

            case Actor.ENCmdType.enAttackingMoveAction:
            {
                AttackingMoveAction action = Owner.ActionControl.AddAction(ActorAction.ENType.enAttackingMoveAction) as AttackingMoveAction;
                if (action != null)
                {
                    action.InitImpl(Owner.CurrentCmd.m_skillID, Owner.CurrentCmd.m_targetID, cmd.IsSyncPosValidate, cmd.m_syncPos);
                    Owner.CurrentCmd = null;
                }
            }
            break;
            }
        }
    }
Exemple #2
0
    public bool m_isSwitchForDead = false;//死亡后切换
    //private int m_switchBuffID = 0;
    //切换主控角色
    public bool SwitchMainActor(bool isSwitchForDead, bool isAttacking = false)
    {
        if (m_switchCDTotal > 0 && !MainActor.IsDead)
        {//cd中,并且当前角色未死
            //msg("XXX尚未休整完毕,请稍后再试!");
            return(false);
        }
        if (Deputy == null)
        {//没有可切换的角色
            return(false);
        }
        int curID, lastID;

        if (MainActor == Chief)
        {
            curID  = Deputy.ID;
            lastID = Chief.ID;
        }
        else
        {
            curID  = Chief.ID;
            lastID = Deputy.ID;
        }
        MainPlayer curActor = Lookup(curID) as MainPlayer;

        if (curActor.IsDead)
        {//要切换的角色已经死亡
            return(false);
        }
        MainPlayer lastActor = Lookup(lastID) as MainPlayer;

        // 小地图的点管理 把原来的角色移除
        Map.Singleton.RomvePoint(lastActor);


        //退场角色的信息 begin
        Vector3 lastPos     = lastActor.MainPos;
        Vector3 lastForward = lastActor.MainObj.transform.forward;
        Vector3 targetPos   = Vector3.zero;

        if (!isAttacking)
        {
            if (lastActor.ActionControl.IsActionRunning(ActorAction.ENType.enMoveAction))
            {//move action
                MoveAction action = lastActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
                if (action.mRealSpeed / action.m_currentSpeed <= 0.1f)
                {
                }
                else
                {
                    targetPos = action.m_realTargetPos;
                }
            }
        }
        int targetID = 0;

        if (lastActor.TargetManager.CurrentTarget != null)
        {
            targetID = lastActor.TargetManager.CurrentTarget.ID;
        }
        //退场角色的信息 end
        ActorExitAction exitAction = lastActor.ActionControl.AddAction(ActorAction.ENType.enActorExitAction) as ActorExitAction;

        if (exitAction == null)
        {//退场失败,不能切换
            return(false);
        }
        lastActor.ActorExit();

        //开始CD
        m_switchCDTimer   = Time.time;
        m_switchCDTotal   = (curActor.CurrentTableInfo.SwitchCD + lastActor.CurrentTableInfo.SwitchCD) / 2;
        m_isSwitchForDead = isSwitchForDead;

        //当前角色上场
        if (lastActor.IsDead)
        {
            float percent = (float)m_switchCDTotal / ((curActor.CurrentTableInfo.SwitchCD + lastActor.CurrentTableInfo.SwitchCD) / 2);
            float hp      = (float)curActor.HP;
            if (percent != 0)
            {
                hp *= percent;
                curActor.SetCurHP((int)hp);
            }
        }
        curActor.ActorEnter(lastPos, lastForward, targetID, targetPos, isAttacking);

        // 小地图新进入的角色 加入
        Map.Singleton.AddPoint(curActor);
        return(true);
    }
    private ActorAction CreateObj(ActorAction.ENType newType)
    {
        ActorAction action = m_pool.GetObjectFromPool(newType) as ActorAction;

        if (action != null)
        {
            return(action);
        }
        switch (newType)
        {
        case ActorAction.ENType.enStandAction:
            action = new StandAction();
            break;      //站立

        case ActorAction.ENType.enMoveAction:
            action = new MoveAction();
            break;              //移动

        case ActorAction.ENType.enAttackAction:
            action = new AttackAction();
            break;              //攻击

        case ActorAction.ENType.enSpasticityAction:
            action = new SpasticityAction();
            break;              //被动僵直

        case ActorAction.ENType.enBeAttackAction:
            action = new BeAttackAction();
            break;              //受击

        case ActorAction.ENType.enUndownAction:
            action = new UndownAction();
            break;              //霸体

        case ActorAction.ENType.enDeadAction:
            action = new DeadAction();
            break;              //死亡

        case ActorAction.ENType.enReliveAction:
            action = new ReliveAction();
            break;              //复活

        case ActorAction.ENType.enPlayEffectAction:
            action = new PlayEffectAction();
            break;              //播放特效

        case ActorAction.ENType.enSearchEnemyAction:
            //action = new SearchEnemyAction();
            break;              //搜索敌人

        case ActorAction.ENType.enTeleportAction:
            action = new TeleportAction();
            break;              //瞬移

        case ActorAction.ENType.enControlMoveAction:
            action = new ControlMoveAction();
            break;    //控制技能定身

        case ActorAction.ENType.enHoldDownAction:
            action = new HoldDownAction();
            break;            //按下状态

        case ActorAction.ENType.enSelfSpasticityAction:
            action = new SelfSpasticityAction();
            break;      //主动僵直

        case ActorAction.ENType.enAlertAction:
            action = new AlertAction();
            break;          //警戒

        case ActorAction.ENType.enJumpinAction:
            action = new JumpinAction();
            break;      //入场

        case ActorAction.ENType.enJumpoutAction:
            action = new JumpoutAction();
            break;       //退场

        case ActorAction.ENType.enRollAction:
            action = new RollAction();
            break;     //翻滚

        case ActorAction.ENType.enFakeBeAttackAction:
            action = new FakeBeAttackAction();
            break;     //假受击

        case ActorAction.ENType.enActorExitAction:
            action = new ActorExitAction();
            break; //主控角色退场

        case ActorAction.ENType.enActorEnterAction:
            action = new ActorEnterAction();
            break; //主控角色入场

        case ActorAction.ENType.enControlAttackAction:
            action = new ControlAttackAction();
            break; //不能攻击

        case ActorAction.ENType.enControlBeAttackAction:
            action = new ControlBeAttackAction();
            break; //不能受击

        case  ActorAction.ENType.enAttackingMoveAction:
            action = new AttackingMoveAction();
            break;//攻击时移动

        case  ActorAction.ENType.enDragMoveAction:
            action = new DragMoveAction();
            break;//拖拽

        default:
            throw new Exception("Miss Action Create for" + newType.ToString());
        }
        return(action);
    }