Пример #1
0
        void TakeAwayTargets(Vector3 translation)
        {
            Vector3    aimPos, wallPos, pos0, dir;
            List <int> NoUseList = null;

            if (m_TakeAwayGameObjectMap.Count > 0)
            {
                NoUseList = new List <int>();
            }

            if (m_param.bCanNotMoveWhenTakenAway)
            {
                bool    canMoveTarget = false;
                Vector3 tmpPos        = this.transform.position;
                if (m_TakeAwayGameObjectMap.Count > 0)
                {
                    //只有在地面上的位置,才是移动目标的有效位置
                    if (m_baseTool.IsAboveTheGround(tmpPos))
                    {
                        canMoveTarget = true;
                    }
                }

                if (canMoveTarget)
                {
                    foreach (int i in m_TakeAwayGameObjectMap.Keys)
                    {
                        ActorObj actorBase = m_TakeAwayGameObjectMap[i].GetComponent <ActorObj>();
                        if (actorBase != null)
                        {
                            float radius = actorBase.GetColliderRadius();
                            if (BaseTool.instance.CanMoveToPos(actorBase.transform.position, tmpPos, radius))
                            {
                                //m_TakeAwayGameObjectMap[i].transform.position = new Vector3(tmpPos.x, m_TakeAwayGameObjectMap[i].transform.position.y, tmpPos.z);
                                BaseTool.SetPosition(m_TakeAwayGameObjectMap[i].transform, tmpPos);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (int i in m_TakeAwayGameObjectMap.Keys)
                {
                    if (m_TakeAwayGameObjectMap[i] != null)
                    {
                        aimPos  = m_TakeAwayGameObjectMap[i].transform.position + translation;
                        wallPos = m_baseTool.GetWallHitPoint(m_TakeAwayGameObjectMap[i].transform.position, aimPos);
                        if (!wallPos.Equals(aimPos))
                        {
                            // Debug.DrawLine(wallPos, aimPos,Color.cyan);

                            dir = translation;
                            dir.Normalize();
                            //存在空气墙
                            //unity的raycast是向下忽略的,所以不能再下边界做判断,给定的时候,往回取一点值
                            Vector3 wallGroundPos = m_baseTool.GetGroundPoint(wallPos - dir * 0.1f);

                            float distance = Vector3.Distance(m_TakeAwayGameObjectMap[i].transform.position, wallGroundPos);

                            distance -= 0.4f;

                            pos0 = m_TakeAwayGameObjectMap[i].transform.position +
                                   translation.normalized * distance;

                            aimPos = m_baseTool.GetGroundPoint(pos0);

                            m_TakeAwayGameObjectMap[i].transform.Translate(aimPos - m_TakeAwayGameObjectMap[i].transform.position, Space.World);

                            NoUseList.Add(i);
                        }
                        else
                        {
                            m_TakeAwayGameObjectMap[i].transform.Translate(translation, Space.World);
                        }
                    }
                }
            }

            if (NoUseList != null)
            {
                for (int i = 0; i < NoUseList.Count; ++i)
                {
                    //清除物件前,恢复动作
                    ActorObj actorBase = m_TakeAwayGameObjectMap[NoUseList[i]].GetComponent <ActorObj>();
                    if (actorBase != null)
                    {
                        actorBase.CanCurveMove();
                    }
                    m_TakeAwayGameObjectMap.Remove(NoUseList[i]);
                }
            }
        }
Пример #2
0
        void Start()
        {
            CancelInvoke("Start");

            if (m_skillBase == null || m_skillBase.m_actor == null)
            {
                return;
            }

            m_skillBase.m_actor.ReqirueCanNotBeControlledByInput();

            //主角在电梯上禁止美术位移
            if (CoreEntry.gSceneMgr.IsPlayerOnElevator())
            {
                return;
            }

            if (m_movePosAttackDesc == null)
            {
                return;
            }

            LuaTable skillDesc = m_skillBase.m_actor.GetCurSkillDesc(m_skillBase.m_skillID);

            if (skillDesc == null)
            {
                LogMgr.UnityError("non SkillDesc! " + m_skillBase.m_skillID);
                return;
            }

            //SkillClassDisplayDesc skillClass = m_gameDBMgr.GetSkillClassDisplayDesc(skillDesc.Get<int>("skillDisplayID"));

            //计算位移距离
            m_distance = m_movePosAttackDesc.moveDistance;

            //使用目标的位置, 前面0.5米

            if (m_skillBase.m_actor.IsMainPlayer())
            {
                if (m_skillBase.m_actor.m_SelectTargetObject != null)
                {
                    float dist1 = Vector3.Distance(transform.position, m_skillBase.m_actor.m_SelectTargetObject.transform.position) - 0.5f;
                    if (dist1 > m_distance)
                    {
                        dist1 = m_distance;
                    }

                    m_distance = dist1;
                }
            }

            float resetDistance = m_distance;

            //设置位移
            do
            {
                ActorObj ActorObj = m_skillBase.m_actor.GetAttackObj();
                if (ActorObj == null)
                {
                    ActorObj = m_skillBase.m_hitActor;
                }

                if (ActorObj == null)
                {
                    LogMgr.UnityLog("CurveMove:no target");
                    break;
                }

                GameObject targetObj = ActorObj.thisGameObject;
                if (targetObj == null)
                {
                    LogMgr.UnityLog("CurveMove:no target");
                    break;
                }

                ActorObj targetActorBase = targetObj.GetComponent <ActorObj>();
                if (targetActorBase == null)
                {
                    LogMgr.UnityError("CurveMove:no actorbase");
                    break;
                }


                if (m_movePosAttackDesc.isStopForTarget)
                {
                    float fDistTo = m_skillBase.m_actor.GetColliderRadius() + targetObj.GetComponent <ActorObj>().GetColliderRadius();

                    if (CoreEntry.gGameMgr.IsPvpState())
                    {
                        fDistTo += 1.2f;
                    }


                    //不可以穿透,重置位移大小
                    float aimDistance = Vector3.Distance(m_transform.position, targetObj.transform.position) - fDistTo - 0.2f;    //两个物体间的距离

                    //范围内,不需要位移
                    if (aimDistance <= 0)
                    {
                        //Debug.LogWarning("CurveMove: don't need excute!");
                        return;
                    }

                    resetDistance = Mathf.Min(aimDistance, resetDistance);
                }
                else
                {
                    resetDistance = m_distance;
                }
            } while (false);



            Quaternion r0  = Quaternion.Euler(m_transform.eulerAngles);
            Vector3    pos = m_transform.position +
                             r0 * Vector3.forward * resetDistance;

            //找到对应地面上的点
            Vector3 aimPos = m_baseTool.GetGroundPoint(pos);

            if (aimPos.Equals(Vector3.zero))
            {
                return;
            }

            Vector3 dstDir = aimPos - m_transform.position;

            dstDir.Normalize();

            //左手方向
            //Vector3 leftDir = Quaternion.Euler(new Vector3(0, 90, 0)) * dstDir;
            //Vector3 rightDir = Quaternion.Euler(new Vector3(0, -90, 0)) * dstDir;
            //Vector3 backDir = Quaternion.Euler(new Vector3(0, 180, 0)) * dstDir;

            //float dstDistance = Vector3.Distance(m_transform.position, aimPos);
            m_needMove = true;

            //向上移动点
            //aimPos += new Vector3(0, 0.2f, 0);
            aimPos = m_baseTool.GetLineReachablePos(m_transform.position, aimPos);
            aimPos = m_baseTool.GetGroundPoint(aimPos);

            if (m_skillBase.m_actor.IsMainPlayer())
            {
                m_dstPos = aimPos;
            }
            else
            {
                m_dstPos = m_skillBase.m_actor.m_CurveMovePos;
            }

            //使用曲线
            CurveMoveParam param = new CurveMoveParam();

            param.aimActorTypeList = m_movePosAttackDesc.resetAimActorTypeList;
            param.isCarryOffTarget = m_movePosAttackDesc.isCarryOffTarget;
            param.isStopForTarget  = m_movePosAttackDesc.isStopForTarget;

            LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillBase.m_skillID);

            if (skill_action != null)
            {
                m_uuid = m_skillBase.m_actor.UseCurveData3(skill_action.Get <string>("animation"), m_dstPos,// m_dstPos,
                                                           param);
            }

            m_param = param;

            //拖尾特效
            if (m_movePosAttackDesc.efxPrefab.Length > 0)
            {
                //GameObject efxObj = Instantiate(CoreEntry.gResLoader.LoadResource(m_movePosAttackDesc.efxPrefab)) as GameObject;
                GameObject efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(m_movePosAttackDesc.efxPrefab);

                EfxAttachActionPool efx = efxObj.GetComponent <EfxAttachActionPool>();
                if (efx == null)
                {
                    efx = efxObj.AddComponent <EfxAttachActionPool>();
                }

                float efxTime = 1.0f;
                if (skill_action != null)
                {
                    m_skillBase.m_actor.GetLeftActionTime(skill_action.Get <string>("animation"));
                }

                efx.Init(m_skillBase.m_actor.transform, efxTime);
            }
        }