private bool changeResourceProduction(object sender, MessageEventArgs e, TypeResource resourceType, int value) { //int islandNumber = (Int32.Parse((string)e.message.Split('@').GetValue(1)) % 10000)/100; char islandNumber = ((string)e.message.Split('@').GetValue(1))[1]; if (!gameObject.name.Contains(islandNumber)) { //Island not concerned return(false); } Resource resource = this.getResource(resourceType); bool result = false; if (resource != null) { result = resource.changeProduction(value); } else { if (value >= 0) { this.addResource(resourceType, 0, value); result = true; } else { return(false); } } return(result); }
public IEnumerator envoiDataUne(TypeResource resourceLost, int quantityLost, string island) { this.Client.sendData("@3" + island.Split('_')[2] + "770"); yield return new WaitForSeconds(0.5f); Client.sendData("@2" + island.Split('_')[2] + "394@" + resourceLost.ToString() + "@" + quantityLost.ToString()); yield return new WaitForSeconds(0.1f); }
public void init(TypeResource TypeResource) { this.TypeResource = TypeResource; this.Stock = 0; this.Production = 0; this.ProductionInit = 0; }
public Resource(int id, string name, string opis, TypeResource type) { Id = id; Name = name; Opis = opis; Type = type; }
public bool changeResourceStock(object sender, MessageEventArgs e, TypeResource resourceType, int value) { //Debug.Log("Changing resource stock : " + resourceType.ToString() + " - " + value.ToString()); char islandNumber = ((string)e.message.Split('@').GetValue(1))[1]; if (!gameObject.name.Contains(islandNumber)) { //Island not concerned return false; } //Debug.Log("Stock update : " + e.message); Resource resource = this.getResource(resourceType); bool result = false; if (resource != null) { result = resource.changeStock(value); } else { if (value >= 0) { this.addResource(resourceType, value); result = true; } else { return false; } } //The board shouldn't notice the network of an gloabl stock update if(this.ChangeResourceStockEvent != null) // && result) { this.ChangeResourceStockEvent(this, new ChangeResourceStockEventArgs { resourceType = resourceType, stock = value }); // resource.Stock }); } return result; }
public bool addResource(TypeResource resourceType, int quantity, int production) { bool flag = false; foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { flag = true; } } if (flag == true) { return(false); } else { //GameObject myGameObject = new GameObject(); //myGameObject.transform.SetParent(GameObject.Find("Virtual_" + minorIsland.nameMinorIsland).transform); Resource res = ScriptableObject.CreateInstance <Resource>(); res.init(resourceType, quantity, production); this.Resources.Add(res); return(true); } }
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)); }
public IEnumerator envoiDataToutes(TypeResource resourceLost, int quantityLost) { this.Client.sendData("@35770"); yield return new WaitForSeconds(0.5f); this.Client.sendData("@25394@" + resourceLost.ToString() + "@" + quantityLost.ToString()); yield return new WaitForSeconds(0.1f); }
public void putResource(TypeResource type, int n) { switch (type) { case TypeResource.FRUIT: fruit += n; refreshInfo(); break; case TypeResource.MEAT: meat += n; refreshInfo(); break; case TypeResource.STONE: stone += n; refreshInfo(); break; case TypeResource.WOOD: twig += n; refreshInfo(); break; case TypeResource.GRASS: grass += n; refreshInfo(); break; } }
public void init(TypeResource TypeResource, int quantity) { init(TypeResource); if (quantity > 0) { this.Stock = quantity; } }
public Resource(TypeResource types, InternshipResource internships, TierResource tiers, EnchantmentsResource enchantments, int quantityResource) { Types = types; Internships = internships; Tiers = tiers; Enchantments = enchantments; QuantityResource = quantityResource; }
public void init(TypeResource TypeResource, int quantity, int production) { init(TypeResource, quantity); if(production > 0) { this.Production = (int)production; } }
public IEnumerator envoiDataUne(TypeResource resourceLost, int quantityLost, string island) { this.Client.sendData("@3" + island.Split('_')[2] + "770"); yield return(new WaitForSeconds(0.5f)); Client.sendData("@2" + island.Split('_')[2] + "394@" + resourceLost.ToString() + "@" + quantityLost.ToString()); yield return(new WaitForSeconds(0.1f)); }
public void init(TypeResource TypeResource, int quantity, int production) { init(TypeResource, quantity); if (production > 0) { this.Production = (int)production; } }
public IEnumerator envoiDataToutes(TypeResource resourceLost, int quantityLost) { this.Client.sendData("@35770"); yield return(new WaitForSeconds(0.5f)); this.Client.sendData("@25394@" + resourceLost.ToString() + "@" + quantityLost.ToString()); yield return(new WaitForSeconds(0.1f)); }
public GameObject getFoodinStock(TypeResource type) { foreach (GameObject gbj in stockpiles) { return(gbj.GetComponent <StockpileScript>().getFood(type)); } return(null); }
public void init(TypeResource TypeResource, int quantity) { init(TypeResource); if (quantity > 0) { this.Stock = (int)quantity; } this.Production = 0; }
public bool changeResourceProduction(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); int oldProd, newProd; oldProd = (int)resource.Production; bool result = resource.changeProduction(value); newProd = (int)resource.Production; this.Client.sendData("@2" + this.minorIsland.nameMinorIsland.Split('_')[2] + "345@" + resource.TypeResource.ToString() + "@" + (newProd - oldProd).ToString()); return result; }
public bool changeResourceProduction(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); bool result = resource.changeProduction(value); if (result) { this.building.minorIsland.resourceManager.changeResourceProduction(resourceType, value); } return result; }
public bool changeResourceProduction(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); bool result = resource.changeProduction(value); if (result) { this.building.minorIsland.resourceManager.changeResourceProduction(resourceType, value); } return(result); }
public Resource getResource(TypeResource resourceType) { foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { return(item); } } return(null); }
public Resource getResource(TypeResource resourceType) { foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { return item; } } return null; }
public void SetResouce(TypeResource res, float value) // Добавить ресурс на склад { if (StockResouces.ContainsKey((int)res)) { StockResouces[(int)res] += value; } else { StockResouces[(int)res] = value; } }
public bool changeResourceProduction(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); int oldProd, newProd; oldProd = (int)resource.Production; bool result = resource.changeProduction(value); newProd = (int)resource.Production; this.Client.sendData("@2" + this.minorIsland.nameMinorIsland.Split('_')[2] + "345@" + resource.TypeResource.ToString() + "@" + (newProd - oldProd).ToString()); return(result); }
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); } }
private void Client_MessageResourceStockReceivedEvent(object sender, MessageEventArgs e) { //If it concerns my island char islandNumber = (char)e.message.Split('@')[1][1]; if (this.minorIsland.nameMinorIsland.Contains(islandNumber) || islandNumber == '0') { TypeResource resourceType = (TypeResource)Enum.Parse(typeof(TypeResource), (string)e.message.Split('@')[2]); int quantity = Int32.Parse(e.message.Split('@')[3]); this.changeResourceStock(resourceType, quantity); this.Client.sendData("@2" + this.minorIsland.nameMinorIsland.Split('_')[2] + "355@" + resourceType.ToString() + "@" + quantity); } }
public GameObject getFood(TypeResource type) { foreach (Tile t in tiles) { if (t.staticEntity != null) { if (t.staticEntity.GetComponent <ResourceManager>().type == type) { return(t.staticEntity); } } } return(null); }
public IActionResult UpdateType(int id, [FromBody] TypeResource typeResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var type = typeRepository.Get(id); mapper.Map(typeResource, type); uow.Complete(); var result = mapper.Map <Type, TypeResource>(type); return(Ok(result)); }
public IActionResult CreateType([FromBody] TypeResource typeResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var type = mapper.Map <TypeResource, Type>(typeResource); typeRepository.Add(type); uow.Complete(); var result = mapper.Map <Type, TypeResource>(type); return(Ok(result)); }
public int nbRessourceInStockPile(TypeResource type) { int res = 0; foreach (Tile t in tiles) { if (t.staticEntity != null) { if (t.staticEntity.GetComponent <ResourceManager> ().type == type) { res += t.staticEntity.GetComponent <ResourceManager> ().nbResource; } } } return(res); }
static public void AddResource(string name, TypeResource type) { var graphics = GraphicsSingleton.GetInstance(); var content = GraphicsSingleton.GetInstance().Content; switch (type) { case TypeResource.Texture2D: { var tex = content.Load <Texture2D>(name); resources.Add(name, tex); } break; case TypeResource.Font: resources.Add(name, content.Load <SpriteFont>(name)); break; default: throw new Exception("Undefined resource type"); } }
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; } } }
static void Main(string[] args) { Console.WriteLine("Type (Ore, Wood, Fiber, Leather, Stone)"); TypeResource type = Enum.Parse <TypeResource>(Console.ReadLine()); Console.WriteLine("Estagio da materia (Druto/Refined) :"); InternshipResource internship = Enum.Parse <InternshipResource>(Console.ReadLine()); Console.WriteLine("Tier (Tier1/.../Tier8) :"); TierResource tier = Enum.Parse <TierResource>(Console.ReadLine()); Console.WriteLine("Enchantments (1,2 e 3) :"); EnchantmentsResource enchantments = Enum.Parse <EnchantmentsResource>(Console.ReadLine()); Console.WriteLine("Quantity:"); int quantity = int.Parse(Console.ReadLine()); Resource x = new Resource(type, internship, tier, enchantments, quantity); Console.WriteLine(x); }
public bool changeResourceStock(object sender, MessageEventArgs e, TypeResource resourceType, int value) { //Debug.Log("Changing resource stock : " + resourceType.ToString() + " - " + value.ToString()); char islandNumber = ((string)e.message.Split('@').GetValue(1))[1]; if (!gameObject.name.Contains(islandNumber)) { //Island not concerned return(false); } //Debug.Log("Stock update : " + e.message); Resource resource = this.getResource(resourceType); bool result = false; if (resource != null) { result = resource.changeStock(value); } else { if (value >= 0) { this.addResource(resourceType, value); result = true; } else { return(false); } } //The board shouldn't notice the network of an gloabl stock update if (this.ChangeResourceStockEvent != null) // && result) { this.ChangeResourceStockEvent(this, new ChangeResourceStockEventArgs { resourceType = resourceType, stock = value }); // resource.Stock }); } return(result); }
public bool addResource(TypeResource resourceType, int quantity, int production = 0) { bool flag = false; foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { flag = true; } } if (flag == true) { return false; } else { Resource res = ScriptableObject.CreateInstance<Resource>(); res.init(resourceType, quantity); this.Resources.Add(res); return true; } }
public bool changeResourceStock(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); bool result = false; if (resource != null) { result = resource.changeStock(value); } else { if (value >= 0) { this.addResource(resourceType, value, 0); result = true; } else { return(false); } } return(result); }
public bool addResource(TypeResource resourceType, int quantity, int production = 0) { bool flag = false; foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { flag = true; } } if (flag == true) { return(false); } else { Resource res = ScriptableObject.CreateInstance <Resource>(); res.init(resourceType, quantity); this.Resources.Add(res); return(true); } }
public bool changeResourceStock(TypeResource resourceType, int value) { Resource resource = this.getResource(resourceType); bool result = false; if (resource != null) { result = resource.changeStock(value); } else { if (value >= 0) { this.addResource(resourceType, value, 0); result = true; } else { return false; } } return result; }
public bool addResource(TypeResource resourceType, int quantity, int production) { bool flag = false; foreach (Resource item in this.Resources) { if (item.TypeResource == resourceType) { flag = true; } } if (flag == true) { return false; } else { //GameObject myGameObject = new GameObject(); //myGameObject.transform.SetParent(GameObject.Find("Virtual_" + minorIsland.nameMinorIsland).transform); Resource res = ScriptableObject.CreateInstance<Resource>(); res.init(resourceType, quantity, production); this.Resources.Add(res); return true; } }
private bool changeResourceProduction(object sender, MessageEventArgs e, TypeResource resourceType, int value) { //int islandNumber = (Int32.Parse((string)e.message.Split('@').GetValue(1)) % 10000)/100; char islandNumber = ((string)e.message.Split('@').GetValue(1))[1]; if (!gameObject.name.Contains(islandNumber)) { //Island not concerned return false; } Resource resource = this.getResource(resourceType); bool result = false; if(resource!= null) { result = resource.changeProduction(value); } else { if (value >= 0) { this.addResource(resourceType, 0, value); result = true; } else { return false; } } return result; }
void OnMouseDownSimulation() { this.Client = GameObject.Find("Network").GetComponent <Client>(); refresh(); if (!island.otherWindowOpen) { string resourceName; int resourceQuantity; if (resource_sp.GetComponent <SpriteRenderer>().sprite.name == "cercleChoixRessource") //default sprite { resourceName = string.Empty; resourceQuantity = 0; } else { resourceName = Resource.getResourceFromIconName(resource_sp.GetComponent <SpriteRenderer>().sprite.name); resourceQuantity = (int)this.island.resourceManager.getResource((TypeResource)System.Enum.Parse(typeof(TypeResource), resourceName)).Stock; } Vector3 vector3; switch (this.name) { case "ResourceValue": Canvas listResourcesCanvasPrefab = Resources.Load <Canvas>("Prefab/ListResourcesCanvas"); Canvas listResourcesCanvas = Instantiate(listResourcesCanvasPrefab); listResourcesCanvas.name = "listResourcesCanvas_" + island.nameMinorIsland; listResourcesCanvas.transform.SetParent(GameObject.Find(island.nameMinorIsland).transform); vector3 = GameObject.Find("sprite-" + island.nameMinorIsland).transform.position; vector3.z = -6; listResourcesCanvas.transform.position = vector3; foreach (SpriteRenderer sr in listResourcesCanvas.GetComponentsInChildren <SpriteRenderer>()) { sr.GetComponent <BoxCollider>().enabled = true; if ((sr.name != "Close") && (this.island.resourceManager.getResource((TypeResource)System.Enum.Parse(typeof(TypeResource), sr.name)).Stock < 5)) { sr.sprite = Resources.Load <Sprite>("infoBatiments/ResourcesIcons/" + sr.name + "Icon_disabled"); sr.GetComponent <BoxCollider>().enabled = false; } } island.otherWindowOpen = true; quantityValue.text = "0"; //rotation if other side of the table char id = this.island.nameMinorIsland[this.island.nameMinorIsland.Length - 1]; if (id == '1' || id == '2') { listResourcesCanvas.transform.Rotate(Vector3.forward * 180); } break; case "Less": if (quantityValue.text == "0") { this.GetComponent <BoxCollider>().enabled = false; } else { quantityValue.text = (int.Parse(quantityValue.text) - 5).ToString(); more.GetComponent <BoxCollider>().enabled = true; } break; case "More": this.GetComponent <BoxCollider>().enabled = true; if ((quantityValue.name == "QuantityValue") && (int.Parse(quantityValue.text) + 5 <= resourceQuantity)) { quantityValue.text = (int.Parse(quantityValue.text) + 5).ToString(); less.GetComponent <BoxCollider>().enabled = true; } break; case "Island": Canvas listIslandsCanvasPrefab = Resources.Load <Canvas>("Prefab/ListeIslandsCanvas"); Canvas listIslandsCanvas = Instantiate(listIslandsCanvasPrefab); listIslandsCanvas.name = "listIslandsCanvas_" + island.nameMinorIsland; listIslandsCanvas.transform.SetParent(GameObject.Find(island.nameMinorIsland).transform); vector3 = GameObject.Find("sprite-" + island.nameMinorIsland).transform.position; vector3.z = -6; listIslandsCanvas.transform.position = vector3; //disable clic on self island foreach (SpriteRenderer sp in listIslandsCanvas.GetComponentsInChildren <SpriteRenderer>()) { if (sp.name == island.nameMinorIsland) { sp.GetComponent <BoxCollider>().enabled = false; } } island.otherWindowOpen = true; //rotation if other side of the table char idIsland = this.island.nameMinorIsland[this.island.nameMinorIsland.Length - 1]; if (idIsland == '1' || idIsland == '2') { listIslandsCanvas.transform.Rotate(Vector3.forward * 180); } break; case "Close": island.exchangeWindowPresent = false; Destroy(GameObject.Find(this.transform.parent.parent.name)); break; case "Send": if (to.text == "Ile X") { island.displayPopup("Veuillez sélectionner une île, en appuyant sur \"Ile X\".", 3); } else { if (quantityValue.text == "0") { island.displayPopup("Veuillez sélectionner une quantité à envoyer", 3); } else { if (resource_sp.sprite.name == "Knob") //defaults sprite when not already clicked on { island.displayPopup("Veuillez sélectionner une ressource à envoyer", 3); } else { if (MinorIsland.exchangePerforming) { island.displayPopup("Veuillez attendre la fin de l'échange en cours", 3); } else { //withdrawal of resources TypeResource tr = (TypeResource)System.Enum.Parse(typeof(TypeResource), Resource.getResourceFromIconName(this.resource_sp.sprite.name)); int quantitySent = int.Parse(quantityValue.text); Resource res = island.resourceManager.getResource(tr); res.changeStock(-quantitySent); this.Client.sendData("@2" + this.island.nameMinorIsland.Split('_')[2] + "355@" + res.TypeResource.ToString() + "@" + (-quantitySent).ToString()); MinorIsland.exchangePerforming = true; SpriteRenderer exchangeResourceAnimationPrefab = Resources.Load <SpriteRenderer>("Prefab/exchangeResourceAnimation/exchangeResourceAnimation_" + island.nameMinorIsland[island.nameMinorIsland.Length - 1].ToString()); exchangeResourceAnimation = Instantiate(exchangeResourceAnimationPrefab); exchangeResourceAnimation.transform.parent = GameObject.Find(island.nameMinorIsland).transform; exchangeResourceAnimation.name = "ExchangeResourceAnimation_" + island.nameMinorIsland; exchangeResourceAnimation.GetComponent <BoatMoving>().islandToSend = "sous_ile_" + island.islandToSend[island.islandToSend.Length - 1].ToString(); exchangeResourceAnimation.GetComponent <BoatMoving>().quantityCarried = quantitySent; exchangeResourceAnimation.GetComponent <BoatMoving>().resourceSent = tr.ToString(); island.exchangeWindowPresent = false; island.displayPopup("Emmenez le bateau jusqu'au port de l'île sélectionnée pour lui apporter les ressources", 5); Destroy(GameObject.Find(this.transform.parent.parent.name)); } } } } break; } } else //closure of other windows (listResources & listIslands) { if (this.name == "Close") { island.otherWindowOpen = false; island.exchangeWindowPresent = false; Destroy(GameObject.Find("listIslandsCanvas_" + island.nameMinorIsland)); Destroy(GameObject.Find("listResourcesCanvas_" + island.nameMinorIsland)); Destroy(GameObject.Find(this.transform.parent.parent.name)); } } }
public void init(TypeResource TypeResource, int quantity, int production) { init(TypeResource, quantity); this.Production = production; this.ProductionInit = production; }
public bool checkWithdrawPossibility(TypeResource resourceType, int value) { return this.getResource(resourceType).checkChangeStockPossibility(value); }
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; } }
public void init(TypeResource TypeResource) { this.TypeResource = TypeResource; this.Stock = 0; this.Production = 0; }