public void Change_To(Tile prototype) { Internal_Name = prototype.Internal_Name; Terrain = prototype.Terrain; Sprite = prototype.Sprite; Buildable = prototype.Buildable; float old_base_appeal = Base_Appeal; float old_base_appeal_range = Base_Appeal_Range; Base_Appeal = prototype.Base_Appeal; Base_Appeal_Range = prototype.Base_Appeal_Range; Can_Have_Minerals = prototype.Can_Have_Minerals; if (!Can_Have_Minerals) { Minerals.Clear(); } Animation_Sprites = Helper.Clone_List(prototype.Animation_Sprites); Sync_Animation = prototype.Sync_Animation; Animation_Framerate = prototype.Animation_Framerate; SpriteRenderer.sprite = SpriteManager.Instance.Get(Sprite, SpriteManager.SpriteType.Terrain); animation_index = 0; if (Is_Animated && !Sync_Animation) { animation_cooldown = (1.0f / Animation_Framerate) * RNG.Instance.Next_F(); animation_index = RNG.Instance.Next(0, Animation_Sprites.Count - 1); } if (Map.Instance.State == Map.MapState.Normal && Building == null) { if (old_base_appeal != 0.0f) { Appeal -= old_base_appeal; if (old_base_appeal_range != 0.0f) { foreach (Tile affected in Map.Instance.Get_Tiles_In_Circle(Coordinates, old_base_appeal_range)) { if (affected == this) { continue; } affected.Appeal -= Tile.Calculate_Appeal_Effect(Coordinates, old_base_appeal, old_base_appeal_range, affected.Coordinates); } } } if (Base_Appeal != 0.0f) { Appeal += Base_Appeal; if (Base_Appeal_Range != 0.0f) { foreach (Tile affected in Map.Instance.Get_Tiles_In_Circle(Coordinates, Base_Appeal_Range)) { if (affected == this) { continue; } affected.Appeal += Tile.Calculate_Appeal_Effect(Coordinates, Base_Appeal, Base_Appeal_Range, affected.Coordinates); } } } } }
public void MineralsShouldDeserialize(int br, int gr, int ir) { var original = new Minerals(br, gr, ir); var restored = SerializeAndDeserialize(original); Assert.Equal(original, restored); }
public void SetMineralsForOldMinerals() { Minerals minerals = new Minerals(0.0, 0.50); minerals.setMinerals("Stone", 100.0, 1000.0); Assert.AreEqual(minerals.surface["Stone"], 100.0, "Surface mineral is set with new mineral correctly"); Assert.AreEqual(minerals.mineable["Stone"], 1000.0, "Surface mineral is set with new mineral correctly"); }
public TileSaveData Save_Data() { return(new TileSaveData() { X = X, Y = Y, Internal_Name = Internal_Name, Worked_By = Worked_By.Select(x => new WorkSaveData() { Id = x.Building.Id, Type = (int)x.Type }).ToList(), Minerals = Minerals.Select(x => new MineralSaveData() { Mineral = (int)x.Key, Amount = x.Value }).ToList(), Mineral_Spawns = Mineral_Spawns.Select(x => (int)x).ToList(), Water_Flow = Water_Flow.HasValue ? (int)Water_Flow : -1 }); }
public void MineralCorrectlyCreated() { double oceanPer = 1.0; double hillPer = .50; Minerals minerals1 = new Minerals(oceanPer, hillPer); Assert.True(minerals1.surface.ContainsKey("Stone"), "Surface Minerals 1 contains the key Stone"); Assert.True(minerals1.mineable.ContainsKey("Stone"), "Mineable Minerals 1 contains the key Stone"); Assert.AreEqual(minerals1.surface["Stone"], 0.0, "Surface Stone is 0.0 in the ocean."); Assert.AreEqual(minerals1.surface["Stone"], 0.0, "Mineable Stone is 0.0 in the ocean."); oceanPer = 0.0; hillPer = .50; Minerals minerals2 = new Minerals(oceanPer, hillPer); Assert.True(minerals2.surface.ContainsKey("Stone"), "Surface Minerals 2 contains the key Stone"); Assert.True(minerals2.mineable.ContainsKey("Stone"), "Mineable Minerals 2 contains the key Stone"); Assert.GreaterOrEqual(minerals1.surface["Stone"], 0.0, "Surface Stone is >= 0.0 on the land."); Assert.GreaterOrEqual(minerals1.surface["Stone"], 0.0, "Mineable Stone is >= 0.0 on the ocean."); }
/// <summary> /// Minerals together remaining on base. /// </summary> public int MineralsRemaining() { return(Minerals.Where(x => x.Exists).Sum(x => x.Resources)); }
public MineralFormulaVM(ComponentTemplateParentVM parent, StaticDataStore staticDataStore, KeyValuePair <Guid, string> guidFormulaKVP) : this(parent, staticDataStore) { MineralFormula = guidFormulaKVP.Value; Minerals.SelectedIndex = Minerals.GetIndex(new KeyValuePair <Guid, string>(guidFormulaKVP.Key, Minerals[guidFormulaKVP.Key])); }
/// <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 (Barcode != null) { hashCode = hashCode * 59 + Barcode.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Brand != null) { hashCode = hashCode * 59 + Brand.GetHashCode(); } if (Ingredients != null) { hashCode = hashCode * 59 + Ingredients.GetHashCode(); } if (Package != null) { hashCode = hashCode * 59 + Package.GetHashCode(); } if (Serving != null) { hashCode = hashCode * 59 + Serving.GetHashCode(); } if (Categories != null) { hashCode = hashCode * 59 + Categories.GetHashCode(); } if (Nutrients != null) { hashCode = hashCode * 59 + Nutrients.GetHashCode(); } if (DietLabels != null) { hashCode = hashCode * 59 + DietLabels.GetHashCode(); } if (DietFlags != null) { hashCode = hashCode * 59 + DietFlags.GetHashCode(); } if (PackagingPhotos != null) { hashCode = hashCode * 59 + PackagingPhotos.GetHashCode(); } if (Allergens != null) { hashCode = hashCode * 59 + Allergens.GetHashCode(); } if (BrandList != null) { hashCode = hashCode * 59 + BrandList.GetHashCode(); } if (Countries != null) { hashCode = hashCode * 59 + Countries.GetHashCode(); } if (CountryDetails != null) { hashCode = hashCode * 59 + CountryDetails.GetHashCode(); } if (PalmOilIngredients != null) { hashCode = hashCode * 59 + PalmOilIngredients.GetHashCode(); } if (IngredientList != null) { hashCode = hashCode * 59 + IngredientList.GetHashCode(); } if (HasEnglishIngredients != null) { hashCode = hashCode * 59 + HasEnglishIngredients.GetHashCode(); } if (Minerals != null) { hashCode = hashCode * 59 + Minerals.GetHashCode(); } if (Traces != null) { hashCode = hashCode * 59 + Traces.GetHashCode(); } if (Vitamins != null) { hashCode = hashCode * 59 + Vitamins.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (Keywords != null) { hashCode = hashCode * 59 + Keywords.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if BrandedFoodObjectItems instances are equal /// </summary> /// <param name="other">Instance of BrandedFoodObjectItems to be compared</param> /// <returns>Boolean</returns> public bool Equals(BrandedFoodObjectItems other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Barcode == other.Barcode || Barcode != null && Barcode.Equals(other.Barcode) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Brand == other.Brand || Brand != null && Brand.Equals(other.Brand) ) && ( Ingredients == other.Ingredients || Ingredients != null && Ingredients.Equals(other.Ingredients) ) && ( Package == other.Package || Package != null && Package.Equals(other.Package) ) && ( Serving == other.Serving || Serving != null && Serving.Equals(other.Serving) ) && ( Categories == other.Categories || Categories != null && Categories.SequenceEqual(other.Categories) ) && ( Nutrients == other.Nutrients || Nutrients != null && Nutrients.SequenceEqual(other.Nutrients) ) && ( DietLabels == other.DietLabels || DietLabels != null && DietLabels.Equals(other.DietLabels) ) && ( DietFlags == other.DietFlags || DietFlags != null && DietFlags.SequenceEqual(other.DietFlags) ) && ( PackagingPhotos == other.PackagingPhotos || PackagingPhotos != null && PackagingPhotos.Equals(other.PackagingPhotos) ) && ( Allergens == other.Allergens || Allergens != null && Allergens.SequenceEqual(other.Allergens) ) && ( BrandList == other.BrandList || BrandList != null && BrandList.SequenceEqual(other.BrandList) ) && ( Countries == other.Countries || Countries != null && Countries.SequenceEqual(other.Countries) ) && ( CountryDetails == other.CountryDetails || CountryDetails != null && CountryDetails.Equals(other.CountryDetails) ) && ( PalmOilIngredients == other.PalmOilIngredients || PalmOilIngredients != null && PalmOilIngredients.SequenceEqual(other.PalmOilIngredients) ) && ( IngredientList == other.IngredientList || IngredientList != null && IngredientList.SequenceEqual(other.IngredientList) ) && ( HasEnglishIngredients == other.HasEnglishIngredients || HasEnglishIngredients != null && HasEnglishIngredients.Equals(other.HasEnglishIngredients) ) && ( Minerals == other.Minerals || Minerals != null && Minerals.SequenceEqual(other.Minerals) ) && ( Traces == other.Traces || Traces != null && Traces.SequenceEqual(other.Traces) ) && ( Vitamins == other.Vitamins || Vitamins != null && Vitamins.SequenceEqual(other.Vitamins) ) && ( Description == other.Description || Description != null && Description.Equals(other.Description) ) && ( Keywords == other.Keywords || Keywords != null && Keywords.SequenceEqual(other.Keywords) )); }