public static void StopPlacement() { UnSelectAllPlacements(); Center.Instance.DelayPlacementStopping(); BaseCohesionManager.UnMarkAllAttachments(); possiblePlacements = new ArrayList(); if (GameObject.FindGameObjectsWithTag("Placement").Length > 0) { Center.RemoveAllPossiblePlacements(); } GUIManager.Instance.UpdateTowerGUI(); if (tempPlacement != null) { Destroy(tempPlacement.gameObject); } if (rangeIndicator != null) { Destroy(rangeIndicator.gameObject); } }
void Update() { if (Input.GetMouseButtonDown(0) && //check if we clicked a tower !Placement.isPlacingTowers && !GUIManager.Instance.MouseOverUI && WorldManager.instance.isDay) { Attachments[] attachments = GameObject.FindObjectsOfType <Attachments>(); Vector3 mouse = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); mouse = new Vector3(mouse.x, mouse.y, 0); foreach (Attachments attachment in attachments) { if (attachment.collider.bounds.Contains(mouse)) { BaseCohesionManager.UnMarkAllAttachments(); BaseCohesionManager.FindAllNeighbors(attachment.transform); // find out our base cohesion network int totalSellBack = BaseCohesionManager.MarkAllAttachments(attachment.transform); //load up the selling GUI SetVisibility(true); amountText.text = "+" + ((int)totalSellBack).ToString(); cancelButton.color = new Color(1f, 1f, 1f, 1f); sellButton.color = new Color(1f, 1f, 1f, 1f); sellWindow.transform.position = new Vector3(attachment.transform.position.x, attachment.transform.position.y + 2.5f); sellWindow.gameObject.SetActive(true); } } } }
void OnMouseUp() { if (GUIManager.Instance.OnTutorialScreen) { return; } if (preSelected == true) { UnSelectAllPlacements(); selected = true; isPlacingTowers = true; BaseCohesionManager.UnMarkAllAttachments(); } preSelected = false; }
// Use this for initialization void OnMouseDown() { if (GUIManager.Instance.OnTutorialScreen || Time.timeScale == 0) { return; } BaseCohesionManager.UnMarkAllAttachments(); //only create new ones if we have none if (BlorbManager.Instance.HasEnoughResources(this.cost)) { preSelected = true; if (GameObject.FindGameObjectsWithTag("Placement").Length == 0) { center.FindAllPossiblePlacements(); } UpdateGUIColors(); CreatePlacement(); } }
public void takeDamage() { attackingEnemies.RemoveAll(e => (e.gameObject == null || !e.gameObject.activeSelf)); //remove all dead enemies float totalDamage = 0f; foreach (Enemy enemy in attackingEnemies) { totalDamage += enemy.HitDamage; } health -= totalDamage; healthbar.Set(health / 100f); if (health <= 0f) { CancelInvoke(); //find all neighbors if possible (starting from center), skipping this particular attachment BaseCohesionManager.FindAllNeighbors(this.transform); BaseCohesionManager.DeleteUnconnectedAttachments(false); //delete all that were not found BaseCohesionManager.UnMarkAllAttachments(); } }