public bool createBuilding(TypeBuilding buildingType, Vector3 position) { if (this.getBuilding(buildingType) == null) { var buildingTransform = Instantiate(buildingPrefab) as Transform; Building building = buildingTransform.GetComponent<Building>(); if (building != null) { building.init(buildingType, this.minorIsland); building.transform.SetParent(this.transform); this.buildingList.Add(building); Vector3 newPosition; if (buildingType != TypeBuilding.Harbor) { newPosition = Camera.main.ScreenToWorldPoint(position); newPosition.z = -3; } else newPosition = position; building.transform.position = newPosition; //rotation of image according to the place of the island char id = minorIsland.nameMinorIsland[minorIsland.nameMinorIsland.Length - 1]; if (id == '1' || id == '2') building.transform.Rotate(Vector3.forward * 180); return true; } return false; } else { return false; } }
public ITypeBuildingContext ResolveType(string initialUnitPath, Type type, ITypeScriptUnitFactory unitFactory) { if (InternalApiTypeBuildingContext.Accept(type)) { var targetUnit = unitFactory.GetOrCreateTypeUnit(initialUnitPath); return(new InternalApiTypeBuildingContext(targetUnit, type)); } if (type == typeof(Guid)) { return(TypeBuilding.RedirectToType("Guid", @".\DataTypes\Guid", typeof(Guid))); } if (type == typeof(DateTime)) { return(TypeBuilding.RedirectToType("DateTime", @".\DataTypes\DateTime", typeof(DateTime))); } if (type == typeof(DateTimeOffset)) { return(TypeBuilding.RedirectToType("DateTime", @".\DataTypes\DateTime", typeof(DateTimeOffset))); } if (type == typeof(TimeSpan)) { return(TypeBuilding.RedirectToType("TimeSpan", @".\DataTypes\TimeSpan", typeof(TimeSpan))); } return(null); }
public Building getBuilding(TypeBuilding buildingType) { foreach (Building item in this.buildingList) { if (item.TypeBuilding == buildingType) { return item; } } return null; }
public Building getBuilding(TypeBuilding buildingType) { foreach (Building item in this.buildingList) { if (item.TypeBuilding == buildingType) { return(item); } } return(null); }
public IEnumerator destroyBuilding(TypeBuilding buildingType) { Building buildingToDestroy = this.getBuilding(buildingType); GameObject objectToDestroy = GameObject.Find(this.minorIsland.nameMinorIsland + "_" + buildingType.ToString()); //update resource production in island resource manager this.minorIsland.resourceManager.changeResourceProduction(buildingToDestroy.resourceProduced.TypeResource, -buildingToDestroy.quantityProduced); buildingToDestroy.quantityProduced = 0; //remove the building in the list of this manager this.buildingList.Remove(this.getBuilding(buildingType)); this.Client.sendData("@2" + minorIsland.nameMinorIsland.Split('_')[2] + "161@" + buildingType.ToString()); //update resource production in island resource manager) //Delete game object yield return StartCoroutine(fadeAndDestroy(objectToDestroy)); }
IEnumerator wait() { yield return(new WaitForSeconds(1f)); /*Color color; * for (int i = 0; i < 100; i++) * { * yield return new WaitForSeconds(0.001f); * * color = background.material.color; * color.a -= 0.01f; * background.material.color = color; * }*/ //minorIsland.buildingClicked is a string --> conversion necessary if (Enum.IsDefined(typeof(TypeBuilding), minorIsland.buildingClickedWheel)) { TypeBuilding typeBuilding = (TypeBuilding)Enum.Parse(typeof(TypeBuilding), minorIsland.buildingClickedWheel, true); //construction of building bool newBuilding = minorIsland.buildingManager.createBuilding(typeBuilding, minorIsland.placeOfBuildingConstruction); if (newBuilding == false) { minorIsland.displayPopup("Le bâtiment " + Building.translateBuildingName(typeBuilding.ToString()) + " a déjà été créé !", 3); } else { Building buildingConstructed = minorIsland.buildingManager.getBuilding(typeBuilding); if (goodAnswer) { minorIsland.displayPopup("Grâce à votre bonne réponse, la production du bâtiment " + Building.translateBuildingName(typeBuilding.ToString()) + " double !", 3, explainations); buildingConstructed.changeProduction(buildingConstructed.quantityProduced); } else { minorIsland.displayPopup("Mauvaise réponse ... ", 3, explainations); } } } minorIsland.challengePresent = false; clicked = false; Destroy(this.transform.parent.gameObject); }
public IEnumerator destroyBuilding(TypeBuilding buildingType) { Building buildingToDestroy = this.getBuilding(buildingType); GameObject objectToDestroy = GameObject.Find(this.minorIsland.nameMinorIsland + "_" + buildingType.ToString()); //update resource production in island resource manager this.minorIsland.resourceManager.changeResourceProduction(buildingToDestroy.resourceProduced.TypeResource, -buildingToDestroy.quantityProduced); buildingToDestroy.quantityProduced = 0; //remove the building in the list of this manager this.buildingList.Remove(this.getBuilding(buildingType)); this.Client.sendData("@2" + minorIsland.nameMinorIsland.Split('_')[2] + "161@" + buildingType.ToString()); //update resource production in island resource manager) //Delete game object yield return(StartCoroutine(fadeAndDestroy(objectToDestroy))); }
public virtual ITypeBuildingContext?ResolveType(string initialUnitPath, ITypeGenerator typeGenerator, ITypeInfo typeInfo, ITypeScriptUnitFactory unitFactory) { if (typeRedirects.TryGetValue(typeInfo, out var redirect)) { return(TypeBuilding.RedirectToType(redirect.Name, redirect.Location, typeInfo)); } var contextCreation = typeBuildingContextRules.SingleOrDefault(x => x.Accept(typeInfo)); if (contextCreation == null) { return(null); } return(contextCreation.CreateContext != null ? contextCreation.CreateContext(typeInfo) : contextCreation.CreateContextWithUnit(unitFactory.GetOrCreateTypeUnit(initialUnitPath), typeInfo)); }
public virtual ITypeBuildingContext?ResolveType(string initialUnitPath, ITypeGenerator typeGenerator, ITypeInfo typeInfo, ITypeScriptUnitFactory unitFactory) { if (typeRedirects.TryGetValue(typeInfo, out var redirect)) { return(TypeBuilding.RedirectToType(redirect.Name, redirect.Location, typeInfo)); } if (typeBuildingContexts.TryGetValue(typeInfo, out var createContext)) { return(createContext(typeInfo)); } foreach (var typeBuildingContextWithAcceptanceChecking in typeBuildingContextsWithAcceptanceChecking) { if (typeBuildingContextWithAcceptanceChecking.Accept(typeInfo)) { return(typeBuildingContextWithAcceptanceChecking.CreateContext(unitFactory.GetOrCreateTypeUnit(initialUnitPath), typeInfo)); } } return(null); }
public ITypeBuildingContext ResolveType(string initialUnitPath, ITypeGenerator typeGenerator, ITypeInfo type, ITypeScriptUnitFactory unitFactory) { if (type.Equals(TypeInfo.From <TimeGuid>())) { return(TypeBuilding.RedirectToType("TimeGuid", @"..\DataTypes\TimeGuid", type)); } if (type.Equals(TypeInfo.From <Timestamp>())) { return(TypeBuilding.RedirectToType("Timestamp", @"..\DataTypes\Timestamp", type)); } if (type.Equals(TypeInfo.From <TimestampRange>())) { return(TypeBuilding.RedirectToType("DateTimeRange", @"..\DataTypes\DateTimeRange", type)); } if (InternalApiTypeBuildingContext.Accept(type)) { return(new InternalApiTypeBuildingContext(unitFactory.GetOrCreateTypeUnit(initialUnitPath), type)); } return(null); }
public bool createBuilding(TypeBuilding buildingType, Vector3 position) { if (this.getBuilding(buildingType) == null) { var buildingTransform = Instantiate(buildingPrefab) as Transform; Building building = buildingTransform.GetComponent <Building>(); if (building != null) { building.init(buildingType, this.minorIsland); building.transform.SetParent(this.transform); this.buildingList.Add(building); Vector3 newPosition; if (buildingType != TypeBuilding.Harbor) { newPosition = Camera.main.ScreenToWorldPoint(position); newPosition.z = -3; } else { newPosition = position; } building.transform.position = newPosition; //rotation of image according to the place of the island char id = minorIsland.nameMinorIsland[minorIsland.nameMinorIsland.Length - 1]; if (id == '1' || id == '2') { building.transform.Rotate(Vector3.forward * 180); } return(true); } return(false); } else { return(false); } }
public void init(TypeChallenge tc, MinorIsland island, TypeBuilding typeBuilding) { canvasChallenge = this.transform.parent.GetComponent<Canvas>(); this.minorIsland = island; this.typeChallenge = tc; if (typeChallenge == TypeChallenge.QCM) this.nbPropositions = 3; else this.nbPropositions = 2; //CSV part //row[0] : question ; row[1] : answer ; row[2] : explainations ; after : propositions //VraiFaux : answer = Proposition0 ou answer = Proposition1 //QCM : answer = Proposition0 ou answer = Proposition1 ou answer = Proposition2 //ENCODAGE : UTF8-16-LE //last line of file usually blank --> to be removed! //csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); if (RegisterScene.level == 0) //collège csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/College/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); else csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/Lycee/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); Debug.Log("File : " + typeChallenge.ToString() + "_" + typeBuilding.ToString()); string[] row = CSV_reader.GetRandomLine(csv.text); try { this.question = row[0]; } catch { error = true; } finally { if (!error) { addLineBreaks(); this.answer = row[1]; this.explainations = row[2]; this.propositions = new string[nbPropositions]; this.propositions[0] = row[3]; this.propositions[1] = row[4]; if (this.nbPropositions == 3) this.propositions[2] = row[5]; //graphic part foreach (Text text in canvasChallenge.GetComponentsInChildren<Text>()) { switch (text.name) { case "Question": text.text = this.question; break; case "Result": resultText = text; break; case "Proposition0": if (typeChallenge == TypeChallenge.QCM) text.text = this.propositions[0]; break; case "Proposition1": if (typeChallenge == TypeChallenge.QCM) text.text = this.propositions[1]; break; case "Proposition2": if (typeChallenge == TypeChallenge.QCM) text.text = this.propositions[2]; break; } } this.background = this.GetComponent<SpriteRenderer>(); } else { minorIsland.displayPopup("Oups ! Une erreur s'eest produite, veuillez ré-essayer ...", 3); Destroy(this.transform.parent.gameObject); } } }
public void init(TypeChallenge tc, MinorIsland island, TypeBuilding typeBuilding) { canvasChallenge = this.transform.parent.GetComponent <Canvas>(); this.minorIsland = island; this.typeChallenge = tc; if (typeChallenge == TypeChallenge.QCM) { this.nbPropositions = 3; } else { this.nbPropositions = 2; } //CSV part //row[0] : question ; row[1] : answer ; row[2] : explainations ; after : propositions //VraiFaux : answer = Proposition0 ou answer = Proposition1 //QCM : answer = Proposition0 ou answer = Proposition1 ou answer = Proposition2 //ENCODAGE : UTF8-16-LE //last line of file usually blank --> to be removed! //csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); if (RegisterScene.level == 0) //collège { csv = Resources.Load <TextAsset>("Challenges/ChallengesFiles/College/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); } else { csv = Resources.Load <TextAsset>("Challenges/ChallengesFiles/Lycee/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + typeBuilding.ToString()); } Debug.Log("File : " + typeChallenge.ToString() + "_" + typeBuilding.ToString()); string[] row = CSV_reader.GetRandomLine(csv.text); try { this.question = row[0]; } catch { error = true; } finally { if (!error) { addLineBreaks(); this.answer = row[1]; this.explainations = row[2]; this.propositions = new string[nbPropositions]; this.propositions[0] = row[3]; this.propositions[1] = row[4]; if (this.nbPropositions == 3) { this.propositions[2] = row[5]; } //graphic part foreach (Text text in canvasChallenge.GetComponentsInChildren <Text>()) { switch (text.name) { case "Question": text.text = this.question; break; case "Result": resultText = text; break; case "Proposition0": if (typeChallenge == TypeChallenge.QCM) { text.text = this.propositions[0]; } break; case "Proposition1": if (typeChallenge == TypeChallenge.QCM) { text.text = this.propositions[1]; } break; case "Proposition2": if (typeChallenge == TypeChallenge.QCM) { text.text = this.propositions[2]; } break; } } this.background = this.GetComponent <SpriteRenderer>(); } else { minorIsland.displayPopup("Oups ! Une erreur s'eest produite, veuillez ré-essayer ...", 3); Destroy(this.transform.parent.gameObject); } } }
public void init(TypeBuilding TypeBuilding, MinorIsland island) { this.Client = GameObject.Find("Network").GetComponent<Client>(); this.level = 0; this.TypeBuilding = TypeBuilding; this.buildState = 0; this.minorIsland = island; this.constructionResourceNeeded = new List<Tuple<TypeResource, int>>(); this.upgrade1ResourceNeeded = new List<Tuple<TypeResource, int>>(); this.upgrade2ResourceNeeded = new List<Tuple<TypeResource, int>>(); this.upgrade3ResourceNeeded = new List<Tuple<TypeResource, int>>(); this.name = this.minorIsland.nameMinorIsland + "_" + this.TypeBuilding.ToString(); this.resourceProduced = ScriptableObject.CreateInstance<Resource>(); this.texturePath = "Building/Icons/wheelIcon_" + TypeBuilding.ToString(); this.constructionResourceNeeded = getConstructionResourcesNeeded(TypeBuilding.ToString()); switch (TypeBuilding) { case TypeBuilding.GoldMine: this.resourceProduced.init(TypeResource.Gold, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 5; break; case TypeBuilding.StoneMine: this.resourceProduced.init(TypeResource.Stone, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.OilPlant: this.resourceProduced.init(TypeResource.Oil, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 5; break; case TypeBuilding.Sawmill: this.resourceProduced.init(TypeResource.Wood, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Factory: this.resourceProduced.init(TypeResource.Manufacture, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.WindTurbine: this.resourceProduced.init(TypeResource.Electricity, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.Farm: this.resourceProduced.init(TypeResource.Food, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 80)); this.constructionTime = 5; break; case TypeBuilding.Harbor: this.resourceProduced.init(TypeResource.Food, 0, 1); this.quantityProduced = 1; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.constructionTime = 5; break; case TypeBuilding.PowerPlant: this.resourceProduced.init(TypeResource.Electricity, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.Lab: this.resourceProduced.init(TypeResource.Health, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Airport: this.resourceProduced.init(TypeResource.Tourism, 0, 10); this.quantityProduced = 10; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 100)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 100)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 150)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 150)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 200)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 200)); this.constructionTime = 20; break; case TypeBuilding.Hotel: this.resourceProduced.init(TypeResource.Tourism, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 30; break; case TypeBuilding.School: this.resourceProduced.init(TypeResource.Education, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Church: this.resourceProduced.init(TypeResource.Religion, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 10; break; case TypeBuilding.Cinema: this.resourceProduced.init(TypeResource.Happiness, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 15; break; case TypeBuilding.AmusementPark: this.resourceProduced.init(TypeResource.Happiness, 0, 10); this.quantityProduced = 10; this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 100)); this.upgrade1ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 100)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 150)); this.upgrade2ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 150)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Gold, 200)); this.upgrade3ResourceNeeded.Add(new Tuple<TypeResource, int>(TypeResource.Oil, 200)); this.constructionTime = 20; break; } GetComponent<Transform>().localScale = new Vector3(9f, 9f, 1f); StartCoroutine("build"); }
public void init(TypeBuilding TypeBuilding, MinorIsland island) { this.Client = GameObject.Find("Network").GetComponent <Client>(); this.level = 0; this.TypeBuilding = TypeBuilding; this.buildState = 0; this.minorIsland = island; this.constructionResourceNeeded = new List <Tuple <TypeResource, int> >(); this.upgrade1ResourceNeeded = new List <Tuple <TypeResource, int> >(); this.upgrade2ResourceNeeded = new List <Tuple <TypeResource, int> >(); this.upgrade3ResourceNeeded = new List <Tuple <TypeResource, int> >(); this.name = this.minorIsland.nameMinorIsland + "_" + this.TypeBuilding.ToString(); this.resourceProduced = ScriptableObject.CreateInstance <Resource>(); this.texturePath = "Building/Icons/wheelIcon_" + TypeBuilding.ToString(); this.constructionResourceNeeded = getConstructionResourcesNeeded(TypeBuilding.ToString()); switch (TypeBuilding) { case TypeBuilding.GoldMine: this.resourceProduced.init(TypeResource.Gold, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 5; break; case TypeBuilding.StoneMine: this.resourceProduced.init(TypeResource.Stone, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.OilPlant: this.resourceProduced.init(TypeResource.Oil, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 5; break; case TypeBuilding.Sawmill: this.resourceProduced.init(TypeResource.Wood, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Factory: this.resourceProduced.init(TypeResource.Manufacture, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.WindTurbine: this.resourceProduced.init(TypeResource.Electricity, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.Farm: this.resourceProduced.init(TypeResource.Food, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 80)); this.constructionTime = 5; break; case TypeBuilding.Harbor: this.resourceProduced.init(TypeResource.Food, 0, 1); this.quantityProduced = 1; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.constructionTime = 5; break; case TypeBuilding.PowerPlant: this.resourceProduced.init(TypeResource.Electricity, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 5; break; case TypeBuilding.Lab: this.resourceProduced.init(TypeResource.Health, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Airport: this.resourceProduced.init(TypeResource.Tourism, 0, 10); this.quantityProduced = 10; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 100)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 100)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 150)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 150)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 200)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 200)); this.constructionTime = 20; break; case TypeBuilding.Hotel: this.resourceProduced.init(TypeResource.Tourism, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 30; break; case TypeBuilding.School: this.resourceProduced.init(TypeResource.Education, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Food, 80)); this.constructionTime = 5; break; case TypeBuilding.Church: this.resourceProduced.init(TypeResource.Religion, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Wood, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Stone, 80)); this.constructionTime = 10; break; case TypeBuilding.Cinema: this.resourceProduced.init(TypeResource.Happiness, 0, 5); this.quantityProduced = 5; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 40)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 40)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 60)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 60)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 80)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 80)); this.constructionTime = 15; break; case TypeBuilding.AmusementPark: this.resourceProduced.init(TypeResource.Happiness, 0, 10); this.quantityProduced = 10; this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 100)); this.upgrade1ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 100)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 150)); this.upgrade2ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 150)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Gold, 200)); this.upgrade3ResourceNeeded.Add(new Tuple <TypeResource, int>(TypeResource.Oil, 200)); this.constructionTime = 20; break; } GetComponent <Transform>().localScale = new Vector3(9f, 9f, 1f); StartCoroutine("build"); }