public static Group CreateGroup(string name, EntityInfo entityInfo, Tech tech) { Group result = null; if (entityInfo != null) { result = new Group(); result.Name = name; result.Tech.Weapon = tech.Weapon; result.Tech.Shield = tech.Shield; result.Tech.Armor = tech.Armor; foreach (var entityinfo in entityInfo.EntityQuanties) { Parallel.For(0, entityinfo.Value, i => { lock (result.Entities) { result.Entities.Add(new Entity(entityinfo.Key, tech)); } }); /* * for (int i = 0; i < entityinfo.Value; i++) * { * result.Entities.Add(new Entity(entityinfo.Key, tech)); * } */ } } return(result); }
public Entity(EntityType entityType, Tech tech) { EntityType = entityType; var values = GetBaseValues(entityType); WeaponPower = (int)((1 + 0.1 * tech.Weapon) * values.Item2); ShieldPower = (int)((1 + 0.1 * tech.Shield) * values.Item3); HullPoint = (int)(values.Item1 / 10 * (1 + 0.1 * tech.Armor)); ShieldPowerInit = ShieldPower; HullPointInit = HullPoint; ExplodeMe = false; }
public Group() { Entities = new List <Entity>(); Tech = new Tech(); }