public override bool DropInteract(ChoiceContent drop) { bool val = false; if(transform.parent != null) { val = ((ItemCollector)transform.parent.GetComponent(typeof(ItemCollector))).DropInteract(drop); } return val; }
public ChoiceContent[] GetLanguageChoice() { ChoiceContent[] choice = new ChoiceContent[name.Length+1]; for(int i=0; i<name.Length; i++) { choice[i] = new ChoiceContent(new GUIContent(this.GetName(i))); } choice[choice.Length-1] = new ChoiceContent(new GUIContent(DataHolder.MainMenu().GetCancelText())); return choice; }
public override bool DropInteract(ChoiceContent drop) { bool val = false; if(EventStartType.DROP.Equals(this.startType) && GameHandler.IsControlField() && this.CheckVariables() && this.gameObject.active && this.CheckDrop(drop)) { this.CollectItem(); val = true; } return val; }
public override bool DropInteract(ChoiceContent drop) { bool val = false; if(EventStartType.DROP.Equals(this.startType) && this.CheckVariables() && this.gameObject.active && this.CheckDrop(drop)) { this.CallSaveMenu(); val = true; } return val; }
public DragSprite AddDragSprite(ChoiceContent cc) { DragSprite sprite = null; if(cc != null) { GameObject tmp = GameObject.CreatePrimitive(PrimitiveType.Plane); tmp.name = "_DragSprite"; sprite = (DragSprite)tmp.AddComponent("DragSprite"); sprite.drag = cc; this.AddSprite(sprite); } return sprite; }
/* ============================================================================ Choice content array functions ============================================================================ */ public static ChoiceContent[] CreateChoiceContents(string[] choices) { ChoiceContent[] ch = null; if(choices != null) { ch = new ChoiceContent[choices.Length]; for(int i=0; i<ch.Length; i++) { ch[i] = new ChoiceContent(choices[i]); } } return ch; }
public override bool DropInteract(ChoiceContent drop) { bool dropped = false; if(drop == null) { GameHandler.GetLevelHandler().BattleTargetClicked(this.combatant.battleID); } else if(DragOrigin.INVENTORY.Equals(drop.dragOrigin)) { if(DragType.ITEM.Equals(drop.dragType)) { dropped = this.UseItem(drop.dragID); } else if(DragType.SKILL.Equals(drop.dragType)) { dropped = this.UseSkill(drop.dragID, drop.characterID, drop.dragLevel); } else if(DragType.WEAPON.Equals(drop.dragType) || DragType.ARMOR.Equals(drop.dragType)) { dropped = this.Equip(drop.dragID, drop.dragType); } } else if(DragOrigin.BATTLE_MENU.Equals(drop.dragOrigin)) { Combatant c = DataHolder.BattleSystem().GetCombatantForBattleID(drop.characterID); if(c != null) { if(DragType.ITEM.Equals(drop.dragType)) { dropped = this.BattleItem(drop.dragID, c); } else if(DragType.SKILL.Equals(drop.dragType)) { dropped = this.BattleSkill(drop.dragID, c, drop.dragLevel); } else if(DragType.ATTACK.Equals(drop.dragType)) { dropped = this.BattleAttack(c); } if(dropped && c is Character) { ((Character)c).EndBattleMenu(false); GameHandler.GetLevelHandler().ExitBattleMenu(); } } } return dropped; }
public bool CheckDrop(ChoiceContent drop) { bool check = false; if(drop != null && drop.dragID == this.dropID && ( (DragType.ITEM.Equals(drop.dragType) && ItemDropType.ITEM.Equals(this.dropType)) || (DragType.WEAPON.Equals(drop.dragType) && ItemDropType.WEAPON.Equals(this.dropType)) || (DragType.ARMOR.Equals(drop.dragType) && ItemDropType.ARMOR.Equals(this.dropType)))) { GameHandler.ChangeHappened(1, 0, 0); check = true; if(this.consumeDrop) { GameHandler.RemoveFromInventory(this.dropType, this.dropID, 1); } } return check; }
/* ============================================================================ Init functions ============================================================================ */ public void Show(string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar, bool dt) { this.destroyTextures = dt; if(this.skin == null) this.LoadSkins(); if(this.fadeIn && !this.inDone) this.alpha = 0; if(this.sprite == null) { this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); this.sprite = GameHandler.GUIHandler().AddDPSprite(this); } else { this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); } }
public void Preload(string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar) { if(this.skin == null) this.LoadSkins(); if(this.fadeIn && !this.inDone) this.alpha = 0; this.multiLabel.CreateContent(this, name, text, choices, speakerPortrait, bar); this.preloaded = true; this.destroyTextures = false; }
public bool ShowChoice(DialoguePosition dp, string text, string name, ChoiceContent[] choices) { return this.ShowChoice(dp, text, name, choices, null, null); }
public ChoiceContent[] GetLoadFileChoice() { ChoiceContent[] choice; int offset = 0; if(SaveHandler.FileExists(SaveHandler.AUTOSAVE_INDEX)) { choice = new ChoiceContent[this.maxSaveGames+2]; offset = 1; choice[0] = new ChoiceContent(new GUIContent(SaveHandler.GetFileInfo(-1), this.fileIcon), true); } else choice = new ChoiceContent[this.maxSaveGames+1]; for(int i=0; i<choice.Length-1-offset; i++) { choice[i+offset] = new ChoiceContent(new GUIContent(SaveHandler.GetFileInfo(i), this.fileIcon), SaveHandler.FileExists(i)); } choice[choice.Length-1] = new ChoiceContent(new GUIContent(this.spCancelText[GameHandler.GetLanguage()])); return choice; }
public ChoiceContent CheckDrop(Vector2 mousePosition) { ChoiceContent cc = null; if(this.choice != null && this.dp.IsInWindow(mousePosition)) { float scrollOffsetY = 0; if(this.addScroll) { scrollOffsetY = -(dp.scrollBoundTop-dp.scrollSize.y)/dp.scrollPixelVertical; } for(int i=0; i<this.choice.Length; i++) { if(this.choice[i].droptarget && this.choice[i].CheckClicked(mousePosition, scrollOffsetY, new Vector2(dp.currentPos.x+dp.boxPadding.x, dp.currentPos.y+dp.boxPadding.y))) { cc = this.choice[i]; break; } } // return something cause drop is in window if(cc == null) cc = new ChoiceContent(""); } return cc; }
public ChoiceContent[] GetSavePointChoice() { ChoiceContent[] choice; if(this.showLoad) { choice = new ChoiceContent[3]; choice[0] = new ChoiceContent(new GUIContent(this.spSaveText[GameHandler.GetLanguage()])); choice[1] = new ChoiceContent(new GUIContent(this.spLoadText[GameHandler.GetLanguage()])); choice[2] = new ChoiceContent(new GUIContent(this.spCancelText[GameHandler.GetLanguage()])); } else { choice = new ChoiceContent[2]; choice[0] = new ChoiceContent(new GUIContent(this.spSaveText[GameHandler.GetLanguage()])); choice[1] = new ChoiceContent(new GUIContent(this.spCancelText[GameHandler.GetLanguage()])); } return choice; }
public static ChoiceContent[] Remove(int index, ChoiceContent[] list) { ArrayList tmp = new ArrayList(); foreach(ChoiceContent str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(ChoiceContent)) as ChoiceContent[]; }
public ChoiceContent GetDropOnPosition(Vector2 pos) { ChoiceContent cc = null; if(this.choice != null && this.windowRect.x < pos.x && this.windowRect.y < pos.y && (this.windowRect.x + this.windowRect.width) > pos.x && (this.windowRect.y + this.viewHeight) > pos.y) { for(int i=0; i<this.choice.Length; i++) { if(this.choice[i].droptarget && (this.choicePositions[i].x) < pos.x && (this.choicePositions[i].y - this.scroll.y) < pos.y && (this.choicePositions[i].x + this.choiceSizes[i].x) > pos.x && (this.choicePositions[i].y + this.choiceSizes[i].y - this.scroll.y) > pos.y) { cc = this.choice[i]; break; } } // return something cause drop is in window if(cc == null) cc = new ChoiceContent(""); } return cc; }
/* ============================================================================ Menu functions ============================================================================ */ public ChoiceContent[] GetDifficultyChoice(bool addCancel) { ChoiceContent[] choice = new ChoiceContent[this.difficulty.Length]; for(int i=0; i<choice.Length; i++) { choice[i] = this.GetChoiceContent(i, HUDContentType.BOTH); } if(addCancel) { choice = ArrayHelper.Add(new ChoiceContent(new GUIContent(DataHolder.MainMenu().GetCancelText())), choice); } return choice; }
public bool EqualContent(string text, ChoiceContent[] choices) { bool equals = false; if(this.bgTexture != null && this.contentTexture != null && this.text == text && this.EqualChoices(choices)) { equals = true; } return equals; }
public bool EqualChoices(ChoiceContent[] choices) { bool equals = false; if(this.choice == null && choices == null) equals = true; else if(this.choice != null && choices != null && this.choice.Length == choices.Length) { equals = true; for(int i=0; i<this.choice.Length; i++) { if(!this.choice[i].EqualsWithoutActive(choices[i])) { equals = false; break; } } } return equals; }
public void CreateContent(DialoguePosition dp, string name, string text, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar) { this.dp = dp; // if same content > exit, nothing to do if(this.EqualContent(text, choices)) { bool change = false; for(int i=0; i<this.choice.Length; i++) { if(this.choice[i].ActiveChange(dp, choices[i].active)) { change = true; this.contentTexture = this.choice[i].SetTexture(this.contentTexture, dp, i==this.selection); } } if(change) this.contentTexture.Apply(); return; } this.text = text; this.speakerPortrait = speakerPortrait; this.bar = bar; TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing); textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z); textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w); text = MultiLabel.ReplaceSpecials(text); this.content = new MultiContent(text, dp); if(choices != null) { this.choice = choices; this.choicePositions = new Vector2[choices.Length]; this.choiceSizes = new Vector2[choices.Length]; this.maxSelection = choices.Length; for(int i=0; i<this.choice.Length; i++) { this.choice[i].InitContent(dp); } } else { this.choice = null; this.maxSelection = 0; } float contentHeightAdd = 0; if(this.choice != null) { colFill = dp.columnFill; if(ColumnFill.VERTICAL.Equals(colFill)) { maxCol = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns)); colCount = dp.choiceColumns; } else { maxCol = dp.choiceColumns; colCount = (int)Mathf.Ceil(((float)choice.Length) / ((float)dp.choiceColumns)); } float addHlp = 0; if(dp.choiceColumns > 1) { for(int i=0; i<this.choice.Length; i++) { if(addHlp < this.choice[i].leftSize.y) addHlp = this.choice[i].leftSize.y; if(addHlp < this.choice[i].rightSize.y) addHlp = this.choice[i].rightSize.y; if(addHlp < this.choice[i].titleSize.y) addHlp = this.choice[i].titleSize.y; } if(ColumnFill.VERTICAL.Equals(colFill)) { contentHeightAdd = addHlp*maxCol+dp.columnSpacing*(maxCol-1); } else { contentHeightAdd = addHlp*colCount+dp.columnSpacing*(colCount-1); } } else { for(int i=0; i<this.choice.Length; i++) { addHlp = this.choice[i].leftSize.y; if(addHlp < this.choice[i].rightSize.y) addHlp = this.choice[i].rightSize.y; if(addHlp < this.choice[i].titleSize.y) addHlp = this.choice[i].titleSize.y; contentHeightAdd += addHlp; if(i < this.choice.Length-1) contentHeightAdd += dp.columnSpacing; } } } if(dp.autoCollapse && !DataHolder.GameSettings().noAutoCollapse) { dp.boxBounds.height = this.content.yPos + dp.boxPadding.y + dp.boxPadding.w + contentHeightAdd; textPosition.bounds.height = this.content.yPos + contentHeightAdd; } this.addScroll = false; if(dp.scrollable && (this.content.yPos + contentHeightAdd) > textPosition.bounds.height) { textPosition.bounds.height = this.content.yPos + contentHeightAdd; textPosition.bounds.width -= dp.skin.verticalScrollbarThumb.fixedWidth; this.addScroll = true; } Rect b = this.AddBox(textPosition); float p2OffsetY = this.AddContent(textPosition); this.AddScroll(b, p2OffsetY, textPosition); this.AddName(name); this.AddOk(); this.newTextures = true; }
public bool ShowChoice(DialoguePosition dp, string text, string name, GUIContent[] choices, SpeakerPortrait speakerPortrait) { ChoiceContent[] ch = new ChoiceContent[choices.Length]; for(int i=0; i<ch.Length; i++) { ch[i] = new ChoiceContent(choices[i]); } return this.ShowChoice(dp, text, name, ch, speakerPortrait, null); }
public static ChoiceContent[] Add(ChoiceContent n, ChoiceContent[] list) { ArrayList tmp = new ArrayList(); foreach(ChoiceContent str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(ChoiceContent)) as ChoiceContent[]; }
public bool EqualsWithoutActive(ChoiceContent cc) { bool equals = false; if(this.info == cc.info && this.isButton == cc.isButton && this.CompareGUIContent(this.content, cc.content) && this.CompareGUIContent(this.title, cc.title)) { equals = true; } return equals; }
public ChoiceContent[] GetMainMenuChoice() { ChoiceContent[] choice = new ChoiceContent[] {new ChoiceContent(new GUIContent(this.newGameText[GameHandler.GetLanguage()], this.newIcon))}; if(this.showLoad) choice = ArrayHelper.Add(new ChoiceContent(new GUIContent(this.loadGameText[GameHandler.GetLanguage()], this.loadIcon), SaveHandler.FileExists()), choice); if(this.showLanguage) choice = ArrayHelper.Add(new ChoiceContent(new GUIContent(this.languageText[GameHandler.GetLanguage()], this.languageIcon)), choice); if(this.showAbout) choice = ArrayHelper.Add(new ChoiceContent(new GUIContent(this.aboutText[GameHandler.GetLanguage()], this.aboutIcon)), choice); if(this.showExit) choice = ArrayHelper.Add(new ChoiceContent(new GUIContent(this.exitText[GameHandler.GetLanguage()], this.exitIcon)), choice); return choice; }
public ChoiceContent[] GetFileList(bool isLoad) { ChoiceContent[] choice; int offset = 0; if(isLoad && SaveHandler.FileExists(SaveHandler.AUTOSAVE_INDEX)) { choice = new ChoiceContent[this.maxSaveGames+1]; offset = 1; choice[0] = new ChoiceContent(new GUIContent( SaveHandler.GetFileInfo(SaveHandler.AUTOSAVE_INDEX), this.fileIcon), true); } else choice = new ChoiceContent[this.maxSaveGames]; for(int i=0; i<choice.Length-offset; i++) { if(isLoad) { choice[i+offset] = new ChoiceContent(new GUIContent(SaveHandler.GetFileInfo(i), this.fileIcon), SaveHandler.FileExists(i)); } else { choice[i] = new ChoiceContent(new GUIContent(SaveHandler.GetFileInfo(i), this.fileIcon)); } } return choice; }
public ChoiceContent[] GetYesNoChoice() { ChoiceContent[] choice = new ChoiceContent[2]; choice[0] = new ChoiceContent(new GUIContent(this.questionYes[GameHandler.GetLanguage()])); choice[1] = new ChoiceContent(new GUIContent(this.questionNo[GameHandler.GetLanguage()])); return choice; }
public ChoiceContent[] GetSaveFileChoice() { ChoiceContent[] choice = new ChoiceContent[this.maxSaveGames+1]; for(int i=0; i<choice.Length-1; i++) { choice[i] = new ChoiceContent(new GUIContent(SaveHandler.GetFileInfo(i), this.fileIcon)); } choice[choice.Length-1] = new ChoiceContent(new GUIContent(this.spCancelText[GameHandler.GetLanguage()])); return choice; }
public bool ShowChoice(DialoguePosition dp, string text, string name, ChoiceContent[] choices, SpeakerPortrait speakerPortrait, StatusBar[] bar) { bool press = false; if(dp.skin) GUI.skin = dp.skin; this.maxSelection = choices.Length; Color c = GUI.backgroundColor; c.a = dp.alpha; GUI.backgroundColor = c; c = GUI.color; c.a = dp.alpha; GUI.color = c; if(this.newContent || this.content == null) { GUIStyle shadowStyle = new GUIStyle(GUI.skin.label); shadowStyle.normal.textColor = DataHolder.Color(1); GUIStyle textStyle = new GUIStyle(GUI.skin.label); textStyle.wordWrap = false; TextPosition textPosition = new TextPosition(dp.boxBounds, dp.boxPadding, dp.lineSpacing); textPosition.bounds.width -= (dp.boxPadding.x + dp.boxPadding.z); textPosition.bounds.height -= (dp.boxPadding.y + dp.boxPadding.w); text = MultiLabel.ReplaceSpecials(text); this.content = new MultiContent(text, textStyle, shadowStyle, textPosition, dp.scrollable); this.choice = choices; this.choicePositions = new Vector2[choices.Length]; this.choiceSizes = new Vector2[choices.Length]; for(int i=0; i<choice.Length; i++) { choice[i].InitContent(textStyle, shadowStyle, textPosition, dp.scrollable, dp.selectFirst); if(dp.showShadow) choice[i].SetDragGUI(dp.skin, textStyle, shadowStyle, dp.choicePadding.x, dp.shadowOffset); else choice[i].SetDragGUI(dp.skin, textStyle, null, dp.choicePadding.x, dp.shadowOffset); this.choicePositions[i] = new Vector2(0, 0); this.choiceSizes[i] = new Vector2(0, 0); } this.newContent = false; } if(speakerPortrait != null && !speakerPortrait.inBox) { speakerPortrait.ShowPortrait(); } this.windowRect.x = dp.currentPos.x; this.windowRect.y = dp.currentPos.y; this.windowRect.width = dp.boxBounds.width; this.windowRect.height = dp.boxBounds.height; int windowID = dp.GetWindowID(); this.dp = dp; this.text = text; this.speakerPortrait = speakerPortrait; this.bar = bar; if(dp.isDragWindow) { this.windowRect = GUI.Window(windowID, this.windowRect, ChoiceWindow, name); if(dp.currentPos.x != this.windowRect.x || dp.currentPos.y != this.windowRect.y) { if(dp.focusable) GameHandler.WindowHandler().SetFocusID(windowID); if(DataHolder.GameSettings().saveWindowDrag) { if(this.windowRect.x < 0) this.windowRect.x = 0; else if((this.windowRect.x+this.windowRect.width) > DataHolder.GameSettings().defaultScreen.x) { this.windowRect.x = DataHolder.GameSettings().defaultScreen.x-this.windowRect.width; } if(this.windowRect.y < 0) this.windowRect.y = 0; else if((this.windowRect.y+this.windowRect.height) > DataHolder.GameSettings().defaultScreen.y) { this.windowRect.y = DataHolder.GameSettings().defaultScreen.y-this.windowRect.height; } } dp.currentPos.x = this.windowRect.x; dp.currentPos.y = this.windowRect.y; dp.SetBasePosition(this.windowRect.x, this.windowRect.y); } } else { if(name != "") { GUIStyle shadowStyle = new GUIStyle(GUI.skin.label); shadowStyle.normal.textColor = DataHolder.Color(1); GUIStyle textStyle = new GUIStyle(GUI.skin.label); textStyle.wordWrap = false; if(dp.nameSkin) GUI.skin = dp.nameSkin; Vector2 v = textStyle.CalcSize(new GUIContent(name)); TextPosition namePosition = new TextPosition(dp.nameBounds, dp.namePadding, 0); namePosition.bounds.x = dp.currentPos.x+dp.nameOffset.x; namePosition.bounds.y = dp.currentPos.y+dp.nameOffset.y; namePosition.bounds.width = v.x + dp.namePadding.x + dp.namePadding.z; if(dp.showNameBox) GUI.Box(namePosition.bounds, ""); namePosition.bounds.x += dp.namePadding.x; namePosition.bounds.y += dp.namePadding.y; namePosition.bounds.width -= (dp.namePadding.x + dp.namePadding.z); namePosition.bounds.height -= (dp.namePadding.y + dp.namePadding.w); if(dp.showShadow) { GUI.Label( new Rect(namePosition.bounds.x + dp.shadowOffset.x, namePosition.bounds.y + dp.shadowOffset.y, namePosition.bounds.width, namePosition.bounds.height), name, shadowStyle); } GUI.Label(new Rect(namePosition.bounds.x, namePosition.bounds.y, namePosition.bounds.width, namePosition.bounds.height), name, textStyle); if(dp.skin) GUI.skin = dp.skin; } if(dp.showBox) { this.windowRect = GUI.Window(windowID, this.windowRect, ChoiceWindow, "", "box"); } else { GUI.BeginGroup(this.windowRect); this.ChoiceWindow(-1); GUI.EndGroup(); } } if(this.windowPress) { press = true; this.windowPress = false; } c = GUI.backgroundColor; c.a = 1; GUI.backgroundColor = c; c = GUI.color; c.a = 1; GUI.color = c; return press; }
public ChoiceContent[] GetYesNoChoice() { ChoiceContent[] choice = new ChoiceContent[2]; choice[0] = new ChoiceContent(new GUIContent(this.saveYesText[GameHandler.GetLanguage()])); choice[1] = new ChoiceContent(new GUIContent(this.saveNoText[GameHandler.GetLanguage()])); return choice; }
public ChoiceContent GetTimeContent(HUDContentType type) { ChoiceContent cc = null; if(HUDContentType.TEXT.Equals(type)) { cc = new ChoiceContent(new GUIContent(this.GetTimeText())); } else if(HUDContentType.ICON.Equals(type)) { cc = new ChoiceContent(new GUIContent(this.timeIcon)); } else if(HUDContentType.BOTH.Equals(type)) { cc = new ChoiceContent(new GUIContent(this.GetTimeText(), this.timeIcon)); } return cc; }