void OnMouseDownSimulation() { island = this.transform.parent.parent.parent.gameObject.GetComponent <MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent <Building>(); island.nameBuildingTouched = string.Empty; if (this.name == "Upgrade") { if (building.level < 3) { island.buildingInfoPresent = false; island.createChallengeUpgrade(building); island.challengePresent = true; //To be cheked this.Client.sendData("@30505@" + (100 * (building.level + 1)).ToString()); } else { island.displayPopup("Ce bâtiment est déjà au niveau maximal !", 3); //StartCoroutine(island.destroyPopup(island.createPopup("Ce bâtiment est déjà au niveau maximal !"), 3)); } } island.upgradeBuildingInfoPresent = false; Destroy(GameObject.Find(this.transform.parent.parent.name)); }
void OnMouseDownSimulation() { island = this.transform.parent.parent.parent.gameObject.GetComponent<MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent<Building>(); island.nameBuildingTouched = string.Empty; if (this.name == "Upgrade") { if (building.level < 3) { island.buildingInfoPresent = false; island.createChallengeUpgrade(building); island.challengePresent = true; //To be cheked this.Client.sendData("@30505@" + (100*(building.level + 1)).ToString()); } else { island.displayPopup("Ce bâtiment est déjà au niveau maximal !", 3); //StartCoroutine(island.destroyPopup(island.createPopup("Ce bâtiment est déjà au niveau maximal !"), 3)); } } island.upgradeBuildingInfoPresent = false; Destroy(GameObject.Find(this.transform.parent.parent.name)); }
void OnMouseDownSimulation() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent <MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent <Building>(); island.nameBuildingTouched = string.Empty; if (this.name == "Remove") { building.removed = true; //regain of resources TypeResource res1 = building.constructionResourceNeeded[0].First; int value1 = building.constructionResourceNeeded[0].Second / 2; island.resourceManager.changeResourceStock(res1, value1); GameObject.Find("Network").GetComponent <Client>().sendData("@2" + island.nameMinorIsland.Split('_')[2] + "355@" + res1.ToString() + "@" + value1.ToString()); TypeResource res2; int value2; if (building.constructionResourceNeeded.Count == 2) { res2 = building.constructionResourceNeeded[1].First; value2 = building.constructionResourceNeeded[1].Second / 2; island.resourceManager.changeResourceStock(res2, value2); GameObject.Find("Network").GetComponent <Client>().sendData("@2" + island.nameMinorIsland.Split('_')[2] + "355@" + res2.ToString() + "@" + value2.ToString()); } StartCoroutine(building.minorIsland.buildingManager.destroyBuilding(building.TypeBuilding)); } island.removeBuildingInfoPresent = false; Destroy(GameObject.Find(this.transform.parent.parent.name)); }
void OnMouseDownSimulation() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent<MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent<Building>(); island.nameBuildingTouched = string.Empty; if (this.name == "Remove") { building.removed = true; //regain of resources TypeResource res1 = building.constructionResourceNeeded[0].First; int value1 = building.constructionResourceNeeded[0].Second / 2; island.resourceManager.changeResourceStock(res1, value1); GameObject.Find("Network").GetComponent<Client>().sendData("@2" + island.nameMinorIsland.Split('_')[2] + "355@" + res1.ToString() + "@" + value1.ToString()); TypeResource res2; int value2; if (building.constructionResourceNeeded.Count == 2) { res2 = building.constructionResourceNeeded[1].First; value2 = building.constructionResourceNeeded[1].Second / 2; island.resourceManager.changeResourceStock(res2, value2); GameObject.Find("Network").GetComponent<Client>().sendData("@2" + island.nameMinorIsland.Split('_')[2] + "355@" + res2.ToString() + "@" + value2.ToString()); } StartCoroutine(building.minorIsland.buildingManager.destroyBuilding(building.TypeBuilding)); } island.removeBuildingInfoPresent = false; Destroy(GameObject.Find(this.transform.parent.parent.name)); }
void OnMouseDownSimulation() { string name = this.gameObject.transform.parent.name; this.namePopupCanvas = name; string[] nameSplitted = name.Split('_'); this.island = GameObject.Find(nameSplitted[1] + "_" + nameSplitted[2] + "_" + nameSplitted[3]).GetComponent<MinorIsland>(); this.touched = true; this.gameObject.GetComponent<BoxCollider>().enabled = false; Destroy(GameObject.Find(namePopupCanvas)); }
public bool donateResource(MinorIsland remoteIsland, TypeResource typeResource, int quantity) { if (checkWithdrawPossibility(typeResource, -quantity)) { changeResourceStock(typeResource, -quantity); remoteIsland.resourceManager.changeResourceStock(typeResource, quantity); return(true); } else { return(false); } }
void Start() { GetComponent <Animator>().SetInteger("animCargo", 0); this.island = this.transform.parent.GetComponent <MinorIsland>(); this.startPosition = this.transform.position; this.harbor = GameObject.Find(this.islandToSend + "_Harbor"); StartCoroutine(startBoatAppearance()); SpriteRenderer cyclonePrefab = Resources.Load <SpriteRenderer>("Prefab/cyclone"); SpriteRenderer cyclone = Instantiate(cyclonePrefab); cyclone.name = "cyclone"; StartCoroutine(spine(cyclone)); }
void Awake() { rnd = new System.Random(); this.island1 = GameObject.Find("sous_ile_1").GetComponent <MinorIsland>(); this.island2 = GameObject.Find("sous_ile_2").GetComponent <MinorIsland>(); this.island3 = GameObject.Find("sous_ile_3").GetComponent <MinorIsland>(); this.island4 = GameObject.Find("sous_ile_4").GetComponent <MinorIsland>(); this.Client = GameObject.Find("Network").GetComponent <Client>(); this.Client.MessagePiratesStartArrivalEvent += Client_MessagePiratesStartArrivalEvent; this.Client.MessagePiratesIncreaseRateEvent += Client_MessagePiratesIncreaseRateEvent; this.interval = this.initInterval; }
void Awake() { rnd = new System.Random(); this.island1 = GameObject.Find("sous_ile_1").GetComponent<MinorIsland>(); this.island2 = GameObject.Find("sous_ile_2").GetComponent<MinorIsland>(); this.island3 = GameObject.Find("sous_ile_3").GetComponent<MinorIsland>(); this.island4 = GameObject.Find("sous_ile_4").GetComponent<MinorIsland>(); this.Client = GameObject.Find("Network").GetComponent<Client>(); this.Client.MessagePiratesStartArrivalEvent += Client_MessagePiratesStartArrivalEvent; this.Client.MessagePiratesIncreaseRateEvent += Client_MessagePiratesIncreaseRateEvent; this.interval = this.initInterval; }
void OnMouseDownSimulation() { island = this.transform.parent.parent.parent.GetComponent <MinorIsland>(); buildingClicked = island.buildingClickedWheel; if (this.name == "Build") { island.wheelPresent = false; island.createChallengeBuild(buildingClicked); island.challengePresent = true; Destroy(GameObject.Find("WheelCanvas_" + this.transform.parent.parent.parent.name)); } island.buildingInfoPresent = false; Destroy(this.transform.parent.parent.gameObject); }
void OnMouseDownSimulation() { island = this.transform.parent.parent.parent.GetComponent<MinorIsland>(); buildingClicked = island.buildingClickedWheel; if (this.name == "Build") { island.wheelPresent = false; island.createChallengeBuild(buildingClicked); island.challengePresent = true; Destroy(GameObject.Find("WheelCanvas_" + this.transform.parent.parent.parent.name)); } island.buildingInfoPresent = false; Destroy(this.transform.parent.parent.gameObject); }
void OnTriggerEnter(Collider col) { this.Client = GameObject.Find("Network").GetComponent <Client>(); if (col.name == islandToSend + "_Harbor") { MinorIsland islandReceiver = GameObject.Find(islandToSend).GetComponent <MinorIsland>(); this.collided = true; islandReceiver.displayPopup("Vous venez de recevoir une cargaison de " + this.quantityCarried.ToString() + " " + Resource.translateResourceName(resourceSent) + " !", 3); MinorIsland.exchangePerforming = false; //add resources to islandToSend TypeResource res = (TypeResource)System.Enum.Parse(typeof(TypeResource), resourceSent); islandReceiver.resourceManager.changeResourceStock(res, this.quantityCarried); this.Client.sendData("@2" + islandReceiver.nameMinorIsland.Split('_')[2] + "355@" + islandReceiver.resourceManager.getResource(res).TypeResource.ToString() + "@" + this.quantityCarried.ToString()); StartCoroutine(startBoatDisappearance()); } else { if (this.quantityCarried / 2 == 0) { this.collided = true; island.displayPopup("Suite aux dommages subis, votre bateau coule, ainsi que toutes les ressources transportées ...", 3); MinorIsland.exchangePerforming = false; //SINK ANIMATION StartCoroutine(SinkingCargo()); //StartCoroutine(startBoatDisappearance()); } else { resetting = true; StartCoroutine(resetPosition()); if (col.name.Contains("Harbor")) { island.displayPopup("Ce n'est pas le bon port ! Vous perdez donc la moitié des ressources à transmettre.", 3); } else { island.displayPopup("Attention ! Vous venez de subir une collision, vous perdez donc la moitié des ressources à transmettre.", 3); } this.quantityCarried /= 2; } } }
public void init(MinorIsland island) { this.Client = GameObject.Find("Network").GetComponent <Client>(); this.Client.MessageResourceInitEvent += Client_MessageResourceInitEvent; this.Client.MessageResourceStockReceivedEvent += Client_MessageResourceStockReceivedEvent; this.minorIsland = island; this.Resources = new List <Resource>(); //Add all resources foreach (TypeResource resourceType in Enum.GetValues(typeof(TypeResource))) { this.addResource(resourceType, 5, 0); } switch (this.minorIsland.nameMinorIsland) { case "sous_ile_1": this.changeResourceStock(TypeResource.Gold, 10); this.changeResourceStock(TypeResource.Stone, 5); break; case "sous_ile_2": this.changeResourceStock(TypeResource.Gold, 5); this.changeResourceStock(TypeResource.Stone, 10); this.changeResourceStock(TypeResource.Oil, 20); this.changeResourceStock(TypeResource.Wood, 10); break; case "sous_ile_3": this.changeResourceStock(TypeResource.Gold, 5); this.changeResourceStock(TypeResource.Stone, 10); break; case "sous_ile_4": this.changeResourceStock(TypeResource.Stone, 5); this.changeResourceStock(TypeResource.Wood, 10); break; } }
public void init(MinorIsland island) { this.minorIsland = island; buildingList = new List <Building>(); }
void Start() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent <MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent <Building>(); }
public void init(MinorIsland island) { this.minorIsland = island; buildingList = new List<Building>(); }
void Start() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent<MinorIsland>(); building = GameObject.Find(island.nameBuildingTouched).GetComponent<Building>(); }
// Use this for initialization void Start() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent <MinorIsland>(); }
// Use this for initialization void Start() { island = GameObject.Find("sous_ile_" + gameObject.transform.parent.name.Split('_')[3].ToString()).GetComponent <MinorIsland>(); }
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"); }
public bool donateResource(MinorIsland remoteIsland, TypeResource typeResource, int quantity) { if (checkWithdrawPossibility(typeResource, -quantity)) { changeResourceStock(typeResource, -quantity); remoteIsland.resourceManager.changeResourceStock(typeResource, quantity); return true; } else { return false; } }
// Use this for initialization void Start() { island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent<MinorIsland>(); }
public void init(MinorIsland island) { this.Client = GameObject.Find("Network").GetComponent<Client>(); this.Client.MessageResourceInitEvent += Client_MessageResourceInitEvent; this.Client.MessageResourceStockReceivedEvent += Client_MessageResourceStockReceivedEvent; this.minorIsland = island; this.Resources = new List<Resource>(); //Add all resources foreach (TypeResource resourceType in Enum.GetValues(typeof(TypeResource))) { this.addResource(resourceType, 5, 0); } switch (this.minorIsland.nameMinorIsland) { case "sous_ile_1": this.changeResourceStock(TypeResource.Gold, 10); this.changeResourceStock(TypeResource.Stone, 5); break; case "sous_ile_2": this.changeResourceStock(TypeResource.Gold, 5); this.changeResourceStock(TypeResource.Stone, 10); this.changeResourceStock(TypeResource.Oil, 20); this.changeResourceStock(TypeResource.Wood, 10); break; case "sous_ile_3": this.changeResourceStock(TypeResource.Gold, 5); this.changeResourceStock(TypeResource.Stone, 10); break; case "sous_ile_4": this.changeResourceStock(TypeResource.Stone, 5); this.changeResourceStock(TypeResource.Wood, 10); break; } }
public void init(TypeChallenge tc, MinorIsland island, Building myBuilding) { this.Client = GameObject.Find("Network").GetComponent <Client>(); canvasChallenge = this.transform.parent.GetComponent <Canvas>(); this.building = myBuilding; 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() + "_" + myBuilding.TypeBuilding.ToString()); if (RegisterScene.level == 0) //collège { csv = Resources.Load <TextAsset>("Challenges/ChallengesFiles/College/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + myBuilding.TypeBuilding.ToString()); } else { csv = Resources.Load <TextAsset>("Challenges/ChallengesFiles/Lycee/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + myBuilding.TypeBuilding.ToString()); } Debug.Log("File : " + typeChallenge.ToString() + "_" + myBuilding.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]; } 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; } } foreach (SpriteRenderer sp in canvasChallenge.GetComponentsInChildren <SpriteRenderer>()) { if (sp.name == "background") { this.background = sp; } } } else { minorIsland.displayPopup("Oups ! Une erreur s'eest produite, veuillez ré-essayer ...", 3); Destroy(GameObject.Find("Challenge_" + typeChallenge + "_" + minorIsland.nameMinorIsland)); } } }
// Use this for initialization void Start() { island = GameObject.Find("sous_ile_" + gameObject.transform.parent.name.Split('_')[3].ToString()).GetComponent<MinorIsland>(); }
void Start() { GetComponent<Animator>().SetInteger("animCargo", 0); this.island = this.transform.parent.GetComponent<MinorIsland>(); this.startPosition = this.transform.position; this.harbor = GameObject.Find(this.islandToSend + "_Harbor"); StartCoroutine(startBoatAppearance()); SpriteRenderer cyclonePrefab = Resources.Load<SpriteRenderer>("Prefab/cyclone"); SpriteRenderer cyclone = Instantiate(cyclonePrefab); cyclone.name = "cyclone"; StartCoroutine(spine(cyclone)); }
public void init(TypeChallenge tc, MinorIsland island, Building myBuilding) { this.Client = GameObject.Find("Network").GetComponent<Client>(); canvasChallenge = this.transform.parent.GetComponent<Canvas>(); this.building = myBuilding; 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() + "_" + myBuilding.TypeBuilding.ToString()); if (RegisterScene.level == 0) //collège csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/College/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + myBuilding.TypeBuilding.ToString()); else csv = Resources.Load<TextAsset>("Challenges/ChallengesFiles/Lycee/" + typeChallenge.ToString() + "/" + typeChallenge.ToString() + "_" + myBuilding.TypeBuilding.ToString()); Debug.Log("File : " + typeChallenge.ToString() + "_" + myBuilding.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]; 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; } } foreach (SpriteRenderer sp in canvasChallenge.GetComponentsInChildren<SpriteRenderer>()) { if (sp.name == "background") this.background = sp; } } else { minorIsland.displayPopup("Oups ! Une erreur s'eest produite, veuillez ré-essayer ...", 3); Destroy(GameObject.Find("Challenge_" + typeChallenge + "_" + minorIsland.nameMinorIsland)); } } }