Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        base.Initialize();

        // Load Action Func으로 뺴세요
        if (MoveAction == null)
        {
            MoveAction = GetComponent <MoveAction>();
        }

        if (IdleAction == null)
        {
            IdleAction = GetComponent <IdleAction>();
        }

        if (RollAction == null)
        {
            RollAction = GetComponent <RollAction>();
        }

        if (AttackAction == null)
        {
            AttackAction = GetComponent <AttackAction>();
        }

        if (KnockBackAction == null)
        {
            KnockBackAction = GetComponent <KnockBackAction>();
        }

        if (BackStepAction == null)
        {
            BackStepAction = GetComponent <BackStepAction>();
        }

        if (BlockAction == null)
        {
            BlockAction = GetComponent <BlockAction>();
        }

        var mainCamera = Camera.main.GetComponent <TargetCamera>();

        MoveAction.OnMoveEndCallBack += mainCamera.OnUpdateCamera;
        RollAction.OnMoveEndCallBack += mainCamera.OnUpdateCamera;
        mainCamera.SetTarget(this);
    }
Esempio n. 2
0
        private Task OnRollAction(Guid gameId, RollAction action)
        {
            _gameConnector.DoAction(Context.ConnectionId, gameId, action);

            return(Task.CompletedTask);
        }
Esempio n. 3
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;
            }
        }
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
    public override void Update()
    {
        base.Update();
        if (Self.IsActorExit)
        {
            return;                  //当前角色离场
        }
        //TimeToRelive();
        ReliveUI();
        #region Unlock
        if (!Self.CurrentTargetIsDead)
        {//判断距离 清除目标
            float distance = ActorTargetManager.GetTargetDistance(Self.MainPos, Self.CurrentTarget.MainPos);
            if (distance > Self.CurrentTableInfo.UnlockRange)
            {
                Self.CurrentTarget = null;
                Self.DamageSource  = null;
            }
        }
        #endregion
        CheckAllSkill(); //检测可释放技能
        if (Self.CurrentCmd == null)
        {                //当前没有命令
            MoveAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
            if ((action == null || action.IsStopMove) &&
                !Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction) &&
                !Self.ActionControl.IsActionRunning(ActorAction.ENType.enRollAction))
            {     //不在移动、攻击、翻滚等位移动作中
                if (!Self.CurrentTargetIsDead)
                { //当前目标没死
                    float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos);
                    if (Self.CurrentTableInfo.AutoAttackRange > distance)
                    {//当前目标在自动攻击范围内
                        //Self.FireNormalSkill();
                        return;
                    }
                }
                else
                {
                    if (m_isAutoAttack)
                    {
                        m_autoAttackInterval -= Time.deltaTime;
                        if (m_autoAttackInterval < 0)
                        {
                            GetRangeTargetList(ENTargetType.enEnemy, Self.CurrentTableInfo.AutoAttackRange);
                            if (m_targetIDList.Count > 0)
                            {
                                Self.TargetManager.CurrentTarget = m_minActor;
                                Self.CurrentCmd           = new Player.Cmd(Player.ENCmdType.enLoopNormalAttack);
                                Self.CurrentCmd.m_skillID = Self.NormalSkillList[0];
                                return;
                            }
                        }
                    }
                }
                //自动反击
                if (m_lastActionTime == 0)
                {
                    m_lastActionTime = Time.time;
                }
                if (!m_isCounterattack && Time.time - m_lastActionTime > GameSettings.Singleton.m_autoCounterattack)
                {//距离最后一次位移动作 已超过3秒 可以反击
                    m_isCounterattack = false;
                }
            }
            if (m_isCounterattack)
            {//可以反击
                if (Self.DamageTime > m_lastActionTime + GameSettings.Singleton.m_autoCounterattack)
                {
                    if (Self.DamageSource != null && !Self.DamageSource.IsDead && ActorTargetManager.IsEnemy(Self, Self.DamageSource))
                    {
                        if (m_counterSkillRange == 0)
                        {
                            SkillInfo info = GameTable.SkillTableAsset.Lookup(Self.NormalSkillList[0]);
                            m_counterSkillRange = info.AttackDistance;
                        }
                        Vector3 distance = Owner.RealPos - Self.DamageSource.RealPos;
                        distance.y = 0;
                        if (distance.magnitude > m_counterSkillRange)
                        {//不在攻击范围内
                            //向技能目标移动
                            ActionMoveTo(Self.DamageSource.RealPos);
                        }
                        else
                        {//在攻击范围内
                            //释放技能
                            if (ActionTryAttack(Self.NormalSkillList[0], Self.DamageSource))
                            {
                                m_curTargetID      = Self.DamageSource.ID;
                                Self.CurrentTarget = ActorManager.Singleton.Lookup(m_curTargetID);
                                m_lastActionTime   = 0;
                                m_isCounterattack  = false;
                                return;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            MainPlayer.Cmd cmd = Self.CurrentCmd;
            if (cmd.m_type != Player.ENCmdType.enSkill && cmd.m_type != Player.ENCmdType.enLoopNormalAttack)
            {//取消自动攻击
                m_isAutoAttack = false;
            }
            //最后一次动作的时间
            m_lastActionTime = 0;
            //清除自动反击
            m_isCounterattack = false;
            if (cmd.m_type != Player.ENCmdType.enSkill)
            {//取消技能高亮
                DelSkillHighlight();
            }

            m_autoAttackInterval = GameSettings.Singleton.m_autoAttackInterval;
            if (!IsCmdExecute())
            {//命令不允许执行
                Self.CurrentCmd = null;
                return;
            }

            m_curTargetID = 0;
            if (!Self.CurrentTargetIsDead)
            {
                m_curTargetID = Self.CurrentTarget.ID;
            }
            switch (cmd.m_type)
            {
            case Player.ENCmdType.enMove:
            {
                //  [8/3/2015 tgame]
                if (cmd.m_isMoveByNoAStar)
                {
                    if (ActionMoveToNotAStar(cmd.m_moveTargetPos))
                    {
                        //点击地面特效
                        Self.IsMoveAfterSwitch = false;
                        Self.CurrentCmd        = null;
                    }
                }
                else
                {
                    if (ActionMoveTo(cmd.m_moveTargetPos))
                    {
                        //点击地面特效
                        Self.IsMoveAfterSwitch = false;
                        Self.CurrentCmd        = null;
                    }
                }
            }
            break;

            case Player.ENCmdType.enStopMove:
            {
                MoveAction ac = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
                if (ac != null)
                {
                    Self.ActionControl.RemoveAction(ActorAction.ENType.enMoveAction);
                }
            }
            break;

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

            case Player.ENCmdType.enSwitchActor:
            {
                if (!m_isAttacking)
                {
                    if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction))
                    {
                        if (ActorManager.Singleton.m_switchCDTotal > 0)
                        {        //cd中,继续攻击
                            Self.FireNormalSkill();
                            return;
                        }
                        m_isAttacking = true;
                    }
                }
                if (ActorManager.Singleton.SwitchMainActor(false, m_isAttacking))
                {
                    Self.CurrentCmd = null;
                    m_isAttacking   = false;
                }
            }
            break;

            case Player.ENCmdType.enSkill:
            {
                int skillID = cmd.m_skillID;
                Actor.ActorSkillInfo info = Self.SkillBag.Find(item => item.SkillTableInfo.ID == skillID);
                if (IsFireSkill(skillID))
                {
                    GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange, Self.m_firstTargetType);
                    if (ActionTryFireSkill(skillID))
                    {
                        m_isAutoAttack = false;
                        m_lastSkillID  = skillID;
                        DelSkillHighlight();

                        Actor target = ActorManager.Singleton.Lookup(m_curTargetID);
                        if (target != null && ActorTargetManager.IsEnemy(Self, target))
                        {        //只对仇人进行循环普攻
                            Self.CurrentTarget        = target;
                            Self.CurrentCmd.m_skillID = Self.NormalSkillList[0];
                            Self.CurrentCmd.m_type    = Player.ENCmdType.enStop;     //enLoopNormalAttack;
                        }
                        else
                        {
                            Self.CurrentCmd = null;
                        }
                    }
                    else
                    {
                        if (m_targetIDList.Count == 0)
                        {
                            DelSkillHighlight();
                            Self.CurrentCmd = null;
                        }
                    }
                }
                else
                {
                    GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange);
                    if (m_targetIDList.Count != 0 && skillID != m_highlightSkillID)
                    {        //技能高亮的通知
                        AddSkillHighlight();
                        m_highlightSkillID = skillID;
                    }
                }
            }
            break;

            case Player.ENCmdType.enLoopNormalAttack:
            {
                int skillID = Self.CurrentCmd.m_skillID;
                if (Self.CurrentTargetIsDead)
                {        //循环攻击时 必须要有目标 目标不能死亡
                    Self.CurrentCmd = null;
                    return;
                }
                if (IsFireSkill(skillID))
                {
                    if (ActionTryFireSkill(skillID))
                    {
                        m_lastSkillID = skillID;
                    }
                }
            }
            break;

            default:
                break;
            }
        }
    }