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); }
public PlayerState(int clientHash, string name, int id, int level, float x, float y, int vitality, int strength, int energy, int dexterity, long experience, eHero herotype, IHeroTypeConfig heroconfig, ILevelExperienceConfig expconfig) : base(name, id, level, 0, x, y) { this.ClientHash = clientHash; Stamina = new Stat(0, 0, 0, true); Mana = new Stat(0, 0, 0, true); ManaRegen = new Stat(0, heroconfig.StartingManaRegen, heroconfig.StartingManaRegen, true); Vitality = new Stat(0, vitality, vitality, true); Strength = new Stat(0, strength, strength, true); Energy = new Stat(0, energy, energy, true); Dexterity = new Stat(0, dexterity, dexterity, true); AttackRating = new Stat(0, 0, 0, false); DefenseRating = new Stat(0, 0, 0, false); WalkVelocity = new Stat(0, heroconfig.WalkVelocity, 100, false); // TODO: what should max velocity be? (replace the 100) RunVelocity = new Stat(0, heroconfig.RunVelocity, 100, false); // TODO: what should max velocity be? RunDrain = new Stat(0, heroconfig.RunDrain, heroconfig.RunDrain, true); Experience = experience; // how much total exp do they have HeroType = herotype; HeroTypeConfig = heroconfig; ExperienceConfig = expconfig; AddFlag(eMobFlags.PLAYER); RefreshMaxes(); // initialize the max health / mana / energy Health.SetCurrent(Health.GetMax()); Mana.SetCurrent(Mana.GetMax()); Energy.SetCurrent(Energy.GetMax()); RefreshDerived(); }