示例#1
0
    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);
                }
            }
        }
    }
示例#2
0
    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();
        }
    }