Exemple #1
0
    /// <summary>
    /// /////////////////////
    /// </summary>
    /// <param name="fingerType"></param>
    public void OnTriggerEvent(ENFingerType fingerType, Vector3 curPos)
    {
        if (!mIsTrigger)
        {
            return;
        }
        //ENFingerType lastType = CurFingerType;
        CurFingerType = fingerType;
        if (fingerType == ENFingerType.enOnPressDownType || fingerType == ENFingerType.enOnTapType ||
            fingerType == ENFingerType.enOnDragMoveEndType)
        {
            if (mCursorEffect != null)
            {
                //GameObject.Destroy(mCursorEffect);
                PoolManager.Singleton.ReleaseObj(mCursorEffect);
                mCursorEffect = null;
            }
        }
        else if (fingerType == ENFingerType.enOnPressUpType)
        {
            if (mCursorEffect != null)
            {
                //GameObject.Destroy(mCursorEffect);
                PoolManager.Singleton.ReleaseObj(mCursorEffect);
                mCursorEffect = null;
            }
            if (mFlagMoveDirection != null)
            {
                //GameObject.Destroy(mFlagMoveDirection);
                PoolManager.Singleton.ReleaseObj(mFlagMoveDirection);
                mFlagMoveDirection = null;
            }
            if (null != mainPlayer.mActorBlendAnim)
            {
                mainPlayer.mActorBlendAnim.OnPressUp();
            }

            return;
        }
        else if (fingerType == ENFingerType.enOnDragMoveType)
        {
            if (CurCursorType != ENCursorType.enClickGround_E00)
            {
                if (mCursorEffect != null)
                {
                    //GameObject.Destroy(mCursorEffect);
                    PoolManager.Singleton.ReleaseObj(mCursorEffect);
                    mCursorEffect = null;
                }
            }
        }
        Ray ray = Camera.main.ScreenPointToRay(curPos);

        RaycastHit[] rayHitArray = Physics.RaycastAll(ray, 1500.0f);
        if (rayHitArray.Length == 0)
        {
            return;
        }
        int i = 0;

        for (; i < rayHitArray.Length; i++)
        {
            if (rayHitArray[i].collider.gameObject.name == "GlobalGround")
            {
                break;
            }
        }
        if (i >= rayHitArray.Length)
        {
            return;
        }
        RaycastHit hitInfo  = rayHitArray[i];
        Vector3    worldPos = new Vector3(hitInfo.point.x, 0.2f, hitInfo.point.z);

        MainGame.Singleton.mSelectBoxObj.transform.localPosition = worldPos;
        Collider collider = MainGame.Singleton.mSelectBoxObj.gameObject.GetComponent <Collider>();
        Actor    actor    = ActorManager.Singleton.ForEach_Bound(collider.bounds);

        if (null != actor && mainPlayer.IsCanSelectTarget(actor))
        {
            Actor lastActor = mainPlayer.TargetManager.CurrentTarget;
            if (actor != mainPlayer)
            {
                if (fingerType == ENFingerType.enOnPressDownType)
                {
                    SetChooseTargetEffect00(actor);
                }
                else if (fingerType == ENFingerType.enOnTapType ||
                         fingerType == ENFingerType.enOnDragMoveEndType)
                {
                    mainPlayer.TargetManager.ClearTarget();
                    mainPlayer.TargetManager.SetCurrentTarget(actor);
                    if (actor.Type == ActorType.enNPC || actor.Type == ActorType.enNPCTrap)
                    {
                        mainPlayer.NotifyChangedButton(actor);
                    }
                }
                else if (fingerType == ENFingerType.enOnDragMoveType)
                {
                    SetChooseTargetEffect00(actor);
                    MainPlayer.Cmd cmd = new MainPlayer.Cmd(hitInfo.point);
                    cmd.m_isMoveByNoAStar = true;
                    mainPlayer.CurrentCmd = cmd;
                }
            }
            else
            {
                if (fingerType == ENFingerType.enOnPressDownType)
                {
                    SetClickGroundEffect00(hitInfo.point);
                }
                else if (fingerType == ENFingerType.enOnDragMoveType)
                {
                    SetDragMoveEffect(hitInfo.point);
                }
            }
            if (fingerType == ENFingerType.enOnTapType)
            {
                if (lastActor != actor && actor != mainPlayer)
                {
                    AttackAction action = mainPlayer.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction;
                    if (action != null && action.IsNormalAttack())
                    {//普攻,移除AttackAction
                        mainPlayer.ActionControl.RemoveAction(ActorAction.ENType.enAttackAction);
                    }
                }
                if (actor.Type == ActorType.enNPC || actor.Type == ActorType.enNPCTrap)
                {
                    mainPlayer.FireNormalSkill();
                }
            }
            return;
        }
        if (fingerType == ENFingerType.enOnPressDownType)
        {
            SetClickGroundEffect00(hitInfo.point);
            if (null != mainPlayer.mActorBlendAnim)
            {
                mainPlayer.mActorBlendAnim.OnPressDown(hitInfo.point);
            }
        }
        else if (fingerType == ENFingerType.enOnTapType ||
                 fingerType == ENFingerType.enOnDragMoveEndType)
        {
            if (fingerType == ENFingerType.enOnTapType)
            {
                StartMove(hitInfo.point);
            }
            else
            {
                //mainPlayer.CurrentCmd = new MainPlayer.Cmd(hitInfo.point);
            }
            //
        }
        else if (fingerType == ENFingerType.enOnDragMoveType)
        {
            MainPlayer.Cmd cmd = new MainPlayer.Cmd(hitInfo.point);
            cmd.m_isMoveByNoAStar = true;
            mainPlayer.CurrentCmd = cmd;
            OnDragMoveEffectOp(curPos, hitInfo.point);
            if (null != mainPlayer.mActorBlendAnim)
            {
                mainPlayer.mActorBlendAnim.OnPressDown(hitInfo.point);
            }
        }
    }
Exemple #2
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;
            }
        }
    }