83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using NaughtyAttributes;
|
|
using UnityEngine;
|
|
|
|
public class GhostStrategyHandler : MonoBehaviour
|
|
{
|
|
private static GhostStrategyHandler instance;
|
|
public static GhostStrategyHandler getInstance() => instance;
|
|
|
|
private GhostManagerV2 ghostManager;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null) instance = this;
|
|
else Destroy(gameObject);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
ghostManager = GhostManagerV2.getInstance();
|
|
}
|
|
|
|
// MoveAxis strategy
|
|
|
|
public void StartDraggingRight()
|
|
{
|
|
var MoveStategy = new AxisMoveStrategy(Quaternion.identity);
|
|
MoveStategy.BeginDrag(Vector3.right, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(MoveStategy);
|
|
}
|
|
|
|
public void StartDraggingUp()
|
|
{
|
|
var MoveStategy = new AxisMoveStrategy(Quaternion.identity);
|
|
MoveStategy.BeginDrag(Vector3.up, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(MoveStategy);
|
|
}
|
|
|
|
public void StartDraggingForward()
|
|
{
|
|
var MoveStategy = new AxisMoveStrategy(Quaternion.identity);
|
|
MoveStategy.BeginDrag(Vector3.forward, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(MoveStategy);
|
|
}
|
|
|
|
public void EndDragging()
|
|
{
|
|
ghostManager.SetMovementStrategy(new FreeMoveStrategy());
|
|
}
|
|
|
|
// RotateAxis strategy
|
|
|
|
public AxisRotateStrategy StartRotatingRight()
|
|
{
|
|
var RotateStrategy = new AxisRotateStrategy(AxisRotateStrategy.LocalAxis.Right, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(RotateStrategy);
|
|
return RotateStrategy;
|
|
}
|
|
|
|
public AxisRotateStrategy StartRotatingUp()
|
|
{
|
|
var RotateStrategy = new AxisRotateStrategy(AxisRotateStrategy.LocalAxis.Up, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(RotateStrategy);
|
|
return RotateStrategy;
|
|
}
|
|
|
|
public AxisRotateStrategy StartRotatingForward()
|
|
{
|
|
var RotateStrategy = new AxisRotateStrategy(AxisRotateStrategy.LocalAxis.Forward, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(RotateStrategy);
|
|
return RotateStrategy;
|
|
}
|
|
|
|
public void StartRotation()
|
|
{
|
|
var RotateStrategy = new AxisRotateStrategy(AxisRotateStrategy.LocalAxis.Right, Vector3.zero);
|
|
ghostManager.SetMovementStrategy(RotateStrategy);
|
|
return;
|
|
}
|
|
}
|