// Called when one resource is to be exchanged for another public void ExchangeResources(int index) { AudioManager.instance.PlayOneShot(AudioManager.EventType.ButtonSound); // Rules for resource exchanging if (sliderData.structArray[index].counterSlider.value <sliderData.exchangeAmount || sliderData.structArray[index].slider.value + sliderData.exchangeAmount> sliderData.structArray[index].slider.maxValue) { if (sliderData.structArray[index].counterSlider.value < sliderData.exchangeAmount) { sliderController.ExchangeResources(ref sliderData.structArray[index].slider, ref sliderData.structArray[index].counterSlider, sliderData.structArray[index].counterSlider.value); } else if (sliderData.structArray[index].slider.value == sliderData.structArray[index].slider.maxValue) { return; } else { sliderController.ExchangeResources(ref sliderData.structArray[index].slider, ref sliderData.structArray[index].counterSlider, sliderData.structArray[index].slider.maxValue - sliderData.structArray[index].slider.value); ItweenManager.instance.PunchScaleSlider(sliderData.structArray[index].slider); } } else { sliderController.ExchangeResources(ref sliderData.structArray[index].slider, ref sliderData.structArray[index].counterSlider, sliderData.exchangeAmount); ItweenManager.instance.PunchScaleSlider(sliderData.structArray[index].slider); } }