private NaturalResource CreateRSS(int insId) { NaturalResource rss = Instantiate(RssPrefab, resourceContainer.transform); rss.FirstSetup(insId); return(rss); }
// Start is called before the first frame update void Start() { _nodes = new NodeBehaviour[_baseIndustryNumber.Length - 1]; _natRes = new NaturalResource[_naturalResources.Length]; for (int i = 0; i < _baseIndustryNumber.Length - 1; ++i) { int var = _baseIndustryNumber[i] + (Random.Range(-_industryNumberVariations[i], _industryNumberVariations[i])); _totalIndusty += var; _nodes[i] = new NodeBehaviour(); _nodes[i].ammount = var; _nodes[i].acceptancePerc = _baseIndustryNumber[5] + (Random.Range((float)-_industryNumberVariations[5], (float)_industryNumberVariations[5])); _nodes[i].industry = new Industry(); _nodes[i].industry.industryName = _baseWorld.baseIndustries[i].industryName; _nodes[i].industry.baseGenerationPerDay = _baseWorld.baseIndustries[i].baseGenerationPerDay; _nodes[i].industry.baseMultiplierPerDay = _baseWorld.baseIndustries[i].baseMultiplierPerDay; WorldBehaviour.onDayUpdate += _nodes[i].OnDateUpdate; } for (int i = 0; i < _naturalResources.Length; ++i) { int var = _naturalResources[i] + (Random.Range(-_naturalResourcesVariation[i], _naturalResourcesVariation[i])); _totalNaturalResources += var; _natRes[i] = new NaturalResource(); _natRes[i].ammount = var; _natRes[i].resourceName = _baseWorld.naturalResources[i].resourceName; _natRes[i].baseReductionPerDay = _baseWorld.naturalResources[i].baseReductionPerDay; WorldBehaviour.onDayUpdate += _natRes[i].OnDateUpdate; } }
void DragNaturalResource() { RaycastHit2D hit = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { GameObject hitGO = hit.transform.gameObject; if (hitGO.tag == "ShopTile") { originTile = null; resourceSelected = hitGO.GetComponent <NaturalResource>(); print("Compra"); } else if (hitGO.tag == "MapTile") { originTile = hitGO.GetComponent <TileLogic>(); resourceSelected = originTile.resource; originTile.resource = resourceSelected; print("YaY"); } } else { print("Nay!"); } }
void DropNaturalResource() { RaycastHit2D hit = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { GameObject hitGO = hit.collider.gameObject; if (hitGO.tag == "MapTile") { hitGO.GetComponent <TileLogic>().OnApplyResource(resourceSelected); if (originTile != null) { originTile.OnRemoveResource(resourceSelected); } else { } } else if (hitGO.tag == "ShopTile") { if (originTile != null) { print("venta"); flagSelected = false; originTile.OnRemoveResource(resourceSelected); } } } resourceSelected = null; originTile = null; }
public void OnReceiveInfluence(NaturalResource _resource, float percentageInfluence) { luminosity -= _resource.luminosity; humidity -= _resource.humidity; nutrients -= _resource.nutrients; GetComponent <TileVisual>().OnApplyResource(); }
void AddResources(BattleField field) { NaturalResource[] res = field.NaturalResources; for (int i = 0; i < res.Length; i++) { NaturalResource obj = res[i]; switch (obj.Type) { case NaturalResourceType.Oil: OilFieldObject oilfld = obj as OilFieldObject; if (oilfld != null) { oilfld.ResVisible += scene.Resource_Visible; oilfld.InitalizeGraphics(renderSys); scene.Scene.AddObjectToScene(oilfld); } break; case NaturalResourceType.Wood: ForestObject forest = obj as ForestObject; if (forest != null) { forest.ResVisible += scene.Resource_Visible; forest.InitalizeGraphics(renderSys); scene.Scene.AddObjectToScene(forest); } break; } } }
void ApplyResourceEffect(NaturalResource resource, int x, int y) { for (int xx = -resource.rangeAction; xx < resource.rangeAction; xx++) { for (int yy = -resource.rangeAction; yy < resource.rangeAction; yy++) { bool xValid = x + xx >= 0 && x + xx < 15; bool yValid = y + yy >= 0 && y + yy < 15; bool inRange = Mathf.Abs(xx) + Mathf.Abs(yy) <= resource.rangeAction; if (xValid && yValid && inRange && (xx != 0 || yy != 0)) { TileLogic currTile = tiles[x + xx, y + yy].GetComponent <TileLogic>(); currTile.luminosity += resource.luminosity; currTile.humidity += resource.humidity; currTile.nutrients += resource.nutrients; } } } for (int xx = -resource.rangeHealing; xx < resource.rangeHealing; xx++) { for (int yy = -resource.rangeHealing; yy < resource.rangeHealing; yy++) { bool xValid = x + xx >= 0 && x + xx < 15; bool yValid = y + yy >= 0 && y + yy < 15; bool inRange = Mathf.Abs(xx) + Mathf.Abs(yy) < resource.rangeHealing; if (xValid && yValid && inRange) { TileLogic currTile = tiles[x + xx, y + yy].GetComponent <TileLogic>(); currTile.recovered = true; } } } }
public override void OnAfterResourcesModified(int x, int z, NaturalResource type, int amount) { if ((type == NaturalResource.Oil || type == NaturalResource.Ore) && amount < 0) { ExtendedGameOptionsSerializable o = Singleton <ExtendedGameOptionsManager> .instance.values; if (type == NaturalResource.Oil) { // Vanilla original rate (100%) if (o.OilDepletionRate == 100) { return; } if (o.OilDepletionRate == 0) { // Vanilla original UnlimitedOilAndOre mod resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } else { // 1% ~ 99% if (Singleton <SimulationManager> .instance.m_randomizer.Int32(100u) >= o.OilDepletionRate) { resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } } } else if (type == NaturalResource.Ore) { // Vanilla original rate (100%) if (o.OreDepletionRate == 100) { return; } if (o.OreDepletionRate == 0) { // Vanilla original UnlimitedOilAndOre mod resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } else { // 1% ~ 99% if (Singleton <SimulationManager> .instance.m_randomizer.Int32(100u) >= o.OreDepletionRate) { resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } } } } }
public bool OnApplyResource(NaturalResource _resource) { if (map.OnApplyResource(logicPosX, logicPosY, _resource)) { resource = _resource; renderContenido.sprite = resource.spriteResource; MapController.instance.OnTilesRecovered(); GameController.instance.OnResourceBought(resource); UIController.instance.CalculateProgress(); UIController.instance.UpdateMoney(); return(true); } else { return(false); } }
public override void OnAfterResourcesModified(int x, int z, NaturalResource type, int amount) { if ((type == NaturalResource.Oil || type == NaturalResource.Ore) && amount < 0) { int depletionRate = Singleton <GameSpeedManager> .instance.Parameters.OilOreDepletionRate; // Vanilla original rate (100%) if (depletionRate == 100) { return; } if (Singleton <SimulationManager> .instance.m_randomizer.Int32(100u) >= depletionRate) { // From the vanilla original UnlimitedOilAndOre mod resourceManager.SetResource(x, z, type, (byte)(resourceManager.GetResource(x, z, type) - amount), false); } } }
public void SetNaturalResource(NaturalResource resource) { resourceSelected = resource; if (resource != null) { this.transform.position = Input.mousePosition; GetComponent <Image>().sprite = resourceSelected.spriteResource; GetComponent <Image>().enabled = true; flagSelected = true; TileVisual.target = resourceSelected; TileVisual.mode = VisualTileMode.ShowAvailability; } else { flagSelected = false; GetComponent <Image>().enabled = false; TileVisual.mode = VisualTileMode.ShowWater; } }
void OnReleaseResource() { RaycastHit2D hit = Physics2D.Raycast(cam.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { GameObject hitGO = hit.collider.gameObject; if (hitGO.tag == "ShopTile") { if (originTile != null) { print("venta"); flagSelected = false; originTile.OnRemoveResource(resourceSelected); } } } resourceSelected = null; originTile = null; }
public void OnRemoveResource(NaturalResource _resource) { //Desplantar }
public void Add(NaturalResource naturalResource) { database.Add(naturalResource); }
public void Remove(NaturalResource naturalResource) { database.Remove(naturalResource); }
// Start is called before the first frame update void Start() { resource = null; }
public void Initialization(NaturalResource naturalResources) { FarmingGameController.ChangeResourcesAction += UpdateText; _naturalResources = naturalResources; _saleButtton.onClick.AddListener(SaleResource); }
public void OnResourceSell(NaturalResource newResource) { money += newResource.cost; //resourcesBought.Add(newResource); }
private IEnumerator StartCreateRssWaiting() { AJPHelper.Operation oper = RSSPositionTable.Operation; while (!oper.IsDone) { yield return(null); } //if (!treeInited) //{ // int rssCount = RSSPositionTable.Count; // for (int iter = 0; iter < rssCount; iter++) // { // rssPositionTree.Insert // (RSSPositionTable.ReadOnlyRows[iter].Position.Parse3Int().ToClientPosition()); // } // treeInited = true; //} if (!treeInited) { rssPositionTree.AsyncCreateTree(GetRssPositionEnumerable()); while (!rssPositionTree.IsAsyncCreateComplete) { yield return(null); } treeInited = true; Debugger.Log("quad tree inited"); } isCreateComplete = false; int count = WaitForCreate.Count; //int i = count - 1; while (WaitForCreate.Count > 0 && !isCreateComplete) { Vector3Int pos = WaitForCreate[WaitForCreate.Count - 1].ToSerPosition(); RSS_PositionRow rssData = RSSPositionTable.GetRssAt(pos); if (rssData != null && !Resources.ContainsKey(rssData.ID)) { /// Using pool object for natural resource NaturalResource rs = RssPooling.GetItem(); rs.gameObject.name = "Resource" + rssData.RssType.ToString() + rssData.ID; Vector3 worldPos = MapIns.CellToWorld(rssData.Position.Parse3Int().ToClientPosition()); rs.SetResourceData(rssData, Flag.Owner, worldPos); Resources[rssData.ID] = rs; rs.gameObject.SetActive(true); //Debugger.Log("Created " + rssData.ID); } WaitForCreate.RemoveAt(WaitForCreate.Count - 1); //i--; yield return(null); } isCreateComplete = true; yield break; }
public void OnSetDragableObject(int i) { dragableResource = GameController.instance.naturalResources[i]; //dragableResource.spriteResource }