using DG.Tweening;
using Protobuf;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// 子弹充能对应的数据结构.
///
public class BulletUICtl : MonoBehaviour
{
public Image bulletScaleMask;
public float fAdjValue;
///
/// 最大子弹数目.
///
public int maxBulletNum;
///
/// 当前的子弹数目.
///
protected int curBulletNum;
// Start is called before the first frame update
void Start()
{
resetToMaxBullet();
}
///
/// 获取进度条进度.
///
///
public int GetCtlProgress()
{
return this.curBulletNum;
}
///
/// 设置进度.
///
///
public void SetCtlProcess( int pro)
{
this.curBulletNum = pro;
this.updateBulletUI(pro, maxBulletNum);
}
///
/// 重设子弹数目到最大.
///
public void resetToMaxBullet()
{
if (this.curBulletNum == maxBulletNum) return;
this.curBulletNum = maxBulletNum;
this.updateBulletUI(curBulletNum, maxBulletNum);
}
///
/// 减少子弹,返回减少后的子弹数目。
///
///
public int decBullet()
{
if (this.curBulletNum <= 0) return 0;
this.curBulletNum--;
this.updateBulletUI(curBulletNum, maxBulletNum);
return curBulletNum;
}
///
/// 更新子弹界面对应的缩放信息
///
///
///
public void updateBulletUI( int curBNum,int totalBNum)
{
if (bulletScaleMask == null) return;
float scaleY = 1.0f - curBNum / (float)totalBNum - fAdjValue;
bulletScaleMask.rectTransform.DOScaleY( scaleY, 0.0f);
}
// Update is called once per frame
void Update()
{
}
}