61 lines
1.4 KiB
C#
61 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MoveMapObj : MapControlBase
|
|
{
|
|
public int onStage, onWave;
|
|
public Transform MoveTarget;
|
|
public float m_Speed = 1f;
|
|
|
|
Vector3 oriPos;
|
|
bool IsUpdate;
|
|
|
|
private void Awake()
|
|
{
|
|
oriPos = transform.position;
|
|
enabled = onStage > 0 && onWave > 0;
|
|
IsUpdate = false;
|
|
|
|
if (enabled)
|
|
{
|
|
MobInfo.Ins.onChangeWave += Event_WaveChange;
|
|
MobInfo.Ins.onInitStage += Event_InitStage;
|
|
}
|
|
}
|
|
|
|
private void Event_InitStage()
|
|
{
|
|
IsUpdate = false;
|
|
transform.position = oriPos;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (enabled)
|
|
{
|
|
MobInfo.Ins.onChangeWave -= Event_WaveChange;
|
|
MobInfo.Ins.onInitStage -= Event_InitStage;
|
|
}
|
|
}
|
|
|
|
private void Event_WaveChange(int stage, int wave)
|
|
{
|
|
if (stage == onStage && wave == onWave - 1)
|
|
IsUpdate = true;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (IsUpdate)
|
|
{
|
|
transform.position = Vector3.MoveTowards(transform.position, MoveTarget.position, m_Speed * Time.deltaTime);
|
|
if (Equals(transform.position, MoveTarget.position))
|
|
{
|
|
IsComplete = tag.Equals("ChapterClear");
|
|
IsUpdate = false;
|
|
}
|
|
}
|
|
}
|
|
} |