public static void SetItemSlots(Character character, ItemSlots slots) { GmSerializer serializer = new GmSerializer(); MemoryStream stream = new MemoryStream(); serializer.Serialize(stream, slots); character.itemSlotData = System.Convert.ToBase64String(stream.ToArray()); }
public static ItemSlots GetItemSlots(Character character) { if (character.itemSlotData == null) { Debug.Log("ItemSlotData is null"); return new ItemSlots(); } GmSerializer serializer = new GmSerializer(); MemoryStream stream = new MemoryStream(System.Convert.FromBase64String(character.itemSlotData)); return serializer.Deserialize(stream, new ItemSlots(), typeof(ItemSlots)) as ItemSlots; }
private void CreateNpc(NpcGroup group, NpcDef npcDef, Character character, int order) { Vector3 spawnPosition = SpawnPoint.Instance().GetObjectSpawnPoint(gameObject); GameObject prefab = GameEntityFactory.instance.GetGameEntityPrefab(npcDef.prefabName); IGameEntity gameEntity = CreateGameEntity(character.playerId, character, spawnPosition, prefab); Npc npc = gameEntity.GetGameObject().AddComponent<Npc>() as Npc; npc.group = group; npc.gameEntity = gameEntity; if (order == 0) { group.SetLeader(npc); } npc.order = order; npc.SetNpcDef(npcDef); group.AddNpc(npc); gameEntities.Add(gameEntity); characterIdToGameEntity[character.id] = gameEntity; entityIdToGameEntity[gameEntity.GetEntityId()] = gameEntity; }
private IGameEntity CreateGameEntity(string entityId, Character character, Vector3 spawnPosition, GameObject prefab) { IGameEntity gameEntity = GameEntityFactory.instance.CreateLocalNpc(entityId, character, spawnPosition, prefab); gameEntity.SetTargetPosition(spawnPosition); return gameEntity; }