34 lines
No EOL
1.3 KiB
C#
34 lines
No EOL
1.3 KiB
C#
using Patterns_And_Principles.Patterns.The_State_Pattern.Script.Manager;
|
|
using UnityEngine;
|
|
|
|
namespace Patterns_And_Principles.Patterns.The_State_Pattern.Script.State
|
|
{
|
|
public class AppleGrowingState : AppleBaseState
|
|
{
|
|
private readonly Vector3 _appleStartScale = new Vector3(0.25f, 0.25f, 0.25f);
|
|
private readonly Vector3 _appleGrowScaler = new Vector3(0.2f, 0.2f, 0.2f);
|
|
private readonly Vector3 _appleMaxScale = new Vector3(1f, 1f, 1f);
|
|
public override void EnterState(AppleStateManager appleStateManager)
|
|
{
|
|
Debug.Log("Entered AppleGrowingState");
|
|
appleStateManager.gameObject.transform.localScale = _appleStartScale;
|
|
}
|
|
|
|
public override void UpdateState(AppleStateManager appleStateManager)
|
|
{
|
|
if (appleStateManager.gameObject.transform.localScale.x < _appleMaxScale.x)
|
|
{
|
|
appleStateManager.gameObject.transform.localScale += (_appleGrowScaler * Time.deltaTime);
|
|
}
|
|
else
|
|
{
|
|
appleStateManager.SwitchState(appleStateManager._wholeState);
|
|
}
|
|
}
|
|
|
|
public override void OnCollisionEnter(AppleStateManager appleStateManager, Collision collision)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |