Exemplo n.º 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;
            }
        }
    }
Exemplo n.º 2
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);
        }
    }
Exemplo n.º 3
0
    //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);
        }
    }
Exemplo n.º 4
0
    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]);
                }
            }
        }
    }
Exemplo n.º 5
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);
        }
    }
Exemplo n.º 6
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);
            }
        }
    }