private void OnMouseDown() { Vector2 rawPos = CalculateWorldPositionMOuseClick(); Vector2 roundPos = SnapToGrid(rawPos); GameObject defender = Button.selectedDefender; int defenderCost = defender.GetComponent <Defenders>().startCost; if (starDisplay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS) { SpawnDefender(roundPos, defender); } }
void OnMouseDown() { Vector2 pos = SnapToGrid(CalculateWorldPointOfMouseClick()); GameObject defender = Button.selectedDefender; int defenderCost = defender.GetComponent <Defender> ().starCost; if (starDisplay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS) { SpawnDefender(pos, defender); } else { Debug.Log("insufficient Stars"); } }
private bool IsAffordable() { var price = Button.SelectedDefender.GetComponent <Defenders> ().StarCost; var canAffordDefender = StarBalance.UseStars(price); if (canAffordDefender == StarsDisplay.TransactionStatus.SUCCESS) { return(true); } else { Debug.Log("Insufficient funds."); return(false); } }
void OnMouseDown() { GameObject defender = Button.selectedDefender; int defenderCost = defender.GetComponent <Defender> ().starCost; bool enoughtStars = starsDislay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS; if (defender && enoughtStars) { Vector2 pos = SnapToGrip(CalculateWorldPointOfMouseClick()); SpawnDefender(pos, defender); } else { Debug.Log("Insufficient stars"); } }
private void OnMouseDown() { Vector2 position = SnapToGrid(CalculateWorldPointOfMouseClick()); if (ButtonBar.selectedDefender) { int defenderCost = ButtonBar.selectedDefender.GetComponent <Defender>().starCost; if (starsDisplay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS) { SpawnDefender(position); } else { Debug.Log("Insufficient stars"); } } }
void OnMouseDown() { Vector2 boxPosition = CalculateWorldPointOfMouseClick(Input.mousePosition); Vector2 rounedBoxPosition = SnapToGrid(boxPosition); GameObject defender = Button.selectedDefender; int defenderCost = defender.GetComponent<Defender>().starCost; if(starDisplay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS) { GameObject newDefender = Instantiate(Button.selectedDefender,rounedBoxPosition,Quaternion.identity) as GameObject; //Quaternion.identity means No Rotation newDefender.transform.SetParent(DefenderHierarchy.transform); } else { Debug.LogError("Not enough Stars"); } }
void OnMouseDown() { Vector2 clickedPoint = SnapToGrid(CalculateWorldPointOfMouseClick()); print(clickedPoint); if (Button.selectedDefender) { GameObject defender = Button.selectedDefender; int starValue = defender.GetComponent <Defender>().getStarValue(); if (starsDisplay.CheckIfCanSpendStars(starValue)) { Quaternion zeroRot = Quaternion.identity; GameObject newDef = Instantiate(defender, clickedPoint, zeroRot) as GameObject; newDef.transform.parent = defenderParent.transform; starsDisplay.UseStars(starValue); } } }
void OnMouseDown() { GameObject selectedDefender = Button.selectedDefender; if (selectedDefender) { Vector2 rawPos = CalculateWorldPointOfMouseClick(); Vector2 roundedPos = SnapToGrid(rawPos); int defenderCost = selectedDefender.GetComponent <Defenfer>().starsCost; if (starsDisplay.UseStars(defenderCost) == StarsDisplay.Status.SUCCESS) { SpawnDefender(selectedDefender, roundedPos); } else { Debug.Log("Insufficient Stars to spawn"); } } }
void OnMouseDown() { Vector2 rawPos = CalculateWorldPointOfMouseClick(); Vector2 roundedPos = SnapToGrid(rawPos); GameObject goDefender = Button.selectedDefender; Quaternion zeroRotation = Quaternion.identity; if (goDefender) { Defender defender = goDefender.GetComponent <Defender>(); if (_starsDisplay.UseStars(defender.startCost) == StarsDisplay.Status.SUCCESS) { // Spawn Defender GameObject newDef = Instantiate(goDefender, roundedPos, zeroRotation) as GameObject; newDef.transform.parent = _parent.transform; } else { Debug.Log("Insufficient stars"); } } }