Files
KOF/Assets/_KOF/Scripts/Towers/DoubleTubeTower.cs
2025-07-02 15:13:26 +08:00

70 lines
1.5 KiB
C#

using UnityEngine;
public class DoubleTubeTower : AutoTower
{
public Launcher leftGun;
public Launcher rightGun;
private int _shotTime = 0;
private float _nextShootTime = 0;
private bool _nowLeft = false;
public override void OnSpawn(int id, TowerType type, int lvl)
{
base.OnSpawn(id, type, lvl);
_nextShootTime = Time.time + gcd;
}
public override void Update()
{
base.Update();
if (!isServer)
{
return;
}
if (!IsAlive || state == TowerState.Broken)
{
return;
}
if ((mode == TowerMode.Auto && targetId != -1) || (mode == TowerMode.Joint && controllerId != -1))
{
if (Time.time < _nextShootTime)
{
return;
}
if (_nowLeft)
{
if (rightGun.Shoot())
{
// UnityEngine.Debug.Log("右");
_shotTime++;
};
}
else
{
if (leftGun.Shoot())
{
// UnityEngine.Debug.Log("左");
_shotTime++;
};
}
// 换枪
if (_shotTime % 4 == 0)
{
_nowLeft = !_nowLeft;
}
// 公共冷却
if (_shotTime % 8 == 0)
{
_nextShootTime = Time.time + gcd;
}
}
}
}