123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- public class YotogiStageUnit : MonoBehaviour
- {
- public void Awake()
- {
- GameObject childObject = UTY.GetChildObject(base.gameObject, "Parent", false);
- this.thumbnail_sprite_ = UTY.GetChildObject(childObject, "Icon", false).GetComponent<UI2DSprite>();
- EventDelegate.Add(childObject.GetComponent<UIButton>().onClick, new EventDelegate.Callback(this.UpdateBG));
- this.button_ = childObject.GetComponent<UIWFTabButton>();
- this.name_label_ = UTY.GetChildObject(childObject, "Name", false).GetComponent<UILabel>();
- this.star_parent_ = new GameObject[2];
- this.star_parent_[0] = UTY.GetChildObject(childObject, "StarGroup", false);
- this.star_parent_[1] = UTY.GetChildObject(childObject, "StarMarkGroup", false);
- Transform transform = UTY.GetChildObject(childObject, "StarGroup", false).transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- this.star_sprite_list_.Add(transform.GetChild(i).GetComponent<UISprite>());
- }
- this.is_change_bg_ = true;
- }
- public void OnDestroy()
- {
- if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
- {
- UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
- }
- }
- public void SetOnSelectEvent(YotogiStageUnit.OnSelectEvent call_back)
- {
- this.on_select_event_ = call_back;
- }
- public void SetStageData(YotogiStage.Data stage_data, bool enabled, bool isDaytime)
- {
- this.stage_data_ = stage_data;
- this.is_daytime_ = isDaytime;
- if (enabled)
- {
- this.name_label_.text = this.stage_data_.drawName;
- this.name_label_.GetComponent<Localize>().SetTerm(stage_data.termName);
- }
- else
- {
- this.name_label_.text = "??????";
- }
- foreach (GameObject gameObject in this.star_parent_)
- {
- gameObject.SetActive(true);
- }
- for (int j = 0; j < this.star_sprite_list_.Count; j++)
- {
- if (j < this.stage_data_.drawClubGrade)
- {
- this.star_sprite_list_[j].enabled = true;
- }
- else
- {
- this.star_sprite_list_[j].enabled = false;
- }
- }
- int num = (!isDaytime) ? 1 : 0;
- string text = this.stage_data_.thumbnailName[num];
- text = ScriptManager.ReplacePersonal(GameMain.Instance.CharacterMgr.GetMaid(0), text);
- if (!enabled)
- {
- text = "cm3d2_stageselectpreview_nowprinting.tex";
- }
- if (!GameUty.FileSystem.IsExistentFile(text))
- {
- text = "cm3d2_stageselectpreview_dammy.tex";
- }
- if (GameUty.FileSystem.IsExistentFile(text))
- {
- Texture2D texture2D = ImportCM.CreateTexture(text);
- Sprite sprite = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
- sprite.name = stage_data.drawName;
- if (this.thumbnail_sprite_.sprite2D != null && this.thumbnail_sprite_.sprite2D.texture != null)
- {
- UnityEngine.Object.DestroyImmediate(this.thumbnail_sprite_.sprite2D.texture);
- }
- this.thumbnail_sprite_.sprite2D = sprite;
- this.thumbnail_sprite_.SetDimensions(texture2D.width, texture2D.height);
- }
- this.button_.isEnabled = enabled;
- }
- public void UpdateBG()
- {
- if (this.stage_data_ == null)
- {
- return;
- }
- if (this.is_change_bg)
- {
- int num = (!GameMain.Instance.CharacterMgr.status.isDaytime) ? 1 : 0;
- GameMain.Instance.BgMgr.ChangeBg(this.stage_data_.prefabName[num]);
- }
- if (this.on_select_event_ != null)
- {
- this.on_select_event_(this);
- }
- }
- public YotogiStage.Data stage_data
- {
- get
- {
- return this.stage_data_;
- }
- }
- public bool is_daytime
- {
- get
- {
- return this.is_daytime_;
- }
- }
- public UIWFTabButton button
- {
- get
- {
- return this.button_;
- }
- }
- public bool is_change_bg
- {
- get
- {
- return this.is_change_bg_;
- }
- set
- {
- this.is_change_bg_ = value;
- }
- }
- public UI2DSprite thumbnail_sprite
- {
- get
- {
- return this.thumbnail_sprite_;
- }
- }
- private YotogiStage.Data stage_data_;
- private bool is_daytime_;
- private YotogiStageUnit.OnSelectEvent on_select_event_;
- private UILabel name_label_;
- private UI2DSprite thumbnail_sprite_;
- private List<UISprite> star_sprite_list_ = new List<UISprite>();
- private GameObject[] star_parent_;
- private UIWFTabButton button_;
- private bool is_change_bg_;
- public delegate void OnSelectEvent(YotogiStageUnit click_unit);
- }
|