using Core.Utilities;
|
using JetBrains.Annotations;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class HealthHeartState : Singleton<HealthHeartState>
|
{
|
public List<Image> selfHeartList;
|
public List<Image> oppoHeartList;
|
|
public Sprite heartBreakImg;
|
|
|
protected bool[] selfHeartState;
|
protected bool[] oppoHeartState;
|
|
// Start is called before the first frame update
|
void Start()
|
{
|
selfHeartState = new bool[selfHeartList.Count];
|
oppoHeartState = new bool[oppoHeartList.Count];
|
for( int ti = 0;ti<selfHeartList.Count;ti ++ )
|
{
|
selfHeartState[ti] = true;
|
oppoHeartState[ti] = true;
|
}
|
}
|
|
// Update is called once per frame
|
void Update()
|
{
|
|
}
|
|
/// <summary>
|
/// 删除一个对应的红心.
|
/// </summary>
|
/// <param name="opponent"></param>
|
public void killHeart( bool opponent)
|
{
|
if (opponent)
|
{
|
for( int ti = 0;ti< oppoHeartState.Length;ti ++)
|
{
|
if( oppoHeartState[ti])
|
{
|
if (this.heartBreakImg)
|
oppoHeartList[ti].sprite = heartBreakImg;
|
else
|
oppoHeartList[ti].gameObject.SetActive(false);
|
oppoHeartState[ti] = false;
|
return;
|
}
|
}
|
}
|
else
|
{
|
for (int ti = 0; ti < selfHeartState.Length; ti++)
|
{
|
if( selfHeartState[ti])
|
{
|
if (this.heartBreakImg)
|
selfHeartList[ti].sprite = heartBreakImg;
|
else
|
selfHeartList[ti].gameObject.SetActive(false);
|
selfHeartState[ti] = false;
|
return;
|
}
|
}
|
}
|
}
|
}
|