Exemple #1
0
    public static void CreateStoryLineNpcFromID(int npcID, Vector3 position)
    {
        Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("NPC");
        NpcMissionDataRepository.Reset();
        while (reader.Read())
        {
            int id      = Convert.ToInt32(reader.GetString(reader.GetOrdinal("NPC_ID")));
            int protoId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("PrototypeNPC")));

            if (id == npcID)
            {
                PeEntity entity = PeCreature.Instance.CreateNpc(id, protoId, Vector3.zero, Quaternion.identity, Vector3.one);
                if (entity == null)
                {
                    continue;
                }

                InitNpcWithDb(entity, reader);
                NpcMissionData nmd = NpcMissionDataRepository.GetMissionData(entity.Id);
                entity.SetUserData(nmd);
                SetNpcShopIcon(entity);

                entity.position = position;
                break;
            }
        }
    }
    void Import(byte[] buffer)
    {
        MemoryStream ms  = new MemoryStream(buffer);
        BinaryReader _in = new BinaryReader(ms);

        /*int readVersion = */ _in.ReadInt32();
        int count = _in.ReadInt32();

        for (int i = 0; i < count; i++)
        {
            mActivelist.Add(_in.ReadInt32());
        }

        count = _in.ReadInt32();
        for (int i = 0; i < count; i++)
        {
            NpcMissionData data  = new NpcMissionData();
            int            npcid = _in.ReadInt32();

            if (npcid == -1)
            {
                continue;
            }

            data.m_Rnpc_ID              = _in.ReadInt32();
            data.m_QCID                 = _in.ReadInt32();
            data.m_CurMissionGroup      = _in.ReadInt32();
            data.m_CurGroupTimes        = _in.ReadInt32();
            data.mCurComMisNum          = _in.ReadByte();
            data.mCompletedMissionCount = _in.ReadInt32();
            data.m_RandomMission        = _in.ReadInt32();
            data.m_RecruitMissionNum    = _in.ReadInt32();

            int num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionList.Add(_in.ReadInt32());
            }

            num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionListReply.Add(_in.ReadInt32());
            }

            mNpcList.Add(npcid);
            NpcMissionDataRepository.AddMissionData(npcid, data);
        }

        _in.Close();
        ms.Close();
    }
Exemple #3
0
    //to judge if a building is rendered
    //public bool IsRendered(BuildingID buildingNo)
    //{
    //    if (renderManager.ContainsKey(buildingNo))
    //        return renderManager[buildingNo];
    //    else
    //        return true;
    //}


    public void Export(BinaryWriter bw)
    {
        bw.Write(createdNpcIdList.Count);
        for (int i = 0; i < createdNpcIdList.Count; i++)
        {
            BuildingNpcIdStand ite = createdNpcIdList [i];
            int            npcid   = ite.npcId;
            NpcMissionData data    = NpcMissionDataRepository.GetMissionData(npcid);
            if (data == null)
            {
                bw.Write(-1);
            }
            else
            {
                bw.Write(npcid);
                bw.Write(data.m_Rnpc_ID);
                bw.Write(data.m_QCID);
                bw.Write(data.m_CurMissionGroup);
                bw.Write(data.m_CurGroupTimes);
                bw.Write(data.mCurComMisNum);
                bw.Write(data.mCompletedMissionCount);
                bw.Write(data.m_RandomMission);
                bw.Write(data.m_RecruitMissionNum);
                bw.Write(data.m_MissionList.Count);
                for (int m = 0; m < data.m_MissionList.Count; m++)
                {
                    bw.Write(data.m_MissionList [m]);
                }
                bw.Write(data.m_MissionListReply.Count);
                for (int m = 0; m < data.m_MissionListReply.Count; m++)
                {
                    bw.Write(data.m_MissionListReply [m]);
                }
                bw.Write(ite.isStand);
                bw.Write(ite.rotY);
            }
        }

        bw.Write(mCreatedNpcBuildingID.Count);
        foreach (BuildingID b in mCreatedNpcBuildingID.Keys)
        {
            bw.Write(b.townId);
            bw.Write(b.buildingNo);
        }
    }
Exemple #4
0
    public static void LoadData()
    {
        Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("NPCMission");

        while (reader.Read())
        {
            NpcMissionData missionData = new NpcMissionData();
            int            id          = System.Convert.ToInt32(reader.GetString(reader.GetOrdinal("NPC_ID")));

            string   strTemp     = reader.GetString(reader.GetOrdinal("missionlist"));
            string[] missionlist = strTemp.Split(',');
            for (int i = 0; i < missionlist.Length; i++)
            {
                if (missionlist[i] != "0")
                {
                    missionData.m_MissionList.Add(System.Convert.ToInt32(missionlist[i]));
                }
            }

            strTemp = reader.GetString(reader.GetOrdinal("missionlistreply"));
            string[] missionlistreply = strTemp.Split(',');
            for (int i = 0; i < missionlistreply.Length; i++)
            {
                if (missionlistreply[i] != "0")
                {
                    missionData.AddMissionListReply(System.Convert.ToInt32(missionlistreply[i]));
                }
            }

            strTemp     = reader.GetString(reader.GetOrdinal("Colony_RecruitMissionID"));
            missionlist = strTemp.Split(',');
            for (int i = 0; i < missionlist.Length; i++)
            {
                if (missionlist[i] != "0")
                {
                    missionData.m_CSRecruitMissionList.Add(Convert.ToInt32(missionlist[i]));
                }
            }

            NpcMissionDataRepository.AddMissionData(id, missionData);
        }

        LoadNpcRandomMissionData();
        LoadAdRandMisNpcData();
    }
    //public VATownNpcInfo GetNpcInfoByPos(IntVector2 posXZ)
    //{
    //    if (!npcInfoMap.ContainsKey(posXZ))
    //    {
    //        return null;
    //    }

    //    return npcInfoMap[posXZ];
    //}

    public void Export(BinaryWriter bw)
    {
        bw.Write(createdNpcIdList.Count);
        for (int i = 0; i < createdNpcIdList.Count; i++)
        {
            int            npcid = createdNpcIdList [i];
            NpcMissionData data  = NpcMissionDataRepository.GetMissionData(npcid);
            if (data == null)
            {
                bw.Write(-1);
            }
            else
            {
                bw.Write(npcid);
                bw.Write(data.m_Rnpc_ID);
                bw.Write(data.m_QCID);
                bw.Write(data.m_CurMissionGroup);
                bw.Write(data.m_CurGroupTimes);
                bw.Write(data.mCurComMisNum);
                bw.Write(data.mCompletedMissionCount);
                bw.Write(data.m_RandomMission);
                bw.Write(data.m_RecruitMissionNum);
                bw.Write(data.m_MissionList.Count);
                for (int m = 0; m < data.m_MissionList.Count; m++)
                {
                    bw.Write(data.m_MissionList [m]);
                }
                bw.Write(data.m_MissionListReply.Count);
                for (int m = 0; m < data.m_MissionListReply.Count; m++)
                {
                    bw.Write(data.m_MissionListReply [m]);
                }
            }
        }

        bw.Write(createdPosList.Count);
        for (int i = 0; i < createdPosList.Count; i++)
        {
            IntVector2 posXZ = createdPosList [i];
            bw.Write(posXZ.x);
            bw.Write(posXZ.y);
        }
    }
    public void Export(BinaryWriter bw)
    {
        bw.Write(Version);
        bw.Write(mActivelist.Count);
        for (int i = 0; i < mActivelist.Count; i++)
        {
            bw.Write((int)mActivelist [i]);
        }

        bw.Write(mNpcList.Count);
        for (int i = 0; i < mNpcList.Count; i++)
        {
            NpcMissionData data = NpcMissionDataRepository.GetMissionData(mNpcList[i]);
            if (data == null)
            {
                bw.Write(-1);
            }
            else
            {
                bw.Write(mNpcList[i]);
                bw.Write(data.m_Rnpc_ID);
                bw.Write(data.m_QCID);
                bw.Write(data.m_CurMissionGroup);
                bw.Write(data.m_CurGroupTimes);
                bw.Write(data.mCurComMisNum);
                bw.Write(data.mCompletedMissionCount);
                bw.Write(data.m_RandomMission);
                bw.Write(data.m_RecruitMissionNum);

                bw.Write(data.m_MissionList.Count);
                for (int m = 0; m < data.m_MissionList.Count; m++)
                {
                    bw.Write(data.m_MissionList[m]);
                }

                bw.Write(data.m_MissionListReply.Count);
                for (int m = 0; m < data.m_MissionListReply.Count; m++)
                {
                    bw.Write(data.m_MissionListReply[m]);
                }
            }
        }
    }
Exemple #7
0
    public static void CreateStoryLineNpc()
    {
        Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("NPC");
        NpcMissionDataRepository.Reset();
        while (reader.Read())
        {
            int id      = Convert.ToInt32(reader.GetString(reader.GetOrdinal("NPC_ID")));
            int protoId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("PrototypeNPC")));
            if (PeGameMgr.IsMultiStory)
            {
                return;
                //				string strTemp = reader.GetString(reader.GetOrdinal("startpoint"));
                //				string[] pos = strTemp.Split(',');
                //				if (pos.Length < 3)
                //				{
                //					Debug.LogError("Npc's StartPoint is Error");
                //				}
                //				else
                //				{
                //					float x = System.Convert.ToSingle(pos[0]);
                //					float y = System.Convert.ToSingle(pos[1]);
                //					float z = System.Convert.ToSingle(pos[2]);
                //					Vector3 startPos = new Vector3(x, y, z);
                //					PlayerNetwork.MainPlayer.RequestCreateStNpc(id, startPos,protoId);
                //				}
                //				continue;
            }
            PeEntity entity = PeCreature.Instance.CreateNpc(id, protoId, Vector3.zero, Quaternion.identity, Vector3.one);
            if (entity == null)
            {
                continue;
            }

            InitNpcWithDb(entity, reader);
            NpcMissionData nmd = NpcMissionDataRepository.GetMissionData(entity.Id);
            entity.SetUserData(nmd);
            SetNpcShopIcon(entity);
        }
    }
Exemple #8
0
    public static void CreateTutorialLineNpc()
    {
        Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("NPC");
        while (reader.Read())
        {
            int    id      = Convert.ToInt32(reader.GetString(reader.GetOrdinal("NPC_ID")));
            int    protoId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("PrototypeNPC")));
            string strTemp = reader.GetString(reader.GetOrdinal("training_pos"));

            if (strTemp != "0,0,0")
            {
                string[] strPos = strTemp.Split(',');
                Vector3  pos    = Vector3.zero;
                if (strPos.Length < 3)
                {
                    Debug.LogError("Npc's StartPoint is Error at NPC_ID=" + id);
                }
                else
                {
                    pos.x = System.Convert.ToSingle(strPos[0]);
                    pos.y = System.Convert.ToSingle(strPos[1]);
                    pos.z = System.Convert.ToSingle(strPos[2]);
                }
                PeEntity entity = PeCreature.Instance.CreateNpc(id, protoId, pos, Quaternion.identity, Vector3.one);
                if (entity == null)
                {
                    continue;
                }

                SetNpcMoney(entity, reader.GetString(reader.GetOrdinal("money")));
                AddWeaponItem(entity, reader.GetString(reader.GetOrdinal("weapon")), reader.GetString(reader.GetOrdinal("item")));
                SetNpcAbility(entity, reader.GetString(reader.GetOrdinal("speciality")));
                NpcMissionData nmd = NpcMissionDataRepository.GetMissionData(entity.Id);
                entity.SetUserData(nmd);
                SetNpcShopIcon(entity);
            }
        }
    }
 public int GetEnemyNpcId(int id)
 {
     return(NpcMissionDataRepository.GetRNpcId(id) + AllyConstants.EnemyNpcIdAddNum);
 }
    public void Import(byte[] buffer)
    {
        LogManager.Info("TownNpcManager.Instance.Import()");
        Clear();
        if (buffer.Length == 0)
        {
            return;
        }

        MemoryStream ms  = new MemoryStream(buffer);
        BinaryReader _in = new BinaryReader(ms);

        int iSize = _in.ReadInt32();

        for (int i = 0; i < iSize; i++)
        {
            NpcMissionData data  = new NpcMissionData();
            int            npcid = _in.ReadInt32();

            if (npcid == -1)
            {
                continue;
            }

            data.m_Rnpc_ID              = _in.ReadInt32();
            data.m_QCID                 = _in.ReadInt32();
            data.m_CurMissionGroup      = _in.ReadInt32();
            data.m_CurGroupTimes        = _in.ReadInt32();
            data.mCurComMisNum          = _in.ReadByte();
            data.mCompletedMissionCount = _in.ReadInt32();
            data.m_RandomMission        = _in.ReadInt32();
            data.m_RecruitMissionNum    = _in.ReadInt32();

            int num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionList.Add(_in.ReadInt32());
            }

            num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionListReply.Add(_in.ReadInt32());
            }

            createdNpcIdList.Add(npcid);
            NpcMissionDataRepository.AddMissionData(npcid, data);
        }

        iSize = _in.ReadInt32();
        for (int i = 0; i < iSize; i++)
        {
            int x = _in.ReadInt32();
            int z = _in.ReadInt32();
            createdPosList.Add(new IntVector2(x, z));
        }


        _in.Close();
        ms.Close();
    }
Exemple #11
0
    public void Import(byte[] buffer)
    {
        //LogManager.Error("BuildingInfoManager.Instance.Import()");
        Clear();
        if (buffer.Length == 0)
        {
            return;
        }

        MemoryStream ms  = new MemoryStream(buffer);
        BinaryReader _in = new BinaryReader(ms);

        int iSize = _in.ReadInt32();

        for (int i = 0; i < iSize; i++)
        {
            NpcMissionData data  = new NpcMissionData();
            int            npcid = _in.ReadInt32();

            if (npcid == -1)
            {
                continue;
            }

            data.m_Rnpc_ID              = _in.ReadInt32();
            data.m_QCID                 = _in.ReadInt32();
            data.m_CurMissionGroup      = _in.ReadInt32();
            data.m_CurGroupTimes        = _in.ReadInt32();
            data.mCurComMisNum          = _in.ReadByte();
            data.mCompletedMissionCount = _in.ReadInt32();
            data.m_RandomMission        = _in.ReadInt32();
            data.m_RecruitMissionNum    = _in.ReadInt32();

            int num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionList.Add(_in.ReadInt32());
            }

            num = _in.ReadInt32();
            for (int j = 0; j < num; j++)
            {
                data.m_MissionListReply.Add(_in.ReadInt32());
            }

            bool  isStand = _in.ReadBoolean();
            float rotY    = _in.ReadSingle();
            createdNpcIdList.Add(new BuildingNpcIdStand(npcid, isStand, rotY));
            NpcMissionDataRepository.AddMissionData(npcid, data);
        }

        iSize = _in.ReadInt32();
        for (int i = 0; i < iSize; i++)
        {
            BuildingID no = new BuildingID();
            no.townId     = _in.ReadInt32();
            no.buildingNo = _in.ReadInt32();
            mCreatedNpcBuildingID.Add(no, 0);
        }


        _in.Close();
        ms.Close();
        //loadRecord = LOADMARK;
    }
    public static void LoadAllData()
    {
        if (s_localDatabase != null)
        {
            return;
        }

#if UNITY_EDITOR
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
        sw.Start();
#endif
        s_localDatabase = LoadDb();
        SkillSystem.SkData.LoadData();
        Pathea.Effect.EffectData.LoadData();
        Pathea.Projectile.ProjectileData.LoadData();
        Pathea.RequestRelation.LoadData();
        Pathea.CampData.LoadData();
        Pathea.ThreatData.LoadData();
        Pathea.DamageData.LoadData();
        HumanSoundData.LoadData();
        ItemDropData.LoadData();

        PELocalization.LoadData();

        NaturalResAsset.NaturalRes.LoadData();
        //SkillAsset.EffCastData.LoadData();
        //SkillAsset.EffSkill.LoadData();
        //SkillAsset.MergeSkill.LoadData();
        //AnimData.LoadData();
        //AnimSoundData.LoadData();

        AiAsset.AiData.LoadData();

        SoundAsset.SESoundBuff.LoadData();
        SoundAsset.SESoundStory.LoadData();
        //CharacterData.LoadCharacterData();
        StoryDoodadMap.LoadData();
        StoreRepository.LoadData();
        NpcMissionDataRepository.LoadData();
        //PlayerAttribute.LoadData();
        MissionRepository.LoadData();
        TalkRespository.LoadData();
        //NpcRandomRepository.LoadData();
        ShopRespository.LoadData();
        WareHouseManager.LoadData();
        //HeroTalkRepository.LoadData();
        MutiPlayRandRespository.LoadData();
        PromptRepository.LoadData();

        //MapIconData.LoadDate();
        //MapMaskData.LoadDate();
        CampPatrolData.LoadDate();
        Camp.LoadData();
        RepProcessor.LoadData();

        CloudManager.LoadData();
        //BattleUnitData.LoadData();
        TutorialData.LoadData();
        //RepairMachineManager.LoadData();
        MapMaskData.LoadDate();
        MessageData.LoadData();         //lz-2016.07.13 Add it
        MonsterHandbookData.LoadData(); //lz-2016.07.20 Add it
        StoryRepository.LoadData();
        RMRepository.LoadRandMission();
        MisInitRepository.LoadData();
        CameraRepository.LoadCameraPlot();
        AdRMRepository.LoadData();
        VCConfig.InitConfig();
        Cutscene.LoadData();

//		BuildBrushData.LoadBrush();
        BSPattern.LoadBrush();
        BSVoxelMatMap.Load();
        BSBlockMatMap.Load();
        BlockBuilding.LoadBuilding();
        LifeFormRule.LoadData();
        PlantInfo.LoadData();
        MetalScanData.LoadData();
        BattleConstData.LoadData();
        CustomCharactor.CustomMetaData.LoadData();
        SkillTreeInfo.LoadData();
        VArtifactUtil.LoadData();
        Pathea.ActionRelationData.LoadActionRelation();

        //colony
        CSInfoMgr.LoadData();
        ProcessingObjInfo.LoadData();
        CSTradeInfoData.LoadData();
        CampTradeIdData.LoadData();
        AbnormalTypeTreatData.LoadData();
        CSMedicineSupport.LoadData();
        //RandomItemMgr
        RandomItemDataMgr.LoadData();
        FecesData.LoadData();
        //randomdungeon
        RandomDungeonDataBase.LoadData();
        AbnormalData.LoadData();
        PEAbnormalNoticeData.LoadData();

        RelationInfo.LoadData();
        EquipSetData.LoadData();
        SuitSetData.LoadData();

        CheatData.LoadData();

        Pathea.NpcProtoDb.Load();
        Pathea.MonsterProtoDb.Load();
        Pathea.MonsterRandomDb.Load();
        Pathea.MonsterGroupProtoDb.Load();
        Pathea.RandomNpcDb.Load();
        Pathea.PlayerProtoDb.Load();
        Pathea.TowerProtoDb.Load();
        Pathea.DoodadProtoDb.Load();
        Pathea.AttPlusNPCData.Load();
        Pathea.AttPlusBuffDb.Load();
        Pathea.NpcTypeDb.Load();
        Pathea.NpcRandomTalkDb.Load();
        Pathea.NpcThinkDb.LoadData();
        Pathea.NpcEatDb.LoadData();
        Pathea.NpcRobotDb.Load();
        Pathea.NPCScheduleData.Load();
        Pathea.NpcVoiceDb.LoadData();
        InGameAidData.LoadData(); //lz-2016.08.21 add it
        MountsSkillDb.LoadData();

#if UNITY_EDITOR
        sw.Stop();
        Debug.Log("Database Loaded : " + sw.ElapsedMilliseconds);
        sw.Reset();
#else
        Debug.Log("Database Loaded");
#endif
    }
    public static void Import(byte[] buffer)
    {
        if (buffer.Length == 0)
        {
            return;
        }

        MemoryStream ms  = new MemoryStream(buffer);
        BinaryReader _in = new BinaryReader(ms);

        int iSize = _in.ReadInt32();
        int count = 0;

        for (int k = 0; k < iSize; k++)
        {
            int id = _in.ReadInt32();
            if (!m_RandMisMap.ContainsKey(id))
            {
                return;
            }

            MissionCommonData data = m_RandMisMap[id];
            if (data == null)
            {
                continue;
            }

            data.m_TargetIDList.Clear();
            data.m_TalkOP.Clear();
            data.m_TalkIN.Clear();
            data.m_TalkED.Clear();
            data.m_PromptOP.Clear();
            data.m_PromptIN.Clear();
            data.m_PromptED.Clear();
            data.m_Com_RewardItem.Clear();
            data.m_Com_RemoveItem.Clear();

            //lz-2016.08.17 因为开始存储的不是映射,这里读到的数据是上一次语言的数据,所以不对,原本的数据是对的,不用修改
            _in.ReadString();
            //data.m_MissionName = _in.ReadString();

            data.m_iNpc      = _in.ReadInt32();
            data.m_iReplyNpc = _in.ReadInt32();
            NpcMissionDataRepository.AddReplyMission(data.m_iReplyNpc, id);
            data.m_Type   = (MissionType)_in.ReadInt32();
            data.m_MaxNum = _in.ReadInt32();

            //lz-2016.08.17 因为开始存储的不是映射,这里读到的数据是上一次语言的数据,所以不对,原本的数据是对的,不用修改
            _in.ReadString();
            //data.m_Description = _in.ReadString();

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                data.m_TargetIDList.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                data.m_PlayerTalk[i] = Convert.ToInt32(_in.ReadInt32());
            }

            MissionIDNum idnum;
            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Get_DemandItem.Add(idnum);
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Get_DeleteItem.Add(idnum);
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Get_MissionItem.Add(idnum);
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Com_RewardItem.Add(idnum);
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Com_SelRewardItem.Add(idnum);
            }

            count = _in.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                idnum.id  = Convert.ToInt32(_in.ReadInt32());
                idnum.num = Convert.ToInt32(_in.ReadInt32());
                data.m_Com_RemoveItem.Add(idnum);
            }

            count = _in.ReadInt32();
            data.m_TalkOP.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_TalkOP.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            data.m_OPID.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_OPID.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            data.m_TalkIN.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_TalkIN.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            data.m_INID.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_INID.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            data.m_TalkED.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_TalkED.Add(Convert.ToInt32(_in.ReadInt32()));
            }

            count = _in.ReadInt32();
            data.m_EDID.Clear();
            for (int i = 0; i < count; i++)
            {
                data.m_EDID.Add(Convert.ToInt32(_in.ReadInt32()));
            }
        }

        _in.Close();
        ms.Close();
    }
Exemple #14
0
    public static void CreateNpc(SceneEntityPosAgent agent)
    {
        agent.entity = null;
        if (agent.protoId < 0)
        {
            List <int> adnpcList = NpcMissionDataRepository.GetAdRandListByWild(1);
            int        idx       = UnityEngine.Random.Range(0, adnpcList.Count);
            agent.protoId = adnpcList[idx];
        }

        AdNpcData data = NpcMissionDataRepository.GetAdNpcData(agent.protoId);

        if (data == null)
        {
            return;
        }

        if (NetworkInterface.IsClient && !PeGameMgr.IsMultiStory)
        {
            if (agent.protoId > 100)
            {
                NetworkManager.WaitCoroutine(PlayerNetwork.RequestCreateAdNpc(agent.protoId, agent.Pos));
            }
            else
            {
                NetworkManager.WaitCoroutine(PlayerNetwork.RequestCreateAdMainNpc(agent.protoId, agent.Pos));
            }
            return;
        }
        int id = WorldInfoMgr.Instance.FetchRecordAutoId();

//		agent.entity = PeCreature.Instance.CreateRandomNpc(data.mRnpc_ID, data.mID, agent.Pos, agent.Rot, agent.Scl);
        agent.entity = PeCreature.Instance.CreateRandomNpc(data.mRnpc_ID, id, agent.Pos, agent.Rot, agent.Scl);
        if (null == agent.entity)
        {
            Debug.LogError("[SceneEntityCreator]Failed to create npc:" + agent.protoId);
            return;
        }
        if (MissionManager.Instance && agent.protoId < 100 && !MissionManager.Instance.m_PlayerMission.adId_entityId.ContainsKey(agent.protoId))
        {
            MissionManager.Instance.m_PlayerMission.adId_entityId[agent.protoId] = agent.entity.Id;
        }

        agent.entity.SetBirthPos(agent.Pos);//delete npc need

        NpcMissionData useData = new NpcMissionData();

        useData.m_bRandomNpc = true;
        useData.m_Rnpc_ID    = data.mRnpc_ID;
        useData.m_QCID       = data.mQC_ID;
        int misid = AdRMRepository.GetRandomMission(useData.m_QCID, useData.m_CurMissionGroup);

        if (misid != 0)
        {
            useData.m_RandomMission = misid;
        }
        for (int i = 0; i < data.m_CSRecruitMissionList.Count; i++)
        {
            useData.m_CSRecruitMissionList.Add(data.m_CSRecruitMissionList[i]);
        }
        NpcMissionDataRepository.AddMissionData(agent.entity.Id, useData);
        agent.entity.SetUserData(useData);
        return;
    }
Exemple #15
0
    static void LoadNpcRandomMissionData()
    {
        Mono.Data.SqliteClient.SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("RandNPCMission");
        while (reader.Read())
        {
            NpcMissionData missionData = new NpcMissionData();
            missionData.mCurComMisNum = 0;

            int id = Convert.ToInt32(reader.GetString(reader.GetOrdinal("ID")));
            missionData.m_Rnpc_ID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("RNPC_ID")));

            string   tmp;
            string[] tmplist;


            tmp     = reader.GetString(reader.GetOrdinal("natalplace"));
            tmplist = tmp.Split(',');
            if (tmplist.Length == 3)
            {
                float x = Convert.ToSingle(tmplist[0]);
                float y = Convert.ToSingle(tmplist[1]);
                float z = Convert.ToSingle(tmplist[2]);
                missionData.m_Pos = new Vector3(x, y, z);
            }

            tmp = reader.GetString(reader.GetOrdinal("Rmissionlist"));
            if (tmp != "0")
            {
                missionData.m_RandomMission = Convert.ToInt32(tmp);
            }

            tmp     = reader.GetString(reader.GetOrdinal("missionlist"));
            tmplist = tmp.Split(',');
            for (int i = 0; i < tmplist.Length; i++)
            {
                if (tmplist[i] != "0")
                {
                    missionData.m_MissionList.Add(Convert.ToInt32(tmplist[i]));
                }
            }

            tmp     = reader.GetString(reader.GetOrdinal("RecruitMissionID"));
            tmplist = tmp.Split(',');
            for (int i = 0; i < tmplist.Length; i++)
            {
                if (tmplist[i] != "0")
                {
                    missionData.m_RecruitMissionList.Add(Convert.ToInt32(tmplist[i]));
                }
            }

            missionData.mCompletedMissionCount = Convert.ToInt32(reader.GetString(reader.GetOrdinal("RecruitMissionNum")));

            tmp     = reader.GetString(reader.GetOrdinal("Colony_RecruitMissionID"));
            tmplist = tmp.Split(',');
            for (int i = 0; i < tmplist.Length; i++)
            {
                if (tmplist[i] != "0")
                {
                    missionData.m_CSRecruitMissionList.Add(Convert.ToInt32(tmplist[i]));
                }
            }

            missionData.m_bRandomNpc = true;
            NpcMissionDataRepository.AddMissionData(id, missionData);
        }
    }