예제 #1
0
    public void UpgradeButton()
    {
        if (PlayerStats.Money >= 100)
        {
            GameObject effect = (GameObject)Instantiate(sellEffect, TowerControl.selected[0].GetBuildPosition(), Quaternion.identity);
            Destroy(effect, 5f);

            if (TowerControl.selected[0].turret.name == "StandardTurret")
            {
                GameObject ST_UP_CLONE = (GameObject)Instantiate(Upgraded_Standard, TowerControl.selected[0].GetBuildPosition(), Quaternion.identity);
                ST_UP_CLONE.name = "Improved " + TowerControl.selected[0].turret.name;
                Destroy(TowerControl.selected[0].turret);
                TowerControl.selected[0].turret = ST_UP_CLONE;
            }
            else if (TowerControl.selected[0].turret.name == "Missile Launcher")
            {
                GameObject MS_UP_CLONE = (GameObject)Instantiate(Upgraded_Missile, TowerControl.selected[0].GetBuildPosition(), Quaternion.identity);
                MS_UP_CLONE.name = "Improved " + TowerControl.selected[0].turret.name;
                Destroy(TowerControl.selected[0].turret);
                TowerControl.selected[0].turret = MS_UP_CLONE;
            }


            TowerControl.delete_SelectionList(TowerControl.selected, TowerControl.selected_circle);
            SelectedUnitImage.update_image(null);
            SelectedUnitStat.update_stat(null);
            PlayerStats.Money -= 100;
        }
    }
예제 #2
0
    private void OnMouseDown()
    {
        //prevent clicking overgameObject
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        /*   if (!buildManager.CanBuild)
         *     return;*/
        if (turret != null || this.tag != "Node")
        {
            Debug.Log("Can't build there! - TODO: Display on Screen");
            if (turret != null)
            {
                // < circle = (GameObject)Instantiate(select_circle, transform.position, transform.rotation); >
                if (TowerControl.selected.Count != 0)
                {
                    TowerControl.delete_SelectionList(TowerControl.selected, TowerControl.selected_circle);
                }
                TowerControl.add_Node_To_SelectionList(this);                  // add selected node to list
                // < TowerControl.selected.Add(this); >
                TowerControl.DrawCircle(TowerControl.selected, select_circle); //draw circle on selected nodes

                turretStat = this.turret.GetComponent <Turret>();

                TurretRangeCircle.Delete_Range_Circle();
                TurretRangeCircle.Draw_Range_Circle(range_circle, this, turretStat.range);          //Show the range of turret by drawing purple circle.
                is_selecting = true;
                SelectedUnitImage.update_image(this);                                               //Show turret sprite and status for players.
                SelectedUnitStat.update_stat(this);
                //GeneralUIButton.PressCancelButton();
                TowerControl.selected.TrimExcess();
                TowerControl.selected_circle.TrimExcess(); //TrimExcess() for optimizing capacity in condition that has only one selected
                                                           //model. May need to modify later if the list can hold more data.
                buildManager.UnselectTurretToBuild();
            }

            //draw circle to notify user select this turret.

            /*           else
             *             Debug.Log(TowerControl.selected.Count);*/
            return;
        }

        if (turret == null && TowerControl.selected.Count != 0)
        {
            TowerControl.delete_SelectionList(TowerControl.selected, TowerControl.selected_circle); //delete existing circle on clicking
                                                                                                    //empty node
            TurretRangeCircle.Delete_Range_Circle();
            SelectedUnitImage.update_image(this);
            SelectedUnitStat.update_stat(this);
        }

        //Build a turret
        buildManager.BuildTurretOn(this);
    }
예제 #3
0
    public void SellButton()
    {
        GameObject effect = (GameObject)Instantiate(sellEffect, TowerControl.selected[0].GetBuildPosition(), Quaternion.identity);

        Destroy(effect, 5f);

        Destroy(TowerControl.selected[0].turret);
        TowerControl.delete_SelectionList(TowerControl.selected, TowerControl.selected_circle);
        SelectedUnitImage.update_image(null);
        SelectedUnitStat.update_stat(null);
        PlayerStats.Money += 50;
    }