Ejemplo n.º 1
0
 public void InitAttr(MsgData_sSceneObjectEnterMonster es)
 {
     mBaseAttr.InitMonsterAttr(es);
     if (mHealth != null)
     {
         mHealth.OnResetHP();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 延迟刷怪。 。保存 怪物信息
 /// </summary>
 /// <param name="monster"></param>
 public void AddMonster(MsgData_sSceneObjectEnterMonster monster)
 {
     if (DungeonMono.instance == null)
     {
         if (!monsterList.Contains(monster))
         {
             monsterList.Add(monster);
         }
         return;
     }
     if (!DungeonMono.instance.bStart)       //倒计时未结束时,服务端推的怪物信息 ,先保存
     {
         if (!monsterList.Contains(monster))
         {
             monsterList.Add(monster);
         }
     }
     else
     {
         DungeonMono.instance.LoadModel(monster);   //倒计时结束后 推的 怪物,直接显示出来
     }
 }
Ejemplo n.º 3
0
 public void LoadModel(MsgData_sSceneObjectEnterMonster monster)
 {
     CoreEntry.gSceneLoader.LoadMonster(monster);
 }
Ejemplo n.º 4
0
        void Update()
        {
            if (!bSceneLoaded)
            {
                return;
            }

            float time = 0.0f;
            float lastTime = Time.realtimeSinceStartup;
            while (mSceneCache.Count > 0)
            {
                if (time > mMaxPrcessingTime)
                {
                    return;
                }

                SceneObj sceneObj = mSceneCache[0];
                switch (sceneObj.ObjType)
                {
                    case EnEntType.EnEntType_Player:
                        MsgData_sSceneObjectEnterHuman humanStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterHuman;
                        CoreEntry.gSceneLoader.LoadOtherPlayer(humanStruct);
                        if (sceneObj.PlayerData != null)
                        {
                            sceneObj.PlayerData = null;
                        }
                        break;
                    case EnEntType.EnEntType_Monster:
                        MsgData_sSceneObjectEnterMonster monsterStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterMonster;
                        //Debug.LogError("创建怪物:" + monsterStruct.Guid);
                        if (!mObjRecord.ContainsKey(monsterStruct.Guid))
                        {
                            CoreEntry.gSceneLoader.LoadMonster(monsterStruct);
                            mObjRecord.Add(monsterStruct.Guid, CoreEntry.gActorMgr.GetActorByServerID(monsterStruct.Guid));
                        }
                        else
                        {
                            //Debug.LogError("重复怪物:" + monsterStruct.Guid);
                        }
                        break;
                    case EnEntType.EnEntType_NPC:
                        MsgData_sSceneObjectEnterNPC npcStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterNPC;
                        CoreEntry.gSceneLoader.LoadNPC(npcStruct);
                        break;
                    case EnEntType.EnEntType_StaticObj:
                        MsgData_sSceneObjectEnterStaticObj sstaticStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterStaticObj;
                        CoreEntry.gSceneLoader.LoadStaticObj(sstaticStruct);
                        break;
                    case EnEntType.EnEntType_Item:
                        MsgData_sSceneObjectEnterItem itemStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterItem;
                        EventParameter param = EventParameter.Get();
                        param.objParameter = itemStruct;
                        CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OBJ_ITEM_ENTER, param);
                        break;
                    case EnEntType.EnEntType_GatherObj:
                        MsgData_sSceneObjectEnterCollection collectionStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterCollection;
                        CoreEntry.gSceneLoader.LoadCollection(collectionStruct);
                        break;
                    case EnEntType.EnEntType_Pet:
                        MsgData_sSceneObjectEnterPet petStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterPet;
                        CoreEntry.gSceneLoader.LoadPet(petStruct);
                        break;
                    case EnEntType.EnEntType_BiaoChe:
                        MsgData_sSceneObjectEnterBiaoChe cheStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterBiaoChe;
                        CoreEntry.gSceneLoader.LoadBiaoChe(cheStruct);
                        break;
                    case EnEntType.EnEntType_Trap:
                        MsgData_sSceneObjectEnterTrap trapStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterTrap;
                        CoreEntry.gSceneLoader.LoadTrap(trapStruct);
                        break;
                    case EnEntType.EntType_VirtualPlayer:
                        MsgData_sSceneObjectEnterVirtualPlayer vpStruct = sceneObj.ObjData as MsgData_sSceneObjectEnterVirtualPlayer;
                        CoreEntry.gSceneLoader.LoadVirtualPlayer(vpStruct);
                        break;
                    default:
                        break;
                }
                
                mSceneCache.RemoveAt(0);

                time += Time.realtimeSinceStartup - lastTime;
            }

            for (int i = 0; i < mDeathCache.Count; i++)
            {
                MsgData_sObjDeadInfo msg = mDeathCache[i];
                ActorObj behitActor = CoreEntry.gActorMgr.GetActorByServerID(msg.ID);
                if (null == behitActor)
                {
                    continue;
                }

                ActorObj attackActor = CoreEntry.gActorMgr.GetActorByServerID(msg.KillerID);

                BehitParam behitParam = new BehitParam();
                DamageParam damageParam = new DamageParam();
                damageParam.attackActor = attackActor;
                damageParam.behitActor = behitActor;
                damageParam.skillID = msg.KillerSkillID;

                behitParam.damgageInfo = damageParam;
                behitActor.OnDead(msg.KillerSkillID, attackActor, behitParam, EventParameter.Get());

                mDeathCache.RemoveAt(i);
                i--;
            }

            for (int i = 0; i < mLeaveCache.Count; i++)
            {
                ActorObj actor = mLeaveCache[i];
                if (null != actor)
                {
                    if (actor.mActorState.IsDeathEnd())
                    {
                        CoreEntry.gActorMgr.RemoveActorByServerID(actor.ServerID);
                        actor.RecycleObj();

                        EventParameter param = EventParameter.Get();
                        param.longParameter = actor.ServerID;
                        CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_ACTOR_REMOVE, param);

                        if (actor is OtherPlayer)
                        {
                            param = EventParameter.Get();
                            param.longParameter = actor.ServerID;
                            CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OTHERPLAYER_LEAVE, param);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                mLeaveCache.RemoveAt(i);
                i--;
            }
        }
Ejemplo n.º 5
0
        private void OnEnterScene(GameEvent ge, EventParameter parameter)
        {
            NetReadBuffer buffer = parameter.objParameter as NetReadBuffer;
            CacheEnterHead.unpack(buffer);
            buffer.pos = 0;     //重新给具体类型的消息读取
            if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_Player)//其它玩家
            {
                MsgData_sSceneObjectEnterHuman humanStruct = new MsgData_sSceneObjectEnterHuman();
                humanStruct.unpack(buffer);

                //队友一定创建
                bool inteam = PlayerData.Instance.TeamData.IsInTeam(humanStruct.Guid);
                int num = inteam ? 0 : (CoreEntry.gActorMgr.GetAllPlayerActors().Count - 1 + GetCacheNumber(EnEntType.EnEntType_Player));
                if (num < CreateMaxPlayer)
                {
                    CacheSceneObj(EnEntType.EnEntType_Player, humanStruct.Guid, humanStruct);
                }
                else
                {
                    ScenePlayerData playerdata = new ScenePlayerData();
                    playerdata.EnterData = humanStruct;
                    if (!mBackgroundPlayer.ContainsKey(playerdata.Guid))
                    {
                        mBackgroundPlayer.Add(playerdata.Guid, playerdata);
                    }
                    else
                    {
                        LogMgr.LogError("玩家已经在缓存中 guid:{0}", playerdata.Guid);
                    }                    
                }                
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_Monster)//怪物
            {
                MsgData_sSceneObjectEnterMonster monsterStruct = new MsgData_sSceneObjectEnterMonster();
                monsterStruct.unpack(buffer);
                if (CoreEntry.gCurrentMapDesc.Get<int>("type") == 31)   //幻灵副本 ,延时刷怪
                {
                    DungeonMgr.Instance.AddMonster(monsterStruct);
                }
                else
                {
                    CacheSceneObj(EnEntType.EnEntType_Monster, monsterStruct.Guid, monsterStruct);
                }
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_NPC)//NPC
            {
                MsgData_sSceneObjectEnterNPC npcStruct = new MsgData_sSceneObjectEnterNPC();
                npcStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_NPC, npcStruct.Guid, npcStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_Item)//物品
            {
                MsgData_sSceneObjectEnterItem itemStruct = new MsgData_sSceneObjectEnterItem();
                itemStruct.unpack(buffer);

                if (itemStruct.Owner == PlayerData.Instance.RoleID)
                {
                    CacheSceneObj(EnEntType.EnEntType_Item, itemStruct.Guid, itemStruct);

                    EventParameter ep = EventParameter.Get();
                    ep.intParameter = itemStruct.ConfigID;
                    ep.intParameter1 = itemStruct.Count;
                    ep.longParameter = itemStruct.Source;
                    CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_ITEM_DROP, ep);
                }                
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_GatherObj)
            {
                MsgData_sSceneObjectEnterCollection collectionStruct = new MsgData_sSceneObjectEnterCollection();
                collectionStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_GatherObj, collectionStruct.Guid, collectionStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_Trap)//陷阱
            {
                MsgData_sSceneObjectEnterTrap trapStruct = new MsgData_sSceneObjectEnterTrap();
                trapStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_Trap, trapStruct.Guid, trapStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_Pet)
            {
                MsgData_sSceneObjectEnterPet petStruct = new MsgData_sSceneObjectEnterPet();
                petStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_Pet, petStruct.Guid, petStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_BiaoChe)
            {
                MsgData_sSceneObjectEnterBiaoChe cheStruct = new MsgData_sSceneObjectEnterBiaoChe();
                cheStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_BiaoChe, cheStruct.Guid, cheStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EnEntType_StaticObj)//Portal
            {
                MsgData_sSceneObjectEnterStaticObj sstaticStruct = new MsgData_sSceneObjectEnterStaticObj();
                sstaticStruct.unpack(buffer);
                CacheSceneObj(EnEntType.EnEntType_StaticObj, sstaticStruct.Guid, sstaticStruct);
            }
            else if (CacheEnterHead.ObjType == (sbyte)EnEntType.EntType_VirtualPlayer)//EntType_VirtualPlayer
            {
                MsgData_sSceneObjectEnterVirtualPlayer sstaticStruct = new MsgData_sSceneObjectEnterVirtualPlayer();
                sstaticStruct.unpack(buffer);
                //Debug.LogError(sstaticStruct.Guid+"   " + sstaticStruct.HP+"  " +sstaticStruct.Level + "  "+sstaticStruct.Power+"  " +sstaticStruct.Wing);
                CacheSceneObj(EnEntType.EntType_VirtualPlayer, sstaticStruct.Guid, sstaticStruct);
            }


            //下方的游戏中还没用到,就不改了,减少被没必要的GC,以后需要可参照上方定义协议数据后使用
            //else if (baseStruct.ObjType == (sbyte)EnEntType.EnEntType_Patrol)
            //{
            //    PatrolEnterStruct patrolStruct = new PatrolEnterStruct();
            //    PacketUtil.Unpack<PatrolEnterStruct>(data.Data, out patrolStruct);
            //}
            //else if (baseStruct.ObjType == (sbyte)EnEntType.EnEntType_Duke)
            //{
            //    DukeEnterStruct dukeStruct = new DukeEnterStruct();
            //    PacketUtil.Unpack<DukeEnterStruct>(data.Data, out dukeStruct);
            //}

            //else if (baseStruct.ObjType == (sbyte)EnEntType.EnEntType_BiaoChe)
            //{
            //    BiaoCheEnterStruct biaocheStruct = new BiaoCheEnterStruct();
            //    PacketUtil.Unpack<BiaoCheEnterStruct>(data.Data, out biaocheStruct);
            //}
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 通过怪物进场数据初始化属性。
 /// </summary>
 /// <param name="es">进场数据。</param>
 public void InitMonsterAttr(MsgData_sSceneObjectEnterMonster mes)
 {
     SetBasicAttrValue((int)BasicAttrEnum.Speed, CommonTools.ServerValueToClient(mes.Speed));
     SetBasicAttrValue((int)BasicAttrEnum.MaxHP, mes.MaxHp);
     SetBasicAttrValue((int)BasicAttrEnum.CurHP, mes.CurHp);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载怪物
        /// </summary>
        /// <param name="monsterStruct"></param>
        /// <returns></returns>
        public GameObject LoadMonster(MsgData_sSceneObjectEnterMonster monsterStruct)
        {
            if (MainPanelMgr.Instance.bInsertStatus)
            {
                return(null);
            }
            LuaTable cfg = ConfigManager.Instance.Actor.GetMonsterConfig(monsterStruct.ConfigID);

            if (null == cfg)
            {
                return(null);
            }

            int      modleid  = cfg.Get <int>("modelId");
            LuaTable modelCfg = ConfigManager.Instance.Common.GetModelConfig(modleid);

            Vector3    position   = CommonTools.ServerPosToClient(monsterStruct.PosX, monsterStruct.PosY);
            Vector3    eulerAngle = CommonTools.ServerDirToClient(monsterStruct.Dir);
            GameObject obj        = CreateGameObject(modleid, position, eulerAngle);

            if (obj == null)
            {
                Object oj = CoreEntry.gResLoader.LoadResource("Animation/monster/mon041_shouchengshibing/mon041_shouchengshibing_pre");
                if (oj != null)
                {
                    obj = (GameObject)Instantiate(oj);
                }
            }

            {
                float s = cfg.Get <float>("scale");
                obj.transform.localScale = new Vector3(s, s, s);
                ParticleScaler[] scalers = obj.GetComponentsInChildren <ParticleScaler>(true);
                for (int i = 0; i < scalers.Length; i++)
                {
                    scalers[i].particleScale = s;
                }

                ActorObj actorObject = null;
                actorObject = obj.GetComponent <ActorObj>();
                if (null != actorObject)
                {
                    Object.DestroyImmediate(actorObject);
                }

                MonsterObj monster = obj.AddComponent <MonsterObj>();
                if (monster != null)
                {
                    monster.Init(modleid, monsterStruct.ConfigID, monsterStruct.Guid);
                    monster.ServerID = monsterStruct.Guid;
                    monster.InitAttr(monsterStruct);
                    monster.mBaseAttr.Name  = cfg.Get <string>("name");
                    monster.mBaseAttr.Level = cfg.Get <int>("level");
                    monster.Faction         = monsterStruct.Faction;
                    CoreEntry.gActorMgr.AddActorObj(monster);
                    StoryTriggerOnBossBorn.CheckRegister();
                }
                else
                {
                    //Debug.LogError("monster null");
                    return(obj);
                }

                EventParameter parameter = EventParameter.Get();
                parameter.goParameter  = obj;
                parameter.objParameter = monster;
                CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_MONSTER_LOADED, parameter);

                return(obj);
            }
        }