Пример #1
0
    void AnalyseTouchPos_Click(Vector3 posPressed, Touch touch)
    {
        if ((m_SceneTouchFingerID == -1) ||
            (m_SceneTouchFingerID != -1 && touch.fingerId == m_SceneTouchFingerID))
        {
            if (!UIManager.IsSubUIShow())
            {
                Ray        ray = Camera.main.ScreenPointToRay(posPressed);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    if (touch.phase != TouchPhase.Ended)
                    {
                        //if (null != PlayerFrameLogic.Instance() && !PlayerFrameLogic.Instance().Fold)
                        //{
                        //PlayerFrameLogic.Instance().m_PlayerHeadButton.gameObject.GetComponent<UIPlayTween>().Play(false);
                        //PlayerFrameLogic.Instance().PlayerFrameHeadOnClick();
                        //}

                        // 客户单物品 点击拾取
                        if (hit.collider.gameObject.CompareTag("CollectItem"))
                        {
                            Singleton <CollectItem> .GetInstance().RemoveItem(hit.collider.gameObject);

                            GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT);
                            Singleton <EventSystem> .GetInstance().PushEvent(gameEvent);

                            return;
                        }

                        Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

                        if (null == _mainPlayer)
                        {
                            return;
                        }

                        //Obj点击操作,单击点选目标,双击移动过去
                        Obj_Character npcScript = hit.collider.gameObject.GetComponent <Obj_Character>();
                        if (npcScript)
                        {
                            if (m_bIsMouseDBClick || Reputation.IsEnemy(npcScript))
                            {
                                //npcScript.FaceTo(Singleton<ObjManager>.GetInstance().MainPlayer.transform.position);
                                if (_mainPlayer.IsCanOperate_Move())
                                {
                                    _mainPlayer.BreakAutoCombatState();
                                    _mainPlayer.LeaveTeamFollow();
                                    _mainPlayer.MoveTo(hit.collider.gameObject.transform.position, hit.collider.gameObject, 1.0f);
                                    _mainPlayer.FaceTo(hit.collider.transform.position);
                                    _mainPlayer.OnSelectTarget(hit.collider.gameObject);
                                    _mainPlayer.HasSendpos = false;
                                }
                                else
                                {
                                    if (!_mainPlayer.HasSendpos)
                                    {
                                        _mainPlayer.HasSendpos = true;
                                        _mainPlayer.SynCleanCacheSkillToServer();
                                        _mainPlayer.LastForceSynPosTime = Time.time;
                                    }
                                }
                            }
                            else
                            {
                                //选择目标
                                _mainPlayer.OnSelectTarget(hit.collider.gameObject);
                            }

                            GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT);
                            Singleton <EventSystem> .GetInstance().PushEvent(gameEvent);
                        }
                    }
                }
            }
        }
        return;
    }
Пример #2
0
        public override void UpdateAI()
        {
            base.UpdateAI();
            if (m_player == null || m_player.Controller == null)
            {
                return;
            }
            if (m_player.IsDie())
            {
                return;
            }
            if (m_player.Controller.CombatFlag == false)
            {
                return;
            }
            if (m_player.AutoComabat == false)
            {
                return;
            }
            //轻功状态下 不挂机
            if (m_player.QingGongState)
            {
                return;
            }
            if (m_player.AcceleratedMotion != null && m_player.AcceleratedMotion.Going == true)
            {
                return;
            }
            //剧情播放中不挂机
            if (m_player.IsInModelStory)
            {
                return;
            }
            // 跟随不挂机
            if (false == m_player.IsTeamLeader() && m_player.IsInTeamFollow)
            {
                return;
            }
            if (Cutscene.CutsceneManager.Instance.IsPlayingMovieStory)
            {
                return;
            }
            //阻塞状态不挂机
            if (Cutscene.CutsceneManager.Instance.BlockAutoBattle)
            {
                return;
            }
            //自动交接任务的寻路过程中不挂机
            if (null != GameManager.gameManager.AutoSearch &&
                true == GameManager.gameManager.AutoSearch.IsAutoSearching)
            {
                return;
            }
            //modify 普通攻击:可以连续按。在技能结束前可以再次释放不能直接return。
            if (m_player.SkillCore.IsUsingSkill)
            {
                bool shouldReturn = true;
                if ((Time.time * 1000 - CurUseSkillStartTime) >= m_nNormalSkillInterval)
                {
                    if (IsNormalSkill(CurUseSkillId))
                    {
                        shouldReturn = false;
                    }
                }
                if (shouldReturn)
                {
                    return;
                }
            }

            #region UnUsed

            /* if (m_player.SkillCore.IsUsingSkill)
             * {
             *
             *   return;
             *   if (m_player.SkillCore.UsingSkillBaseInfo != null && m_player.SkillCore.UsingSkillExInfo !=null)
             *   {
             *       //正在使用祝融掌 则检测下当前目标是否还存在 不存在则重新选取目标
             *       //if (m_player.SkillCore.UsingSkillBaseInfo.Id ==(int)SKILLBASEID.ZLZ)
             *       //{
             *       //    if (m_player.SelectTarget ==null || m_player.SelectTarget.IsDie())
             *       //    {
             *       //        Obj_Character _NewAttackCharacter = SeleCanAttackTar(m_player.SkillCore.UsingSkillExInfo.Radius);
             *       //        if (_NewAttackCharacter != null)
             *       //        {
             *       //            //设置新的选中目标
             *       //            m_player.OnSelectTarget(_NewAttackCharacter.gameObject,false);
             *       //            m_player.MoveTo(_NewAttackCharacter.transform.position, _NewAttackCharacter.gameObject,1.0f);
             *       //        }
             *       //    }
             *       //}
             *
             *       //连续技特殊判定:
             *       //1、判定玩家是否主动打断;
             *       //2、不判定是否释放完成,一直尝试是否可释放;
             *       if (IsPlayerBreakRepeatSkill())
             *       {
             *           ClearPlayerBreakRepeatSkill();
             *           return;
             *       }
             *       //非连续技则等待一帧
             *       if (!IsUsingRepeatSkillWithNext())
             *       {
             *           return;
             *       }
             *   }
             * }
             * else
             * {
             *   if (m_fLastUseEndTime <=0.1f)
             *   {
             *       m_fLastUseEndTime = Time.time;
             *   }
             * }*/
            #endregion
            //留个缓冲时间
            //if (Time.time -m_fLastUseEndTime <0.5f)
            //{
            //    return;
            //}
            //有轻功点了出现了 向轻功点移动
            if (m_player.AutoMovetoQGPointId != -1)
            {
                //打断挂机状态
                m_player.BreakAutoCombatState();

                /*if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANZIWU)
                 * {
                 *  //燕子坞轻功点移动
                 *  m_player.AutoFightFlyInYanZiWu();
                 * }*/
                m_player.AutoMovetoQGPointId = -1;
                return;
            }
            m_fLastUseEndTime = 0.0f;
            int skillId = SeleSkill();
            if (skillId == -1)
            {
                return;
            }
            Tab_SkillEx skillExInfo = TableManager.GetSkillExByID(skillId, 0);
            if (skillExInfo == null)
            {
                return;
            }
            Tab_SkillBase skillBaseInfo = TableManager.GetSkillBaseByID(skillExInfo.BaseId, 0);
            if (skillBaseInfo == null)
            {
                return;
            }

            Obj_Character CanAttackCharacter = null;
            //如果当前选中的目标是敌对的了 则不需要再次选取目标
            if (m_player.SelectTarget != null && m_player.SelectTarget.IsDie() == false)
            {
                if (Reputation.IsEnemy(m_player.SelectTarget) ||
                    Reputation.IsNeutral(m_player.SelectTarget))
                {
                    CanAttackCharacter = m_player.SelectTarget;
                }
            }

            float skillRadius = skillExInfo.Radius;

            if (CanAttackCharacter == null ||
                (CanAttackCharacter != null && IsDisStartPointTooFar(skillRadius, CanAttackCharacter.Position))
                )
            {
                CanAttackCharacter = SeleCanAttackTar(skillRadius);
            }
            //是否有攻击目标 没有攻击目标就不要自动放技能了
            if (CanAttackCharacter == null)
            {
                /*
                 * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_ZHENLONGQIJU)
                 * {
                 *  Vector3 pos = new Vector3(18, m_player.gameObject.transform.position.y, 16);
                 *  m_player.MoveTo(pos, null, 0.0f);
                 *
                 * }
                 * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANGWANGGUMU)
                 * {
                 *  Vector3 pos = new Vector3(20, m_player.gameObject.transform.position.y, 21);
                 *  m_player.MoveTo(pos, null, 0.0f);
                 * }
                 *
                 * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_YANZIWU)
                 * {
                 *  m_player.AutoFightInYanziwu();
                 * }
                 * if (GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_FOURVILLAIN)
                 * {
                 *  Singleton<ObjManager>.Instance.MainPlayer.AutoFightInFourVillain();
                 * }
                 */
                if (GameManager.gameManager.ActiveScene != null && GameManager.gameManager.ActiveScene.IsStoryCopyScene())
                {
                    if (Singleton <ObjManager> .GetInstance().MainPlayer != null)
                    {
                        if (Singleton <ObjManager> .GetInstance().MainPlayer.AutoComabat)
                        {
                            float x = 0.0f, y = 0.0f, z = 0.0f;
                            if (GameManager.gameManager.ActiveScene.GetGuideDestination(ref x, ref z))
                            {
                                y = GameManager.gameManager.ActiveScene.GetTerrainHeight(new Vector3(x, 0.0f, z));
                                Singleton <ObjManager> .GetInstance().MainPlayer.MoveTo(new Vector3(x, y, z), null, 0.0f);
                            }
                        }
                    }
                }
                return;
            }
            //如果在野外场景攻击其它玩家return;
            if (CanAttackCharacter.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
            {
                if (GameManager.gameManager.ActiveScene.IsWildeScene())
                {
                    return;
                }
            }
            //设置为选中目标
            m_player.OnSelectTarget(CanAttackCharacter.gameObject, false);
            //距离不过 先跑过去
            float dis          = Vector3.Distance(m_player.Position, CanAttackCharacter.Position);
            float diffDistance = dis - skillRadius;
            m_player.CurUseSkillId = skillId;
            //需要向目标移动 则想目标移动
            if (diffDistance > 0 && skillBaseInfo.IsMoveToTarInAutoCombat == 1)
            {
                //move
                if (m_player.IsMoving == false && m_player.IsCanOperate_Move())
                {
                    m_player.MoveTo(CanAttackCharacter.Position, CanAttackCharacter.gameObject, skillRadius - 1.0f);
                    return;
                }
            }
            m_player.UseSkillOpt(skillId, null);
        }
Пример #3
0
    void AnalyseMousePos_Click(Vector3 posPressed)
    {
        if (null != UICamera.mainCamera)
        {
            Ray        nUIRay = UICamera.mainCamera.ScreenPointToRay(posPressed);
            RaycastHit nHit;
            if (Physics.Raycast(nUIRay, out nHit))
            {
                if (nHit.collider.gameObject.CompareTag("SubUI") || nHit.collider.gameObject.CompareTag("UI"))
                {
                    return;
                }
            }
        }

        if (!UIManager.IsSubUIShow())
        {
            Ray        ray = Camera.main.ScreenPointToRay(posPressed);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                // 客户单物品 点击拾取
                if (hit.collider.gameObject.CompareTag("CollectItem"))
                {
                    Singleton <CollectItem> .GetInstance().RemoveItem(hit.collider.gameObject);

                    GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT);
                    Singleton <EventSystem> .GetInstance().PushEvent(gameEvent);

                    return;
                }

                Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

                if (null == _mainPlayer)
                {
                    return;
                }

                //Obj点击操作,单击点选目标,双击移动过去
                Obj_Character npcScript = hit.collider.gameObject.GetComponent <Obj_Character>();
                if (npcScript)
                {
                    if (m_bIsMouseDBClick || Reputation.IsEnemy(npcScript))
                    {
                        if (_mainPlayer.IsCanOperate_Move())
                        {
                            _mainPlayer.BreakAutoCombatState();
                            _mainPlayer.LeaveTeamFollow();
                            _mainPlayer.MoveTo(hit.collider.gameObject.transform.position, hit.collider.gameObject, 1.0f);
                            _mainPlayer.FaceTo(hit.collider.transform.position);
                            _mainPlayer.OnSelectTarget(hit.collider.gameObject);
                            _mainPlayer.HasSendpos = false;
                        }
                        else
                        {
                            if (!_mainPlayer.HasSendpos)
                            {
                                _mainPlayer.HasSendpos = true;
                                _mainPlayer.SynCleanCacheSkillToServer();
                                _mainPlayer.LastForceSynPosTime = Time.time;
                            }
                        }
                    }
                    else
                    {
                        //选择目标
                        _mainPlayer.OnSelectTarget(hit.collider.gameObject);
                    }

                    GameEvent gameEvent = new GameEvent(Games.GlobeDefine.GameDefine_Globe.EVENT_DEFINE.EVENT_TOUCH_OBJECT);
                    Singleton <EventSystem> .GetInstance().PushEvent(gameEvent);
                }

                Obj_Mount mountScript = hit.collider.gameObject.GetComponent <Obj_Mount>();
                if (null != mountScript)
                {
                    if (mountScript.PlayerObj == null)
                    {
                        return;
                    }
                    //Obj_Character Obj_Char = mountScript.PlayerObj.gameObject.GetComponent<Obj_Character>();
                    //if (Obj_Char == null)
                    //{
                    //    return;
                    //}
                    if (m_bIsMouseDBClick || Reputation.IsEnemy(mountScript.PlayerObj))
                    {
                        //npcScript.FaceTo(Singleton<ObjManager>.GetInstance().MainPlayer.transform.position);
                        if (_mainPlayer.IsCanOperate_Move())
                        {
                            _mainPlayer.BreakAutoCombatState();
                            _mainPlayer.LeaveTeamFollow();
                            _mainPlayer.MoveTo(mountScript.PlayerObj.gameObject.transform.position, hit.collider.gameObject, 1.0f);
                            _mainPlayer.FaceTo(mountScript.PlayerObj.ObjTransform.position);
                            _mainPlayer.OnSelectTarget(mountScript.PlayerObj.gameObject);
                            _mainPlayer.HasSendpos = false;
                        }
                        else
                        {
                            if (!_mainPlayer.HasSendpos)
                            {
                                _mainPlayer.HasSendpos = true;
                                _mainPlayer.SynCleanCacheSkillToServer();
                                _mainPlayer.LastForceSynPosTime = Time.time;
                            }
                        }
                    }
                    else
                    {
                        //选择目标
                        _mainPlayer.OnSelectTarget(mountScript.PlayerObj.gameObject);
                    }
                }
            }
        }
        return;
    }