private void SetDropper() { GameObject dropper = GameObject.FindWithTag("Dropper"); if (dropper != null) { _dropper = dropper.GetComponent <OreDropper>(); } }
public override void GetReward() { double oreRewardSecondsMining = OreRewardMinutesMining * 60; int rocksDestroyed = GetCurrentRocksDestroyed(oreRewardSecondsMining); OreDropper dropper = GameObject.FindWithTag("Dropper").GetComponent <OreDropper>(); dropper.DropOre(rocksDestroyed); CreateOreRewardText(); }
public void UpdateProbabilities() { List <Ore> droppbaleOres = _oreDropper.GetDroppableOres(); float droppableOresTotalWeight = OreDropper.GetTotalWeight(droppbaleOres); foreach (Transform child in transform) { Destroy(child.gameObject); } foreach (var element in droppbaleOres) { GameObject probabilitySlotGameObject = Instantiate(ProbabilitySlot, transform); probabilitySlotGameObject.transform.Find("Ore").GetComponent <Image>().sprite = element.OreSprite; float dropProbability = element.DropWeight / droppableOresTotalWeight * _oreDropper.DropChance; probabilitySlotGameObject.transform.Find("ProbabilityText").GetComponentInChildren <Text>().text = dropProbability.ToString("P"); } }
private static Dictionary <Ore, int> DropOres(int dropAttempts) { OreDropper dropper = GameObject.FindGameObjectWithTag("Dropper").GetComponent <OreDropper>(); return(dropper.DropOre(dropAttempts)); }
private void Start() { _oreDropper = GameObject.FindWithTag("Dropper").GetComponent <OreDropper>(); UpdateProbabilities(); }