private void DeleteSelected() { if (currentSelectedObject) { PlaceablesScript DeviceMainScript = currentSelectedObject.GetComponent <PlaceablesScript>(); PlaceablesData DeviceDataScript = currentSelectedObject.GetComponent <PlaceablesScript>().PlaceablesDataScript; DeviceMainScript.InvokeDelete(); ColorManager colorManager = currentSelectedObject.GetComponent <ColorManager>(); colorManager.ResetColor(); currentSelectedObject = null; } }
private void ReleaseIfClicked() { canPlace = CheckPlacementValidity(); if (Input.GetKeyDown(placeHotkey)) { PlaceablesScript PlaceableScript = currentPlaceableObject.GetComponent <PlaceablesScript>(); PlaceablesData DeviceDataScript = PlaceableScript.PlaceablesDataScript; if (canPlace && currentPlaceableObject.activeSelf) { FixedJoint joint = currentPlaceableObject.gameObject.AddComponent <FixedJoint>(); joint.connectedBody = returnObject.GetComponent <Rigidbody>(); PlaceableScript.PlaceablesManagerScript = DataManagerScript; PlaceableScript.PlacementControllerScript = this; PlaceableScript.InvokePlacement(); HasThesePlaceables.Add(currentPlaceableObject); currentPlaceableObject = null; } } }
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); }