コード例 #1
0
    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);
        }
    }
コード例 #2
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);
                }
            }
        }
    }
コード例 #3
0
    void OnMouseUp()
    {
        if (GUIManager.Instance.OnTutorialScreen)
        {
            return;
        }

        if (preSelected == true)
        {
            UnSelectAllPlacements();

            selected        = true;
            isPlacingTowers = true;
            BaseCohesionManager.UnMarkAllAttachments();
        }

        preSelected = false;
    }
コード例 #4
0
    void OnMouseDown()
    {
        // reap the money from towers that are marked and delete them

        int totalSellBackAmount = BaseCohesionManager.DeleteUnconnectedAttachments(true);

        SellingManager.Instance.SetVisibility(false);         //remove the window

        //do something with the sell back amount
        BlorbManager.Instance.Transaction(totalSellBackAmount, sellWindow.position);

        this.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f);

        //reconfigure placement spots if they are already there...
        if (GameObject.FindGameObjectsWithTag("Placement").Length > 0)
        {
            center.RecalculateAllPossiblePlacements();
        }
    }
コード例 #5
0
    // 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();
        }
    }
コード例 #6
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();
        }
    }