// player has chosen a die public void ChooseDie(PharoahDie die) { pgs.UndoState(); // go back to previous state before WaitingToSelectDie bool bSuccessfulDieChosen = pgs.ChooseDie(die); // calls OnDieSelect delegate. For scarabs, this will reroll or addpip. For TileAbility, it will call the ability's delegate, if any if (bSuccessfulDieChosen) { // this should be made generic for all TileAbility if (this.curScarabInUse && this.curScarabInUse.isConsumed) { Destroy(this.curScarabInUse.gameObject); // destroy the scarab after we've rolled/added pip to the die. this.curScarabInUse = null; } // This will fire the trigger from the player's point of view. The die chosen should be saved by the delegate in ChooseDie if (this.curTileInUse) { this.curTileInUse.FireTrigger(TileAbility.PlayerTurnStateTriggers.ChooseDie, this); } } else// we were not able to select a valid die { if (this.curScarabInUse) { // return the scarab back to our list without consuming it scarabList.Add(this.curScarabInUse); PlayerBoardAllUI.RefreshScarabUI(); this.curScarabInUse = null; } } }
public Scarab AddScarab(Scarab.ScarabType scarabType) { GameState curGamestate = GameState.GetCurrentGameState(); Scarab prefab = curGamestate.scarabPrefab; GameObject prefabGO = prefab.gameObject; GameObject bugGO = GameObject.Instantiate(prefabGO); GameState.Message("Instantiate bugGO"); Scarab bug = bugGO.GetComponent <Scarab>(); bug.type = scarabType; scarabList.Add(bug); bugGO.transform.parent = this.transform; // put this under the player board hierarchy. PlayerBoardAllUI.RefreshScarabUI(); return(bug); }
public bool UseScarab(Scarab.ScarabType type) { bool bSuccess = false; Scarab hasScarab = hasScarabType(type); if (hasScarab != null) { curScarabInUse = hasScarab; scarabList.Remove(hasScarab); // remove my scarab from the list and hold it in curScarabInUse until we've decided what happens to it. Consumed or Undo. PlayerBoardAllUI.RefreshScarabUI(); // this will wait until the player has selected a die, and then perform the scarab's delegate function on that die. this.AskToChooseDie(curScarabInUse.onDieSelect, type.ToString()); } return(bSuccess); }
public void DestroyScarab(Scarab scarab) { scarabList.Remove(scarab); Destroy(scarab.gameObject); PlayerBoardAllUI.RefreshScarabUI(); }