Added basic bouncing
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace InterfaceOff
|
||||
@@ -7,7 +8,10 @@ namespace InterfaceOff
|
||||
public WindowInteractions Interactions { get; set; }
|
||||
public WindowComponents Components { get; set; }
|
||||
|
||||
public Vector3 Velocity { get; set; }
|
||||
protected Vector3 Velocity { get; set; }
|
||||
|
||||
[SerializeField] private int m_FlipCooldown;
|
||||
private static int MAX_FLIP_COOLDOWN = 20;
|
||||
|
||||
public void InstantiateWindowBase()
|
||||
{
|
||||
@@ -16,11 +20,22 @@ namespace InterfaceOff
|
||||
OnWindowInstantiation();
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
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() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user