예제 #1
0
    protected override void InitAOIData(xc.UnitCacheInfo info)
    {
        base.InitAOIData(info);

        ParentActor = info.ParentActor;
        UpdateBattleAttribute();
    }
예제 #2
0
파일: Pet.cs 프로젝트: wuhuolong/MaxBooks
    protected override void InitAOIData(xc.UnitCacheInfo info)
    {
        base.InitAOIData(info);

        PetId = info.AOIPet.pet_id;

        CreateParam createParam = mCreateParam as CreateParam;

        if (createParam == null)
        {
            return;
        }

        ParentActor = ActorManager.Instance.GetActor(createParam.master);

        if (ParentActor != null)
        {
            mActorAttr.Camp = ParentActor.ActorAttribute.Camp;
        }
        else
        {
            Debug.LogError("Pet's parent is null, UID: " + info.UnitID.obj_idx);
        }


        HPProgressBarIsActive = false;
        UpdateBattleAttribute();
    }
예제 #3
0
 /// <summary>
 /// 角色组件被添加到GameObject之后调用的函数
 /// </summary>
 protected override void InitAOIData(xc.UnitCacheInfo info)
 {
     base.InitAOIData(info);
     // 因为NPC继承自Player因此需要判断UnitType类型
     if (info.UnitType == EUnitType.UNITTYPE_PLAYER && info.AOIPlayer.pet_id != 0)
     {
         CachePetInfo(info.AOIPlayer.pet_id, 0);
     }
 }
예제 #4
0
        public UnitCacheInfo PopUnitCacheData()
        {
            if (mUnitCacheData.Count == 0)
            {
                return(null);
            }
            UnitCacheInfo head = mUnitCacheData.First.Value;

            mUnitCacheData.RemoveFirst();

            mCacheDataMap.Remove(head.UnitID);
            return(head);
        }
예제 #5
0
        /// <summary>
        /// 根据PkgPlayerBrief来初始化AOI数据
        /// </summary>
        public static UnitCacheInfo CreateUnitCacheInfo(PkgPlayerBrief info, Vector3 pos)
        {
            var cache_info = new xc.UnitCacheInfo(EUnitType.UNITTYPE_PLAYER, info.uuid);

            cache_info.CacheType               = xc.UnitCacheInfo.EType.ET_Create;
            cache_info.PosBorn                 = pos;
            cache_info.AOIPlayer.type_idx      = ActorHelper.RoleIdToTypeId(info.rid);
            cache_info.AOIPlayer.name          = System.Text.Encoding.UTF8.GetString(info.name);
            cache_info.AOIPlayer.model_id_list = new List <uint>();
            cache_info.AOIPlayer.fashions      = new List <uint>();
            ActorHelper.GetModelFashionList(info.shows, cache_info.AOIPlayer.model_id_list, cache_info.AOIPlayer.fashions);
            cache_info.AOIPlayer.suit_effects = info.effects;
            cache_info.AOIPlayer.level        = (short)info.level;
            cache_info.AOIPlayer.mount_id     = info.ride;
            cache_info.AOIPlayer.name_color   = info.name_color;
            cache_info.AOIPlayer.state        = info.state;
            cache_info.AOIPlayer.honor_id     = info.honor;
            cache_info.AOIPlayer.title_id     = info.title;
            cache_info.AOIPlayer.transfer_lv  = info.transfer;
            cache_info.AOIPlayer.mate_info    = info.mate;

            if (info.war != null)
            {
                cache_info.AOIPlayer.camp      = info.war.side;
                cache_info.AOIPlayer.team_id   = info.war.team_id;
                cache_info.AOIPlayer.pet_id    = info.war.pet_skin; //宠物皮肤
                cache_info.AOIPlayer.escort_id = info.war.escort_id;
            }
            else
            {
                cache_info.AOIPlayer.camp      = 0;
                cache_info.AOIPlayer.team_id   = 0;
                cache_info.AOIPlayer.pet_id    = 0;
                cache_info.AOIPlayer.escort_id = 0;
            }
            if (info.guild != null)
            {
                cache_info.AOIPlayer.guild_id   = info.guild.guild_id;
                cache_info.AOIPlayer.guild_name = System.Text.Encoding.UTF8.GetString(info.guild.guild_name);
            }
            else
            {
                cache_info.AOIPlayer.guild_id   = 0;
                cache_info.AOIPlayer.guild_name = "";
            }

            return(cache_info);
        }
예제 #6
0
        /// <summary>
        /// 根据宠物信息创建UnitCacheInfo
        /// </summary>
        /// <param name="pet_uid"></param>
        /// <param name="pet_id"></param>
        /// <param name="actor_id"></param>
        /// <param name="pos"></param>
        /// <param name="rot"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static UnitCacheInfo CreatePetUnitCacheInfo(uint pet_uid, uint pet_id, uint actor_id, Vector3 pos, Quaternion rot, Actor parent)
        {
            var unit_cache_info = new xc.UnitCacheInfo(EUnitType.UNITTYPE_PET, pet_uid);

            unit_cache_info.CacheType       = xc.UnitCacheInfo.EType.ET_Create;
            unit_cache_info.PosBorn         = pos;
            unit_cache_info.Rotation        = rot;
            unit_cache_info.AOIPet.pet_id   = pet_id;
            unit_cache_info.AOIPet.type_idx = actor_id;
            if (parent != null)
            {
                unit_cache_info.AOIPet.is_local = (parent.UID.Equals(Game.GetInstance().LocalPlayerID));
            }
            unit_cache_info.ParentActor = parent;

            return(unit_cache_info);
        }
예제 #7
0
    protected override void InitAOIData(xc.UnitCacheInfo info)
    {
        base.InitAOIData(info);

        if (ActorManager.Instance.MonsterSet.ContainsKey(info.UnitID) == false)
        {
            if (!(this is Pet))
            {
                ActorManager.Instance.MonsterSet.Add(info.UnitID, this);
            }
            else
            {
                ActorManager.Instance.PetSet.Add(info.UnitID, this);
            }
        }
        else
        {
            GameDebug.LogError("MonsterSet has conflict key " + info.UnitID.obj_idx);
        }
    }
예제 #8
0
        /// <summary>
        /// 根据PkgMonBrief来初始化AOI数据
        /// </summary>
        /// <param name="info"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public static UnitCacheInfo CreateUnitCacheInfo(PkgMonBrief info, Vector3 pos)
        {
            var unit_cache_info = new xc.UnitCacheInfo(EUnitType.UNITTYPE_MONSTER, info.uuid);

            unit_cache_info.CacheType           = xc.UnitCacheInfo.EType.ET_Create;
            unit_cache_info.PosBorn             = pos;
            unit_cache_info.AOIMonster.type_idx = info.actor_id;
            unit_cache_info.AOIMonster.camp     = info.side;
            unit_cache_info.AOIMonster.level    = info.lv;
            Actor parent = ActorManager.Instance.GetPlayer(info.father_id);

            unit_cache_info.ParentActor  = parent;
            unit_cache_info.AttrElements = info.attr_elm;

            Neptune.MonsterBase monster = Neptune.DataManager.Instance.Data.GetNode <Neptune.MonsterBase>((int)(info.group_id));
            if (monster != null)
            {
                unit_cache_info.Rotation = monster.Rotation;
            }

            return(unit_cache_info);
        }
예제 #9
0
        public void UpdateUnitCache(bool doAll, UnitCacheDataFilter filter)
        {
            const int MAX_PROCESS_UNIT_PER_FRAME = 3;

            for (int i = 0; mUnitCacheData.Count != 0; ++i)
            {
                if (!doAll)
                {
                    if (i >= MAX_PROCESS_UNIT_PER_FRAME)
                    {
                        break;
                    }
                }

                UnitCacheInfo info = PopUnitCacheData();

                if (info == null)
                {
                    continue;
                }

                if (info.UnitType != EUnitType.UNITTYPE_PLAYER && info.UnitType != EUnitType.UNITTYPE_NPC &&
                    info.UnitType != EUnitType.UNITTYPE_MONSTER && info.UnitType != EUnitType.UNITTYPE_PET)
                {
                    continue;
                }

                if (filter != null && !filter(info))
                {
                    continue;
                }

                Actor actor = null;
                if (info.CacheType == UnitCacheInfo.EType.ET_Create)
                {
                    float rawY = info.PosBorn.y;
                    info.PosBorn = PhysicsHelp.GetPosition(info.PosBorn.x, info.PosBorn.z);
                    if (info.UnitType == EUnitType.UNITTYPE_PLAYER)
                    {
                        if (info.UnitID.Equals(mGame.LocalPlayerID))// 创建本地玩家
                        {
                            actor = mGame.GetLocalPlayer();
                            if (actor == null)
                            {
                                var vocation = (Actor.EVocationType)ActorHelper.TypeIdToRoleId(info.AOIPlayer.type_idx);
                                info.AOIPlayer.model_id_list = ReplaceModelList(info.AOIPlayer.model_id_list, vocation, false);
                                actor = ActorManager.Instance.CreateActor <LocalPlayer>(info, info.Rotation, null);
                                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCALPLAYER_CREATE, new CEventBaseArgs(actor));
                            }
                        }
                        else// 创建其他玩家
                        {
                            if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                            {
                                GameDebug.Log(string.Format("Player(ID: {0}) has been created.", info.UnitID.obj_idx));
                                continue;
                            }

                            actor = ActorManager.Instance.CreateActor <RemotePlayer>(info, info.Rotation, null);

                            // FIXME 创建本地玩家的时候也会发送该消息
                            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_REMOTEPLAYER_CREATE, new CEventBaseArgs(actor));
                        }
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_NPC)
                    {
                        actor = ActorManager.Instance.CreateActor <NpcPlayer>(info, info.ClientNpc.Rotation, null);
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_MONSTER)
                    {
                        if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                        {
                            GameDebug.LogError(string.Format("Monster(ID: {0}) has been created.", info.UnitID.obj_idx));
                            continue;
                        }
                        Monster.CreateParam createParam = new Monster.CreateParam();
                        createParam.is_pet = false;
                        if (ActorHelper.IsSummon(info.UnitID.obj_idx))
                        {
                            createParam.summon     = true;
                            createParam.summonType = Monster.MonsterType.SummonRemoteMonster;
                            if (info.ParentActor != null)
                            {
                                createParam.master = info.ParentActor.UID;
                                // 判断是不是本地召唤怪
                                if (createParam.master.Equals(Game.Instance.LocalPlayerID) == true)
                                {
                                    createParam.summonType = Monster.MonsterType.SummonLocalMonster;
                                }
                            }
                        }
                        var obj = ActorManager.Instance.CreateActor <Monster>(info, info.Rotation, createParam);
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_PET)
                    {
                        if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                        {
                            GameDebug.LogError(string.Format("Pet(ID: {0}) has been created.", info.UnitID.obj_idx));
                            continue;
                        }

                        Monster.CreateParam createParam = new Monster.CreateParam();
                        createParam.is_pet = true;
                        createParam.summon = false;
                        if (info.ParentActor != null)
                        {
                            createParam.master = info.ParentActor.UID;
                        }

                        if (info.AOIPet.is_local)
                        {
                            ActorManager.Instance.CreateActor <LocalPet>(info, info.Rotation, createParam);
                        }
                        else
                        {
                            ActorManager.Instance.CreateActor <RemotePet>(info, info.Rotation, createParam);
                        }
                    }
                }
                else if (info.CacheType == UnitCacheInfo.EType.ET_Destroy)
                {
                    ActorManager.Instance.DestroyActor(info.UnitID, 0);
                }
                else
                {
                    GameDebug.LogError("Error Cache data!");
                }
            }
        }
예제 #10
0
 public void PushUnitCacheData(UnitCacheInfo data)
 {
     mUnitCacheData.AddLast(data);
     mCacheDataMap[data.UnitID] = data;
 }
예제 #11
0
    protected override void InitAOIData(xc.UnitCacheInfo info)
    {
        base.InitAOIData(info);

        ActorManager.Instance.PlayerSet [info.UnitID] = this;
    }
예제 #12
0
    /// <summary>
    /// 在创建怪物后的处理
    /// </summary>
    private void OnCreateSummonMonster(xc.UnitCacheInfo info, CreateParam param)
    {
        Actor master = ActorManager.Instance.GetActor(param.master);

        if (param.summonByMonster)
        {
            BeSummonedType = Monster.BeSummonType.BE_SUMMON_BY_MONSTER;
        }
        else
        {
            if (master is LocalPlayer)
            {
                BeSummonedType = Monster.BeSummonType.BE_SUMMON_BY_PLAYER;
            }
            else
            {
                BeSummonedType = Monster.BeSummonType.BE_SUMMON_BY_ROBOT;
            }
        }

        // 初始化怪物的各种数据
        if (master != null)
        {
            Camp = master.Camp;
        }
        else
        {
            Camp = info.AOIMonster.camp;
        }

        SetMonsterType(param.summonType);
        if (param.summonType == Monster.MonsterType.SummonRemoteMonster)
        {
            ActiveAI(false);
        }
        else
        {
            ActiveAI(true);
        }

        if (param.summonByMonster)
        {
            CenterSpawnPos = info.PosBorn;
        }

        if (BeSummonedType == BeSummonType.BE_SUMMON_BY_MONSTER)
        {
            if (!ActorManager.Instance.CalledMonsterSet.ContainsKey(info.UnitID))
            {
                ActorManager.Instance.CalledMonsterSet.Add(info.UnitID, this);
            }
        }
        else if (this is Pet)
        {
        }
        else
        {
            if (!ActorManager.Instance.SummonMonsterSet.ContainsKey(info.UnitID))
            {
                ActorManager.Instance.SummonMonsterSet.Add(info.UnitID, this);
            }
        }

        if (param.summonType == Monster.MonsterType.LocalMonster)
        {
            // 定时销毁召唤怪

            /*DelayTimeComponent delayTime = GetModel().AddComponent<DelayTimeComponent>();
             * delayTime.DelayTime = param.time;
             * delayTime.SetEndCallBack(new DelayDestroyComponent.EndCallBackInfo(OnSummonMonsterDisappear, info.UnitID));
             * if(!param.summonByMonster)
             *  // 显示血条
             *  HPProgressBarIsActive = true;*/
        }

        // 设置sonActor
        if (master != null)
        {
            master.AddSonActor(this);
        }

        ParentActor = master;


        if (param.summonType == MonsterType.SummonRemoteMonster)
        {
            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_REMOTEMONSTERCREATEED, new CEventBaseArgs(this));
        }
        else
        {
            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCALMONSTERCREATEED, new CEventBaseArgs(this));
        }

        // 添加CE_MONSTERCREATEED消息通知Lua,避免Monster类对象的传递
        ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MONSTERCREATEED, new CEventObjectArgs(this.UID.obj_idx, this.TypeIdx));
    }