Exemplo n.º 1
0
        void DoAction()
        {
            //播放动作,特效
            if (m_actionCellDesc.name.Length > 0)
            {
                m_actor.PlayAction(m_actionCellDesc.name, false);
                m_actor.SetActionTime(m_actionCellDesc.name, m_actionCellDesc.setStartTime);
                m_actor.SetActionSpeed(m_actionCellDesc.name, m_actionCellDesc.speed);
            }

            //播放声音
            string sound1 = "";
            string sound2 = "";
            bool   ret1   = AudioCore.GenerateAudio(m_actionCellDesc.sound1, ref sound1);
            bool   ret2   = AudioCore.GenerateAudio(m_actionCellDesc.sound2, ref sound2);

            if (ret1 && sound1.Length > 0)
            {
                m_actor.StopSound();
                m_actor.PlaySound(sound1);
            }

            if (ret2 && sound2.Length > 0)
            {
                m_actor.StopSound2();
                m_actor.PlaySound2(sound2);
            }

            if (m_actionCellDesc.efx.Length > 0)
            {
                //GameObject efxObj = Instantiate(
                //    CoreEntry.gResLoader.LoadResource(m_actionCellDesc.efx)) as GameObject;
                GameObject efxObj = CoreEntry.gGameObjPoolMgr.InstantiateEffect(m_actionCellDesc.efx);

                float maxEfxTime = 0;
                NcCurveAnimation[] efxAnimations = efxObj.GetComponentsInChildren <NcCurveAnimation>();
                for (int i = 0; i < efxAnimations.Length; ++i)
                {
                    efxAnimations[i].m_fDelayTime    /= m_actionCellDesc.speed;
                    efxAnimations[i].m_fDurationTime /= m_actionCellDesc.speed;

                    float efxTime = efxAnimations[i].m_fDelayTime + efxAnimations[i].m_fDurationTime;
                    if (efxTime > maxEfxTime)
                    {
                        maxEfxTime = efxTime;
                    }
                }

                LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(m_skillBase.m_skillID);
                if (skill_action != null && skill_action.Get <float>("skillEfxLength") > 0)
                {
                    maxEfxTime = skill_action.Get <float>("skillEfxLength");
                }

                //LogMgr.UnityLog("maxEfxTime=" + maxEfxTime + ", " + m_strActionName);

                //特效存在时间
                if (maxEfxTime <= 0.001)
                {
                    maxEfxTime = 5;
                }

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

                m_actionEfx = efx;

                if (m_actionCellDesc.shouldAttachToOwner)
                {
                    efx.Init(m_skillBase.m_actor.transform, maxEfxTime);

                    //设置有挂点的特效
                    Transform[] childTransform = efxObj.GetComponentsInChildren <Transform>();
                    foreach (Transform childTrans in childTransform)
                    {
                        EfxSetAttachPoint setAttach = childTrans.gameObject.GetComponent <EfxSetAttachPoint>();
                        if (setAttach == null || setAttach.m_attachPointEnum == AttachPoint.E_None)
                        {
                            continue;
                        }

                        setAttach.Init(false);

                        Transform parent = m_actor.GetChildTransform(setAttach.m_attachPointEnum.ToString());
                        if (parent != null)
                        {
                            childTrans.parent        = parent;
                            childTrans.localPosition = Vector3.zero;
                            childTrans.localRotation = Quaternion.identity;
                            childTrans.localScale    = Vector3.one;

                            if (m_attachEfxObjectlist == null)
                            {
                                m_attachEfxObjectlist = new List <GameObject>();
                            }
                            m_attachEfxObjectlist.Add(childTrans.gameObject);
                        }
                    }

                    //影子
                    ghostMesh[] ghostMesh = efx.GetComponentsInChildren <ghostMesh>();

                    SkinnedMeshRenderer MianSkinMesh = m_actor.m_skinnedMeshRenderer[0];
                    for (int i = 0; i < m_actor.m_skinnedMeshRenderer.Length; ++i)
                    {
                        if (m_actor.m_skinnedMeshRenderer[i].name.Contains("weapon"))
                        {
                            continue;
                        }
                        MianSkinMesh = m_actor.m_skinnedMeshRenderer[i];
                    }

                    for (int i = 0; i < ghostMesh.Length; ++i)
                    {
                        ghostMesh[i].characterMesh[0] = MianSkinMesh;
                    }
                }
                else
                {
                    efx.Init(m_skillBase.transform, maxEfxTime, false);
                    efx.transform.parent = m_skillBase.transform;
                    BaseTool.ResetTransform(efx.transform);
                }
            }
        }
Exemplo n.º 2
0
        //浮空受击
        public void DoBehit()
        {
            //浮空状态不能释放技能
            m_BehitState.isNonControl = true;

            //离地面高度
            float height = GetHeightToGround();

            if (height <= 0.1f)
            {
                return;
            }

            if (nCount > 2)
            {
                m_actor.StopAll();
                string clipName = "hit006";
                m_actor.PlayAction(clipName);

                m_actor.SetActionSpeed(clipName, 2f);

                m_actor.UseCurveData1(clipName, 2.5f);

                m_isUseGravity = false;
                //  ExitBehitState();

                if (!m_actor.IsHadAction(clipName))
                {
                    Vector3    vCurPos = m_actor.transform.position;
                    RaycastHit curHit;
                    //强拉到地面
                    if (Physics.Raycast(vCurPos, -Vector3.up, out curHit, 10, m_groundLayerMask))
                    {
                        vCurPos.y = curHit.point.y;
                    }

                    BaseTool.SetPosition(m_transform, vCurPos);
                }


                float actionLen = m_actor.GetActionLength(clipName);
                Invoke("ExitBehitState", actionLen);
                nCount = 0;
                return;
            }

            nCount++;

            m_behitParame = m_actor.damageBebitParam;

            int skillID = m_behitParame.damgageInfo.skillID;

            //ActorObj m_hitActorBase = m_behitParame.damgageInfo.attackActor;

            //只处理带位移的普通技能
            //LuaTable skillDesc = m_hitActorBase.GetCurSkillDesc(skillID);
            char bodyType = (char)m_actor.BodyType;

            int weight = 1;

            //技能力度纠正
            if (m_behitParame.damgageInfo.weight > 0)
            {
                weight = m_behitParame.damgageInfo.weight;
                LogMgr.UnityLog("Gravity dobehit skillid=" + skillID + ", reset weight=" + weight);
            }

            //获取技能受击反馈
            SkillBehitDisplayDesc behitDisplay = m_gameDataBase.GetSkillBehitDisplayDesc(weight, bodyType);

            if (behitDisplay == null)
            {
                return;
            }

            //没有硬直,定格,没有位移
            if (!behitDisplay.isNonControl)
            {
                return;
            }

            //带位移
            float moveDistance = 0;

            //动作
            if (behitDisplay.behitType == BehitType.BT_NORMAL)
            {
                //普通受击
                // moveDistance = skillDesc.hitMoveDistance;
                moveDistance = 0.2f;
            }
            else if (behitDisplay.behitType == BehitType.BT_HITBACK)
            {
                //美术位移
                if (!m_behitParame.damgageInfo.isNotUseCurveMove)
                {
                    string clipName = behitDisplay.actionList[0];
                    moveDistance = m_actor.GetAnimationCurveLength(clipName);

                    //LogMgr.UnityLog("moveDistance=" + moveDistance + ", clipName=" + clipName);
                }
            }
            else if (behitDisplay.behitType == BehitType.BT_HITDOWN)
            {
                m_actor.StopAll();
                string clipName = behitDisplay.actionList[0];
                m_actor.PlayAction(clipName);
                m_actor.UseCurveData1(clipName, 2.5f);

                m_isUseGravity = false;
                //  ExitBehitState();

                if (!m_actor.IsHadAction(clipName))
                {
                    Vector3    vCurPos = m_actor.transform.position;
                    RaycastHit curHit;
                    //强拉到地面
                    if (Physics.Raycast(vCurPos, -Vector3.up, out curHit, 10, m_groundLayerMask))
                    {
                        vCurPos.y = curHit.point.y;
                    }

                    BaseTool.SetPosition(m_transform, vCurPos);
                }


                float actionLen = m_actor.GetActionLength(clipName);
                Invoke("ExitBehitState", actionLen);

                return;
            }


            else if (behitDisplay.behitType == BehitType.BT_HITSKY)
            {
                //浮空追击
                CancelInvoke("MoveDistanceEnd");
                CancelInvoke("AutoCancelStatic");

                F_ACCE = 0;
                //  SetOriginV(skillDesc.hitSkyOriginV, skillDesc.hitSkyAngle);

                m_actor.StopAll();
                m_actor.PlayAction("hit013", false);
                return;
            }

            //LogMgr.UnityLog("moveDistance=" + moveDistance);


            if (height < 0.5f)
            {
                return;
            }


            //没有位移
            if (moveDistance <= 0.001)
            {
                //F_ACCE = G_ACCE;
                SetOriginV(1, 90);
                m_actor.StopAll();
                m_actor.PlayAction("hit013", false);
            }
            else
            {
                //当前的高度
                SetOriginV(3, 75);
                m_actor.StopAll();
                m_actor.PlayAction("hit013", false);
            }
        }
Exemplo n.º 3
0
        protected override void UpdateImpl(float deltaTime)
        {
            if (XZDistanceSqr(currentDestination, transform.position) < 1e-3f)
            {
                if (pointList.Count < 1)
                {
                    Stop();
                    return;
                }

                currentDestination = pointList.Dequeue();
                FaceTo(currentDestination);
                SendMoveTo(transform.position, currentDestination);
            }

            //todo ,get move speed from actor
            float speed = GetSpeed();

            //float speed = 6.0f;
            if (isSlide)
            {
                speed *= 0.2f;
            }

            float   dist;
            float   moveDist      = deltaTime * speed;
            float   remainDist    = moveDist;
            Vector3 prevPositioin = transform.position;

            while (true)
            {
                dist = XZDistance(currentDestination, prevPositioin);
                if (remainDist <= dist)
                {
                    break;
                }
                if (pointList.Count < 1)
                {
                    currentDestination.y = pathFinder.GetTerrainHeight(currentDestination.x, currentDestination.z);
                    BaseTool.SetPosition(transform, currentDestination);

                    Stop();
                    return;
                }
                remainDist        -= dist;
                prevPositioin      = currentDestination;
                currentDestination = pointList.Dequeue();
                FaceTo(currentDestination);
                SendMoveTo(transform.position, currentDestination);
            }

            Vector3 pos    = prevPositioin + (currentDestination - prevPositioin).normalized * remainDist;
            float   height = pathFinder.GetTerrainHeight(pos.x, pos.z);

            if (0 != height)
            {
                pos.y = height;
            }

            //SendMoveTo(transform.position, currentDestination);
            //transform.position = pos;

            BaseTool.SetPosition(transform, pos);
        }
Exemplo n.º 4
0
        // Update is called once per frame
        void Update()
        {
            if (m_actor == null)
            {
                return;
            }

            if (m_actor.IsDeath())
            {
                m_isUseGravity = false;
                return;
            }

            if (m_actor.IgnoredGravityMotion)
            {
                m_isUseGravity = false;
                return;
            }

            if (!m_isUseGravity)
            {
                nCount = 0;
                return;
            }

            float diffTime = Time.time - m_startMotionTime;

            //Y轴当前速度
            float vY = m_originVelocity.vSubY - (G_ACCE - F_ACCE) * diffTime;

            //Y轴位移
            float dY = (m_originVelocity.vSubY - 0.5f * (G_ACCE - F_ACCE) * diffTime) * diffTime;;

            if (m_gravityMotionType == GravityMotionType.GMT_DOWN)
            {
                dY = dY * 0.8f;
            }

            //Z轴位移
            float dZ = m_originVelocity.vSubZ * diffTime;

            Vector3 movePos = m_attackObjForward.normalized * dZ;

            //LogMgr.UnityLog("movePos="+movePos.ToString("f4")+", dir="+m_attackObjForward.normalized.ToString("f4"));
            Vector3 curPos = m_transform.position;
            Vector3 aimPos = m_startPos + new Vector3(movePos.x, dY, movePos.z);

            //m_transform.position = m_startPos + new Vector3(movePos.x, dY, movePos.z);

            bool isOverHeight = false;
            //float heigth = m_transform.position.y - m_startToSkyPos.y;
            float heigth = aimPos.y - m_startToSkyPos.y;

            if (heigth > 5)
            {
                //m_transform.position -= new Vector3(0, heigth-5, 0);
                aimPos      -= new Vector3(0, heigth - 2, 0);
                isOverHeight = true;
            }

            //是否碰到墙壁
            bool isToWall = false;

            if (!(Mathf.Abs(m_originVelocity.vSubZ) <= 0.0001))
            {
                Vector3 dir = m_attackObjForward;

                RaycastHit beHit;

                if (!BaseTool.instance.CanMoveToPos(curPos, aimPos, m_curRadius) ||
                    Physics.Raycast(m_transform.position, dir, out beHit, m_curRadius + 0.5f, m_groundLayerMask))
                {
                    //碰到阻挡墙,直接下落
                    aimPos   = curPos;
                    isToWall = true;
                }
            }

            //Vector3 groundPos = BaseTool.instance.GetGroundPoint(m_transform.position);
            //if (aimPos.y < groundPos.y)
            //{
            //    aimPos.y = groundPos.y + 0.01f;
            //}
            BaseTool.SetPosition(m_transform, aimPos);

            //到达最高点, 碰到墙壁
            if (isOverHeight || isToWall || (m_gravityMotionType == GravityMotionType.GMT_UP && vY <= 0.0001))
            {
                F_ACCE = 0;
                if (isOverHeight || isToWall)
                {
                    SetOriginV(1, 270);
                }
                else
                {
                    //有水平速度,保持不变
                    if (!(Mathf.Abs(m_originVelocity.vSubZ) <= 0.0001))
                    {
                        m_gravityMotionType = GravityMotionType.GMT_DOWN;
                        return;
                    }

                    m_actor.StopAll();
                    SetOriginV(0, 270);
                    m_actor.PlayAction("hit011", false);
                }
            }
        }