Exemplo 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));
        }
Exemplo n.º 2
0
    //This instantiates the player to the middle of the playzone, using zenject factory here
    public void InitializePlayer(Vector3 a_vec3PointA, Vector3 a_vec3PointB)
    {
        Vector3 vec3SpawnPoint = new Vector3((a_vec3PointA.x + a_vec3PointB.x) / 2, ((a_vec3PointA.y + a_vec3PointB.y) / 2) + 0.5f, (a_vec3PointA.z + a_vec3PointB.x) / 2);

        m_refPlayer = m_refPlayerFactory.Create(vec3SpawnPoint);
    }