66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class MoleModule : BodyModule
|
|
{
|
|
private static WhackMoleSystem WhackMoleSystem => FixSystemCenter.SystemDic.Get<WhackMoleSystem>();
|
|
|
|
private Material _picMaterial;
|
|
|
|
public bool isInMoleGame;
|
|
private static readonly int SineGlowFade = Shader.PropertyToID("_SineGlowFade");
|
|
private static readonly int AddColorFade = Shader.PropertyToID("_AddColorFade");
|
|
private static readonly int AddColorColor = Shader.PropertyToID("_AddColorColor");
|
|
|
|
protected override void InitReference()
|
|
{
|
|
base.InitReference();
|
|
_picMaterial = transform.Find("Module Pic").GetComponent<SpriteRenderer>().material;
|
|
}
|
|
|
|
// 重写PlugIn和PlugOut就好了
|
|
public override void PlugIn()
|
|
{
|
|
if (!isInMoleGame)
|
|
{
|
|
base.PlugIn();
|
|
}
|
|
else
|
|
{
|
|
// 触发WhackMoleSystem的插入事件
|
|
WhackMoleSystem.OnPlugIn(data.moduleName);
|
|
}
|
|
}
|
|
|
|
public override void PlugOut()
|
|
{
|
|
// TODO 拔出来会有效果吗?存疑
|
|
}
|
|
|
|
#region 表现相关的功能
|
|
|
|
public void StartFlicker()
|
|
{
|
|
_picMaterial.SetFloat(SineGlowFade, 1);
|
|
}
|
|
|
|
public void StopFlicker()
|
|
{
|
|
_picMaterial.SetFloat(SineGlowFade, 0);
|
|
}
|
|
|
|
public void LightOn(Color color)
|
|
{
|
|
_picMaterial.SetColor(AddColorColor, color);
|
|
_picMaterial.SetFloat(AddColorFade, 1);
|
|
}
|
|
|
|
public void LightOff()
|
|
{
|
|
_picMaterial.SetFloat(AddColorFade, 0);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |