43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace InterfaceOff
|
|
{
|
|
public abstract class WindowBase : MonoBehaviour
|
|
{
|
|
public WindowInteractions Interactions { get; set; }
|
|
public WindowComponents Components { get; set; }
|
|
|
|
protected Vector3 Velocity { get; set; }
|
|
|
|
[SerializeField] private int m_FlipCooldown;
|
|
private static int MAX_FLIP_COOLDOWN = 20;
|
|
|
|
public void InstantiateWindowBase()
|
|
{
|
|
transform.position = CanvasManager.GetRandomPositionOnCanvas();
|
|
|
|
OnWindowInstantiation();
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!CanvasManager.IsRectWithinCanvas(Components.Rect) && m_FlipCooldown == 0)
|
|
{
|
|
m_FlipCooldown = MAX_FLIP_COOLDOWN;
|
|
Velocity = -Velocity;
|
|
}
|
|
|
|
transform.position += Velocity * Time.deltaTime;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
m_FlipCooldown = Math.Clamp(m_FlipCooldown - 1, 0, MAX_FLIP_COOLDOWN);
|
|
}
|
|
|
|
public virtual void OnWindowInstantiation() { }
|
|
public virtual void OnWindowClicked() { }
|
|
}
|
|
}
|