Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
0
        private void OnSkillEffect(GameEvent ge, EventParameter parameter)
        {
            MsgData_sCastEffect data = parameter.msgParameter as MsgData_sCastEffect;

            ActorObj actor = CoreEntry.gActorMgr.GetActorByServerID(data.TargetID);

            if (null == actor)
            {
                return;
            }

            bool   isPlayer = actor.mActorType == ActorType.AT_LOCAL_PLAYER;
            string text     = string.Empty;
            int    flag     = data.Flags;
            int    damage   = (int)data.Damage;

            damage = CheckHP(actor, damage);
            FlyTextType type;

            //幻灵或者魔宠技能伤害
            LuaTable skillCfg = ConfigManager.Instance.Skill.GetSkillConfig(data.SkillID);

            if (null != skillCfg)
            {
                if ((int)SkillShowType.ST_MAGICKEY == skillCfg.Get <int>("showtype"))
                {
                    type = FlyTextType.Mochong;
                    if (damage == 0)
                    {
                        return;
                    }
                    else if (damage < 0)
                    {
                        text = string.Format("魔宠 +{0}", -damage);
                    }
                    else
                    {
                        text = string.Format("魔宠 -{0}", damage);
                    }

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    return;
                }
                else if ((int)SkillShowType.ST_HUANLING == skillCfg.Get <int>("showtype"))
                {
                    type = FlyTextType.Huanling;
                    if (damage == 0)
                    {
                        return;
                    }
                    else if (damage < 0)
                    {
                        text = string.Format("幻灵 +{0}", -damage);
                    }
                    else
                    {
                        text = string.Format("幻灵 -{0}", damage);
                    }

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    return;
                }
            }

            if (0 == flag)
            {
                if (damage == 0)
                {
                    return;
                }
                if (damage < 0)
                {
                    text = string.Format("+{0}", -damage);
                    type = FlyTextType.AddHP;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);

                    return;
                }

                text = string.Format("{0}", damage);
                type = FlyTextType.Max;

                if (actor.mActorType == ActorType.AT_LOCAL_PLAYER)
                {
                    type = FlyTextType.PlayerNormal;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }
                else
                {
                    type = FlyTextType.MonsterNormal;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }

                return;
            }

            bool showDamage = false;

            if (CheckMask(flag, EFFECTMASK.SUPER))
            {
                if (!isPlayer && damage != 0)//玩家不显示
                {
                    showDamage = true;

                    text = string.Format("卓越一击 {0}", damage);
                    type = FlyTextType.Special;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }
            }
            if (CheckMask(flag, EFFECTMASK.IGDEF))
            {
                if (!isPlayer && damage != 0)//玩家不显示
                {
                    showDamage = true;

                    text = string.Format("无视一击 {0}", damage);
                    type = FlyTextType.Special;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }
            }
            if (CheckMask(flag, EFFECTMASK.CRIT))
            {
                if (damage != 0)
                {
                    showDamage = true;

                    text = string.Format("暴击 {0}", damage);
                    type = FlyTextType.Crit;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }
            }
            if (CheckMask(flag, EFFECTMASK.IGNORE))//免疫伤害
            {
                text = string.Format("无");
                type = FlyTextType.Buff;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.MISS))
            {
                text = string.Format("闪避");
                type = FlyTextType.Buff;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.BLOCKED))
            {
                text = string.Format("格挡");
                type = FlyTextType.Buff;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.IMMUNITY))
            {
                text = string.Format("免疫");
                type = FlyTextType.Buff;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.REFLEX))
            {
                text = string.Format("反弹伤害");
                type = FlyTextType.Special;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.RAMPAGE))
            {
                text = string.Format("狂暴");
                type = FlyTextType.Buff;

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                //ShowText(actor.gameObject, text, type);
            }
            if (CheckMask(flag, EFFECTMASK.REALM))
            {
                if (!isPlayer)//玩家不显示
                {
                    text = string.Format("境界压制");
                    type = FlyTextType.Special;

                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    //ShowText(actor.gameObject, text, type);
                }
            }
            if (CheckMask(flag, EFFECTMASK.KILL))
            {
                if (!showDamage)
                {
                    showDamage = true;

                    if (damage < 0)
                    {
                        text = string.Format("+{0}", -damage);
                        type = FlyTextType.AddHP;

                        AddProcessInfo(isPlayer, actor.gameObject, text, type);
                        //ShowText(actor.gameObject, text, type);
                    }
                    else if (damage > 0)
                    {
                        text = string.Format("{0}", damage);

                        if (actor.mActorType == ActorType.AT_LOCAL_PLAYER)
                        {
                            type = FlyTextType.PlayerNormal;

                            AddProcessInfo(isPlayer, actor.gameObject, text, type);
                            //ShowText(actor.gameObject, text, type);
                        }
                        else
                        {
                            type = FlyTextType.MonsterNormal;

                            AddProcessInfo(isPlayer, actor.gameObject, text, type);
                            //ShowText(actor.gameObject, text, type);
                        }
                    }
                }
            }
            if (CheckMask(flag, EFFECTMASK.PULL))
            {
            }
            if (CheckMask(flag, EFFECTMASK.KNOCKBACK))
            {
                if (!showDamage)
                {
                    showDamage = true;
                    if (damage < 0)
                    {
                        text = string.Format("+{0}", -damage);
                        type = FlyTextType.AddHP;

                        AddProcessInfo(isPlayer, actor.gameObject, text, type);
                    }
                    else if (damage > 0)
                    {
                        text = string.Format("{0}", damage);
                        if (actor.mActorType == ActorType.AT_LOCAL_PLAYER)
                        {
                            type = FlyTextType.PlayerNormal;

                            AddProcessInfo(isPlayer, actor.gameObject, text, type);
                            //ShowText(actor.gameObject, text, type);
                        }
                        else
                        {
                            type = FlyTextType.MonsterNormal;

                            AddProcessInfo(isPlayer, actor.gameObject, text, type);
                            //ShowText(actor.gameObject, text, type);
                        }
                    }
                }
            }
            if (CheckMask(flag, EFFECTMASK.STIFF))
            {
            }
            if (CheckMask(flag, EFFECTMASK.REBIRTH))
            {
            }
            if (CheckMask(flag, EFFECTMASK.HORSE))
            {
            }
            if (CheckMask(flag, EFFECTMASK.DIAMONDS))
            {
                text = string.Format("钻石一击");
                type = FlyTextType.VipEquip;
                FlyTextMapping fun = LuaMgr.Instance.GetLuaEnv().Global.GetInPath <FlyTextMapping>("Common.FlyTextMapping");
                if (fun != null)
                {
                    text = fun((int)FlyTextType.VipEquip, "1");
                }

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                if (damage > 0)
                {
                    text = string.Format("{0}", damage);
                    type = FlyTextType.VipEquipNum;
                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                }
            }

            if (CheckMask(flag, EFFECTMASK.KING))
            {
                text = string.Format("王者二鸡");
                type = FlyTextType.VipEquip;

                FlyTextMapping fun = LuaMgr.Instance.GetLuaEnv().Global.GetInPath <FlyTextMapping>("Common.FlyTextMapping");
                if (fun != null)
                {
                    text = fun((int)FlyTextType.VipEquip, "2");
                }
                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                if (damage > 0)
                {
                    type = FlyTextType.VipEquipNum;
                    text = string.Format("{0}", damage);
                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                }
            }
            if (CheckMask(flag, EFFECTMASK.SUPREME))
            {
                text = string.Format("至尊三机");
                type = FlyTextType.VipEquip;
                FlyTextMapping fun = LuaMgr.Instance.GetLuaEnv().Global.GetInPath <FlyTextMapping>("Common.FlyTextMapping");
                if (fun != null)
                {
                    text = fun((int)FlyTextType.VipEquip, "3");
                }

                AddProcessInfo(isPlayer, actor.gameObject, text, type);
                if (damage > 0)
                {
                    type = FlyTextType.VipEquipNum;
                    text = string.Format("{0}", damage);
                    AddProcessInfo(isPlayer, actor.gameObject, text, type);
                }
            }
        }