//バイナリ読み込み public void OnRead(BinaryReader reader) { this.ClearSub(); int version = reader.ReadInt32(); if (version == VERSION) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); selections.Add(selection); } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); spriteSelections.Add(selection); AddSpriteClickEvent(selection); } } else if (version == VERSION_0) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); selections.Add(selection); } } else { Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version)); } }
/// <summary> /// 選択肢追加 /// </summary> /// <param name="label">ジャンプ先のラベル</param> /// <param name="name">クリックを有効にするオブジェクト名</param> /// <param name="isPolygon">ポリゴンコライダーを使うか</param> /// <param name="exp">選択時に実行する演算式</param> public void AddSelectionClick(string label, string name, bool isPolygon, ExpressionParser exp, StringGridRow row) { AdvSelection select = new AdvSelection(label, name, isPolygon, exp, row); spriteSelections.Add(select); AddSpriteClickEvent(select); }
//リストビューのアイテムが作成されるときに呼ばれるコールバック protected virtual void CallbackCreateItem(GameObject go, int index) { AdvSelection data = SelectionManager.Selections[index]; AdvUguiSelection selection = go.GetComponentInChildren <AdvUguiSelection>(); selection.Init(data, OnTap); }
public void AddData(AdvSelection selection) { if ((selection.Label != "Alaways") && !this.Check(selection)) { this.dataList.Add(new AdvSelectedHistoryData(selection)); } }
/// <summary> /// 初期化 /// </summary> /// <param name="data">選択肢データ</param> public virtual void Init(AdvSelection data, Action <AdvUguiSelection> ButtonClickedEvent) { this.data = data; this.text.text = data.Text; UnityEngine.UI.Button button = this.GetComponent <UnityEngine.UI.Button> (); button.onClick.AddListener(() => ButtonClickedEvent(this)); }
public bool Check(AdvSelection selection) { if (!string.IsNullOrEmpty(this.Label) || !string.IsNullOrEmpty(selection.Label)) { return(this.Label == selection.Label); } return((this.Text == selection.Text) && (this.JumpLabel == selection.JumpLabel)); }
/// <summary> /// 初期化 /// </summary> /// <param name="data">選択肢データ</param> public void Init(AdvSelection data, Action<AdvUguiSelection> ButtonClickedEvent) { this.data = data; this.text.text = data.Text; // Debug.Log (data.Text); UnityEngine.UI.Button button = this.GetComponent<UnityEngine.UI.Button> (); button.onClick.AddListener( ()=>ButtonClickedEvent(this) ); }
/// <summary> /// 既読チェック /// </summary> public bool Check(AdvSelection selection) { //選択済みにしない if (selection.Label == Ignore) { return(false); } return(dataList.Find(x => x.Check(selection)) != null); }
/// <summary> /// 選択肢データをクリア /// </summary> public void Clear() { isWaitSelect = false; selected = null; selections.Clear(); foreach (AdvSelection selection in spriteSelections) { Engine.GraphicManager.RemoveClickEvent(selection.SpriteName); } spriteSelections.Clear(); }
void ClearSub() { selected = null; selections.Clear(); foreach (AdvSelection selection in spriteSelections) { Engine.GraphicManager.RemoveClickEvent(selection.SpriteName); } spriteSelections.Clear(); IsShowing = false; IsWaitInput = false; }
/// <summary> /// 選択 /// </summary> /// <param name="selected">選んだ選択肢</param> public virtual void Select(AdvSelection selected) { this.selected = selected; string label = selected.JumpLabel; if (selected.Exp != null) { Engine.Param.CalcExpression(selected.Exp); } this.OnSelected.Invoke(this); Engine.SystemSaveData.SelectionData.AddData(selected); Clear(); Engine.ScenarioPlayer.MainThread.JumpManager.RegistoreLabel(label); }
/// <summary> /// 「選択済み」のデータ追加 /// </summary> public void AddData(AdvSelection selection) { //選択済みにしない if (selection.Label == Ignore) { return; } //既に選択済みなのでそのまま if (Check(selection)) { return; } dataList.Add(new AdvSelectedHistoryData(selection)); }
//コマンド終了待ち public override bool Wait(AdvEngine engine) { if (!engine.SelectionManager.IsWaitSelect) { AdvSelection selected = engine.SelectionManager.Selected; string label = selected.JumpLabel; if (selected.Exp != null) { engine.Param.CalcExpression(selected.Exp); } engine.SelectionManager.Clear(); engine.JumpScenario(label); } //JumpScenarioした場合でも常にtrueを返すのが必須 return(true); }
//コマンド終了待ち public override bool Wait(AdvEngine engine) { if (engine.SelectionManager.IsSelected) { AdvSelection selected = engine.SelectionManager.Selected; string label = selected.JumpLabel; if (selected.Exp != null) { engine.Param.CalcExpression(selected.Exp); } engine.SelectionManager.Clear(); engine.ScenarioPlayer.JumpManager.RegistoreLabel(label); return(false); } return(true); }
//バイナリ読み込み void Read(BinaryReader reader) { int version = reader.ReadInt32(); if (version == VERSION) { this.Clear(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader); selections.Add(selection); } } else { Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version)); } }
//選択肢表示に使うプレハブを取得 protected virtual GameObject GetPrefab(AdvSelection selectionData) { GameObject prefab = null; if (!string.IsNullOrEmpty(selectionData.PrefabName)) { //プレハブ名と一致するものを探す prefab = PrefabList.Find(x => x.name == selectionData.PrefabName); if (prefab != null) { return(prefab); } else { //見つからないとき Debug.LogError("Not found Selection Prefab : " + selectionData.PrefabName); } } //プレハブ名の指定がなかったら、リストの一番目を //旧バージョンとの互換性のためListViewから選ぶ prefab = PrefabList.Count > 0 ? PrefabList[0] : ListView.ItemPrefab; return(prefab); }
void OnSpriteClick(BaseEventData eventData, AdvSelection select) { Select(select); }
//バイナリ読み込み void Read(BinaryReader reader) { this.Clear(); int version = reader.ReadInt32(); if (version == VERSION) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); selections.Add(selection); } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); spriteSelections.Add(selection); AddSpriteClickEvent(selection); } } else if (version == VERSION_0) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AdvSelection selection = new AdvSelection(reader, engine); selections.Add(selection); } } else { Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version)); } }
void AddSpriteClickEvent(AdvSelection select) { Engine.GraphicManager.AddClickEvent(select.SpriteName, select.IsPolygon, select.RowData, (eventData) => OnSpriteClick(eventData, select)); }
/// <summary> /// 選択 /// </summary> /// <param name="index">選択肢のインデックス</param> public void Select(int index) { selected = selections[index]; isWaitSelect = false; }
public bool Check(AdvSelection selection) {
public AdvSelectedHistoryData(AdvSelection selection) { this.Label = selection.Label; this.Text = selection.Text; this.JumpLabel = selection.JumpLabel; }
public void Init(AdvSelection data, Action <AdvUguiSelection> ButtonClickedEvent) {
/// <summary> /// 選択肢データをクリア /// </summary> public void Clear() { isWaitSelect = false; selected = null; selections.Clear(); }
/// <summary> /// 初期化 /// </summary> /// <param name="data">選択肢データ</param> public void Init(AdvSelection data) { text.text = data.Text; }
private GameObject GetPrefab(AdvSelection selectionData) {
/// <summary> /// 選択の入力待ち開始 /// </summary> public void StartWaiting() { isWaitSelect = true; selected = null; }
private void CallbackCreateItem(GameObject go, int index) { AdvSelection data = this.SelectionManager.Selections[index]; go.GetComponentInChildren <AdvUguiSelection>().Init(data, new Action <AdvUguiSelection>(this.OnTap)); }
/// <summary> /// 選択の表示 /// </summary> public void Show() { selected = null; IsShowing = true; OnBeginShow.Invoke(this); }
/// <summary> /// 選択 /// </summary> /// <param name="selected">選んだ選択肢</param> public void Select( AdvSelection selected) { this.selected = selected; isWaitSelect = false; }
/// <summary> /// 選択 /// </summary> /// <param name="selected">選んだ選択肢</param> public void Select(AdvSelection selected) { this.selected = selected; isWaitSelect = false; }