public PharoahDie GetChildAsDie() { GameObject childGO = this.myChild; PharoahDie die = childGO.GetComponent <PharoahDie>(); return(die); }
public bool AddPip(PharoahDie die) { if (!die.isActiveDie()) { GameState.Message("Cannot use Scarab on non-active die."); return(false); } int val = die.GetValue(); if (val + 1 > die.MaxValue()) { GameState.Message("Cannot AddPip beyond die's max value of " + die.MaxValue().ToString()); return(false); } GameState.Message("Adding Pip to " + die.name); val++; if (val >= die.MaxValue()) { val = die.MaxValue(); } die.SetDie(val); isConsumed = true; return(true); }
// 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 override void OnStartTurn(PlayerBoard plr) { base.OnStartTurn(plr); this.isUsedThisTurn = false; // refresh this every turn. hasBeenActivatedBySpecificRoll = false; curDie = null; adjustedDice.Clear(); }
// ============================================================================= // add a new die to myself public PharoahDie AddDie(DiceFactory.DieType dieType) { PharoahDie die = GameState.GetCurrentGameState().diceFactory.NewDie(dieType); diceList.Add(die); die.ReadyToRoll(); return(die); }
public PharoahDie NewDie(DieType dieType) { PharoahDie newDie = GameObject.Instantiate(prefabDice[(int)dieType]); if (newDie.isSetDie()) { newDie.MoveToSetDieArea(); } return(newDie); }
public void EndTurn() { GameState.Message(this.name + " turn has ended"); this.gameObject.SetActive(false); // End of Turn Triggers foreach (Tile tile in tileList) { TileAbility ability = tile.GetComponent <TileAbility>(); if (ability) { // Herder ability. If the player has locked a pair, then give the player a die for the remainder of the turn. if (ability.onStateTrigger == TileAbility.PlayerTurnStateTriggers.LockedAny) { } } } // remove all temporary tiles. RemoveAllTempTiles(); // for all dice - remove all temporary dice for (int ii = diceList.Count - 1; ii >= 0; ii--) // reverse remove so we don't get weird list problems { PharoahDie d6 = diceList[ii]; if (d6.isTemporary()) // remove temporary dice { diceList.RemoveAt(ii); // take this die out of this list Destroy(d6.gameObject); // destroy this whole die. } } /* * foreach (PharoahDie d6 in diceList) * { * if (d6.isTemporary()) // remove temporary dice * { * diceList.Remove(d6); * Destroy(d6.gameObject); * } * } */ // for all dice - reset all permanent dice foreach (PharoahDie d6 in diceList) { d6.ReadyToRoll(); d6.EndTurn(); d6.transform.parent = this.transform; } foreach (Tile tile in tileList) { tile.canUndo = false; } pgs.SetState(PlayerGameState.PlayerGameStates.WaitingNextTurn); }
// selecting a die public bool ChooseDie(PharoahDie die) { bool bSuccess = false; if (OnDieSelect != null) { bSuccess = OnDieSelect(die); if (bSuccess) curDie = die; } return bSuccess; }
// roll a single die public bool RollDie(PharoahDie die) { if (die == null) { return(false); } GameState.GetCurrentGameState().purchaseBoard.SetState(PurchaseBoard.PurchaseBoardState.isTuckedAway); UnhideDice(); DiceCup.StartRolling(); die.ReadyToRoll(); die.RollDie(); return(true); }
// get the first die that is not the specified one. PharoahDie GetOtherDie(PharoahDie notThisDie) { PharoahDie theDie = null; foreach (PharoahDie die in adjustedDice) { if (die != notThisDie) { theDie = die; return(theDie); } } return(theDie); }
// selecting a die public bool ChooseDie(PharoahDie die) { bool bSuccess = false; if (OnDieSelect != null) { bSuccess = OnDieSelect(die); if (bSuccess) { curDie = die; } } return(bSuccess); }
public bool Reroll(PharoahDie die) { if (!die.isActiveDie()) { GameState.Message("Cannot use Scarab on non-active die."); return false; } GameState.Message("Rerolling " + die.name); DiceCup.StartRolling(); die.ReadyToRoll(); die.RollDie(); isConsumed = true; return true; }
public bool Reroll(PharoahDie die) { if (!die.isActiveDie()) { GameState.Message("Cannot use Scarab on non-active die."); return(false); } GameState.Message("Rerolling " + die.name); DiceCup.StartRolling(); die.ReadyToRoll(); die.RollDie(); isConsumed = true; return(true); }
// get a new die that is ready to roll immediately PharoahDie GetNewDie(PlayerBoard plr) { PharoahDie die = plr.AddDie(type); myDie = die; // remember the die that this tileAbility bought. We may need to do something with it later. if (setDieValue > 0) { die.MakeSetDie(setDieValue); } if (isTemporary) { die.MakeTemporary(); } return(die); }
bool OnCancel(PharoahDie d) { bool bSuccess = false; this.isUsedThisTurn = false; this.isUsedThisRoll = false; GameState.Message("Cancel"); foreach (PharoahDie die in adjustedDice) { die.UndoTempPips(); bSuccess = true; } myPlayer.UndoState(); // go back to previous state UIState.EnableCancelButton(false); UIState.EnableDoneButton(false); return(bSuccess); }
public List <PharoahDie> GetLockedDiceList() { List <PharoahDie> diceList = new List <PharoahDie>(); foreach (DieSlot ds in lockedDiceSlots) { if (!ds.isEmpty()) { if (ds.GetChildAsDie() != null) { diceList.Add(ds.GetChildAsDie()); } } } PharoahDie.SortList(diceList); return(diceList); }
bool OnDone(PharoahDie d) { bool bSuccess = false; GameState.Message("Done"); hasBeenActivatedBySpecificRoll = false; // deactivate this die ability when done. foreach (PharoahDie die in adjustedDice) { die.FinalizeTempPips(); bSuccess = true; } myPlayer.UndoState(); // go back to previous state UIState.EnableCancelButton(false); UIState.EnableDoneButton(false); this.isUsedThisTurn = true; this.isUsedThisRoll = true; return(bSuccess); }
public override void OnSelect(PlayerBoard plr) { base.OnSelect(plr); if (this.isUsedThisTurn && this.onlyOneUsePerTurn) { GameState.Message("Already used " + this.name + "\nduring this turn."); return; } if (this.isUsedThisRoll) { GameState.Message("Already used " + this.name + "\nduring this roll."); return; } // sometimes, this is a DieAbility rather than a TileAbility. SOme die abilities only are allowed on certain rolls of that die. if (specificRoll > 0) { if (this.myDie != null) { if (this.myDie.GetValue() != specificRoll) { GameState.Message("Die " + this.myDie.name + " must be " + specificRoll.ToString() + " to use this ability.\n"); return; } } } curDie = null; adjustedDice.Clear(); if (nDice == -1) { actualNumDice = plr.GetNumValidDice(onlyFor); } else { actualNumDice = nDice; } myPlayer = plr; plr.SetTileInUse(this.GetComponent<Tile>()); plr.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice plr.AskToChooseCancel(this.OnCancel); plr.AskToChooseDone(this.OnDone); }
public override void OnSelect(PlayerBoard plr) { base.OnSelect(plr); if (this.isUsedThisTurn && this.onlyOneUsePerTurn) { GameState.Message("Already used " + this.name + "\nduring this turn."); return; } if (this.isUsedThisRoll) { GameState.Message("Already used " + this.name + "\nduring this roll."); return; } // sometimes, this is a DieAbility rather than a TileAbility. SOme die abilities only are allowed on certain rolls of that die. if (specificRoll > 0) { if (this.myDie != null) { if (this.myDie.GetValue() != specificRoll) { GameState.Message("Die " + this.myDie.name + " must be " + specificRoll.ToString() + " to use this ability.\n"); return; } } } curDie = null; adjustedDice.Clear(); if (nDice == -1) { actualNumDice = plr.GetNumValidDice(onlyFor); } else { actualNumDice = nDice; } myPlayer = plr; plr.SetTileInUse(this.GetComponent <Tile>()); plr.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice plr.AskToChooseCancel(this.OnCancel); plr.AskToChooseDone(this.OnDone); }
public bool AddPip(PharoahDie die) { if (!die.isActiveDie()) { GameState.Message("Cannot use Scarab on non-active die."); return false; } int val = die.GetValue(); if (val+1 > die.MaxValue()) { GameState.Message("Cannot AddPip beyond die's max value of " + die.MaxValue().ToString()); return false; } GameState.Message("Adding Pip to " + die.name); val++; if (val >= die.MaxValue()) val = die.MaxValue(); die.SetDie(val); isConsumed = true; return true; }
bool SetState(ScarabUIState newState) { bool bSuccess = false; switch (newState) { default: case ScarabUIState.ready: selectedDie = null; bSuccess = true; SetNumScarabsUI(); break; // try to use the scarab case ScarabUIState.scarab_activated: // set aside the scarab for use if (GameState.GetCurrentGameState().currentPlayer.UseScarab(type)) { if (SetState(ScarabUIState.waiting_die_select)) { bSuccess = true; newState = ScarabUIState.waiting_die_select; } } break; case ScarabUIState.waiting_die_select: //GameState.GetCurrentGameState().currentPlayer.AskToChooseDie(this.type.ToString()); //GameState.Message(this.name + " please select a die for scarab action"); bSuccess = true; break; } if (bSuccess) { scuiState = newState; } return(bSuccess); }
bool isNewDie(PharoahDie die) { return (!adjustedDice.Contains(die)); }
// get the first die that is not the specified one. PharoahDie GetOtherDie(PharoahDie notThisDie) { PharoahDie theDie = null; foreach (PharoahDie die in adjustedDice) { if (die != notThisDie) { theDie = die; return theDie; } } return theDie; }
public void GiveHerderDie(PharoahDie die) { bHasExtraHerderDie = true; pgs.mayRollDice = true; // if we JUST got a herder die, we are always allowed a roll of the herder die, even if we just locked all of our other dice. GameState.Message(this.name + " received a Herder die!"); }
// roll a single die public bool RollDie(PharoahDie die) { if (die == null) return false; GameState.GetCurrentGameState().purchaseBoard.SetState(PurchaseBoard.PurchaseBoardState.isTuckedAway); UnhideDice(); DiceCup.StartRolling(); die.ReadyToRoll(); die.RollDie(); return true; }
bool isNewDie(PharoahDie die) { return(!adjustedDice.Contains(die)); }
bool OnDone(PharoahDie d) { bool bSuccess = false; GameState.Message("Done"); hasBeenActivatedBySpecificRoll = false; // deactivate this die ability when done. foreach (PharoahDie die in adjustedDice) { die.FinalizeTempPips(); bSuccess = true; } myPlayer.UndoState(); // go back to previous state UIState.EnableCancelButton(false); UIState.EnableDoneButton(false); this.isUsedThisTurn = true; this.isUsedThisRoll = true; return bSuccess; }
public virtual void OnAcquireDie(PharoahDie die) { GameState.Message("Tile " + this.name + " triggered OnAcquireDie PharoahDie " + die.name + "\n"); myDie = die; }
// delegate: when the player chooses a die, this will get called. // user clicked on a die. Which one is it? We have to keep track here for this ability. bool PickDie(PharoahDie die) { return(myPlayer.RollDie(die)); }
void UndoPips(PharoahDie die) { die.UndoTempPips(); }
// delegate: when the player chooses a die, this will get called. // user clicked on a die. Which one is it? We have to keep track here for this ability. bool PickDie(PharoahDie die) { bool bLegalDie = false; bool bIsNewDie = false; if (!die.isDieType(onlyFor)) { myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("Cannot pick " + die.name + " because it's\nthe wrong type."); return false; } if (isNewDie(die)) { bIsNewDie = true; } else { bLegalDie = true; // we picked a die that we already have picked } if (adjustedDice.Count < actualNumDice) // can still pick new dice { if (bIsNewDie) { die.ClearTempPips(); adjustedDice.Add(die); // add the new die to the list of dice we are modifying bLegalDie = true; } } // if we are a legal die, then we can add pips to it (or undo the addpips) if (bLegalDie) { if (die != curDie) lastDie = curDie; curDie = die; if (isExactlyNumPips) // we add exactly this number of pips. { if (die.getTempPips()==0) // we haven't messed with this die yet { if (die.GetSide() + nPips > 6) // failure case. we can't add this many pips! { adjustedDice.Remove(die); myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("ERROR: Can't add exactly " + nPips.ToString() + " to " + die.name); return false; } else { die.AddTempPips(nPips); } } else// we've messed with this die already { die.UndoTempPips(); } } else// we can add up to the number of pips specified in nPips to any die { if (die.getTempPips()+1 > nPips) { die.UndoTempPips(); } else { if (!setToAnyFace && (die.GetSide() + 1 > 6)) // failure case. we can't add this many pips! { die.UndoTempPips(); } if (!isEntertainer) { if (!isSoothsayer) { // do the wrap around. if (die.GetSide() + 1 > 6) { // set the temppips such that it equals 1. die.SetTempPipsValue(1); } else { die.AddTempPips(1); } } else// Soothsayer nonsense here { int exactlyNumDice = 2; if (isAstrologer) exactlyNumDice = 3; if (adjustedDice.Count!= exactlyNumDice) { GameState.Message("Select exactly " + exactlyNumDice.ToString() + " dice."); } else { PharoahDie otherDie = GetOtherDie(die); if (isAstrologer) otherDie = lastDie; if ((otherDie.GetSide() > 1) && (die.GetSide() < 6)) // we can still subtract value from otherDie { die.AddTempPips(1); otherDie.AddTempPips(-1); } else if ((die.GetSide() > 1) && (otherDie.GetSide() < 6))// if we have some value in this die, we can add to the other { die.AddTempPips(-1); otherDie.AddTempPips(1); } else// can't do either, both dice are 1. Make an error { GameState.Message("Cannot change values."); } } } } else// entertainer flipping nonsense { int setVal = 7-die.GetSide(); if (die.getTempPips() == 0) { die.SetTempPipsValue(setVal); } else { die.UndoTempPips(); } } } } } else { GameState.Message("Can't choose " + die.name + " for " + this.name); } myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice return bLegalDie; }
// delegate: when the player chooses a die, this will get called. // user clicked on a die. Which one is it? We have to keep track here for this ability. bool PickDie(PharoahDie die) { bool bLegalDie = false; bool bIsNewDie = false; if (!die.isDieType(onlyFor)) { myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("Cannot pick " + die.name + " because it's\nthe wrong type."); return(false); } if (isNewDie(die)) { bIsNewDie = true; } else { bLegalDie = true; // we picked a die that we already have picked } if (adjustedDice.Count < actualNumDice) // can still pick new dice { if (bIsNewDie) { die.ClearTempPips(); adjustedDice.Add(die); // add the new die to the list of dice we are modifying bLegalDie = true; } } // if we are a legal die, then we can add pips to it (or undo the addpips) if (bLegalDie) { if (die != curDie) { lastDie = curDie; } curDie = die; if (isExactlyNumPips) // we add exactly this number of pips. { if (die.getTempPips() == 0) // we haven't messed with this die yet { if (die.GetSide() + nPips > 6) // failure case. we can't add this many pips! { adjustedDice.Remove(die); myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice GameState.Message("ERROR: Can't add exactly " + nPips.ToString() + " to " + die.name); return(false); } else { die.AddTempPips(nPips); } } else// we've messed with this die already { die.UndoTempPips(); } } else// we can add up to the number of pips specified in nPips to any die { if (die.getTempPips() + 1 > nPips) { die.UndoTempPips(); } else { if (!setToAnyFace && (die.GetSide() + 1 > 6)) // failure case. we can't add this many pips! { die.UndoTempPips(); } if (!isEntertainer) { if (!isSoothsayer) { // do the wrap around. if (die.GetSide() + 1 > 6) { // set the temppips such that it equals 1. die.SetTempPipsValue(1); } else { die.AddTempPips(1); } } else// Soothsayer nonsense here { int exactlyNumDice = 2; if (isAstrologer) { exactlyNumDice = 3; } if (adjustedDice.Count != exactlyNumDice) { GameState.Message("Select exactly " + exactlyNumDice.ToString() + " dice."); } else { PharoahDie otherDie = GetOtherDie(die); if (isAstrologer) { otherDie = lastDie; } if ((otherDie.GetSide() > 1) && (die.GetSide() < 6)) // we can still subtract value from otherDie { die.AddTempPips(1); otherDie.AddTempPips(-1); } else if ((die.GetSide() > 1) && (otherDie.GetSide() < 6))// if we have some value in this die, we can add to the other { die.AddTempPips(-1); otherDie.AddTempPips(1); } else// can't do either, both dice are 1. Make an error { GameState.Message("Cannot change values."); } } } } else// entertainer flipping nonsense { int setVal = 7 - die.GetSide(); if (die.getTempPips() == 0) { die.SetTempPipsValue(setVal); } else { die.UndoTempPips(); } } } } } else { GameState.Message("Can't choose " + die.name + " for " + this.name); } myPlayer.AskToChooseDie(this.PickDie, this.GetType().ToString()); // ask the player to choose a die or dice return(bLegalDie); }
public void DestroyDie(PharoahDie die) { die.ReadyToRoll(); diceList.Remove(die); Destroy(die.gameObject); }
bool SetState(ScarabUIState newState) { bool bSuccess = false; switch (newState) { default: case ScarabUIState.ready: selectedDie = null; bSuccess = true; SetNumScarabsUI(); break; // try to use the scarab case ScarabUIState.scarab_activated: // set aside the scarab for use if (GameState.GetCurrentGameState().currentPlayer.UseScarab(type)) { if (SetState(ScarabUIState.waiting_die_select)) { bSuccess = true; newState = ScarabUIState.waiting_die_select; } } break; case ScarabUIState.waiting_die_select: //GameState.GetCurrentGameState().currentPlayer.AskToChooseDie(this.type.ToString()); //GameState.Message(this.name + " please select a die for scarab action"); bSuccess = true; break; } if (bSuccess) { scuiState = newState; } return bSuccess; }
public void SortDiceList() { PharoahDie.SortList(diceList); }
public PlayerTurnStateTriggers onStateTrigger = PlayerTurnStateTriggers.AllTrigger; // on this state, trigger this ability /* * // Use this for initialization * void Start () { * * } * * // Update is called once per frame * void Update () { * * } */ public void SetMyDie(PharoahDie die) { myDie = die; }
public void DestroyDie(PharoahDie die) { die.ReadyToRoll(); diceList.Remove(die); Destroy (die.gameObject); }
bool OnCancel(PharoahDie d) { bool bSuccess = false; this.isUsedThisTurn = false; this.isUsedThisRoll = false; GameState.Message("Cancel"); foreach(PharoahDie die in adjustedDice) { die.UndoTempPips(); bSuccess = true; } myPlayer.UndoState(); // go back to previous state UIState.EnableCancelButton(false); UIState.EnableDoneButton(false); return bSuccess; }
/* // Use this for initialization void Start () { } // Update is called once per frame void Update () { } */ public void SetMyDie(PharoahDie die) { myDie = die; }