public Game1() { var graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; ScreenRectangle = new Rectangle(0, 0, 1280, 720); graphics.PreferredBackBufferWidth = ScreenRectangle.Width; graphics.PreferredBackBufferHeight = ScreenRectangle.Height; var gameStateManager = new GameStateManager(this); Components.Add(gameStateManager); this.IsMouseVisible = true; TitleIntroState = new TitleIntroState(this); StartMenuState = new MainMenuState(this); GamePlayState = new GamePlayState(this); ConversationState = new ConversationState(this); BattleState = new BattleState(this); BattleOverState = new BattleOverState(this); DamageState = new DamageState(this); LevelUpState = new LevelUpState(this); // begin game at TitleIntroState gameStateManager.ChangeState((TitleIntroState)TitleIntroState, PlayerIndex.One); CharacterManager = CharacterManager.Instance; }
public void skin(string skin_name) { if (String.IsNullOrEmpty(skin_name)) { printer("Usage: skin [skin name]"); } else { State state = ServiceManager.StateManager.CurrentState; if (state is GamePlayState) { GamePlayState gameState = (GamePlayState)state; PlayerTank localPlayer = gameState.LocalPlayer; try { Texture2D skin = ServiceManager.Resources.Load <Texture2D>( String.Format(@"models\tanks\skins\{0}", skin_name)); localPlayer.ApplySkin(skin); printer("New skin applied."); } catch (Exception) { printer("That skin does not exist!"); } } else { printer("You can't do that outside of a game."); } } }
public PlayerRotateEvent(GamePlayState _game, int id, double angle, VTankObject.Direction direction) : base(_game) { this.id = id; this.angle = angle; this.direction = direction; }
private void InitializeLevel() { gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); //Set Player to spawn point Vector2 position = new Vector2(spawn.position.x, spawn.position.y + 0.5f); player.transform.position = position; //Load unimog prefab GameObject obj = Instantiate(Resources.Load("Prefabs/Vehicles/" + gameManager.GetUnimogPrefabPath(), typeof(GameObject)), player.transform) as GameObject; CarAttributes carAttribs = obj.GetComponent <CarAttributes>(); //spawn boxes on cargoCheck Transform cargoCheck = GameObject.Find("cargoCheck").GetComponent <Transform>(); for (int i = 0; i < 2; i++) // amount of boxes from JSON { GameObject box = Instantiate(Resources.Load("Prefabs/Objects/Box"), new Vector3(cargoCheck.position.x, cargoCheck.position.y + 0.5f, cargoCheck.position.z), Quaternion.identity) as GameObject; } //Load level informations currentLevel = new Level(gameManager.GetSceneId()); gamePlayState = new GamePlayState(this, currentLevel, carAttribs, victoryScreen, gameOverScreen); SetCountdownState(); }
public SupplyNetwork(Army army, LevelV0 level, GamePlayState gamePlayState) { this.gamePlayState = gamePlayState; NetworkNodes = new SortedDictionary<int, SupplyNode>(); NetworkConnections = new Dictionary<int, List<int>>(); // add nodes for all the entry points in our level. // caution is needed when changing, since we are calling a static method // that does a lot of writing to various locations. If this constructor // is ever called twice in one succession, disaster might arise. level.AddBuildingEntryPointsToNetwork(this); int startingPointId = level.Buildings.Single(building => building.isStartingPosition == true).nodeIdsForEntryPoints.First(); this.NetworkNodes[startingPointId].SquadsInNode = army.Squads; // instead of adding new functions to 'initialize' the units in there initial starting building, // we'll reuse the Event Queue, adding 'unit arrived' events. army.Squads.ForEach( squad => { UnityEngine.Object unitResource = Resources.Load(@"Unit"); GameObject unitTest = UnityEngine.Object.Instantiate( unitResource, Vector3.zero, Quaternion.identity) as GameObject; Unit unit = unitTest.GetComponent(typeof(Unit)) as Unit; unit.InitializeOnGameSetup(startingPointId, squad.id,this.gamePlayState); unit.gameObject.SetActive(false); GameObject.Destroy(unitTest); GameObject.Destroy(unit); }); }
public LazerBeamManager(GamePlayState _game) : base() { game = _game; currentTime = 0; Technique = RendererAssetPool.UniversalEffect.Techniques.LazerBeam; }
public void StartPlayGame() { Debug.Log(string.Format("Ground size: {0}, {1}", ground.transform.localScale.x, ground.transform.localScale.z)); this.playState = GamePlayState.Prepare; ///Reset playing state this.timeStartPlay = Time.time; this.blockStack.Clear(); this.blockStopped.Clear(); this.topBlock = null; this.blockCounter = 0; this.score = 0; ///Setup first block Block genesisBlock = blockPool.GetPlayingBlock(); genesisBlock.SetActive(); Vector3 pos = this.fallingPoint; pos.y = this.fallingPoint.y + genesisBlock.transform.localScale.y / 2; genesisBlock.transform.position = pos; AddNewBlockToStack(genesisBlock); }
public void Initialize(ContentManager content) { gameplayState = GamePlayState.Idle; book = new Book(content); background = content.Load <Texture2D>("Environment\\bakgrund_color"); bord = content.Load <Texture2D>("Environment\\bord"); font = content.Load <BitmapFont>("Font\\OneFont"); smallFont = content.Load <BitmapFont>("Font\\FreePixel"); happinessIcon = content.Load <Texture2D>("happinessIcon"); moneyIcon = content.Load <Texture2D>("moneyIcon"); gameOverTex = content.Load <Texture2D>("GameOver"); gameWinTex = content.Load <Texture2D>("GameOver"); noteBoard = new NoteBoard(content); screen = new Screen(content); stuff = new List <Interactable>(); phone = new Phone(content); //Who dis? stuff.Add(phone); stuff.Add(book); activeCases = new List <Call>(); computer = new Computer(content); stuff.Add(computer); hand = new Hand(content, stuff); resource = new Resources(); }
public FlagDroppedEvent(GamePlayState _game, int droppedId, VTankObject.Point where, GameSession.Alliance flagColor) : base(_game) { this.droppedId = droppedId; this.where = where; this.flagColor = flagColor; }
public PlayerMoveEvent(GamePlayState _game, int id, VTankObject.Point point, VTankObject.Direction direction) : base(_game) { this.id = id; this.direction = direction; this.point = point; }
public PlayerDamagedByEnvironmentEvent(GamePlayState _game, int playerId, int environId, int damageTaken, bool killingBlow) : base(_game) { this.playerId = playerId; this.environId = environId; this.damageTaken = damageTaken; this.killingBlow = killingBlow; }
} // void public void EndTurn() //--------------------------------------------------------- // automatically changes to endTurn state // and resets values //--------------------------------------------------------- { m_gamePlayState = GamePlayState.ENDTURN; } //end public void ENDTURN()
public AddUtilityEvent(GamePlayState _game, int _utilityID, VTankObject.Utility _utility, Vector3 _position) : base(_game) { utilityID = _utilityID; utility = _utility; position = _position; }
public SpawnEnvironmentEffectEvent(GamePlayState _game, int id, int typeId, VTankObject.Point location, int ownerId) : base(_game) { this.id = id; this.typeId = typeId; this.location = location; this.ownerId = ownerId; }
public BaseCapturedEvent(int eventId, GameSession.Alliance newBaseColor, int capturerId, GameSession.Alliance oldBaseColor, GamePlayState _game) : base(_game) { this.baseEventId = eventId; this.newBaseColor = newBaseColor; this.capturerId = capturerId; this.oldBaseColor = oldBaseColor; }
public ApplyUtilityEvent(GamePlayState _game, int _utilityID, VTankObject.Utility _utility, int _playerID) : base(_game) { utilityID = _utilityID; utility = _utility; playerID = _playerID; }
public override void DoAction() { Game.Flags.PositionFlag(flagColor, new Vector3((float)where.x, (float)where.y, 0)); GamePlayState state = (GamePlayState)ServiceManager.StateManager.CurrentState; string message = state.Players[droppedId].Name + " dropped the " + Enum.GetName(typeof(GameSession.Alliance), flagColor).ToLower() + " flag."; Game.Chat.AddMessage(message, Color.Chartreuse); }
public void NextState() //--------------------------------------------------------- // changes to the next state // -MIGHT NOT BE NEEDED IF GUI CONTROLS // WHICH STATES COME NEXT //---------------------------------------------------------- { m_gamePlayState = m_gamePlayState + 1; } //end public void NextStage()
public DamageBaseByEnvironmentEvent(GamePlayState _game, GameSession.Alliance baseColor, int baseId, int envId, int damage, bool isDestroyed) : base(_game) { this.baseColor = baseColor; this.baseId = baseId; this.environmentEffectId = envId; this.damage = damage; this.isDestroyed = isDestroyed; }
public override void DoAction() { GamePlayState state = (GamePlayState)ServiceManager.StateManager.CurrentState; Game.Flags.FlagPickedUp(flagColor, ServiceManager.Scene.Access3D(state.Players[pickedUpById].RenderID)); string message = state.Players[pickedUpById].Name + " has the " + Enum.GetName(typeof(GameSession.Alliance), flagColor).ToLower() + " flag."; Game.Chat.AddMessage(message, Color.Chartreuse); }
public GlitchRunnerGame() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = 768; graphics.PreferredBackBufferWidth = 1024; graphics.ApplyChanges(); GlitchRunnerGame.ContentManager = Content; Content.RootDirectory = "Content"; CurrentGameState = GamePlayState.Loading; }
public override void DoAction() { Game.Flags.ResetFlag(flagColor); GamePlayState state = (GamePlayState)ServiceManager.StateManager.CurrentState; string message = state.Players[returnedById].Name + " returned the " + Enum.GetName(typeof(GameSession.Alliance), flagColor).ToLower() + " flag."; Game.Chat.AddMessage(message, Color.Chartreuse); //TODO do something with returnedById }
public override void DoAction() { Game.Flags.DespawnAll(); GamePlayState state = (GamePlayState)ServiceManager.StateManager.CurrentState; string message = state.Players[capturedById].Name + " captured the " + Enum.GetName(typeof(GameSession.Alliance), flagColor).ToLower() + " flag."; state.Scores.AddObjCapture(state.Players[capturedById].Name, 1); Game.Chat.AddMessage(message, Color.Chartreuse); }
public PlayerDamagedEvent(GamePlayState _game, int victimId, int projectileId, int ownerId, int damageTaken, bool killingBlow) : base(_game) { this.victimId = victimId; this.projectileId = projectileId; this.ownerId = ownerId; this.damageTaken = damageTaken; this.killingBlow = killingBlow; }
public CreateProjectileEvent(GamePlayState _game, int projectileTypeId, VTankObject.Point point, int ownerId, int projectileId) : base(_game) { this.projectileTypeId = projectileTypeId; this.point = point; this.ownerId = ownerId; this.projectileId = projectileId; }
public void SetMap(Map map, GamePlayState _state) { currentGameMode = _state.CurrentGameMode; flags = _state.Flags; utilities = _state.Utilities; bases = _state.Bases; try { GraphicsDevice device = Renderer.GraphicOptions.graphics.GraphicsDevice; PresentationParameters pp = device.PresentationParameters; renderTarget = new RenderTarget2D(device, (int)map.Width * miniMapScaleFactor + 2 * miniMapBorderBuffer, (int)map.Height * miniMapScaleFactor + 2 * miniMapBorderBuffer, 1, SurfaceFormat.Color, pp.MultiSampleType, pp.MultiSampleQuality, RenderTargetUsage.PreserveContents); DepthStencilBuffer previousDepth = device.DepthStencilBuffer; device.DepthStencilBuffer = null; device.SetRenderTarget(0, renderTarget); device.Clear(Color.Black); ServiceManager.Game.Batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); Texture2D miniMapDrawer = ServiceManager.Resources.GetTexture2D("textures\\misc\\MiniMap\\wallandbackground"); for (uint x = 0; x < map.Width; x++) { for (uint y = 0; y < map.Height; y++) { Tile tmpTile = map.GetTile(x, y); if (!tmpTile.IsPassable) { ServiceManager.Game.Batch.Draw(miniMapDrawer, new Vector2(x * miniMapScaleFactor + miniMapBorderBuffer, y * miniMapScaleFactor + miniMapBorderBuffer), new Rectangle(0, 0, miniMapScaleFactor, miniMapScaleFactor), Color.White); } } } ServiceManager.Game.Batch.End(); device.DepthStencilBuffer = previousDepth; device.SetRenderTarget(0, null); texture = renderTarget.GetTexture(); renderTarget = new RenderTarget2D(device, 235, 235, 1, SurfaceFormat.Color, pp.MultiSampleType, pp.MultiSampleQuality, RenderTargetUsage.PreserveContents); } catch (Exception ex) { Console.Error.WriteLine(ex); } }
/// <summary> /// /// </summary> /// <param name="id">QuizId</param> /// <returns></returns> public ActionResult StartGame(Guid id) { // User identifizieren var user = GetCurrentUser(); // Spiel anlegen var gameService = new GamePlayService(); var game = gameService.CreateSingleUserGame(user.Id, id); var gameState = new GamePlayState(); gameState.Game = game; gameState.Player = game.Players.First(); gameState.Quiz = game.Levels.First().Quiz; // Den Fragenkatalog sortiert aufbauen foreach (var quizSection in gameState.Quiz.Sections.OrderBy(x => x.Order)) { foreach (var quizQuestion in quizSection.Questions.OrderBy(x => x.Order)) { gameState.QuestionsLeft.Add(quizQuestion.Question); } } // TODO: Hier jetzt die Option des Quiz einbauen // Fragen mischen gameState.QuestionsLeft.Shuffle(); // Statistik erstellen gameState.QuestionTotalCount = gameState.QuestionsLeft.Count; // In einer Session sichern // oder in DB? Session["GameState"] = gameState; var question = gameState.QuestionsLeft.FirstOrDefault(); var model = new QuestionViewModel(); model.Question = question; model.Answers = question.Answers.ToList(); model.Answers.Shuffle(); model.Total = gameState.QuestionTotalCount; model.Index = gameState.QuestionTotalCount - gameState.QuestionsLeft.Count + 1; gameState.CurrentQuestion = model; //return View("PlayGameSPA", model); return(View("PlayGame", model)); }
} //end public void NextStage() public void DoAction(string p_MapEventType, string p_TypeOfResource) //-------------------------------------------------------- // can be called from other objects to start an action // //-------------------------------------------------------- { //set state machine to DOACTION m_gamePlayState = GamePlayState.DOACTION; //set map event typs and call the init m_MapEventString = p_MapEventType; m_MapEventResultString = p_TypeOfResource; } // void
public ActionResult StartGame(Guid id) { // User identifizieren // den gibt es nicht => dummy user! var user = GetAnoynmousUser(); // Spiel anlegen var gameService = new GamePlayService(); var game = gameService.CreateSingleUserGame(user.Id, id); var gameState = new GamePlayState(); gameState.Game = game; gameState.Player = game.Players.First(); gameState.Quiz = game.Levels.First().Quiz; foreach (var quizSection in gameState.Quiz.Sections) { foreach (var quizQuestion in quizSection.Questions) { gameState.QuestionsLeft.Add(quizQuestion.Question); } } // Fragen mischen gameState.QuestionsLeft.Shuffle(); // Statistik erstellen gameState.QuestionTotalCount = gameState.QuestionsLeft.Count; // In einer Session sichern // oder in DB? Session["GameState"] = gameState; var question = gameState.QuestionsLeft.FirstOrDefault(); var model = new QuestionViewModel(); model.Question = question; model.Answers = question.Answers.ToList(); model.Answers.Shuffle(); model.Total = gameState.QuestionTotalCount; model.Index = gameState.QuestionTotalCount - gameState.QuestionsLeft.Count + 1; gameState.CurrentQuestion = model; //return View("PlayGameSPA", model); return(View("PlayGame", model)); }
/// <summary> /// Refresh the list of players. /// </summary> public void refresh() { State state = ServiceManager.StateManager.CurrentState; if (state is GamePlayState) { GamePlayState gameState = (GamePlayState)state; gameState.Players.RefreshPlayerList(); } else { printer("You are not in a game!"); } }
/// <summary> /// Insert a chat message into the chat window. /// </summary> /// <param name="message">Message to insert.</param> public void say(string message) { State state = ServiceManager.StateManager.CurrentState; if (!(state is GamePlayState)) { printer("Cannot chat outside of the game."); } else { GamePlayState game = (GamePlayState)state; ServiceManager.Theater.SendChatMessage(message); } }
internal void OnGameOver(bool isWon) { gamePlayState = GamePlayState.GameOver; if (isWon) { onGamWon?.Invoke(); StartCoroutine(LevelManager.GetIntance.PlayWinParticleEffects()); } else { CharacterController.GetInstance.InstantiateRagDolls(); onGameLose?.Invoke(); } }
// Controls the flow of the game through various states void StateMachine() { // Switch over the GamePlayState's switch (gamePlayState) { // The player begins their turn. case GamePlayState.BeginTurn: { // Get the player's values and update them GetPlayerValues(); // Clear the map event text mapEventResult = ""; //Verify the action button is enabled actionButton.interactable = true; actionButtonActive = true; // Switch the state to the RollDie state gamePlayState = GamePlayState.RollDice; break; } // end Case BeginTurn // The player rolls the dice case GamePlayState.RollDice: { // Set the turn text guiTurnText.text = "Player " + guiPlayerName.text + ", roll dice."; // Set the action button's text to roll dice actionButtonText.text = "Roll Dice"; break; } // end Case RollDice // Calculate the allowed disance to travel case GamePlayState.CalcDistance: { // Set the turn text guiTurnText.text = "Calculating distance..."; // Get the dice's value and calculate the allowed movement guiDiceDistVal = guiDiceDistVal * (guiMaxWeight - guiCurrentWeight) / guiMaxWeight; // Change the state to the DisplayDistance state gamePlayState = GamePlayState.DisplayDistance; break; } // end Case CalcDistance // Display the distance allowed to travel case GamePlayState.DisplayDistance: { // Set the player's Player script Player player = GameMaster.Instance.GetPlayerScript(guiPlayerTurn); // Set the state text guiTurnText.text = "Displaying distance..."; // Display the movement arrows guiMovement.InitThis(player, guiDiceDistVal); // Make the action button clickable again actionButton.interactable = true; actionButtonActive = true; // Change the state to the SelectPathToTake state gamePlayState = GamePlayState.SelectPathToTake; break; } // end Case DisplayDistance // The player selects their path to take on the map case GamePlayState.SelectPathToTake: { // Set the state text guiTurnText.text = "Movement Left: " + guiDiceDistVal + "\nPress 'End Turn' when finished."; // Set the action button's text to end turn actionButtonText.text = "End Turn"; // Update the value of allowed travel distance upon the player pressing a move button guiDiceDistVal = guiMovement.RemainingTravelDistance; break; } // end Case SelectPathToTake // Deal with a MapEvent action case GamePlayState.DoAction: { // Set the state text guiTurnText.text = "Resolving map event..."; // Get and resolve the map event mapEventResult = guiMapEvent.DetermineEvent(guiPlayerTurn, die); // If it's an ally, allow player to accept if(mapEventResult.Contains("Ally")) { // Enable the panel acceptPanel.SetActive(true); // Update the text Text eventText = GameObject.Find("EventText").GetComponent<Text>(); eventText.text = "Porter ally found.\nWould you like to add them?"; } //end if else { // Return the result for now guiTurnText.text = mapEventResult; // Enable Action Button actionButton.interactable = true; actionButtonActive = true; } //end if // Change the state to the EndTurn state gamePlayState = GamePlayState.EndTurn; break; } // end Case DoAction // The player has ended their turn case GamePlayState.EndTurn: { // Get the player's values GetPlayerValues(); // Set Action Button text to prompt next player actionButtonText.text = "Next Player"; // Clear the board of any highlight tiles Highlight.ClearHighlight(); break; } // end Case EndTurn // Its the end of the game case GamePlayState.EndGame: { // Set the state text guiTurnText.text = "Universe Ending"; // Check whether to run the end stuff if (canRunEndStuff) { // Only run this once canRunEndStuff = false; // Force the inventory closed inventory.gameObject.SetActive(false); // Loop through and sell the players's resources and their ally's resources // Note: Ally resources are not setup to pickup or sell right now for (int playerSellIndex = 0; playerSellIndex < guiNumOfPlayers; playerSellIndex++) { // Get the player's merchant entity Merchant playerMerchant = (Merchant)GameMaster.Instance.GetPlayerScript(playerSellIndex).Entity; // We need to access the character script at the given index and sell the resources playerMerchant.SellResources(); } // end for // Save the players GameMaster.Instance.SavePlayers(); // Finally, tell the GameMaster to load the end scene GameMaster.Instance.LoadLevel("EndScene"); } break; } // end Case EndGame // Shouldn't reach here, this is reached if the state isn't listed above default: { Debug.LogWarning("Hit the default case in GamePlayStateMachine!"); break; } // end Case default } // end switch gamePlayState }
private void HandleRemoveState() { foreach (NumberBlock block in blocksToRemove) { List<NumberBlock> col = this.gameBoard[block.column]; /* * Check the locks on the block above */ int index = col.IndexOf(block); if (index > 0) { col[index - 1].checkLock(); } /* * Check the locks on the block bellow */ if (index < col.Count()-1) { col[index + 1].checkLock(); } /* * Check the locks on the block to the left */ int heightCheck = col.Count() - index; if (block.column > 0) { List<NumberBlock> leftColumn = this.gameBoard[block.column - 1]; if (leftColumn.Count() >= heightCheck) { leftColumn[leftColumn.Count()-heightCheck].checkLock(); } } /* * Check the locks on the block to the right */ if (block.column < NUM_COLUMNS-1) { List<NumberBlock> rightColumn = this.gameBoard[block.column + 1]; if (rightColumn.Count() >= heightCheck) { rightColumn[rightColumn.Count() - heightCheck].checkLock(); } } col.RemoveAt(index); for (int i = 0; i < col.Count(); i++) { NumberBlock curBlock = col[i]; if (curBlock.beingRemoved == false && col[i].Drop()) this.dropBlockCount++; } } multiplier++; gamePlayState = GamePlayState.dropping; }
private void DropNextBlock() { if (nextBlock != null) { if (gameBoard[nextBlockColumn].Count() != NUM_ROWS) { gameBoard[nextBlockColumn].Insert(0, nextBlock); nextBlock.column = nextBlockColumn; this.numMovesLeft--; nextBlock.Drop(); nextBlock = null; this.dropBlockCount++; this.gamePlayState = GamePlayState.dropping; } } }
public void PushNewRow() { int pushNonBrickProbability = this.settings.pushNonBrickProbability; int i = 0; foreach (List<NumberBlock> column in this.gameBoard) { int count = column.Count(); if (count == NUM_ROWS) { GameOver(); } NumberBlock newBlock = null; if (rand.Next(100) <= pushNonBrickProbability) { newBlock = randomBlock(false); } else { newBlock = new NumberBlock(this); newBlock.blockNumber = 0; newBlock.lockCount = 2; } newBlock.column = i; Components.Add(newBlock); column.Insert(column.Count(), newBlock); int j = 0; int startHeight = (NUM_ROWS - count - 1) * 50 + BOARD_OFFSET_Y; foreach (NumberBlock block in column) { block.position = new Vector2((BOARD_OFFSET_X + block.column * 50), startHeight + (j+1) * 50); block.destination_y = startHeight + j * 50; block.Float(); this.dropBlockCount++; j++; } i++; } this.Score(new Vector2(BOARD_OFFSET_X, BOARD_OFFSET_SLOT_Y + 5), this.currLevel * 1000); if (gamePlayState != GamePlayState.gameOver) { if (this.currLevel == 31 && achievementHub.hasAchieved(AchievementHub.ACH_SURVIVOR_MAN) == false) { AwardAchievement(AchievementHub.ACH_SURVIVOR_MAN); } gamePlayState = GamePlayState.dropping; } }
// Changes the state to EndGame which ends the game. public void EndGame() { gamePlayState = GamePlayState.EndGame; }
private void generateNewGame() { this.comboString = new StringBuilder(); this.saveHighScore = false; score = 0; currLevel = 1; numMovesPerLevel = GetNextNumBlocks(); numMovesLeft = numMovesPerLevel; ClearGameBoard(); int addElementProbability = this.settings.addElementProbability; for (int i = 0; i < NUM_COLUMNS; i++) { List<NumberBlock> column = gameBoard[i]; for (int j = 0; j < NUM_ROWS; j++) { if (rand.Next(100) <= addElementProbability) { NumberBlock newBlock = randomBlock(true); newBlock.column = i; newBlock.position = new Vector2((i * 48 + BOARD_OFFSET_X + i * 2), (BOARD_OFFSET_Y + j*48 + j*2)); column.Add(newBlock); Components.Add(newBlock); } } //Drop after adding elements, as the indexes can only be known after all blocks are dropped foreach (NumberBlock block in column) { if (block.Drop()) this.dropBlockCount++; } } CreateNextBlock(true); //Create premonition blocks nextBlockQueue = new List<NumberBlock>(); int numBlocksForseen = this.settings.numBlocksForseen; for (int i = 0; i < numBlocksForseen; i++) { nextBlockQueue.Add(randomBlock(false)); } gamePlayState = GamePlayState.dropping; }
private void HandlePlayAppState(GameTime gameTime, KeyboardState keyState, MouseState mouseState) { // Allows the game to exit if (keyState.IsKeyDown(Keys.Escape) || GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { appState = AppState.MainMenu; return; } if (gamePlayState == GamePlayState.idle) { HandleIdleState(keyState, mouseState); } else if (gamePlayState == GamePlayState.checking) { HandleCheckingState(); } else if (gamePlayState == GamePlayState.removingAnim) { if (removingTimeout == 0) { removingTimeout = 0; } removingTimeout += gameTime.ElapsedGameTime.Milliseconds; if (removingTimeout > GetRemoveAnimationTime()) { removingTimeout = 0; gamePlayState = GamePlayState.removing; } } else if (gamePlayState == GamePlayState.removing) { HandleRemoveState(); } else if (gamePlayState == GamePlayState.dropping) { HandleDroppingState(gameTime); } else if (gamePlayState == GamePlayState.gameOver) { HandleGameOver(keyState, mouseState); } }
internal void GenerateOrderGUI() { foreach (tk2dSprite item in arr_orderingBaseItems) { item.spriteId = item.GetSpriteIdByName(BASE_ORDER_ITEM_NORMAL); item.gameObject.SetActiveRecursively (false); } for (int i = 0; i < currentCustomer.customerOrderRequire.Count; i++) { arr_orderingBaseItems[i].gameObject.SetActiveRecursively(true); arr_orderingItems[i].spriteId = arr_orderingItems[i].GetSpriteIdByName(currentCustomer.customerOrderRequire[i].food.name); arr_orderingItems[i].gameObject.name = currentCustomer.customerOrderRequire[i].food.name; } StartCoroutine(this.ShowOrderingGUI()); currentGamePlayState = GamePlayState.Ordering; }
private void HandleDroppingState(GameTime gameTime) { foreach (NumberBlock rblock in blocksToRemove) { Components.Remove(rblock); } blocksToRemove = new List<NumberBlock>(); /* * Catch conditions where blocks drop at the top of a stack * or manage to lock in dropping state */ if (this.dropBlockCount <= 0) { this.dropBlockCount = 0; } else { if (droppingTimeout == 0) { droppingTimeout = 0; } droppingTimeout += gameTime.ElapsedGameTime.Milliseconds; if (droppingTimeout > 750) this.dropBlockCount = 0; } if (this.dropBlockCount == 0) gamePlayState = GamePlayState.checking; }
private void HandleCheckingState() { droppingTimeout = 0; dropBlockCount = 0; int[] maxMatchIndex = new int[NUM_COLUMNS]; //check for matches int i = 0; foreach (List<NumberBlock> column in this.gameBoard) { maxMatchIndex[i] = -1; int j = 0; foreach (NumberBlock block in column) { bool matchFound = false; if (block.lockCount > 0) { //do nothing } else if (block.blockNumber == column.Count()) { matchFound = true; } else { //TODO count contiguous row count int heightCheck = column.Count() - j; int leftCount = 0; for (int l = i - 1; l >= 0; l--) { if (this.gameBoard[l].Count() >= heightCheck) leftCount++; else break; } int rightCount = 0; for (int l = i + 1; l < NUM_COLUMNS; l++) { if (this.gameBoard[l].Count() >= heightCheck) rightCount++; else break; } if (leftCount + rightCount + 1 == block.blockNumber) { matchFound = true; } } if(matchFound) { maxMatchIndex[i] = j; this.blocksToRemove.Add(block); block.beingRemoved = true; this.Score(block.position); this.comboString.Append(block.blockNumber); } j++; } i++; } if (maxMatchIndex.Sum() > -1 * NUM_COLUMNS) { gamePlayState = GamePlayState.removingAnim; } else { this.comboString.Append("|"); if (numMovesLeft == 0) { currLevel++; numMovesPerLevel = GetNextNumBlocks(); numMovesLeft = numMovesPerLevel; PushNewRow(); } else { CheckComboString(); gamePlayState = GamePlayState.idle; } } }
private void UpdateGameCollsions(GameTime gameTime) { GlitchObstacle[] Obs = Obstacles.ToArray(); foreach (GlitchObstacle ob in Obs) { if (ob.BoundingBox.X + ob.ObstacleTex.Width <= 0) //offscreen? Obstacles.Remove(ob); // Remove old Obstacles if (IntersectPixels(Character.Character.BoundingBox, Character.Character.FindSheetWithFrame(Character.Character.CurrentFrameID).PerPixelCollisionInfo[Character.Character.CurrentFrameID], ob.BoundingBox, ob.PerPixelCollisionData)) {// We hit the obstacle CurrentGameState = GamePlayState.Died; Character.Character.SetAnimation("hit1"); Character.CurrentState = PlayerMoveState.Dead; } ob.Update(gameTime, CurrentScrollSpeed); } }
// Controls the flow of the game through various states void StateMachine() { // Switch over the GamePlayState's switch (gamePlayState) { // The player begins their turn. case GamePlayState.BeginTurn: { // Get the player's values and update them GetPlayerValues(); // Clear the map event text mapEventResult = ""; // Check if the player isn't an AI if (isPlayerAI) { // Disable the buttons for AI as they don't use them actionButton.interactable = false; actionButtonActive = false; GameObject.Find("CurrentPlayer/PauseButton").GetComponent<Button>().interactable = false; GameObject.Find("CurrentPlayer/InvAlly/Inventory").GetComponent<Button>().interactable = false; GameObject.Find("CurrentPlayer/InvAlly/Ally").GetComponent<Button>().interactable = false; } // end if else { // Otherwise, Verify the action button is enabled actionButton.interactable = true; actionButtonActive = true; // Enable the pause, inventory, and ally window buttons GameObject.Find("CurrentPlayer/PauseButton").GetComponent<Button>().interactable = true; GameObject.Find("CurrentPlayer/InvAlly/Inventory").GetComponent<Button>().interactable = true; GameObject.Find("CurrentPlayer/InvAlly/Ally").GetComponent<Button>().interactable = true; } // end else // The movement class is not initialised for the current player isMovementInitialized = false; // Switch the state to the RollDie state gamePlayState = GamePlayState.RollDice; break; } // end Case BeginTurn // The player rolls the dice case GamePlayState.RollDice: { // Set the turn text guiTurnText.text = "Player " + guiPlayerName.text + ", roll dice."; // Set the action button's text to roll dice actionButtonText.text = "Roll Dice"; // Check for space or enter key press if(Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)) { ActionButton(); } //end if break; } // end Case RollDice // Calculate the allowed disance to travel case GamePlayState.CalcDistance: { // Set the turn text guiTurnText.text = "Calculating distance..."; // Get the dice's value and calculate the allowed movement guiDiceDistVal = 1 + guiDiceDistVal * (guiMaxWeight - guiCurrentWeight) / guiMaxWeight; // Change the state to the DisplayDistance state gamePlayState = GamePlayState.DisplayDistance; break; } // end Case CalcDistance // Display the distance allowed to travel case GamePlayState.DisplayDistance: { // Set the player's Player script Player player = GameMaster.Instance.GetPlayerScript(guiPlayerTurn); // Set the state text guiTurnText.text = "Displaying distance..."; // Display the movement arrows guiMovement.InitThis(player, guiDiceDistVal, isPlayerAI); // The movement class is now initialised for the current player isMovementInitialized = true; // Make sure the player isn't an AI if (!isPlayerAI) { // Make the action button clickable again actionButton.interactable = true; actionButtonActive = true; } // end if // Change the state to the SelectPathToTake state gamePlayState = GamePlayState.SelectPathToTake; break; } // end Case DisplayDistance // The player selects their path to take on the map case GamePlayState.SelectPathToTake: { // Set the state text guiTurnText.text = "Movement Left: " + guiDiceDistVal + "\nPress 'End Turn' when finished."; // Set the action button's text to end turn actionButtonText.text = "End Turn"; // Update the value of allowed travel distance upon the player pressing a move button guiDiceDistVal = guiMovement.RemainingTravelDistance; // Check if arrow key is pressed, and move in that direction if(Input.GetKey(KeyCode.LeftArrow) && movementCooldown <= Time.time && guiDiceDistVal > 0) { guiMovement.MoveLeft(); movementCooldown = Time.time + 0.3f; } //end if if(Input.GetKey(KeyCode.RightArrow) && movementCooldown <= Time.time && guiDiceDistVal > 0) { guiMovement.MoveRight(); movementCooldown = Time.time + 0.3f; } //end if if(Input.GetKey(KeyCode.UpArrow) && movementCooldown <= Time.time && guiDiceDistVal > 0) { guiMovement.MoveUp(); movementCooldown = Time.time + 0.3f; } //end if if(Input.GetKey(KeyCode.DownArrow) && movementCooldown <= Time.time && guiDiceDistVal > 0) { guiMovement.MoveDown(); movementCooldown = Time.time + 0.3f; } //end if // End turn if space or enter is pressed if(Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)) { ActionButton(); } //end if break; } // end Case SelectPathToTake // Deal with a MapEvent action case GamePlayState.DoAction: { // Set the state text guiTurnText.text = "Resolving map event..."; // Get and resolve the map event mapEventResult = guiMapEvent.DetermineEvent(guiPlayerTurn, die); // If it's an ally, allow player to accept if(mapEventResult.Contains("Ally")) { // Enable the panel acceptPanel.SetActive(true); // Check if the player is an AI if (isPlayerAI) { // Disable the buttons on the accept panel acceptPanel.transform.GetChild(2).gameObject.GetComponent<Button>().interactable = false; acceptPanel.transform.GetChild(3).gameObject.GetComponent<Button>().interactable = false; } // end if else { // Otherwise re-enable the buttons for the player acceptPanel.transform.GetChild(2).gameObject.GetComponent<Button>().interactable = true; acceptPanel.transform.GetChild(3).gameObject.GetComponent<Button>().interactable = true; } // end else // Update the text Text eventText = GameObject.Find("EventText").GetComponent<Text>(); eventText.text = "Porter ally found.\nWould you like to add them?"; } //end if // If it's a market, send them to the market scene else if (mapEventResult.Contains("Market")) { // set the turn text guiTurnText.text = "You found a market!"; // Check if the player is an AI if (isPlayerAI) { // Tell the AI it's at the market GetCurrentPlayer().GetComponent<Player>().IsAtMarket = true; } // end if // Save the players GameMaster.Instance.SavePlayers(); // Save the resources GameMaster.Instance.SaveResources(); // Finally, tell the GameMaster to load the end scene GameMaster.Instance.LoadLevel("Market"); } // end else if // If it's a village, end the game for now else if (mapEventResult.Contains("Village")) { // set the turn text guiTurnText.text = "You found a village!"; // Check if the player is an AI if (isPlayerAI) { // Tell the AI it's the end of the game GetCurrentPlayer().GetComponent<Player>().IsEnd = true; } // end if // Change the state to the EndGame state gamePlayState = GamePlayState.EndGame; break; } // end else if else { // Return the result for now guiTurnText.text = mapEventResult; // Make sure the player isn't an AI if (!isPlayerAI) { // Make the action button clickable again actionButton.interactable = true; actionButtonActive = true; } // end if } //end if // Change the state to the EndTurn state gamePlayState = GamePlayState.EndTurn; break; } // end Case DoAction // The player has ended their turn case GamePlayState.EndTurn: { // Get the player's values GetPlayerValues(); // Set Action Button text to prompt next player actionButtonText.text = "Next Player"; // Clear the board of any highlight tiles Highlight.ClearHighlight(); // Accept or decline ally with key presses if(Input.GetKeyDown(KeyCode.Alpha1) && mapEventResult.Contains("Ally")) { Yes (); } //end if if(Input.GetKeyDown(KeyCode.Alpha2) && mapEventResult.Contains("Ally")) { No (); } //end if // End turn if space or enter is pressed if((Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)) && actionButton.IsInteractable()) { ActionButton(); } //end if break; } // end Case EndTurn // Its the end of the game case GamePlayState.EndGame: { // Set the state text guiTurnText.text = "Universe Ending"; // Check whether to run the end stuff if (canRunEndStuff) { // Only run this once canRunEndStuff = false; // Force the inventory closed inventory.gameObject.SetActive(false); // Force the allies window and ally inventory closed allyTable.gameObject.SetActive(false); allyInventory.gameObject.SetActive(false); // Loop through and sell the players's resources and their ally's resources // Note: Ally resources are not setup to pickup or sell right now for (int playerSellIndex = 0; playerSellIndex < guiNumOfPlayers; playerSellIndex++) { // Get the player's merchant entity Merchant playerMerchant = (Merchant)GameMaster.Instance.GetPlayerScript(playerSellIndex).Entity; Porter allyPorter; // The ally's porter entity // Check if the player has an ally if (playerMerchant.NumAllies > 0) { // Check if the ally type is porter if (playerMerchant.GetAlly(0).GetComponent<PorterMB>() != null) { // THe ally type is porter to get its entity allyPorter = (Porter)playerMerchant.GetAlly(0).GetComponent<PorterMB>().Entity; // Sell the ally's resources allyPorter.SellResources(); // Transfer the currency to the player's merchant allyPorter.TransferCurrency<Merchant>(playerMerchant, allyPorter.Currency); } // end if playerMerchant.GetAlly(0).GetComponent<PorterMB>() != null } // end if // We need to access the character script at the given index and sell the resources playerMerchant.SellResources(); } // end for // Save the players GameMaster.Instance.SavePlayers(); // Finally, tell the GameMaster to load the end scene GameMaster.Instance.LoadLevel("EndScene"); } break; } // end Case EndGame // Shouldn't reach here, this is reached if the state isn't listed above default: { Debug.LogWarning("Hit the default case in GamePlayStateMachine!"); break; } // end Case default } // end switch gamePlayState }
// Runs when the object if first instantiated, because this object will occur once through the game, // these values are the beginning of game values // Note: Values should be updated at the EndTurn State void Start() { // Get the reference to the tile manager tileManager = GameObject.Find("TileManager").GetComponent<TileManager>(); // Generate the map tileManager.GenerateMap(); // Get HUD elements CurrentPlayer = GameObject.Find ("Canvas/CurrentPlayer"); AllPlayers = GameObject.Find("Canvas/AllPlayers"); BKG = GameObject.Find ("Canvas/Background"); guiPlayerName = GameObject.Find("CurrentPlayer/PlayerNamePanel/PlayerName").GetComponent<Text>(); guiTurnText = GameObject.Find("CurrentPlayer/TurnPhasePanel/TurnPhase").GetComponent<Text>(); guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>(); guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>(); actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>(); actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>(); acceptPanel = GameObject.Find("Accept"); pauseMenu = GameObject.Find ("PauseMenu"); instructionsSet = GameObject.Find ("Instructions"); audioSet = GameObject.Find ("Options"); imageParent = GameObject.Find("AllPlayers/ImageOrganizer"); textParent = GameObject.Find("AllPlayers/TextOrganizer"); inventory = GameObject.Find("PlayerInventory").GetComponent<PlayerInventory>(); allyInventory = GameObject.Find("AllyInventory").GetComponent<AllyInventory>(); recycleInventory = GameObject.Find("RecycleBin").GetComponent<RecycleBin>(); allyTable = GameObject.Find("Allies").GetComponent<AllyTable>(); GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false); HUDToggle = true; actionButtonActive = true; isPaused = false; instructionsProgress = 1; // Disable the other panels by default acceptPanel.SetActive(false); pauseMenu.SetActive (false); audioSet.SetActive (false); inventory.gameObject.SetActive(false); allyInventory.gameObject.SetActive(false); recycleInventory.gameObject.SetActive(false); allyTable.gameObject.SetActive(false); // Running the end stuff defaults to true canRunEndStuff = true; // The movement class is not initialised isMovementInitialized = false; // The ally window are closed by default isAlliesOpen = false; // Get the number of players guiNumOfPlayers = GameMaster.Instance.NumPlayers; // Set the turn guiPlayerTurn = GameMaster.Instance.Turn; // Set starting values guiDiceDistVal = 0; movementCooldown = 0.0f; // The player is not an AI by default isPlayerAI = false; // Create a die die = new Die(); // Get movement and map event components guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> (); guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> (); // There isn't a map event in the beginning mapEventResultString = string.Empty; // Initialise other things after Start() runs canInitAfterStart = true; // Set the state to the BeginTurn state gamePlayState = GamePlayState.BeginTurn; }
// Runs when the object if first instantiated, because this object will occur once through the game, // these values are the beginning of game values // Note: Values should be updated at the EndTurn State void Start() { //TODO: Damien: Replace Tile stuff later // Clear the tile dictionary TileDictionary.Clean(); // Set the dimensions and generate/add the tiles TileManager.SetDimensions(64, 20, 16); TileManager.GenerateAndAddTiles(); // Get HUD elements guiPlayerName = GameObject.Find("CurrentPlayer/PlayerName").GetComponent<Text>(); guiTurnText = GameObject.Find("CurrentPlayer/TurnPhase").GetComponent<Text>(); guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>(); guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>(); actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>(); actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>(); acceptPanel = GameObject.Find("Accept"); pauseMenu = GameObject.Find ("PauseMenu"); imageParent = GameObject.Find("AllPlayers/ImageOrganizer"); textParent = GameObject.Find("AllPlayers/TextOrganizer"); inventory = GameObject.Find("Inventory").GetComponent<Inventory>(); allyTable = GameObject.Find("Allies").GetComponent<AllyTable>(); GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false); actionButtonActive = true; isPaused = false; // Disable the accept panel by default acceptPanel.SetActive(false); // Disable the pause menu by default pauseMenu.SetActive (false); // Disable the inventory by default inventory.gameObject.SetActive(false); // Disable the ally window by default allyTable.gameObject.SetActive(false); // Running the end stuff defaults to true canRunEndStuff = true; // The inventory is closed by default isInventoryOpen = false; // The ally window is closed by default isAlliesOpen = false; // Get the number of players guiNumOfPlayers = GameMaster.Instance.NumPlayers; // Set the turn guiPlayerTurn = GameMaster.Instance.Turn; // Set starting values guiDiceDistVal = 0; // Create a die die = new Die(); // Reseed the random number generator die.Reseed(Environment.TickCount); // Get movement and map event components guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> (); guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> (); // There isn't a map event in the beginning mapEventResultString = string.Empty; // Initialise other things after Start() runs canInitAfterStart = true; // Set the state to the BeginTurn state gamePlayState = GamePlayState.BeginTurn; }
private IEnumerator CreateCustomer() { yield return new WaitForSeconds(1f); if(currentCustomer == null) { audioEffect.PlayOnecSound(audioEffect.dingdong_clip); this.manageGoodsComplete_event += Handle_manageGoodsComplete_event; GameObject customer = Instantiate(Resources.Load("Customers/CustomerBeh_obj", typeof(GameObject))) as GameObject; currentCustomer = customer.GetComponent<CustomerBeh>(); currentCustomer.customerSprite_Obj = Instantiate(Resources.Load("Customers/Customer_AnimatedSprite", typeof(GameObject))) as GameObject; currentCustomer.customerSprite_Obj.transform.parent = customerMenu_group_Obj.transform; currentCustomer.customerSprite_Obj.transform.localPosition = new Vector3(-6f, -77f, -.1f); currentCustomer.customerOrderingIcon_Obj = Instantiate(Resources.Load("Customers/CustomerOrdering_icon", typeof(GameObject))) as GameObject; currentCustomer.customerOrderingIcon_Obj.transform.parent = customerMenu_group_Obj.transform; currentCustomer.customerOrderingIcon_Obj.transform.localPosition = new Vector3(35f, -60f, -2f); currentCustomer.customerOrderingIcon_Obj.name = "OrderingIcon"; currentCustomer.customerOrderingIcon_Obj.active = false; } else { Debug.LogError("Current Cusstomer does not correct destroying..." + " :: " + currentCustomer); } currentGamePlayState = GamePlayState.GreetingCustomer; this.SetActiveGreetingMessage(true); }
private IEnumerator ReceiveMoneyFromCustomer() { currentGamePlayState = GamePlayState.receiveMoney; if (cash_obj == null) { cash_obj = Instantiate(Resources.Load("Money/Cash", typeof(GameObject))) as GameObject; cash_obj.transform.position = new Vector3(0, 0, -5); cash_sprite = cash_obj.GetComponent<tk2dSprite>(); if(currentCustomer.amount < 20) { cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_20"); currentCustomer.payMoney = 20; } else if(currentCustomer.amount < 50) { cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_50"); currentCustomer.payMoney = 50; } else if(currentCustomer.amount <= 100) { cash_sprite.spriteId = cash_sprite.GetSpriteIdByName("cash_100"); currentCustomer.payMoney = 100; } } yield return new WaitForSeconds(3); Destroy(cash_obj.gameObject); calculator_group_instance.SetActiveRecursively(true); this.DeActiveCalculationPriceGUI(); this.ShowGiveTheChangeForm(); currentGamePlayState = GamePlayState.giveTheChange; if(MainMenu._HasNewGameEvent) { audioDescribe.PlayOnecSound(description_clips[6]); } }
// Button Functions // Action Button - Used to move the turn through its phases public void ActionButton() { if(gamePlayState == GamePlayState.RollDice) { // Roll the die guiDiceDistVal = die.Roll(2, 5); //Play dieRoll sound AudioManager.Instance.PlayDie(); // Set Action Button text while disabled actionButtonText.text = "Processing..."; //Disable button while distance is being calculated actionButton.interactable = false; actionButtonActive = false; // Change to the CalcDistance State gamePlayState = GamePlayState.CalcDistance; } //end if else if(gamePlayState == GamePlayState.SelectPathToTake) { // Set Action Button text while disabled actionButtonText.text = "Processing..."; //Disable buttons while turn is ending actionButton.interactable = false; actionButtonActive = false; guiMovement.DisableButtons(); // Change the state to the DoAction state gamePlayState = GamePlayState.DoAction; } //end else if else if(gamePlayState == GamePlayState.EndTurn) { // Close the inventory if it's open if (inventory.IsOpen) { inventory.IsOpen = false; inventory.gameObject.SetActive(false); } // end if // Close the ally's window if it's open if (isAlliesOpen) { isAlliesOpen = false; allyTable.gameObject.SetActive(false); } // end if // Close the ally's inventory if it's open if (allyInventory.IsOpen) { allyInventory.IsOpen = false; allyInventory.gameObject.SetActive(false); } // end if // Update the turn guiPlayerTurn = GameMaster.Instance.NextTurn(); // Change the interface element's colours ChangeColor(); // Change the state to the BeginTurn state gamePlayState = GamePlayState.BeginTurn; } //end else if }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { base.Update(gameTime); if (StaleState == null) StaleState = Keyboard.GetState(); if (CurrentGameState == GamePlayState.Starting) { if (Keyboard.GetState().IsKeyDown(Keys.Space) && !StaleState.IsKeyDown(Keys.Space)) { CurrentGameState = GamePlayState.Playing; CurrentScrollSpeed = StartingScrollSpeed; Character.Character.Location.Y = GraphicsDevice.Viewport.Height - 250; Character.Character.SetAnimation("walk1x"); Character.CurrentState = PlayerMoveState.Walking; Character.Direction = 0; Obstacles = new List<GlitchObstacle>(); Background.ScreenPos = Vector2.Zero; Score = 0; return; // We have done what ever we need this frame } } if (CurrentGameState == GamePlayState.Playing) { LastSpeedIncrease += gameTime.ElapsedGameTime.Milliseconds; if (LastSpeedIncrease > 1000) { CurrentScrollSpeed += 30; LastSpeedIncrease = 0; Score += 1; } Background.Update(gameTime, CurrentScrollSpeed); Character.Update(gameTime); // Update the Character ParticleManager.Update(gameTime); UpdateGameCollsions(gameTime); UpdateGameObjects(gameTime); return; } if (CurrentGameState == GamePlayState.Died) { if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !StaleState.IsKeyDown(Keys.Enter)) { Character.CurrentState = PlayerMoveState.Dead; CurrentGameState = GamePlayState.Starting; CurrentScrollSpeed = StartingScrollSpeed; } return; } StaleState = Keyboard.GetState(); }
private void TradingComplete() { currentGamePlayState = GamePlayState.TradeComplete; foreach(var good in foodTrayBeh.goodsOnTray_List) { Destroy(good.gameObject); } foodTrayBeh.goodsOnTray_List.Clear(); StartCoroutine(this.PackagingGoods()); if(MainMenu._HasNewGameEvent) { MainMenu._HasNewGameEvent = false; Town.IntroduceGameUI_Event += Town.Handle_IntroduceGameUI_Event; Destroy(shopTutor.greeting_textmesh); shopTutor.goaway_button_obj.active = true; shopTutor = null; darkShadowPlane.transform.position += Vector3.forward * 2f; audioDescribe.PlayOnecSound(description_clips[7]); } else { int r = UE.Random.Range(0, thanksCustomer_clips.Length); audioDescribe.PlayOnecSound(thanksCustomer_clips[r]); } }
public CommandEvent(GamePlayState.GameMode command) { this.Command = command; }
/// <summary> /// Handle_manages the goods complete_event. /// </summary> public void Handle_manageGoodsComplete_event(object sender, System.EventArgs eventArgs) { audioEffect.PlayOnecWithOutStop(audioEffect.correctBring_clip); //<@-- Wait for calculation price session complete. currentGamePlayState = GamePlayState.calculationPrice; char_animationManager.PlayGoodAnimation(); currentCustomer.customerOrderingIcon_Obj.active = false; StartCoroutine(this.ShowReceiptGUIForm()); }
private void GameOver() { gamePlayState = GamePlayState.gameOver; if (isHighScore(this.score)) { this.saveHighScore = true; } }
public override void OnInput(string nameInput) { base.OnInput(nameInput); if(MainMenu._HasNewGameEvent) { if(nameInput == "EN_001_textmesh") { StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[0])); // base.SetActivateTotorObject(false); shopTutor.currentTutorState = ShopTutor.TutorStatus.AcceptOrders; return; } } if (nameInput == "NoticeUpgradeButton") { if(Application.isLoadingLevel == false && _onDestroyScene == false) { _onDestroyScene = true; base.extendsStorageManager.SaveDataToPermanentMemory(); this.PreparingToCloseShop(); Mz_LoadingScreen.LoadSceneName = SceneNames.Sheepbank.ToString(); Application.LoadLevel(SceneNames.LoadingScene.ToString()); return; } else return; } //<!-- Close shop button. if(nameInput == close_button.name) { if(Application.isLoadingLevel == false && _onDestroyScene == false) { _onDestroyScene = true; base.extendsStorageManager.SaveDataToPermanentMemory(); this.PreparingToCloseShop(); return; } } if (calculator_group_instance.active) { if(currentGamePlayState == GamePlayState.calculationPrice) { if(nameInput == "ok_button") { this.CallCheckAnswerOfTotalPrice(); return; } } else if(currentGamePlayState == GamePlayState.giveTheChange) { if(nameInput == "ok_button") { this.CallCheckAnswerOfGiveTheChange(); return; } } calculatorBeh.GetInput(nameInput); } if(currentGamePlayState == GamePlayState.GreetingCustomer) { #region <@-- GamePlayState.GreetingCustomer. switch (nameInput) { case TH_001: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[0])); break; case TH_002: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[1])); break; case TH_003: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[2])); break; case TH_004: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[3])); break; case TH_005: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[4])); break; case TH_006: StartCoroutine(this.PlayGreetingAudioClip(th_greeting_clip[5])); break; case EN_001: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[0])); break; case EN_002: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[1])); break; case EN_003: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[2])); break; case EN_004: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[3])); break; case EN_005: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[4])); break; case EN_006: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[5])); break; case EN_007: StartCoroutine(this.PlayGreetingAudioClip(en_greeting_clip[6])); break; default: break; } #endregion } else if (currentGamePlayState == GamePlayState.Ordering) { #region <@-- GamePlayState.Ordering. if (nameInput == GoodDataStore.FoodMenuList.Octopus_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Octopus_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Tempura.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Tempura]); else if (nameInput == GoodDataStore.FoodMenuList.Prawn_brown_maki.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Prawn_brown_maki]); else if (nameInput == GoodDataStore.FoodMenuList.Miso_soup.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Miso_soup]); else if (nameInput == GoodDataStore.FoodMenuList.Kimji.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Kimji]); else if (nameInput == GoodDataStore.FoodMenuList.Roe_maki.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Roe_maki]); else if (nameInput == GoodDataStore.FoodMenuList.Yaki_soba.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Yaki_soba]); else if (nameInput == GoodDataStore.FoodMenuList.Pickling_cucumber_filled_maki.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Pickling_cucumber_filled_maki]); else if (nameInput == GoodDataStore.FoodMenuList.Sweetened_egg_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Sweetened_egg_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.GreenTea_icecream.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.GreenTea_icecream]); else if (nameInput == GoodDataStore.FoodMenuList.Iced_greenTea.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Iced_greenTea]); else if (nameInput == GoodDataStore.FoodMenuList.Spicy_shell_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Spicy_shell_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Hot_greenTea.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Hot_greenTea]); else if (nameInput == GoodDataStore.FoodMenuList.Crab_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Crab_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Prawn_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Prawn_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Zaru_soba.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Zaru_soba]); else if (nameInput == GoodDataStore.FoodMenuList.California_maki.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.California_maki]); else if (nameInput == GoodDataStore.FoodMenuList.Ramen.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Ramen]); else if (nameInput == GoodDataStore.FoodMenuList.Skipjack_tuna_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Skipjack_tuna_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Eel_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Eel_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Fatty_tuna_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Fatty_tuna_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Salmon_sushi.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Salmon_sushi]); else if (nameInput == GoodDataStore.FoodMenuList.Bean_ice_jam_on_crunching.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Bean_ice_jam_on_crunching]); else if (nameInput == GoodDataStore.FoodMenuList.Curry_with_rice.ToString()) audioDescribe.PlayOnecWithOutStop(audioDescriptionData.merchandiseNameDescribes[(int)GoodDataStore.FoodMenuList.Curry_with_rice]); else { switch (nameInput) { case "OK_button": StartCoroutine(this.CollapseOrderingGUI()); break; case "Goaway_button": currentCustomer.PlayRampage_animation(); StartCoroutine(this.ExpelCustomer()); break; case "OrderingIcon": StartCoroutine(this.ShowOrderingGUI()); break; default: break; } if(nameInput == SushiProduction.Crab_sushi_face || nameInput == SushiProduction.Eel_sushi_face || nameInput == SushiProduction.Fatty_tuna_sushi_face || nameInput == SushiProduction.Octopus_sushi_face || nameInput == SushiProduction.Prawn_sushi_face || nameInput == SushiProduction.Salmon_sushi_face || nameInput == SushiProduction.Skipjack_tuna_sushi_face || nameInput == SushiProduction.Spicy_shell_sushi_face || nameInput == SushiProduction.Sweetened_egg_sushi_face) { sushiProduction.OnInput(ref nameInput); return; } else if(nameInput == SushiProduction.SushiIngredientTray || nameInput == SushiProduction.ClosePopup || nameInput == SushiProduction.BucketOfRice || nameInput == SushiProduction.Alga || nameInput == SushiProduction.Pickles || nameInput == SushiProduction.FlyingFishRoe || nameInput == SushiProduction.Roe) { sushiProduction.OnInput(ref nameInput); return; } else if (nameInput == beltMachine_obj.name) { beltMachineBeh.HandleOnInput(ref nameInput); return; } else if (nameInput == manualManager.name) { this.manualManager.OnActiveCookbook(); currentGamePlayState = GamePlayState.DisplayCookbook; return; } else if(nameInput == billingMachine.name) { if (MainMenu._HasNewGameEvent) { base.SetActivateTotorObject(false); } audioEffect.PlayOnecSound(audioEffect.calc_clip); billingMachine.animation.Play(billingMachine_animState.name); StartCoroutine_Auto(CheckingUnityAnimationComplete.ICheckAnimationComplete(billingMachine.animation, billingMachine_animState.name, null, string.Empty)); EventHandler handle = null; handle = (object sender, EventArgs e) => { this.CheckingGoodsObjInTray(string.Empty); CheckingUnityAnimationComplete.TargetAnimationComplete_event -= handle; }; CheckingUnityAnimationComplete.TargetAnimationComplete_event += handle; } else if (nameInput == BeltMachineBeh.CloseButtonName) { beltMachineBeh.DeActiveBeltMachinePopup(); return; } else if (nameInput == BeltMachineBeh.Ramen_UI || nameInput == BeltMachineBeh.CurryWithRice_UI || nameInput == BeltMachineBeh.Tempura_UI || nameInput == BeltMachineBeh.YakiSoba_UI || nameInput == BeltMachineBeh.ZaruSoba_UI) { beltMachineBeh.HandleOnInput(ref nameInput); return; } } #endregion } else if (currentGamePlayState == GamePlayState.PreparingFood) { #region <!-- GamePlayState.PreparingFood. /* if (nameInput == BeltMachineBeh.CloseButtonName) { beltMachine.DeActiveBeltMachinePopup(); return; } else if (nameInput == BeltMachineBeh.Ramen_UI || nameInput == BeltMachineBeh.CurryWithRice_UI || nameInput == BeltMachineBeh.Tempura_UI || nameInput == BeltMachineBeh.YakiSoba_UI || nameInput == BeltMachineBeh.ZaruSoba_UI) { beltMachine.HandleOnInput(ref nameInput); return; } else if (nameInput == BeltMachineBeh.BeltMachineObjectName) { beltMachine.HandleOnInput(ref nameInput); return; } */ #endregion } else if (currentGamePlayState == GamePlayState.DisplayCookbook) { manualManager.Handle_onInput(ref nameInput); } }