private void FireIfReady() { if (Input.GetMouseButtonDown(0) && reloading == false && DataManager.CanAfford(FireCostMetal, FireCostEnergy)) { reloading = true; Invoke("Reload", reloadSpeed); DataManager.SubtractPrice(FireCostMetal, FireCostEnergy); //Fire the weapon! FireWeapon(shootLoc.transform.forward, CurrentPower); } else if (Input.GetMouseButtonDown(0) && reloading == true) { WarningBox.SetWarning("Cannot Fire, Still Reloading"); } else if (Input.GetMouseButtonDown(0) && !DataManager.CanAfford(FireCostMetal, FireCostEnergy)) { WarningBox.SetWarning("Cannot Fire, Not Enough Resources"); } }
private bool CheckPlacementValidity() { PlaceablesScript PlaceableScript = currentPlaceableObject.GetComponent <PlaceablesScript>(); PlaceablesData DeviceDataScript = PlaceableScript.PlaceablesDataScript; //Is object colliding with another? if (returnObject != null && currentPlaceableObject != null) { if (PlaceableScript.isColliding == false) { float returnObjectAngleX = returnObject.transform.eulerAngles.x; returnObjectAngleX = (returnObjectAngleX > 180) ? returnObjectAngleX - 360 : returnObjectAngleX; float returnObjectAngleZ = returnObject.transform.eulerAngles.z; returnObjectAngleZ = (returnObjectAngleZ > 180) ? returnObjectAngleZ - 360 : returnObjectAngleZ; if (!(maxPlaceAngle >= Mathf.Abs(returnObjectAngleX) && maxPlaceAngle >= Mathf.Abs(returnObjectAngleZ))) { return(false); } } else { return(false); } } //Does the player have enough funds? if (!DataManagerScript.CanAfford(DeviceDataScript.MetalCost, DeviceDataScript.EnergyCost)) { WarningBoxScriptLink.SetWarning("Cannot Place, Not Enough Resources"); return(false); } //Does the player have the required tech? if (DeviceDataScript.RequiresTech != "") { if (!HasTheseTech.Any(t => t.name == DeviceDataScript.RequiresTech + "(Clone)")) { WarningBoxScriptLink.SetWarning("Cannot Place, Player Does Not Have Required Technology"); return(false); } } //Does the player already have the maximum amount? if (DeviceDataScript.LimitOfLikePlaceables != 0) { int AmountOfLike = 0; foreach (GameObject ThePlacables in HasThesePlaceables) { if (ThePlacables != null) { if (ThePlacables.name == currentPlaceableObject.name) { AmountOfLike++; } } } if (AmountOfLike >= DeviceDataScript.LimitOfLikePlaceables) { WarningBoxScriptLink.SetWarning("Cannot Place, Player Already Has The Max Amount Of This Placeable"); return(false); } } return(true); }