123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using wf;
- public class YotogiParamScroll : MonoBehaviour
- {
- private void Awake()
- {
- this.panel_ = UTY.GetChildObject(base.gameObject, "Mask", false).GetComponent<UIPanel>();
- this.parent_obj_ = UTY.GetChildObject(base.gameObject, "Parent", false);
- Transform transform = this.parent_obj_.transform;
- this.label_array = new YotogiParamScroll.LabelAndLocalize[transform.childCount];
- for (int i = 0; i < this.label_array.Length; i++)
- {
- this.label_array[i] = new YotogiParamScroll.LabelAndLocalize(transform.GetChild(i).GetComponent<UILabel>(), transform.GetChild(i).GetComponent<Localize>());
- }
- this.base_pos = transform.localPosition;
- this.hide_pos = this.base_pos;
- this.hide_pos.x = this.hide_pos.x - this.panel_.baseClipRegion.z;
- this.end_pos = this.base_pos;
- this.end_pos.y = this.end_pos.y + this.panel_.baseClipRegion.w;
- transform.localPosition = this.hide_pos;
- }
- public void Init()
- {
- for (int i = 0; i < this.label_array.Length; i++)
- {
- this.label_array[i].label.alpha = 0f;
- }
- if (this.state_ == YotogiParamScroll.State.FadeIn || this.state_ == YotogiParamScroll.State.FadeOut)
- {
- iTween.Stop(this.parent_obj_);
- }
- if (this.state_ == YotogiParamScroll.State.FadeOut)
- {
- this.parent_obj_.transform.SetParent(base.transform, false);
- for (int j = 0; j < this.label_array.Length; j++)
- {
- this.label_array[j].label.ParentHasChanged();
- }
- }
- this.parent_obj_.transform.localPosition = this.hide_pos;
- }
- public void CallFadeIn(List<KeyValuePair<string, int>> draw_param)
- {
- draw_param.RemoveAll((KeyValuePair<string, int> key_val) => key_val.Value == 0);
- int num = (this.label_array.Length >= draw_param.Count) ? draw_param.Count : this.label_array.Length;
- for (int i = 0; i < this.label_array.Length; i++)
- {
- this.label_array[i].label.alpha = 0f;
- }
- for (int j = 0; j < num; j++)
- {
- this.label_array[j].label.alpha = 1f;
- KeyValuePair<string, int> keyValuePair = draw_param[j];
- YotogiParamScroll.SetLabelText(this.label_array[j], keyValuePair.Key, keyValuePair.Value);
- }
- if (this.state_ == YotogiParamScroll.State.FadeIn || this.state_ == YotogiParamScroll.State.FadeOut)
- {
- iTween.Stop(this.parent_obj_);
- }
- if (this.state_ == YotogiParamScroll.State.FadeOut)
- {
- this.parent_obj_.transform.SetParent(base.transform, false);
- for (int k = 0; k < this.label_array.Length; k++)
- {
- this.label_array[k].label.ParentHasChanged();
- }
- }
- this.parent_obj_.transform.localPosition = this.hide_pos;
- this.state_ = YotogiParamScroll.State.CallIn;
- }
- private void Update()
- {
- if (this.state_ == YotogiParamScroll.State.Wait && this.fade_out_tick_count <= GameMain.tick_count)
- {
- this.parent_obj_.transform.SetParent(this.panel_.transform, false);
- for (int i = 0; i < this.label_array.Length; i++)
- {
- this.label_array[i].label.ParentHasChanged();
- }
- Hashtable hashtable = TweenHash.EaseOutSine(TweenHash.Type.Position, this.end_pos, this.MoveSpeedTime);
- hashtable.Add("oncomplete", "OnEndFadeOut");
- hashtable.Add("oncompletetarget", base.gameObject);
- iTween.MoveTo(this.parent_obj_, hashtable);
- this.state_ = YotogiParamScroll.State.FadeOut;
- }
- }
- private void LateUpdate()
- {
- if (this.state_ == YotogiParamScroll.State.CallIn && this.parent_obj_.GetComponent<iTween>() == null)
- {
- Hashtable hashtable = TweenHash.EaseOutSine(TweenHash.Type.Position, this.base_pos, this.MoveSpeedTime);
- hashtable.Add("oncomplete", "OnEndFadeIn");
- hashtable.Add("oncompletetarget", base.gameObject);
- iTween.MoveTo(this.parent_obj_, hashtable);
- this.state_ = YotogiParamScroll.State.FadeIn;
- }
- }
- private void OnEndFadeIn()
- {
- iTween.Stop(this.parent_obj_);
- this.fade_out_tick_count = GameMain.tick_count + this.WaitTime;
- this.state_ = YotogiParamScroll.State.Wait;
- }
- private void OnEndFadeOut()
- {
- iTween.Stop(this.parent_obj_);
- this.parent_obj_.transform.SetParent(base.transform, false);
- for (int i = 0; i < this.label_array.Length; i++)
- {
- this.label_array[i].label.ParentHasChanged();
- }
- this.parent_obj_.transform.localPosition = this.hide_pos;
- this.state_ = YotogiParamScroll.State.Null;
- }
- private static void SetLabelText(YotogiParamScroll.LabelAndLocalize labelAndLocalize, string text, int num)
- {
- labelAndLocalize.label.text = text;
- labelAndLocalize.localize.SetTerm("MaidStatus/" + text);
- UILabel label = labelAndLocalize.label;
- label.text = label.text + " " + num.ToString();
- }
- public int WaitTime = 2500;
- public float MoveSpeedTime = 0.7f;
- private UIPanel panel_;
- private GameObject parent_obj_;
- private YotogiParamScroll.LabelAndLocalize[] label_array;
- private Vector3 base_pos;
- private Vector3 hide_pos;
- private Vector3 end_pos;
- private int fade_out_tick_count;
- private YotogiParamScroll.State state_;
- private enum State
- {
- Null,
- CallIn,
- FadeIn,
- Wait,
- FadeOut
- }
- private struct LabelAndLocalize
- {
- public LabelAndLocalize(UILabel label, Localize localize)
- {
- this.label = label;
- this.localize = localize;
- }
- public UILabel label;
- public Localize localize;
- }
- }
|