public int SpawnNewPlayer(int clientHash, string playerName, eHero heroType) { ILevelExperienceConfig expConfig = null; IHeroTypeConfig heroConfig = null; if (engineDataManager.ExperienceConfigs.ContainsKey(heroType)) { expConfig = engineDataManager.ExperienceConfigs[heroType]; } else { log.Error("Error: Experience Config not loaded for '" + heroType.ToString() + "'."); expConfig = new LevelExperienceConfig(new List <long>() { 100 }); // TODO: should we have a more robust default experience config? // or should we just fail in some way here? } if (engineDataManager.HeroTypeConfigs.ContainsKey(heroType)) { heroConfig = engineDataManager.HeroTypeConfigs[heroType]; } else { log.Error("Error: Hero Config not loaded for '" + heroType.ToString() + "'."); // Do we even need a default? //heroConfig = new HeroTypeConfig(10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 9, // 1, 10, 10, 10, 10, 10, 10, 0, "hth"); // TODO: should we have a more robust default hero config? // or should we just fail in some way here? // ... we should probably just fail here } var newPlayer = new PlayerState(clientHash, playerName, mobManager.GetNextAvailableMobId(), 1, 20.5f, 20.5f, 10, 10, 10, 10, 0, heroType, heroConfig, expConfig); // This is probably not the right place to do this. // Only add items with a location set, the other ones go into the inventory - that we do not support yet foreach (var item in heroConfig.InitialEquipment) { if (item.location.Length > 0) { newPlayer.UpdateEquipment(item.location, itemManager.getItemInstance(item.name)); } } // TODO: Default torso for testing. Remove when... we're done testing. newPlayer.UpdateEquipment("tors", itemManager.getItemInstance("aar")); mobManager.AddPlayer(newPlayer); return(newPlayer.Id); }
void SetHero(eHero eHero) { for (int i = 0; i < nHERO_SIZE; ++i) { string heroPath = string.Format(Path.HEROPREFAB, eHero.ToString()); obj = Instantiate(Resources.Load(heroPath)) as GameObject; obj.transform.parent = heroRoot; obj.SetActive(false); heroPoolList.Add(obj.transform); eHeroList.Add(eHero); } }