123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- using System;
- using UnityEngine;
- public abstract class WfScreenChildren : MonoBehaviour
- {
- public virtual void Awake()
- {
- this.root_obj_ = this.RootPanel;
- this.awake_active_ = this.root_obj_.activeSelf;
- if (!this.root_obj_.activeSelf)
- {
- this.root_obj_.SetActive(true);
- }
- this.call_fadein_wait_ = (this.cur_call_fadein_wait_ = 0);
- }
- public virtual void Update()
- {
- if (this.fade_status_ == WfScreenChildren.FadeStatus.FadeInWait)
- {
- this.cur_call_fadein_wait_--;
- if (0 <= this.cur_call_fadein_wait_)
- {
- return;
- }
- if (this.IsCallFadeIn())
- {
- this.cur_call_fadein_wait_ = 0;
- if (this.fade_status_ == WfScreenChildren.FadeStatus.FadeInWait)
- {
- this.FadeIn();
- }
- }
- }
- else
- {
- this.cur_call_fadein_wait_ = 0;
- }
- if (this.fade_status_ == WfScreenChildren.FadeStatus.FadeIn)
- {
- if (!GameMain.Instance.MainCamera.IsFadeProc())
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.Wait;
- }
- }
- else if (this.fade_status_ == WfScreenChildren.FadeStatus.FadeOut)
- {
- if (!GameMain.Instance.MainCamera.IsFadeProc())
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.FadeEnd;
- this.OnFinish();
- }
- }
- else if (this.fade_status_ == WfScreenChildren.FadeStatus.FadeEnd)
- {
- this.OnFadeEnd();
- }
- }
- public bool Call()
- {
- if (!this.init_finishied)
- {
- NDebug.Assert("初期化完了前にCallが呼ばれました", false);
- return false;
- }
- if (this.fade_status_ != WfScreenChildren.FadeStatus.Null)
- {
- Debug.LogWarning("Call呼び出し\nフェード状態は" + this.fade_status_.ToString() + "なのでキャンセルされました");
- return false;
- }
- this.cur_call_fadein_wait_ = 0;
- if (!this.root_obj_.activeSelf)
- {
- this.root_obj_.SetActive(true);
- }
- this.OnCall();
- if (this.call_fadein_wait_ <= 0 && this.IsCallFadeIn())
- {
- this.FadeIn();
- }
- else
- {
- if (0 < this.call_fadein_wait_)
- {
- this.cur_call_fadein_wait_ = this.call_fadein_wait_;
- }
- if (this.fade_status_ == WfScreenChildren.FadeStatus.Null)
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.FadeInWait;
- }
- }
- return true;
- }
- public void Reset()
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.Null;
- }
- protected abstract void OnCall();
- protected virtual bool IsCallFadeIn()
- {
- return true;
- }
- public void SetCallInFadeWaitFrame(int frame)
- {
- this.call_fadein_wait_ = frame;
- }
- protected virtual void OnFinish()
- {
- }
- protected virtual void OnFadeEnd()
- {
- }
- public virtual bool Finish()
- {
- if (this.fade_status_ != WfScreenChildren.FadeStatus.Wait)
- {
- Debug.LogWarning("Finish呼び出し\nフェード状態は" + this.fade_status_.ToString() + "なのでキャンセルされました");
- return false;
- }
- this.FadeOut();
- return true;
- }
- public void SetFadeTime(float time)
- {
- this.fade_time_ = time;
- }
- protected void SetFadeStatus(WfScreenChildren.FadeStatus status)
- {
- this.fade_status_ = status;
- }
- protected virtual void FadeIn()
- {
- GameMain.Instance.MainCamera.FadeIn(this.fade_time_, false, null, true, true, default(Color));
- if (GameMain.Instance.MainCamera.IsFadeProc())
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.FadeIn;
- }
- else
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.Wait;
- }
- }
- protected virtual void FadeOut()
- {
- GameMain.Instance.MainCamera.FadeOut(this.fade_time_, false, null, true, default(Color));
- if (GameMain.Instance.MainCamera.IsFadeProc())
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.FadeOut;
- }
- else
- {
- this.fade_status_ = WfScreenChildren.FadeStatus.FadeEnd;
- this.OnFinish();
- }
- }
- public virtual void LateUpdate()
- {
- if (!this.awake_init_)
- {
- if (!this.awake_active_)
- {
- this.root_obj_.SetActive(false);
- }
- this.awake_init_ = true;
- }
- }
- public bool init_finishied
- {
- get
- {
- return this.awake_init_;
- }
- }
- public GameObject root_obj
- {
- get
- {
- return this.root_obj_;
- }
- }
- public float fade_time
- {
- get
- {
- return this.fade_time_;
- }
- }
- public WfScreenManager parent_mgr { get; set; }
- public WfScreenChildren.FadeStatus fade_status
- {
- get
- {
- return this.fade_status_;
- }
- }
- [SerializeField]
- public GameObject RootPanel;
- private bool awake_active_;
- private bool awake_init_;
- private GameObject root_obj_;
- private float fade_time_ = 0.5f;
- private WfScreenChildren.FadeStatus fade_status_;
- private int call_fadein_wait_;
- private int cur_call_fadein_wait_;
- public enum FadeStatus
- {
- Null,
- FadeInWait,
- FadeIn,
- Wait,
- FadeOut,
- FadeEnd
- }
- }
|