public static Agent CreateAgentFromVaultUnit(int id) { Agent agent = new Agent(); hotEntities he = new hotEntities(); unitvault uv = he.unitvaults.First(a => a.ID == id); CachedCatalogueUnit cachedUnit = CachedObjectContainer.GetCachedCatUnitByID(int.Parse(uv.CatalogueID)); CachedRace cachedRace = CachedObjectContainer.GetCachedRaceByName(cachedUnit.Race); agent.ID = uv.ID; agent.CATID = cachedUnit.CatalogueID; agent.Name = cachedUnit.Name; agent.UnitType = cachedUnit.UnitType; agent.Faction = cachedUnit.Faction; agent.Rarity = cachedUnit.Rarity; agent.Collection = cachedUnit.Collection; agent.Race = cachedUnit.Race; agent.DamageType = cachedUnit.DamageType; agent.BaseAttack = cachedUnit.Attack + int.Parse(uv.Attack) + cachedRace.Attack; agent.BaseAccuracy = cachedUnit.Accuracy + int.Parse(uv.Accuracy) + cachedRace.Accuracy; agent.BaseDodge = cachedUnit.Dodge + int.Parse(uv.Dodge) + cachedRace.Dodge; agent.BaseHitPoints = cachedUnit.HitPoints + int.Parse(uv.HitPoints) + cachedRace.HitPoints; agent.BaseMagic = cachedUnit.Magic + int.Parse(uv.Magic) + cachedRace.Magic; agent.BaseMagicResistance = cachedUnit.MagicResistance + int.Parse(uv.MagicResistance) + cachedRace.MagicResistance; agent.BaseFireResistance = cachedUnit.FireResistance + int.Parse(uv.FireResistance) + cachedRace.FireResistance; agent.BaseSlashResistance = cachedUnit.SlashResistance + int.Parse(uv.SlashResistance) + cachedRace.SlashResistance; agent.BasePiercingResistance = cachedUnit.PiercingResistance + int.Parse(uv.PiercingResistance) + cachedRace.PiercingResistance; agent.BaseBludgeoningResistance = cachedUnit.BludgeoningResistance + int.Parse(uv.BludgeoningResistance) + cachedRace.BludgeoningResistance; agent.BaseMovementSpeed = cachedUnit.MovementSpeed + int.Parse(uv.MovementSpeed) + cachedRace.MovementSpeed; agent.BaseMinAttackRange = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange); agent.BaseMaxAttackRange = cachedUnit.MaxAttackRange + int.Parse(uv.MaxAttRange); agent.BaseMinAttackRange = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange); agent.BaseMinAttackRange = cachedUnit.MinAttackRange + int.Parse(uv.MinAttRange); agent.Level = uv.Level; agent.Owner = uv.Owner; //players team id //hex to spawn on // agent.Abilities = uv.Abilities; string returnString = ""; // unit.iLevel.ToString().ToString() + ">" + // NetworkManager.Instance.cPlayer.sName + ">" + // GameManager.Instance.GetPlayersTeamID().ToString() + ">" + // hex.gameObject.name + ">" + // unit.Abilities; return(agent); }
public static string RequestNewUnitVaultUnit(NetworkMessage message) { string returnString = ""; hotEntities he = new hotEntities(); int i = int.Parse(message.CommandArgs); unitcatalogue catalogueUnit = he.unitcatalogues.First(o => o.CatalogueID == i); unitvault vaultUnit = new unitvault(); vaultUnit.Abilities = catalogueUnit.Abilities; vaultUnit.CatalogueID = catalogueUnit.CatalogueID.ToString(); vaultUnit.Accuracy = 0.ToString(); vaultUnit.Attack = 0.ToString(); vaultUnit.BludgeoningResistance = 0.ToString(); vaultUnit.Dodge = 0.ToString(); vaultUnit.Experience = 0; vaultUnit.FireResistance = 0.ToString(); vaultUnit.HitPoints = 0.ToString(); vaultUnit.Level = 0; vaultUnit.Magic = 0.ToString(); vaultUnit.MagicResistance = 0.ToString(); vaultUnit.MaxAttRange = 0.ToString(); vaultUnit.MinAttRange = 0.ToString(); vaultUnit.MovementSpeed = 0.ToString(); vaultUnit.Owner = message.SendingPlayerName; vaultUnit.PiercingResistance = 0.ToString(); vaultUnit.SlashResistance = 0.ToString(); try { he.unitvaults.Add(vaultUnit); he.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } returnString = vaultUnit.ID.ToString(); return(returnString); }