using AibisDream.Framework; using UnityEngine; namespace AibisDream { public class AirGate : MonoBehaviour, IMoveable { private EngineSystem _engineSystem; [SerializeField] private int curLevel; [SerializeField] private float heightY; private Vector3 _offset; public bool IsBlock { get; } private void Awake() { _engineSystem = transform.parent.GetComponent(); _offset = transform.position; } public void StartMove() { // Debug.Log("Move"); } public void Move(Vector2 mousePos) { SwitchAirLevel(mousePos.y); UpdateTransform(); _engineSystem.UpdateAirLevel(curLevel); } private void UpdateTransform() { float levelHeight = heightY / (_engineSystem.config.maxLevel - 1); var curY = levelHeight * curLevel + _offset.y; transform.position = new Vector3(transform.position.x, curY, transform.position.z); } private void SwitchAirLevel(float mouseY) { mouseY -= _offset.y; float levelHeight = heightY / _engineSystem.config.maxLevel; curLevel = (int)((mouseY) / levelHeight); if (curLevel >= _engineSystem.config.maxLevel) curLevel = _engineSystem.config.maxLevel - 1; if (curLevel < 0) curLevel = 0; } public void StopMove() { } } }