/// <summary> /// Constructor that defines the requirements for a Unit. /// </summary> /// <param name="unitReqs">List of UnitStats of Units needed.</param> /// <param name="buildingReqs">List of BuildingStats of Buildings needed</param> /// <param name="ustats">UnitStats of the kind of Unit the requirements are being defined for.</param> public ReqList(List<UnitStats> unitReqs, List<BuildingStats> buildingReqs, UnitStats ustats) { this.unitReqs = unitReqs; this.buildingReqs = buildingReqs; this.ustats = ustats; type = ReqType.Unit; }
/// <summary> /// Constructor, builds a ReqList defined by the XMl string for a Unit defined by the UnitStats. /// </summary> /// <param name="xml"></param> /// <param name="ustats"></param> public ReqList(string xml, UnitStats ustats) { this.unitReqs = new List<UnitStats>(); this.buildingReqs = new List<BuildingStats>(); this.ustats = ustats; type = ReqType.Unit; readReqXML(xml); }
public ProduceUnit(Building building, string unitType) { this.building = building; this.unitType = unitType; this.stats = Factories.UnitFactory.Instance.getStats(unitType); totalCost = stats.foodCost + stats.lumberCost + stats.metalCost + stats.waterCost; }
public UnitComponent(Entities.UnitStats stats) { actionQueue = new ActionQueue(); AddChild(actionQueue); UnitAddedToCellHandlers = handleUnitAddedToCell; this.maxHealth = stats.maxHealth; this.currentHealth = stats.maxHealth; this.speed = stats.speed; this.buildSpeed = stats.buildSpeed; this.canAttack = stats.canAttack; this.canBuild = stats.canBuild; this.canHarvest = stats.canHarvest; this.isZombie = stats.isZombie; this.type = stats.type; this.visibilityRange = stats.visibilityRange; this.attack = stats.attack; this.attackRange = stats.attackRange; this.attackTicks = stats.attackTicks; }
/// <summary> /// Given a UnitStats object, this function will return a ReqList defining the requirements necessary to produce /// that Unit. /// </summary> /// <param name="ustats"></param> /// <returns></returns> public ReqList getUnitRequirements(UnitStats ustats) { return this.unitReqs[ustats]; }
/// <summary> /// This function will deterimine if a Player meets the requirements to produce a Unit. /// </summary> /// <param name="player">Player being tested</param> /// <param name="ustats">UnitStats defining the Unit</param> /// <returns>true if the player meets the requirements, false if the player does not.</returns> public bool playerMeetsRequirements(Player.Player player, UnitStats ustats) { ReqList reqList = unitReqs[ustats]; return reqList.playerMeetsReqs(player); }
public Unit(Player.Player owner, UnitStats stats) : base(owner, stats.maxHealth, stats.maxHealth) { this.stats = stats; this.entityType = EntityType.Unit; }
/// <summary> /// Constructor for a unit /// </summary> /// <param name="owner">Owner</param> /// <param name="health">Current Health</param> /// <param name="maxHealth">Maximum Health</param> /// <param name="radius">Radius</param> /// <param name="type">Type of unit</param> public Unit(Player.Player owner, short health) : base(owner, health) { this.entityType = EntityType.Unit; this.stats = new UnitStats(); }
private void parseXML(UnitStats stats, string xml) { XmlReader reader = XmlReader.Create(new StringReader(xml)); // maxHealth reader.ReadToFollowing("maxHealth"); stats.maxHealth = (short)reader.ReadElementContentAsInt(); // speed reader.ReadToFollowing("speed"); stats.speed = reader.ReadElementContentAsFloat(); // attackRange reader.ReadToFollowing("attackRange"); stats.attackRange = reader.ReadElementContentAsFloat(); // attack reader.ReadToFollowing("attack"); stats.attack = (short)reader.ReadElementContentAsInt(); // attackTicks reader.ReadToFollowing("attackTicks"); stats.attackTicks = (byte)reader.ReadElementContentAsInt(); //visibilityRange reader.ReadToFollowing("visibilityRange"); stats.visibilityRange = reader.ReadElementContentAsFloat(); //buildSpeed reader.ReadToFollowing("buildSpeed"); stats.buildSpeed = (byte)reader.ReadElementContentAsInt(); //waterCost reader.ReadToFollowing("waterCost"); stats.waterCost = (byte)reader.ReadElementContentAsInt(); //foodCost reader.ReadToFollowing("foodCost"); stats.foodCost = (byte)reader.ReadElementContentAsInt(); //lumberCost reader.ReadToFollowing("lumberCost"); stats.lumberCost = (byte)reader.ReadElementContentAsInt(); //metalCost reader.ReadToFollowing("metalCost"); stats.metalCost = (byte)reader.ReadElementContentAsInt(); //canAttack reader.ReadToFollowing("canAttack"); stats.canAttack = reader.ReadElementContentAsBoolean(); //canHarvest reader.ReadToFollowing("canHarvest"); stats.canHarvest = reader.ReadElementContentAsBoolean(); //canBuild reader.ReadToFollowing("canBuild"); stats.canBuild = reader.ReadElementContentAsBoolean(); //isZombie reader.ReadToFollowing("isZombie"); stats.isZombie = reader.ReadElementContentAsBoolean(); }
Cell myCell; // The cell the unit currently occupies #endregion Fields #region Constructors /// <summary> /// Constructor for a unit /// </summary> /// <param name="owner">Owner</param> /// <param name="health">Current Health</param> /// <param name="maxHealth">Maximum Health</param> /// <param name="radius">Radius</param> /// <param name="type">Type of unit</param> public Unit(Player.Player owner, short health) : base(owner, health) { this.entityType = EntityType.Unit; this.stats = new UnitStats(); }
public Unit(Player.Player owner, UnitStats stats) : base(owner, stats.maxHealth) { this.stats = stats; this.entityType = EntityType.Unit; attackStance = AttackStance.Guard; }
private bool playerHasUnit(Player.Player player, UnitStats ustats) { List<Entity> entities = player.getEntities(); foreach (Entity e in entities) { if (e.entityType == Entity.EntityType.Unit) { Unit u = (Unit)e; if (u.stats.type == ustats.type) { return true; } } } return false; }
byte type; // TODO: Remove this. #endregion Fields #region Constructors /// <summary> /// Constructor for a unit /// </summary> /// <param name="owner">Owner</param> /// <param name="health">Current Health</param> /// <param name="maxHealth">Maximum Health</param> /// <param name="radius">Radius</param> /// <param name="type">Type of unit</param> public Unit(Player.Player owner, short health, short maxHealth, float radius, byte type) : base(owner, health, maxHealth) { this.entityType = EntityType.Unit; this.stats = new UnitStats(); }
private void loadUnitStats(UnitStats stats, string fileName) { string xml = readFile(BASE_DIR + fileName); parseXML(stats, xml); }
public Unit(Player.Player owner, UnitStats stats) : base(owner, stats.maxHealth) { this.stats = stats; this.entityType = EntityType.Unit; }
private void parseUnitList() { string xml = readFile(BASE_DIR + unitList); bool endOfList = false; XmlReader reader = XmlReader.Create(new StringReader(xml)); while (!endOfList) { try { reader.ReadToFollowing("Unit"); string s = reader.ReadElementContentAsString(); unitPrefixes.Add(s); UnitStats uStat = new UnitStats(); uStat.type = s; stats.Add(s, uStat); } catch { endOfList = true; } } reader.Close(); }
public float radius = 0.35f; // Radius of unit. /// <summary> /// Constructor for a unit /// </summary> /// <param name="owner">Owner</param> /// <param name="health">Current Health</param> /// <param name="maxHealth">Maximum Health</param> /// <param name="radius">Radius</param> /// <param name="type">Type of unit</param> public Unit(Player.Player owner, short health, short maxHealth, float radius, byte type) : base(owner, health, maxHealth) { this.entityType = EntityType.Unit; this.stats = new UnitStats(); }
/// <summary> /// Given a string, this function will create a new UnitStats corresponding to that string in the UnitStats dictionary. /// </summary> /// <param name="unitName"></param> public void addUnit(string unitName) { UnitStats s = new UnitStats(); unitPrefixes.Add(unitName); stats.Add(unitName, s); }
private void parseXML(UnitStats stats, string xml) { XmlReader reader = XmlReader.Create(new StringReader(xml)); // maxHealth reader.ReadToFollowing("maxHealth"); stats.maxHealth = (short)reader.ReadElementContentAsInt(); // speed reader.ReadToFollowing("speed"); stats.speed = reader.ReadElementContentAsFloat(); // attackRange reader.ReadToFollowing("attackRange"); stats.attackRange = reader.ReadElementContentAsFloat(); // attack reader.ReadToFollowing("attack"); stats.attack = (short)reader.ReadElementContentAsInt(); //canAttack reader.ReadToFollowing("canAttack"); stats.canAttack = reader.ReadElementContentAsBoolean(); //canHarvest reader.ReadToFollowing("canHarvest"); stats.canHarvest = reader.ReadElementContentAsBoolean(); //canBuild reader.ReadToFollowing("canBuild"); stats.canBuild = reader.ReadElementContentAsBoolean(); }