본문 바로가기
NOTE/SaveSource

[SaveSource] WaveMoveTrigger

by DevAthena 2017. 1. 12.
using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
 
 
 
public class WaveMoveTrigger : MonoBehaviour, ITriggerReceiver
{
    int m_curWave;
    bool m_isMovingDone;
    bool m_fadeOutDone;
 
    [Tooltip("보스가 나타날 웨이브를 지정해주세요")]
    public int m_bossWave = 3;
    [Tooltip("웨이브 추가시 이동")]
    public List<Transform> m_waveTransform = null;
    
    private void Awake()
    {
        m_curWave = 1;
    }
 
    private void Update()
    {
        if (ViveFadeInOut.Instance.m_fadeSate == FadeState.Out)
        {
            m_fadeOutDone = ViveFadeInOut.Instance.FadeOut();
            if(m_fadeOutDone && (m_isMovingDone == false))
            {
                ShowWaveText();
                WavePointMove();
                StartCoroutine(ViveFadeInOut.Instance.WaitTimeAndFadeIn());
            }
        }
        else if (ViveFadeInOut.Instance.m_fadeSate == FadeState.In)
        {
            ViveFadeInOut.Instance.FadeIn();
            HideWaveText();
        }
    }
 
    public void ExecutedTrigger(TriggerType type, params object[] parameters)
    {
        if (type == TriggerType.Active)
        {
            m_isMovingDone = false;
            ViveFadeInOut.Instance.m_fadeSate = FadeState.Out;
        }
    }
 
    private void WavePointMove()
    {
        if(m_waveTransform.Count >= m_curWave)
        {
            m_isMovingDone = true;
            Transform movePosition = m_waveTransform[m_curWave - 1];
            Camera.main.transform.root.position = movePosition.position;
            Camera.main.transform.root.localRotation = movePosition.localRotation;
            m_curWave++;
        }        
    }
 
    private void ShowWaveText()
    {
        if ((m_curWave + 1== m_bossWave)
        {
            UIManager.Instance.Open("UIObviousWarning");
        }
        else if((m_curWave+1< m_bossWave)
        {
            UIManager.Instance.Open("UIWaveText");
            if (UIManager.Instance.IsOpen("UIWaveText"))
            {
                Text waveText = GameObject.Find("UIWaveText").transform.FindChild("wave").GetComponent<Text>();
                waveText.text = "WAVE . " + (m_curWave + 1).ToString();
            }
        }
        else
        {
            // Some
        }
    }
 
    private void HideWaveText()
    {
        if (UIManager.Instance.IsOpen("UIObviousWarning"))
        {
            UIManager.Instance.Close("UIObviousWarning");
        }
        else
        {
            if (UIManager.Instance.IsOpen("UIWaveText"))
            {
                UIManager.Instance.Close("UIWaveText");
            }
        }
    }
}
cs


'NOTE > SaveSource' 카테고리의 다른 글

[SaveSource] StageRankManager  (0) 2017.01.20
[SaveSource] CameraOrbit  (0) 2017.01.12
[SaveSource] SpeicalWeapon  (0) 2017.01.12
[SaveSource] WeaponDrob  (0) 2017.01.04
[SaveSource] ViveTouchPad  (0) 2017.01.04