// Use this for initialization void Start() { gameManager = GameObject.Find("EventManager"); //Find the gameobject used to manage events sectors = GameObject.FindGameObjectsWithTag("Sector"); //Find all gameobjects of sectors inputFieldObject = GameObject.Find("UnitsTextbox"); //Find the gameobject of the input field inputFieldText = inputFieldObject.GetComponentInChildren <UnityEngine.UI.Text> (); //Find the text compontnt of the input field goButton = GameObject.Find("GoButton"); //Find the gameobject of the submit button backButton = GameObject.Find("BackButton"); //Find the gameobject of the submit button mode = 1; //Set the mode to 1...where the attacking sector is picked (where units are moved from) inputFieldObject.SetActive(false); //Disable (and hide) the input field goButton.SetActive(false); //submit button backButton.SetActive(false); //and undo button gameInstructions.text = "Pick a sector to attack with..."; //Set the game instructions to tell user next action they should take chanceCards = GameObject.Find("CardUI").GetComponent <ChanceCards>(); assignUnits = this.gameObject.GetComponentInChildren <AssignUnits>(); settingsButton = GameObject.Find("SettingsButton").GetComponent <Button>(); helpButton = GameObject.Find("HelpButton").GetComponent <Button>(); chanceCardButton = GameObject.Find("CardButton").GetComponent <Button>(); minigame = GameObject.Find("Minigame"); minigame.SetActive(false); minigameStatus = this.gameObject.GetComponent <MinigameStatus>(); }
public static int GetChanceCard( Player player ) { do { _chanceCard = (ChanceCards) random.Next(1, _numChanceCards + 1); } while ( GetOutOfJailFreeCard.ChanceOwner != null & _chanceCard == ChanceCards.GetOutOfJailCard ); return (int)_chanceCard; }
private void GenerateRandomChanceCards() { List <ICard> chanceCards = new List <ICard>(16); chanceCards.Add(new TransactionalCard(banker, CHANCE_BANK_PAYS_50)); chanceCards.Add(new TransactionalCard(banker, CHANCE_PAY_EACH_PLAYER_50)); chanceCards.Add(new TransactionalCard(banker, CHANCE_PAY_TAX_15)); chanceCards.Add(new TransactionalCard(banker, CHANCE_LOAN_MATURES_COLLECT_150)); chanceCards.Add(new TransactionalCard(banker, CHANCE_REPAIRS_25PER_HOUSE_100PER_HOTEL)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_TO_GO)); chanceCards.Add(new LocationalCard(board, CHANCE_GO_TO_JAIL)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_READING_PAY_TWICE_AMOUNT)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_READING_PAY_TWICE_AMOUNT)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_TO_ILLINOIS)); chanceCards.Add(new LocationalCard(board, CHANCE_GO_BACK_3)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_TO_BOARD_WALK)); chanceCards.Add(new LocationalCard(board, CHANCE_GET_OUT_OF_JAIL)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_TO_NEAREST_UTILITY)); chanceCards.Add(new LocationalCard(board, CHANCE_ADVANCE_TO_ST_CHARLES)); chanceCards.Add(new LocationalCard(board, CHANCE_TAKE_RIDE_READING)); chanceCards = chanceCards.OrderBy(p => Guid.NewGuid()).ToList(); foreach (var c in chanceCards) { ChanceCards.Enqueue(c); } }
public static void SaveGame() { // Serializes the game state and writes it to a file string saveName = Application.persistentDataPath + "/" + GetNextSaveGameName(); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(saveName); SaveGame saveGame = new SaveGame(); saveGame.IsDemo = Data.IsDemo; saveGame.RealPlayers = Data.RealPlayers; saveGame.Sections = MakeSerialSections(GameObject.Find("EventManager").GetComponent <AssignUnits>().sectors); saveGame.CurrentTurn = GameObject.Find("EventManager").GetComponent <Game>().GetTurn(); ChanceCards cardObj = GameObject.Find("CardUI").GetComponent <ChanceCards>(); saveGame.ChanceCards = new int[3]; saveGame.ChanceCards[0] = cardObj.GetPlayerOneChance(); saveGame.ChanceCards[1] = cardObj.GetPlayerTwoChance(); saveGame.ChanceCards[2] = cardObj.GetPlayerThreeChance(); bf.Serialize(file, saveGame); file.Close(); Debug.Log("Saved file: " + saveName); }
public ICard DrawChanceCard() { var drawnCard = ChanceCards.Dequeue(); ChanceCards.Enqueue(drawnCard); return(drawnCard); }
//Creates a shuffler object and shuffles the list of Chance Cards. //The shuffle list is than stored in a stack for use when drawing the cards. public static void LoadCards() { shuffler = new Shuffler <ChanceCards>(ChanceCards.LoadChanceFromFile()); List <ChanceCards> cardsToStack = shuffler.GetNewShuffle(); foreach (ChanceCards card in cardsToStack) { chanceCards.Push(card); } }
//Method that is used to determine what the player action should be. //Method depends heavliy on what space is sent over. public void Action(Space space, GameBoard board, List <Player> players) { if (space is PropertySpace) { PropertySpace temp = (PropertySpace)space; PropertySpaceAction(temp); } else if (space is ChanceSpace) { //Player draws a chance card and the card effect is applied ChanceCards card = ChanceSpace.DrawCard(); MessageBox.Show(card.GetChanceDescription()); card.CardEffect(this, board, card, players); //Activates the property space action when player is moved to a property space. if (card.GetChanceEffect() == 2 || card.GetChanceEffect() == 3 || card.GetChanceEffect() == 13 || card.GetChanceEffect() == 12) { PropertySpace temp = (PropertySpace)GetSpaceOccupied(); PropertySpaceAction(temp); } } else if (space is CommunityChestSpace) { //Player draws a community chest card and the card effect is applied CommunuityChestCards card = CommunityChestSpace.DrawCard(); MessageBox.Show(card.GetCommunuityChestName()); card.CardEffect(this, card); } else if (space is UtilitySpace) { UtilityAction(space); } else if (space is FreeParkingSpace) { //Gives player who landed on free parking the total money given to free parking. FreeParkingSpace fpSpace = (FreeParkingSpace)space; MessageBox.Show($"Player {playerId} has collect {fpSpace.GetAccumulatedMoney().ToString("C2")}"); fpSpace.CollectMoney(this); } else if (space is RailroadSpace) { RailroadSpace temp = (RailroadSpace)space; RailroadSpaceAction(temp); } else if (space is GoToJailSpace) { //Sends player to jail space and jails them MessageBox.Show("Sent to Jail"); MovePlayerToSpace(board.GetJailSpace()); JailSpace jailSpace = (JailSpace)spaceOccupied; if (!isJailed) { jailSpace.AddPlayerToJail(this); } else { jailSpace.EscapeJail(this); } } else if (space is JailSpace || IsPlayerJailed() == true) { //If player is jailed, it allows them to attempt escape or if they //have a get out of jail free card, they can instantly escape. JailSpace jailSpace = (JailSpace)board.GetJailSpace(); if (HasGetOutOfJailFreeCard()) { jailSpace.RemovePlayerFromJail(this); } if (isJailed) { jailSpace.EscapeJail(this); } } CheckForLost(); }
void Start() { game = this.gameObject.GetComponent <Game>(); chanceCards = GameObject.Find("CardUI").GetComponent <ChanceCards>(); }