chenxin
2020-10-27 43b531f76be6e12c775a1135f6895e8fdc389a59
Assets/Scripts/TowerDefense/UI/BulletUICtl.cs
@@ -1,4 +1,5 @@
using DG.Tweening;
using Protobuf;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -11,11 +12,62 @@
{
    public Image bulletScaleMask;
    public float fAdjValue;
    /// <summary>
    /// 最大子弹数目.
    /// </summary>
    public int maxBulletNum;
    /// <summary>
    /// 当前的子弹数目.
    /// </summary>
    protected int curBulletNum;
    // Start is called before the first frame update
    void Start()
    {
        resetToMaxBullet();
    }
    /// <summary>
    /// 获取进度条进度.
    /// </summary>
    /// <returns></returns>
    public int GetCtlProgress()
    {
        return this.curBulletNum;
    }
    /// <summary>
    /// 设置进度.
    /// </summary>
    /// <param name="pro"></param>
    public void SetCtlProcess( int pro)
    {
        this.curBulletNum = pro;
        this.updateBulletUI(pro, maxBulletNum);
    }
    /// <summary>
    /// 重设子弹数目到最大.
    /// </summary>
    public void resetToMaxBullet()
    {
        if (this.curBulletNum == maxBulletNum) return;
        this.curBulletNum = maxBulletNum;
        this.updateBulletUI(curBulletNum, maxBulletNum);
    }
    /// <summary>
    /// 减少子弹,返回减少后的子弹数目。
    /// </summary>
    /// <returns></returns>
    public int decBullet()
    {
        if (this.curBulletNum <= 0) return 0;
        this.curBulletNum--;
        this.updateBulletUI(curBulletNum, maxBulletNum);
        return curBulletNum;
    }
    /// <summary>
@@ -27,7 +79,7 @@
    {
        if (bulletScaleMask == null) return;
        float scaleY = 1.0f - curBNum / (float)totalBNum - fAdjValue;
        bulletScaleMask.rectTransform.DOScaleY( scaleY, 0.1f);
        bulletScaleMask.rectTransform.DOScaleY( scaleY, 0.0f);
    }
    // Update is called once per frame