오늘은 추가만 몇개 했습니다.
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class Buff : MonoBehaviour
{
[SerializeField] private NexusSO data;
public static int currentMP;
public Button DamageButton;
public static int damagebuff = 100;
private float damagebufftime = 5f;
private bool cooltime;
private void Start()
{
cooltime = true;
currentMP = data.MaxMP();
if (DamageButton != null)
{
DamageButton.onClick.AddListener(DamageUp);
}
}
private void DamageUp()
{
TurretWeapon[] turrets = GameObject.FindObjectsOfType<TurretWeapon>();
if (cooltime && !IsInvoking("ResetCooltime"))
{
if (currentMP >= 10)
{
currentMP -= 10;
Debug.Log(currentMP);
foreach (TurretWeapon turret in turrets)
{
if (TurretInfo.Load.ContainsKey(turret.gameObject))
{
TurretInfo.Temp = TurretInfo.Load[turret.gameObject];
turret.AddBuff(damagebuff);
}
}
cooltime = false;
Invoke("ResetCooltime", damagebufftime);
Invoke("RemoveBuff", damagebufftime); // 5초 후에 RemoveBuff 호출
}
else
{
Debug.Log("엠피부족");
}
}
else
{
Debug.Log("쿨타임중");
}
}
private void ResetCooltime()
{
cooltime = true;
}
private void RemoveBuff()
{
TurretWeapon[] turrets = GameObject.FindObjectsOfType<TurretWeapon>();
foreach (TurretWeapon turret in turrets)
{
if (TurretInfo.Load.ContainsKey(turret.gameObject))
{
TurretInfo.Temp = TurretInfo.Load[turret.gameObject];
turret.RemoveBuff(damagebuff);
}
}
}
}
하나는 리무브 버프라고 버프 시전하고 몇초뒤 다시 포탑이 원래 공격력을 가지도록
수정했습니다.
using System;
using UnityEngine;
public class Nexus : Unit
{
public Action OnDestroyNexus;
public Action OnDamagedNexus;
public Action OnHealedNexus;
//public GameObject GameOver;
public NexusSO Data;
private float timeSinceLastHeal;
private float healInterval = 1f;
private void Update()
{
timeSinceLastHeal += Time.deltaTime;
if (timeSinceLastHeal >= healInterval)
{
Healed(3); //여기서 수치 조절 가능
OnHealedNexus?.Invoke();
timeSinceLastHeal = 0f;
}
}
private void Awake()
{
if(Data != null)
{
MaxHP = Data.MaxHP();
CurrnetHP = MaxHP;
}
}
public override void Damaged(int dmg)
{
base.Damaged(dmg);
if(CurrnetHP <=0)
{
OnDestroyNexus?.Invoke();
Destroy(this.gameObject);
}
OnDamagedNexus?.Invoke();
//GameOver.SetActive(!GameOver.activeSelf);
//Time.timeScale = 0;
}
public override void Healed(int heal)
{
base.Healed(heal);
OnHealedNexus?.Invoke();
}
}
하나는 이제 넥서스 초당 체력3을 회복하도록 수정했습니다.
내일은 아마 넥서스 체력을 가시화할거같습니다