Ejemplo n.º 1
0
        //int m_num = 1;

        //初始化
        public void Init(GameObject obj)
        {
            m_actorObject = obj;
            //m_ani = m_actorObject.GetComponent<Animation>();
            m_actor = (m_actorObject.GetComponent <ActorObj>());

            m_transform          = m_actorObject.transform;
            m_animationCurveData = m_actorObject.GetComponent <AnimationCurveData>();
            if (m_animationCurveData == null)
            {
                //LogMgr.LogError(obj.name + ":缺少动画曲线组件AnimationCurveData,可能将导致异常。美术请检查该模型!!!");
            }

            if (m_actor != null && m_actor != null)
            {
                m_curRadius = m_actor.GetColliderRadius();
            }
            else
            {
                LogMgr.LogError("Please Check m_actor:" + m_actor + " : " + m_actor);
            }

            //如果是PVP状态
            if (CoreEntry.gGameMgr.IsPvpState())
            {
                m_curRadius += 1.8f;
            }
        }
Ejemplo n.º 2
0
        public void EventFunction(GameEvent ge, EventParameter parameter)
        {
            switch (ge)
            {
            case GameEvent.GE_NOTIFY_CAST_SKILL:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    //玩家释放技能前选择目标
                    if (actorObj.mActorType == ActorType.AT_LOCAL_PLAYER)
                    {
                        //若没有目标则马上选择目标
                        CoreEntry.gActorMgr.MainPlayer.CheckSkillTarget();
                    }

                    actorObj.OnRunToAttack(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            case GameEvent.GE_NOTIFY_SHOW_SKILL_SCOPE:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    actorObj.OnShowSkillScope(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            case GameEvent.GE_NOTIFY_HIDE_SKILL_SCOPE:
            {
                //释放技能
                int        skillID = (int)parameter.intParameter;
                GameObject actor   = parameter.goParameter;

                //调用actorbase释放技能
                ActorObj actorObj = actor.GetComponent <ActorObj>();

                //是否学习了该技能
                if (actorObj.IsHadLearnSkill(skillID))
                {
                    actorObj.OnHideSkillScope(skillID);
                    //actorObj.OnCastSkill(skillID);
                }
            }
            break;

            //
            case GameEvent.GE_SC_SKILLEFFECT:
            {
                MsgData_sCastEffect data = parameter.msgParameter as MsgData_sCastEffect;

                if (data == null)
                {
                    return;
                }


                //服务器这里只冒伤害数字
                bool bIsMainPlayer = false;

                BehitParam behitParam = new BehitParam();

                DamageParam damageParam = new DamageParam();
                damageParam.attackActor = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);
                damageParam.behitActor  = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                damageParam.skillID     = data.SkillID;
                damageParam.Flags       = data.Flags;
                damageParam.DamagaType  = data.DamagaType;
                damageParam.Damage      = (int)data.Damage;
                damageParam.IsClient    = false;


                behitParam.damgageInfo = damageParam;
                behitParam.displayType = (DamageDisplayType)data.DamagaType;
                behitParam.hp          = (int)data.Damage;


                if (behitParam.damgageInfo.attackActor != null &&
                    behitParam.damgageInfo.attackActor.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    bIsMainPlayer = true;
                }

                if (behitParam.damgageInfo.attackActor != null)
                {
                    if (bIsMainPlayer)
                    {
                        behitParam.damgageInfo.attackActor.OnDamage((int)data.Damage, data.SkillID, bIsMainPlayer, behitParam);
                    }
                    else
                    {
                        //其他人要播受击动作
                        OnSkillDamage(damageParam);
                    }
                }
            }
            break;


            case GameEvent.GE_SC_OTHER_CASTSKILL_BEGIN:
            {
                MsgData_sCastBegan data = parameter.msgParameter as MsgData_sCastBegan;
                if (data == null)
                {
                    return;
                }
                ActorObj attackObj = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (attackObj == null)
                {
                    return;
                }

                if (attackObj != null && attackObj.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    return;
                }



                //todo ,先强行同步位置
                attackObj.SetServerPosition(new Vector2(data.CasterPosX, data.CasterPosY));
                attackObj.OnCastSkill(data.SkillID, data.CasterID, data.TargetID, data.PosX, data.PosY);
            }
            break;


            case GameEvent.GE_SC_OTHER_CASTSKILL_END:
            {
                MsgData_sCastEnd data = parameter.msgParameter as MsgData_sCastEnd;
                if (data == null)
                {
                    return;
                }
                ActorObj attackObj = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (attackObj == null)
                {
                    return;
                }

                attackObj.SkillEnd(data.SkillID);
            }
            break;


            //hitback
            case GameEvent.GE_SC_KNOCKBACK:
            {
                MsgData_sKnockBack data = parameter.msgParameter as MsgData_sKnockBack;
                if (data == null)
                {
                    return;
                }
                ActorObj beHitActor  = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                ActorObj attackActor = CoreEntry.gActorMgr.GetActorByServerID(data.CasterID);

                if (beHitActor == null || attackActor == null)
                {
                    return;
                }

                beHitActor.OnHitBack(attackActor, data.MotionSpeed, data.PosX, data.PosY, data.MotionTime);
            }
            break;

            case GameEvent.GE_SC_ADDBUFFList:
            {
                MsgData_sAddBufferList data = parameter.msgParameter as MsgData_sAddBufferList;
                if (data == null)
                {
                    return;
                }
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);
                if (targetObj == null)
                {
                    return;
                }
                for (int i = 0; i < data.BufferList.Count; i++)
                {
                    MsgData_sBuffer _buff    = data.BufferList[i];
                    BuffData        buffdata = new BuffData();
                    buffdata.BufferInstanceID = _buff.BufferInstanceID;
                    buffdata.buffType         = _buff.BufferTemplateID;
                    buffdata.Life             = _buff.Life;
                    buffdata.Count            = 1;
                    //buffdata.Param[0] = data.Param;
                    CoreEntry.gBuffMgr.AddBuff(buffdata, targetObj);
                }
            }
            break;

            case GameEvent.GE_SC_ADDBUFF:
            {
                MsgData_sAddBuffer data = parameter.msgParameter as MsgData_sAddBuffer;

                if (data == null)
                {
                    return;
                }

                /*
                 * if (data.BufferTemplateID == 24100001 || data.BufferTemplateID == 24100002)
                 * {
                 *  Debug.LogError("target目标 "+ data.TargetID +"  添加 iBuffId = " + data.BufferTemplateID);
                 * }
                 */
                // Debug.LogError("target目标 " + data.TargetID + "  添加 iBuffId = " + data.BufferTemplateID);
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);

                if (targetObj == null)
                {
                    return;
                }

                BuffData buffdata = new BuffData();
                buffdata.BufferInstanceID = data.BufferInstanceID;
                buffdata.buffType         = data.BufferTemplateID;
                buffdata.Life             = data.Life;
                buffdata.Count            = 1;

                buffdata.Param[0] = data.Param;
                //LogMgr.LogError("SkillMgr AddBuff " + buffdata.buffType);
                CoreEntry.gBuffMgr.AddBuff(buffdata, targetObj);
            }
            break;

            case GameEvent.GE_SC_UPDATEBUFF:
            {
                MsgData_sUpdateBuffer data = parameter.msgParameter as MsgData_sUpdateBuffer;

                if (data == null)
                {
                    return;
                }

                BuffData buffdata = new BuffData();
                buffdata.BufferInstanceID = data.BufferInstanceID;
                buffdata.Life             = data.Life;
                buffdata.Count            = data.Count;
                buffdata.Param            = data.Param;
                //LogMgr.LogError("SkillMgr UpdateBuff " + buffdata.buffType);
                CoreEntry.gBuffMgr.UpdateBuff(buffdata);
            }
            break;

            case GameEvent.GE_SC_DELBUFF:
            {
                MsgData_sDelBuffer data = parameter.msgParameter as MsgData_sDelBuffer;
                if (data == null)
                {
                    return;
                }
                if (data.BufferTemplateID == 24100001 || data.BufferTemplateID == 24100002)
                {
                    //LogMgr.DebugLog("target目标 "+ data.TargetID + "  删除 iBuffId = " + data.BufferTemplateID);
                }

                //LogMgr.LogError("SkillMgr DelBuff " + data.BufferTemplateID);
                //  if(data.BufferInstanceID)
                ActorObj targetObj = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);

                if (targetObj != null)
                {
                    //LogMgr.LogError("SKillMgr CoreEntry.gBuffMgr.RemoveBuff " + data.BufferTemplateID);
                    CoreEntry.gBuffMgr.RemoveBuff(data.BufferInstanceID, targetObj);
                    if (targetObj.ServerID == CoreEntry.gActorMgr.MainPlayer.ServerID)
                    {
                        EventParameter msg = new EventParameter();
                        msg.longParameter = data.BufferTemplateID;
                        //Debug.LogError("删除BUFF  " + data.BufferTemplateID);
                        CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_CC_DELEBUFF, msg);
                    }
                }
            }
            break;

            case GameEvent.GE_SC_CAST_MOVE_EFFECRT:
            {
                MsgData_sCastMoveEffect data = parameter.msgParameter as MsgData_sCastMoveEffect;
                if (null == data)
                {
                    return;
                }

                if (data.caseterID == CoreEntry.gActorMgr.MainPlayer.ServerID)
                {
                    return;
                }

                ActorObj casterObj = CoreEntry.gActorMgr.GetActorByServerID(data.caseterID);
                if (null == casterObj)
                {
                    return;
                }

                LuaTable skill_action = CoreEntry.gSkillMgr.GetSkillActon(data.skillID);
                if (null == skill_action)
                {
                    return;
                }

                float   posX    = (float)data.posX;
                float   posZ    = (float)data.posY;
                Vector3 destPos = new Vector3(posX, CommonTools.GetTerrainHeight(new Vector2(posX, posZ)), posZ);

                AnimationCurveData curveData = casterObj.GetComponent <AnimationCurveData>();
                if (null == curveData)
                {
                    LogMgr.LogError(casterObj.gameObject.name + " has no AnimationCurveBase, skill id:" + data.skillID);

                    return;
                }

                casterObj.UseCurveData3(skill_action.Get <string>("animation"), destPos, null);
            }
            break;

            default:
                break;
            }
        }