Commit 8b23f045 authored by wanqing's avatar wanqing

进度条动画

parent 3e2f9289
...@@ -680,15 +680,15 @@ ...@@ -680,15 +680,15 @@
<Reference Include="Unity.Rider.Editor"> <Reference Include="Unity.Rider.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro"> <Reference Include="Unity.TextMeshPro">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEditor.UI"> <Reference Include="UnityEditor.UI">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="Assembly-CSharp-firstpass.csproj"> <ProjectReference Include="Assembly-CSharp-firstpass.csproj">
......
...@@ -629,15 +629,15 @@ ...@@ -629,15 +629,15 @@
<Reference Include="Unity.Rider.Editor"> <Reference Include="Unity.Rider.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro"> <Reference Include="Unity.TextMeshPro">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEditor.UI"> <Reference Include="UnityEditor.UI">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup></ItemGroup> <ItemGroup></ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
...@@ -745,15 +745,15 @@ ...@@ -745,15 +745,15 @@
<Reference Include="Unity.Rider.Editor"> <Reference Include="Unity.Rider.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro"> <Reference Include="Unity.TextMeshPro">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.TextMeshPro.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEditor.UI"> <Reference Include="UnityEditor.UI">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath> <HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.2D.Sprite.Editor">
<HintPath>D:/wan/dyspaceGame/BoomMaster_Git/BoomMaster/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="Assembly-CSharp-firstpass.csproj"> <ProjectReference Include="Assembly-CSharp-firstpass.csproj">
......
...@@ -58,6 +58,10 @@ public class BattleUI : MonoBehaviour ...@@ -58,6 +58,10 @@ public class BattleUI : MonoBehaviour
private int m_mouseIndex = 0;//点击次数 private int m_mouseIndex = 0;//点击次数
private bool m_bIsShowMouse = true;//是否显示手指图标 private bool m_bIsShowMouse = true;//是否显示手指图标
private int m_bombIndex = 0;//炸弹计数 private int m_bombIndex = 0;//炸弹计数
private float m_textProgress = 0.0f;
private float m_textProgressTotal = 0.0f;
private float m_sliderProgress = 0.0f;
private float m_sliderProgressTotal = 0.0f;
public bool IsLeftEmtryBomb { get { return m_bombIndex >= 3; } }//是否不剩炸弹了 public bool IsLeftEmtryBomb { get { return m_bombIndex >= 3; } }//是否不剩炸弹了
public bool IsBombButtonCanInteractable { get { return m_boomBtn.interactable; } } public bool IsBombButtonCanInteractable { get { return m_boomBtn.interactable; } }
void Awake() void Awake()
...@@ -269,6 +273,10 @@ public class BattleUI : MonoBehaviour ...@@ -269,6 +273,10 @@ public class BattleUI : MonoBehaviour
{ {
m_progressStar[i].color = m_emptyColor; m_progressStar[i].color = m_emptyColor;
} }
m_textProgress = 0.0f;
m_textProgressTotal = 0.0f;
m_sliderProgress = 0.0f;
m_sliderProgressTotal = 0.0f;
m_levelText.text = string.Format("Level {0:D}", BattleCtrl.instance.levelManager.CurLevelIndex + 1); m_levelText.text = string.Format("Level {0:D}", BattleCtrl.instance.levelManager.CurLevelIndex + 1);
...@@ -339,26 +347,43 @@ public class BattleUI : MonoBehaviour ...@@ -339,26 +347,43 @@ public class BattleUI : MonoBehaviour
//设置进度 //设置进度
public void SetProgress(float progress) public void SetProgress(float progress)
{ {
m_progressText.text = string.Format("{0:D}%",(int)(progress * 100)); m_textProgressTotal = progress;
if(progress >= 0 && progress <= 0.6f) if(progress >= 0 && progress <= 0.6f)
{ {
m_progress.fillAmount = 0.25f * progress/0.6f; m_sliderProgressTotal = 0.25f * progress / 0.6f;
} }
else if(progress > 0.6f && progress <= 0.7f) else if(progress > 0.6f && progress <= 0.7f)
{ {
m_progress.fillAmount = 0.25f + 0.25f * (progress - 0.6f)*10; m_sliderProgressTotal = 0.25f + 0.25f * (progress - 0.6f) * 10;
} }
else if (progress > 0.7f && progress <= 0.8f) else if (progress > 0.7f && progress <= 0.8f)
{ {
m_progress.fillAmount = 0.5f + 0.25f * (progress - 0.7f)*10; m_sliderProgressTotal = 0.5f + 0.25f * (progress - 0.7f) * 10;
} }
else else
{ {
m_progress.fillAmount = 0.75f + 0.25f * (progress - 0.8f)*5; m_sliderProgressTotal = 0.75f + 0.25f * (progress - 0.8f) * 5;
} }
for(int i = 0;i<m_progressStar.Length;i++) for(int i = 0;i<m_progressStar.Length;i++)
{ {
m_progressStar[i].color = (progress >= 0.6f + 0.1f * i) ? m_fullColor : m_emptyColor; m_progressStar[i].color = (progress >= 0.6f + 0.1f * i) ? m_fullColor : m_emptyColor;
} }
} }
private void Update()
{
if (m_textProgress < m_textProgressTotal)
{
m_textProgress += Time.deltaTime;
m_progressText.text = string.Format("{0:D}%", (int)(m_textProgress * 100));
}
else
{
m_progressText.text = string.Format("{0:D}%", (int)(m_textProgressTotal * 100));
}
if(m_sliderProgress < m_sliderProgressTotal)
{
m_sliderProgress += Time.deltaTime;
m_progress.fillAmount = m_sliderProgress;
}
}
} }
...@@ -19,9 +19,11 @@ public class BombView : MonoBehaviour ...@@ -19,9 +19,11 @@ public class BombView : MonoBehaviour
private float m_rotateSpeed = 10.0f;//旋转速度 private float m_rotateSpeed = 10.0f;//旋转速度
private float m_curRotateAngle = 0.0f;//当前旋转角度 private float m_curRotateAngle = 0.0f;//当前旋转角度
private float m_lastRotateAngle = 0.0f;//之前的旋转角度 private float m_lastRotateAngle = 0.0f;//之前的旋转角度
private int m_TotalDamageNum = 0;//破坏数量
private List<Transform> m_lstDamage = new List<Transform>();
private void Awake() private void Awake()
{ {
m_totalChildNum = m_rootTrans.childCount; m_totalChildNum = m_rootTrans.childCount - 1;
} }
private void Start() private void Start()
{ {
...@@ -95,6 +97,23 @@ public class BombView : MonoBehaviour ...@@ -95,6 +97,23 @@ public class BombView : MonoBehaviour
{ {
PoolManager.Instance.ReturnObjectToPool(m_curBombEffect); PoolManager.Instance.ReturnObjectToPool(m_curBombEffect);
}); });
InvokeRepeating("CalculateDamageNum", 0.3f, 0.1f);
}
void CalculateDamageNum()
{
if (m_rootTrans)
{
for (int i = 1; i < m_rootTrans.childCount; i++)
{
Transform varTrans = m_rootTrans.GetChild(i);
if (varTrans && varTrans.GetComponent<Rigidbody>() &&
varTrans.GetComponent<Rigidbody>().useGravity && !m_lstDamage.Contains(varTrans))
{
m_TotalDamageNum++;
m_lstDamage.Add(varTrans);
}
}
}
} }
private void OnDestroy() private void OnDestroy()
{ {
...@@ -110,6 +129,12 @@ public class BombView : MonoBehaviour ...@@ -110,6 +129,12 @@ public class BombView : MonoBehaviour
{ {
GameServices.inputService.pad.onMoveVec3 -= OnMove; GameServices.inputService.pad.onMoveVec3 -= OnMove;
} }
if(IsInvoking("CalculateDamageNum"))
{
CancelInvoke("CalculateDamageNum");
}
m_lstDamage.Clear();
m_lstDamage = null;
} }
private void Update() private void Update()
{ {
...@@ -125,8 +150,8 @@ public class BombView : MonoBehaviour ...@@ -125,8 +150,8 @@ public class BombView : MonoBehaviour
} }
m_lastRotateAngle = m_curRotateAngle; m_lastRotateAngle = m_curRotateAngle;
} }
BattleCtrl.instance.battleUI.SetProgress((m_totalChildNum - m_rootTrans.childCount) / (float)m_totalChildNum); BattleCtrl.instance.battleUI.SetProgress(m_TotalDamageNum / (float)m_totalChildNum);
//Debug.LogError(m_rootTrans.childCount + "................." + m_totalChildNum); //Debug.LogError((m_rootTrans.childCount - 1) + "................." + m_totalChildNum);
if(m_bControlWin) if(m_bControlWin)
{ {
if (BattleCtrl.instance.battleUI.IsLeftEmtryBomb && !BattleCtrl.instance.battleUI.IsBombButtonCanInteractable) if (BattleCtrl.instance.battleUI.IsLeftEmtryBomb && !BattleCtrl.instance.battleUI.IsBombButtonCanInteractable)
...@@ -134,7 +159,7 @@ public class BombView : MonoBehaviour ...@@ -134,7 +159,7 @@ public class BombView : MonoBehaviour
m_bControlWin = false; m_bControlWin = false;
Invoke("CheckSuccess", 4); Invoke("CheckSuccess", 4);
} }
if (m_rootTrans.childCount <= m_totalChildNum * 0.2f) if (m_TotalDamageNum >= m_totalChildNum * 0.8f)
{ {
m_bControlWin = false; m_bControlWin = false;
BattleCtrl.instance.levelManager.curLevel.star = 3; BattleCtrl.instance.levelManager.curLevel.star = 3;
...@@ -147,7 +172,7 @@ public class BombView : MonoBehaviour ...@@ -147,7 +172,7 @@ public class BombView : MonoBehaviour
// BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
//} //}
if (BattleCtrl.instance.battleUI.IsLeftEmtryBomb && !BattleCtrl.instance.battleUI.IsBombButtonCanInteractable if (BattleCtrl.instance.battleUI.IsLeftEmtryBomb && !BattleCtrl.instance.battleUI.IsBombButtonCanInteractable
&& m_rootTrans.childCount > m_totalChildNum * m_rate && m_bControlFail) && m_TotalDamageNum < m_totalChildNum * 0.6f && m_bControlFail)
{ {
m_bControlFail = false; m_bControlFail = false;
Invoke("CheckFail", 4); Invoke("CheckFail", 4);
...@@ -156,17 +181,17 @@ public class BombView : MonoBehaviour ...@@ -156,17 +181,17 @@ public class BombView : MonoBehaviour
//检查胜利 //检查胜利
void CheckSuccess() void CheckSuccess()
{ {
if (m_rootTrans.childCount <= m_totalChildNum * 0.2f) if (m_TotalDamageNum >= m_totalChildNum * 0.8f)
{ {
BattleCtrl.instance.levelManager.curLevel.star = 3; BattleCtrl.instance.levelManager.curLevel.star = 3;
BattleCtrl.instance.OnBattleWin(); BattleCtrl.instance.OnBattleWin();
} }
else if (m_rootTrans.childCount > m_totalChildNum * 0.2f && m_rootTrans.childCount <= m_totalChildNum * 0.3f) else if (m_TotalDamageNum < m_totalChildNum * 0.8f && m_TotalDamageNum >= m_totalChildNum * 0.7f)
{ {
BattleCtrl.instance.levelManager.curLevel.star = 2; BattleCtrl.instance.levelManager.curLevel.star = 2;
BattleCtrl.instance.OnBattleWin(); BattleCtrl.instance.OnBattleWin();
} }
else if (m_rootTrans.childCount > m_totalChildNum * 0.3f && m_rootTrans.childCount <= m_totalChildNum * 0.4f) else if (m_TotalDamageNum >= m_totalChildNum * 0.6f && m_TotalDamageNum < m_totalChildNum * 0.7f)
{ {
BattleCtrl.instance.levelManager.curLevel.star = 1; BattleCtrl.instance.levelManager.curLevel.star = 1;
BattleCtrl.instance.OnBattleWin(); BattleCtrl.instance.OnBattleWin();
......
...@@ -9125,7 +9125,7 @@ RectTransform: ...@@ -9125,7 +9125,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 350, y: 10} m_SizeDelta: {x: 350, y: 20}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3657217846413667314 --- !u!222 &3657217846413667314
CanvasRenderer: CanvasRenderer:
...@@ -14698,7 +14698,7 @@ RectTransform: ...@@ -14698,7 +14698,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1} m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -291.09998} m_AnchoredPosition: {x: 0, y: -291.09998}
m_SizeDelta: {x: 350, y: 10} m_SizeDelta: {x: 350, y: 20}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &115026455693364947 --- !u!222 &115026455693364947
CanvasRenderer: CanvasRenderer:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment