Esempio n. 1
0
        public static IPlayerRepository getInstance(int classChoiceLevel, int levelCap,
                                                    PlayerFactory pf, IEquipmentRepository er, string coinFile, string xpFile,
                                                    string classFile, string playerFile)
        {
            if (PLAYER_SET != null)
            {
                return(new LegacyPlayerRepository(classChoiceLevel, levelCap, PLAYER_SET,
                                                  playerFile));
            }

            if (File.Exists(playerFile))
            {
                PLAYER_SET = Convert(classChoiceLevel, levelCap, er, pf, JsonConvert
                                     .DeserializeObject <ISet <PlayerDTO> >(File.ReadAllText(playerFile)));
                return(new LegacyPlayerRepository(classChoiceLevel, levelCap, PLAYER_SET,
                                                  playerFile));
            }


            //PLAYERS = new Dictionary<string, IPlayer>();
            PLAYER_SET = new HashSet <IPlayer>();

            LEGACY_USER_COINS = JsonConvert
                                .DeserializeObject <Dictionary <string, int> >(File.ReadAllText(coinFile));
            LEGACY_USER_XP = JsonConvert
                             .DeserializeObject <Dictionary <string, int> >(File.ReadAllText(xpFile));
            LEGACY_USER_CHAR_CLASS = JsonConvert
                                     .DeserializeObject <Dictionary <string, CharClass> >(File.ReadAllText(classFile));

            foreach (var kv in LEGACY_USER_CHAR_CLASS)
            {
                IPlayer player = pf.Create(kv.Key, kv.Value, LEGACY_USER_XP[kv.Key], LEGACY_USER_COINS[kv.Key]);
                PLAYER_SET.Add(player);
            }

            return(new LegacyPlayerRepository(classChoiceLevel, levelCap, PLAYER_SET,
                                              playerFile));
        }
Esempio n. 2
0
 public void Construct(Player.PlayerFactory a_refPlayerFactory)
 {
     Debug.Log("[PlayerManagement] Initialize");
     m_refPlayerFactory = a_refPlayerFactory;
 }