コード例 #1
0
    public void OnUpgradeButton()
    {
        //  string str = "가나다$16$3$45" char = ''; // char[] = " "
        //  string[] splits = str.Split('$');
        //  splits[0] = "가나다"
        //  "[1] = 16
        //  "[2] = 3
        //  "[3] = 45

        string[] split = CostText.text.Split('$');
        //  split[0] = '';
        //  split[1] = 해당 금액

        int cost = int.Parse(split[1]);

        if (!IsCheck(cost))
        {
            return;
        }

        TurretStatus turret = prevNode.GetComponentInChildren <TurretStatus>();

        turret.Price += cost;
        turret.transform.localScale += new Vector3(0.1f, 0.1f, 0.1f);

        switch (turret.turretType)
        {
        case TurretStatus.TurretType.Standard:
            turret.Damage += 2;
            turret.Range  += 0.25f;
            break;

        case TurretStatus.TurretType.Missile:
            turret.Damage   += 4;
            turret.Range    += 0.25f;
            turret.FireRate -= 0.25f;
            break;

        case TurretStatus.TurretType.Laser:
            turret.Damage++;
            break;
        }

        OnClose();
    }
コード例 #2
0
    private void ShowMenu()
    {
        ClickMenu.gameObject.SetActive(true);
        BuyMenu.SetActive(false);
        OtherMenu.SetActive(false);

        if (prevNode.transform.childCount == 0)
        {
            BuyMenu.SetActive(true);
        }
        else
        {
            Transform    t      = prevNode.transform.GetChild(0);
            TurretStatus status = t.GetComponent <TurretStatus>();

            SellText.text = $"${Mathf.RoundToInt(status.Price * 0.75f).ToString()}";

            switch (status.turretType)
            {
            case TurretStatus.TurretType.Standard:
                CostText.text = CostString(status.Price);
                break;

            case TurretStatus.TurretType.Missile:
                CostText.text = CostString(status.Price + 1);
                break;

            case TurretStatus.TurretType.Laser:
                CostText.text = CostString(status.Price + 3);
                break;
            }

            OtherMenu.SetActive(true);
        }

        string CostString(int Price)
        {
            int value = (int)(Price * .75f);

            return($"${value.ToString()}");
        }
    }