//Returns the index of this option, from the parent's perspective public int GetIndexInParent() { MenuOption menuOption = parentOption as MenuOption; if (menuOption != null) { return(menuOption.checkChildIndex(this)); } return(-1); }
//Returns the index of the requested child from the derivedOptions array public virtual int checkChildIndex(MenuOption child) { int i = 0; foreach (MenuOption menuOption in derivedOptions) { if (menuOption.optionText == child.optionText) { return(i); } i++; } return(-1); }
//Called when the player presses the selection button public void Select() { MenuOption temp = currentOption.Select() as MenuOption; if (temp != null) { MenuOption menuOp = currentOption.GetParentOption() as MenuOption; if (currentOption.GetParentOption() != null && menuOp != null) { menuOp.SetChildrenNewEnable(false); } currentOption = temp; } }
//Called when the player presses the back button public void Back() { MenuOption temp = currentOption.Back() as MenuOption; if (temp != null) { currentOption = temp; MenuOption menuOp = currentOption.GetParentOption() as MenuOption; if (menuOp != null) { Debug.Log("Parent: " + menuOp.name + "\tChild: " + currentOption); Debug.Log(currentOption.GetIndexInParent()); menuOp.SetChildrenEnableAtIndex(currentOption.GetIndexInParent()); } } }
//Called when this option is selected public override BattleOption Select() { if (increasesDepth) { battleUI.IncreaseDepth(); } battleUI.UpdateOptionBox(0); MenuOption battleOp = derivedOptions[currentIndex]; if (battleOp != null) { SetChildrenEnableAtIndex(currentIndex); battleOp.SetChildrenNewEnable(true); return(battleOp); } else { return(null); } }
void Awake() { currentOption = baseOption; if (currentOption == null) { Debug.LogError("No BaseOption selected"); } if (bm == null) { bm = this; } if (allySpawnPoints.Length == 0) { Debug.LogError("No ally spawn points specified!"); } if (enemySpawnPoints.Length == 0) { Debug.LogError("No enemy spawn points specified!"); } if (battle == null) { Debug.LogError("No Battle specified!"); } }
public override int checkChildIndex(MenuOption child) { return(-1); }