38 lines
993 B
C#
38 lines
993 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
|
|
public class Train : MonoBehaviour
|
|
{
|
|
public TrainType type;
|
|
private LocomotionHandler locomotionHandler;
|
|
|
|
void OnEnable()
|
|
{
|
|
if(locomotionHandler == null)
|
|
locomotionHandler = FindObjectOfType<LocomotionHandler>();
|
|
|
|
var startPosition = locomotionHandler.pullUpPositionBefore;
|
|
var speed = locomotionHandler.trainSpeed;
|
|
|
|
transform.localPosition = new Vector3(transform.localPosition.x,
|
|
transform.localPosition.y,
|
|
startPosition);
|
|
|
|
transform.DOLocalMoveZ(-4, speed)
|
|
.SetEase(Ease.OutSine);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
var endPosition = locomotionHandler.pullUpPositionAfter;
|
|
var speed = locomotionHandler.trainSpeed;
|
|
|
|
transform.DOLocalMoveZ(endPosition, speed)
|
|
.SetEase(Ease.InSine)
|
|
.OnComplete(() => gameObject.SetActive(false));
|
|
}
|
|
}
|