/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (DataRestrictions != null) { hashCode = hashCode * 59 + DataRestrictions.GetHashCode(); } if (DisplayHints != null) { hashCode = hashCode * 59 + DisplayHints.GetHashCode(); } if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (UsedForLookup != null) { hashCode = hashCode * 59 + UsedForLookup.GetHashCode(); } return(hashCode); } }
private void Update() { // one villager per house // TODO: come up with a better algorithm for ratio between houses and villagers houses = GameObject.FindGameObjectsWithTag("Home"); forts = GameObject.FindGameObjectsWithTag("Fort"); currentNumHouses = houses.Length; currentNumForts = forts.Length; if (currentNumHouses > 0 && villagers.Count < currentNumHouses && villagers.Count <= mapSize) { int currFoodCount = int.Parse(foodCount.text); if (currFoodCount > 5 * villagers.Count + 5) { // spawn villager at current home float jackX = houses[currentNumHouses - 1].transform.position.x; float jackZ = houses[currentNumHouses - 1].transform.position.z; GameObject jack = Instantiate(lumberjack, new Vector3(jackX, 0.439f, jackZ), Quaternion.identity); string currentResource = jack.GetComponent<TownFolkAI>().lastResource; string state = jack.GetComponent<TownFolkAI>().state; villagers.Add(jack); if (villagers.Count == 1) { DisplayHints script = GameObject.Find("Hints").GetComponent<DisplayHints>(); StartCoroutine(script.DisplayHint("VillagersFunctionHint", 5)); StartCoroutine(script.DisplayHint("VillagersOverview", 5)); } GameObject.Find("VillagerInfo").GetComponent<UpdateVillagerUIList>().AddVillagerToMenu(villagers.Count, jack); } } if (currentNumForts > 0 && fighters.Count < currentNumForts && fighters.Count <= mapSize) { // spawn villager at current home float jackX = forts[currentNumForts - 1].transform.position.x; float jackZ = forts[currentNumForts - 1].transform.position.z; GameObject jack = Instantiate(fighter, new Vector3(jackX, 0.439f, jackZ), Quaternion.identity); fighters.Add(jack); } // monster spawns after every 4 villagers if (villagers.Count > 4) { elapsedTime += Time.deltaTime; if (elapsedTime > 10) { elapsedTime = 0.0f; GameObject[] trees = GameObject.FindGameObjectsWithTag("Tree"); if (trees.Length > 0) { int rand = UnityEngine.Random.Range(0, trees.Length); float monsterX = trees[rand].transform.position.x; float monsterZ = trees[rand].transform.position.z; GameObject mon = Instantiate(monster, new Vector3(monsterX, 0.439f, monsterZ), Quaternion.identity); monsters.Add(mon); } } } }
/// <summary> /// Returns true if PaymentProductField instances are equal /// </summary> /// <param name="other">Instance of PaymentProductField to be compared</param> /// <returns>Boolean</returns> public bool Equals(PaymentProductField other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( DataRestrictions == other.DataRestrictions || DataRestrictions != null && DataRestrictions.Equals(other.DataRestrictions) ) && ( DisplayHints == other.DisplayHints || DisplayHints != null && DisplayHints.Equals(other.DisplayHints) ) && ( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( UsedForLookup == other.UsedForLookup || UsedForLookup != null && UsedForLookup.Equals(other.UsedForLookup) )); }