public Navigator(GameState game, Civilian civilian) { this.game = game; this.civilian = civilian; this.initializePosition(); }
public void TimeUpGame() { gameState = GameState.TIMEUP; //timer.StopTimer(); fillterController.StopBlinking(); fillterController.Change2Black(); }
private void GameStateSwitch() { if (currentGameState != GameState.Win) { if (Input.GetKeyDown(KeyCode.Escape)) { if (currentGameState == GameState.Paused) { currentGameState = GameState.Playing; } else { currentGameState = GameState.Paused; } } } switch (currentGameState) { case GameState.Paused: Time.timeScale = 0; PauseGame(); break; case GameState.Playing: Time.timeScale = 1; UnPauseGame(); break; case GameState.Win: Time.timeScale = 1; WinGame(); break; } }
// Use this for initialization void Start() { //Set high to be out of pickable range location = 0; // minZombies = 4; maxZombies = 5; zombieSpeed = 3; zombieSpawn = 5; timeToSpawn = 5; // Init Lists // zombies = new List<GameObject>(); currentZombies = new List<GameObject>(); zombieWave = new List<int>(); //Add Zombies to List// zombies.Add(zombie1); zombies.Add(zombie2); zombies.Add(zombie3); zombies.Add(zombie4); // spawnLocations = new List<Vector3>(); //Store locations in list for (int x = -150; x < 180; x += 30) { spawnLocations.Add(new Vector3(x, 0, 1500)); } //LINK Scripts// bc = gameObject.GetComponent<BuildingControl>(); gs = GameObject.Find ("GameController").GetComponent<GameState>(); }
public void PauseGame() { gameState = GameState.PAUSE; timer.StopTimer(); fillterController.StopBlinking(); fillterController.Change2Black(); }
public bool Parse(GameState game, GameState.Entity entity) { this.card_id = entity.CardId; this.used = (entity.GetTagOrDefault(GameTag.EXHAUSTED, 0) != 0); return true; }
protected override void Draw(GameTime gameTime) { if(_state == GameState.Menu) { if (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed) _state = GameState.Menu; GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); play.Draw(spriteBatch); options.Draw(spriteBatch); exit.Draw(spriteBatch); spriteBatch.Draw(Textures.Bullet, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.Gray); spriteBatch.End(); } if (_state == GameState.Game) { GraphicsDevice.Clear(Color.WhiteSmoke); spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend); handler.Draw(gameTime, spriteBatch); spriteBatch.End(); } if (_state == GameState.Pause) { GraphicsDevice.Clear(Color.White); spriteBatch.Begin(SpriteSortMode.Deferred,BlendState.AlphaBlend); handler.Draw(gameTime, spriteBatch); spriteBatch.Draw(_pauseScreen, Vector2.Zero, Color.White); play.Draw(spriteBatch); exit.Draw(spriteBatch); spriteBatch.Draw(Textures.Bullet, new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Color.Gray); spriteBatch.End(); } base.Draw(gameTime); }
//Do the appropriate actions when changing the gamestate public void SwitchTo(GameState newState) { currentState = newState; AudioSource audio = GetComponent<AudioSource>(); switch (currentState) { default: case GameState.NotStarted: DisplayText(GameNotStartedText); break; case GameState.Playing: audio.PlayOneShot(StartSound); DisplayText(""); break; case GameState.Completed: audio.PlayOneShot(StartSound); DisplayText(GameCompletedText); StartCoroutine(RestartAfter(StartSound.length)); break; case GameState.Failed: audio.PlayOneShot(FailedSound); DisplayText(GameFailedText); StartCoroutine(RestartAfter(FailedSound.length)); break; } }
public void Defeat() { defeatUI.SetActive(true); replayBtn.SetActive(true); catAnimator.runtimeAnimatorController = happyAnima; state = GameState.GAME_OVER; }
public void Restart() { var tgi = TerrainGrid.Instance; foreach (var totems in tgi.Totems.Values) { foreach (var t in totems) Destroy(t.gameObject); totems.Clear(); } for (int i = 0; i < tgi.sizeX; i++) for (int j = 0; j < tgi.sizeZ; j++) tgi.Cells[i, j].Occupant = null; foreach (var s in tgi.Summoners.Values) { s.Restart(); var x = (int)Math.Floor(s.transform.position.x); var z = (int)Math.Floor(s.transform.position.z); tgi.Cells[x, z].Occupant = s.gameObject; } Incantation.Instance.Restart(); if (NetworkBootstrap.Instance.LocalMode) TerrainGrid.Instance.Summoners[TerrainGrid.ClientPlayerId].MarkReady(); State = GameState.ReadyToPlay; }
/// <summary> /// This will be run on each turns. It must return a direction fot the bot to follow /// </summary> /// <param name="state">The game state</param> /// <returns></returns> public string Move(GameState state) { myFinder = new Pathfinder(state); string direction; switch (random.Next(0, 5)) { case 0: direction = Direction.East; break; case 1: direction = Direction.West; break; case 2: direction = Direction.North; break; case 3: direction = Direction.South; break; default: direction = Direction.Stay; break; } direction = myFinder.GetNextMoveToGetToDestination(2, 2); Console.WriteLine("Completed turn {0}, going {1}", state.currentTurn, direction); Console.WriteLine(DateTime.Now - delta); return direction; }
public static void BossUpdate(ContentManager Content, GameTime gameTime, Boss bossDragon, List<EnemyAttack> bossFireBalls, GameState CurrentGameState, List<PlayerAttack> ninjaAttacks, Health healthRectangle) { healthRectangle.Widht = (int)bossDragon.Life; BossSummon(Content, gameTime, bossDragon, bossFireBall, bossFireBalls); BossAnimation(gameTime, bossDragon); BossCollision(bossDragon, CurrentGameState, ninjaAttacks); }
// Use this for initialization void Start() { gameState = GameState.InGame; //SAFE CODE : Check si il existe un autre gamemanager si c'est le cas, je m'autodetruit if (gameController != null && gameController != this) { Destroy(this.gameObject); return; } // pour qu'on puisse y accéder dans les methodes statiques gameController = this; // L'objet n'est pas détruit quand on change de scène //DontDestroyOnLoad(this.gameObject); SettingTarget(); BrowseLists(); //chargement de menu //Application.LoadLevel("Menu"); //Application.LoadLevel("arena"); foreach (GameObject go in Killers) { LoadObjectives(go); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { IsMouseVisible = true; gameState = GameState.TitleScreen; camera = new Camera(graphics.GraphicsDevice.Viewport); base.Initialize(); }
public void Generate(PlayerInfo owner, GameState state, ActionCandidates candidates) { if (!owner.IsBallOwner || owner.CanBeTackled.Any()) { return; } foreach (var direction in WalkingDirections) { var target = owner.Position + direction; // Don't try to leave the field. if(Game.Field.IsOnField(target)) { var dribble = PlayerPath.Create(owner, target, MaximumDribbleLength, Distance.Tackle); var catchUp = dribble.GetCatchUps(state.Current.OtherPlayers).FirstOrDefault(); // don't start (too) short walks. if(catchUp == null || catchUp.Turn >= MinimumDribbleLength) { if (catchUp != null) { target = dribble[catchUp.Turn - 2]; } var action = Actions.Move(owner, target); var length = catchUp == null ? dribble.Count : catchUp.Turn - 1; candidates.Add(Evaluator.GetPositionImprovement(owner, target, length), action); } } } }
public void reset() { meFisrt = !meFisrt; whoseTurn = meFisrt ? GameState.MY_TURN : GameState.YOUR_TURN; server.newTurn(whoseTurn); }
public bool Parse(GameState game, GameState.Entity enchant) { this.card_id = enchant.CardId; this.creator_entity_id = enchant.GetTagOrDefault(GameTag.CREATOR, -1); return true; }
public void OnStateChange(GameState oldState, GameState newState) { if (newState == GameState.PostGame) { StopListening(); } }
//处理每回合的发牌 IEnumerator DealCard() { gameState = GameState.CardGenerating; if (currentHeroName == "hero1") { GameObject cardGo = cardGenerator.RandomGenerCard();//调用方法生成一个随机卡牌//等2秒 yield return new WaitForSeconds(2f); //把这个卡片放在卡牌管理器内 myCard.AddCard(cardGo); cardGo = cardGenerator.RandomGenerCard();//调用方法生成一个随机卡牌//等2秒 yield return new WaitForSeconds(2f); //把这个卡片放在卡牌管理器内 enemyCard.AddCard(cardGo); } else { GameObject cardGo = cardGenerator.RandomGenerCard();//调用方法生成一个随机卡牌//等2秒 yield return new WaitForSeconds(2f); //把这个卡片放在卡牌管理器内 enemyCard.AddCard(cardGo); } gameState = GameState.PlayCard; timer = 0; }
public void SwitchState(GameState newGameState, string[] args) { switch (newGameState) { case GameState.Login_Menu: loginMenu = new LoginMenu(this, netClient); loginMenu.LoadContent(this.Content); break; case GameState.Create_Menu: createMenu = new CreateAccountMenu(this, netClient, args); createMenu.LoadContent(this.Content); break; case GameState.Select_Menu: selectMenu = new CharacterSelectionMenu(this, netClient); selectMenu.LoadContent(this.Content); break; case GameState.CreateCharacter_Menu: characterCreateMenu = new CharacterCreateMenu(this, netClient, args); characterCreateMenu.LoadContent(this.Content); break; } gameState = newGameState; }
/// <summary> /// コンストラクタ /// </summary> public MainWindow() { this.InitializeComponent(); this.SetEventHandler(); this.kinectSensorChooser = null; this.pixelBuffer = null; this.skeletonBuffer = null; this.mainImageBuffer = null; this.speechRecognitionEngine = null; this.gameState = GameState.None; this.sound = new Sound(); this.barArray = new Bar[2]; for (int i = 0; i < this.barArray.Length; i++) this.barArray[i] = new Bar(this, i + 1); this.ball = new Ball(this); this.stage = new Stage(); this.score = new Score(this.sound); this.life = 0; this.blockArray = null; }
private void AdvanceState(Side side) { if (StillPlaying()) { if (HasEnteredDeuce()) { this.state = GameState.Deuce; if (GetPointState(side) == PointState.Advantage) { this.state = DetermineWinner(side); return; } if((sideOnePoints == PointState.Deuce && sideTwoPoints == PointState.Deuce) || (sideOnePoints == PointState.Forty && sideTwoPoints == PointState.Forty)) { SetPointState(side, PointState.Advantage); return; } sideOnePoints = PointState.Deuce; sideTwoPoints = PointState.Deuce; return; } RollPoints(side); if (((int)GetPointState(side)) > 4) { this.state = DetermineWinner(side); } } }
// Use this for initialization void Start () { GameState freedom = new GameState(){RoomPrompt=StringsStore.Freedom_Prompt}; GameState lock_1 = new GameState(){RoomPrompt=StringsStore.Lock_1_Prompt}; GameState cell_mirror = new GameState(){RoomPrompt=StringsStore.Cell_Mirror_Prompt}; GameState sheets_1 = new GameState(){RoomPrompt=StringsStore.Sheets_1_Prompt}; GameState mirror_0 = new GameState(){RoomPrompt=StringsStore.Mirror_0_Prompt}; GameState lock_0 = new GameState(){RoomPrompt=StringsStore.Lock_0_Prompt}; GameState sheets_0 = new GameState(){RoomPrompt=StringsStore.Sheets_0_Prompt}; GameState cell_0 = new GameState(){RoomPrompt=StringsStore.PrisonCell_0_Prompt}; cell_0.UserChoices.Add(new UserChoice (KeyCode.S, StringsStore.GoToSheets, sheets_0)); cell_0.UserChoices.Add(new UserChoice (KeyCode.M, StringsStore.GoToMirror, mirror_0)); cell_0.UserChoices.Add(new UserChoice (KeyCode.D, StringsStore.GoToDoor, lock_0)); sheets_0.UserChoices.Add(new UserChoice (KeyCode.R, StringsStore.ReturnToCenterCell, cell_0)); lock_0.UserChoices.Add(new UserChoice(KeyCode.R, StringsStore.ReturnToCenterCell, cell_0)); mirror_0.UserChoices.Add(new UserChoice (KeyCode.T, StringsStore.SmashMirror, cell_mirror)); mirror_0.UserChoices.Add(new UserChoice(KeyCode.R, StringsStore.ReturnToCenterCell, cell_0)); sheets_1.UserChoices.Add(new UserChoice (KeyCode.R, StringsStore.ReturnToBrokenMirror, cell_mirror)); cell_mirror.UserChoices.Add(new UserChoice (KeyCode.S, StringsStore.GoToSheets, sheets_1)); cell_mirror.UserChoices.Add(new UserChoice(KeyCode.D, StringsStore.GoToDoor, lock_1)); lock_1.UserChoices.Add(new UserChoice (KeyCode.O, StringsStore.OpenDoorWithShard, freedom)); lock_1.UserChoices.Add(new UserChoice(KeyCode.R, StringsStore.ReturnToBrokenMirror, cell_mirror)); freedom.UserChoices.Add(new UserChoice(KeyCode.P, StringsStore.PlayAgain, cell_0)); MoveToState(cell_0); }
public bool CaptureAll(GameState state, Coords start, Coords end, Direction dir, out IEnumerable<Coords> capture) { if (pattern.Count() == 0) { capture = new List<Coords>(); return true; } if (end != null && !OnSameLine(start, end)) { capture = new List<Coords>(); return false; } if (!pattern.ElementAt(0).IsTarget) { throw new NotImplementedException("Target other than the beginning is not supported yet."); } List<Coords> cAll = new List<Coords>(); bool retVal = false; foreach (var incrementer in ToIncrementers(dir)) { // Try every direction List<Coords> c = new List<Coords>(); if (FindMatch(state, start, end, incrementer, pattern, out c)) { cAll.AddRange(c); retVal = true; } } capture = cAll; return retVal; }
public bool Match(GameState state, Coords start, Coords end, Direction dir) { if (pattern.Count() == 0) { return true; } if (end != null && !OnSameLine(start, end)) { return false; } if (!pattern.ElementAt(0).IsTarget) { throw new NotImplementedException("Target other than the beginning is not supported yet."); } foreach (var incrementer in ToIncrementers(dir)) { // Try every direction List<Coords> c; if (FindMatch(state, start, end, incrementer, pattern, out c)) { return true; } } return false; }
public void startGame(Game game) { Game.current = game; State = GameState.Building; camera.maxPosition = new Vector3 ((Game.current.Chunk)*34f, 25f, 0f); camera.calculateBounds(); world.clearChunks(); for (int i=0; i<Game.current.Chunk; i++) { GameObject ch = world.generateChunk (i); if (Game.current.Team == 1) { ch.GetComponent<MeshRenderer>().materials = WhiteMaterial; } else { ch.GetComponent<MeshRenderer>().materials = BlackMaterial; } } currentBeam = (GameObject) Instantiate(beam); GameObject c = (GameObject) Instantiate(character); c.transform.position = new Vector3 (1f, 20f, 0f); Grunt ai = c.GetComponent<Grunt>(); ai.isHero = true; ai.team = Game.current.Team; EnemyController cont = c.GetComponent<EnemyController>(); cont.maxSpeed = 2.5f; camera.target = c.transform; }
public override void Proceed(GameState caller) { //Clear the score stacks. Screen.Player.ScoreBar.ClearStacks(); if (caller is AgroState) { //AgroState does all the logic work. No need to add much logic here. Spawner spawner = Spawner.GetInstance(); if (spawner.FriendliesPerEnemies > 2) { spawner.FriendliesPerEnemies -= 2; spawner.MaximumAlive += 50; } } else if (caller is RegularState) { RegularState temp = (RegularState)caller; PushState(new AgroState(this, temp.AgroBorder)); } //Call the base. base.Proceed(caller); }
public Game() { this.sideOnePoints = PointState.Love; this.sideTwoPoints = PointState.Love; this.state = GameState.PriorToDeuce; }
public Button(Texture2D img, Rectangle rect, GameState click) { image = img; boundingRect = rect; clickFunction = click; roomIndex = -1; }
/// <summary> /// This will be run on each turns. It must return a direction fot the bot to follow /// </summary> /// <param name="state">The game state</param> /// <returns></returns> public string Move(GameState state) { string direction; new Disjkstra().pathTo(new Pos(5, 5), state.myHero.pos, state.board); switch (random.Next(0, 5)) { case 0: direction = Direction.East; break; case 1: direction = Direction.West; break; case 2: direction = Direction.North; break; case 3: direction = Direction.South; break; default: direction = Direction.Stay; break; } Console.WriteLine("Completed turn {0}, going {1}", state.currentTurn, direction); return direction; }
virtual public void StoreState() { this.state.townName = this.townName; this.state.id = this.townId; GameState.SetTownState(this.state); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); //Initilizes highscores image highScoresBgImg = Content.Load <Texture2D>("Images/Sprites/highscores"); //Initilizes all the game button's images playBtnImg = Content.Load <Texture2D>("Images/Sprites/play button"); instructionsBtnImg = Content.Load <Texture2D>("Images/Sprites/instructions button"); highScoresBtnImg = Content.Load <Texture2D>("Images/Sprites/highscores button"); exitBtnImg = Content.Load <Texture2D>("Images/Sprites/exit button"); returnBtnImg = Content.Load <Texture2D>("Images/Sprites/return to menu"); //Initilizes all the game buttons playBtn = new Button(playBtnImg, new Vector2(470, 150)); instructionsBtn = new Button(instructionsBtnImg, new Vector2(470, 250)); highScoresBtn = new Button(highScoresBtnImg, new Vector2(470, 350)); exitBtn = new Button(exitBtnImg, new Vector2(470, 450)); returnBtn = new Button(returnBtnImg, new Vector2(470, 530)); //Intilizes the instructions image and its rectangle instructionsImg = Content.Load <Texture2D>("Images/Sprites/instructions"); instructionsRec = new Rectangle(0, 0, windowWidth, windowHeight); menuBgImg = Content.Load <Texture2D>("Images/Sprites/back"); menuBgRec = new Rectangle(0, 0, windowWidth, windowHeight); //Loads main font commandFont = Content.Load <SpriteFont>("Fonts/command font"); //Loads game background image and initilizes its rectangle gameBgImg = Content.Load <Texture2D>("Images/Sprites/game bg"); gameBgRec = new Rectangle(0, 0, windowWidth, windowHeight); //Loads command background image and initilizes its rectangle commandBgImg = Content.Load <Texture2D>("Images/Sprites/command bg"); commandBgRec = new Rectangle(0, windowHeight - 200, windowWidth, 200); //Loads command legend image and initilizes its rectangle commandLegendImg = Content.Load <Texture2D>("Images/Sprites/command legend"); commandLegendRec = new Rectangle(0, 0, windowWidth, windowHeight); //Loads empty bar and progress bar images emptyBarImg = Content.Load <Texture2D>("Images/Sprites/empty bar"); progressBarImg = Content.Load <Texture2D>("Images/Sprites/progress bar"); //Loads name entry background image and initilizes its rectangle nameBgImg = Content.Load <Texture2D>("Images/Sprites/name entry bg"); nameBgRec = new Rectangle(0, 0, windowWidth, windowHeight); //Initilizes empty bar's rectangle emptyBarRec = new Rectangle(30, 630, emptyBarImg.Width, emptyBarImg.Height); //Loads all the game object's images gameObjectsImg[PLAYER] = Content.Load <Texture2D>("Images/Sprites/player"); gameObjectsImg[WALL] = Content.Load <Texture2D>("Images/Sprites/wall"); gameObjectsImg[CRATE] = Content.Load <Texture2D>("Images/Sprites/crate"); gameObjectsImg[GOAL] = Content.Load <Texture2D>("Images/Sprites/goal"); gameObjectsImg[DOOR] = Content.Load <Texture2D>("Images/Sprites/door"); gameObjectsImg[SPIKES] = Content.Load <Texture2D>("Images/Sprites/spikes"); gameObjectsImg[GEM] = Content.Load <Texture2D>("Images/Sprites/gem"); gameObjectsImg[KEY] = Content.Load <Texture2D>("Images/Sprites/key"); //Iterates through each level for (int i = 0; i < levels.Length; ++i) { //Initilizes the level and subscribes to level's out of command event levels[i] = new Level("../../../../Content/Levels/Level " + (i + 1) + ".txt"); levels[i].OutOfCommands += (levelPassed, isAlive) => { //Sets result message to the appropiate one based on level result resultMsg = levelPassed ? levelPassedMsg : levelFailedMsg; //isAlive is false then set resultMsg to diedMsg if (!isAlive) { resultMsg = diedMsg; } //Resets input command Input.Instance.ResetCommand(); //Sets game state to results and levelPassed to the parameter levelPassed gameState = GameState.Results; this.levelPassed = levelPassed; }; } //Loads the first level levels[curLevel].LoadLevel(); //Subscribes to Input's CommandValid event //Creates a new instance of Input Input.Instance = new Input(); //Subscribes to Input's CommandValid event with current levels set command function, commands is not null, //and commandLength is a positive int that is below 69 Input.Instance.CommandValid += (commands, commandLength) => { levels[curLevel].SetCommand(commands, commandLength); }; try { //Opens the file paths of the scores inFile = File.OpenText("../../../../Content/Scores.txt"); inFile.Close(); } //Catches any error catch (Exception e) { //Displays error message Console.WriteLine(e.Message); } //Subscribes to Input's command valid event Input.Instance.CommandValid += (c, l) => gameState = GameState.Game_Excection; }
/// <summary> /// sets the current state of the game manager /// </summary> /// <param name="state"></param> public void setCurrentState(GameState state) { currentState = state; lastStateChange = Time.time; }
public Board(int totalBoardSquares) { _totalBoardSquares = totalBoardSquares; _state = GameState.NotStarted; }
public HttpResponseMessage ResetGame() { GameState gameState = _gameService.resetGame(); return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, data = gameState })); }
public override void Do(GameState gameState) { gameState.Place = Place.Tutorial; }
public override void Do(GameState gameState) { gameState.IsPlaying = false; }
/// <summary> /// Changes the state of the game /// </summary> /// <param name="newState">the new game state</param> public static void ChangeState(GameState newState) { gameState = newState; }
private void HandleGameState() { GameState gameState = (GameState)Enum.Parse(typeof(GameState), _state, true); switch (gameState) { case GameState.INITIAL: ToMenu(); break; case GameState.MENU: if (Input.GetKeyDown(KeyCode.Return)) { ToControls(); } if (Input.GetKeyDown(KeyCode.Escape)) { ToQuit(); } break; case GameState.CONTROLS: if (Input.GetKeyDown(KeyCode.Return)) { ToGame(); } if (Input.GetKeyDown(KeyCode.Escape)) { ToMenu(); } break; case GameState.INGAME: if (Input.GetKeyDown(KeyCode.Escape)) { ToMenu(); } break; case GameState.HIGHSCORE: if (Input.GetKeyDown(KeyCode.Return)) { ToMenu(); } if (Input.GetKeyDown(KeyCode.Escape)) { ToMenu(); } break; case GameState.MIDSCORE: if (Input.GetKeyDown(KeyCode.Return)) { ToMenu(); } if (Input.GetKeyDown(KeyCode.Escape)) { ToMenu(); } break; case GameState.LOWSCORE: if (Input.GetKeyDown(KeyCode.Return)) { ToMenu(); } if (Input.GetKeyDown(KeyCode.Escape)) { ToMenu(); } break; case GameState.QUIT: break; } }
virtual public void InitializeState() { GameState.TownState townState = GameState.GetTownState(this.townId); this.townName = townState.townName; this.state = townState; }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } previousKbstate = kb; kb = Keyboard.GetState(); // TODO: Add your update logic here switch (gameState) { case GameState.start: this.IsMouseVisible = true; gameState = screenManager.UpdateTitleScreen(); break; case GameState.pause: this.IsMouseVisible = true; gameState = screenManager.UpdatePauseScreen(); // If its going to Quitting from pause to menu, it needs to reset stuff if (gameState == GameState.start) { level = 0; // Resets level back to 0 updateManager.CurrentLevel = 0; // Don't ask why, but it fixed a bug worldTile.Clear(); // Clears levels player1 = new Player(448, 448, 70, 95, playerTexture, 5, 17, 10); // Creates a new Player // Makes new levels for next time game is played for (int i = 0; i < maxLevel; i++) { worldTile.Add(new WorldTile(tree, bear, pickupsT, starterBackground)); } } //show menu break; case GameState.loadLevel: this.IsMouseVisible = false; if (updateManager.WaitNextLevel(gameTime) == false) { updateManager.NextLevel(player1, worldTile[level].WorldTrees, worldTile[level].WorldBears, worldTile[level].WorldPickUps, level, nullState); level++; kb = nullState; previousKbstate = nullState; gameState = GameState.gameLoop; } else { gameState = GameState.loadLevel; } break; case GameState.gameLoop: this.IsMouseVisible = false; //does bears and movement etc updateManager.UpdateGameScreenFields(kb, previousKbstate, gameTime); gameState = updateManager.UpdateGameScreen(); if (gameState == GameState.gameOver) { scoreBoardManager.ScoreReset = ScoreState.loading; } /* line of code that * gameState = updateManager.UpdateGameScreen */ if (gameState == GameState.gameOver) { scoreBoardManager.CurrentScore = updateManager.ReturnScore(); } break; case GameState.gameOver: this.IsMouseVisible = false; // Resets avaliable levels, resets current level, and makes new player! kb = nullState; previousKbstate = nullState; level = 0; // Resets level back to 0 updateManager.CurrentLevel = 0; // Don't ask why, but it fixed a bug worldTile.Clear(); // Clears levels player1 = new Player(448, 448, 70, 95, playerTexture, 5, 17, 10); // Creates a new Player // Makes new levels for next time game is played for (int i = 0; i < maxLevel; i++) { worldTile.Add(new WorldTile(tree, bear, pickupsT, starterBackground)); } //display score gameState = scoreBoardManager.UpdateGameover(); if (gameState == GameState.start) { scoreBoardManager.CurrentScore = 0; } break; case GameState.exit: this.Exit(); break; } base.Update(gameTime); }
/// <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) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // update the menu buttons MouseState mouse = Mouse.GetState(); flipCards.Update(mouse); collectWinnings.Update(mouse); quitGame.Update(mouse); // update based on game state if (gameState == GameState.Flip) { // FLIP CARDS INTO BATTLE PILES Card player1Card = handPlayer1.TakeTopCard(); player1Card.FlipOver(); pilePlayer1.AddCard(player1Card); Card player2Card = handPlayer2.TakeTopCard(); player2Card.FlipOver(); pilePlayer2.AddCard(player2Card); //Otherwise //pilePlayer1.AddCard(handPlayer1.TakeTopCard()); //pilePlayer1.GetTopCard().FlipOver(); //pilePlayer2.AddCard(handPlayer2.TakeTopCard()); //pilePlayer2.GetTopCard().FlipOver(); // FIGURE OUT WINNER AND SHOW MESSAGE if (player1Card.WarValue > player2Card.WarValue) { winnerPlayer1.Visible = true; currentWinner = Player.Player1; } else if (player1Card.WarValue < player2Card.WarValue) { winnerPlayer2.Visible = true; currentWinner = Player.Player2; } else { currentWinner = Player.None; } // Otherwise //if (pilePlayer1.GetTopCard().WarValue > pilePlayer2.GetTopCard().WarValue) //{ // winnerPlayer1.Visible = true; //} //else if (pilePlayer1.GetTopCard().WarValue < pilePlayer2.GetTopCard().WarValue) //{ // winnerPlayer2.Visible = true; //} // gameState = GameState.Play; // adjust button visibility flipCards.Visible = false; collectWinnings.Visible = true; // wait for player to collect winnings gameState = GameState.CollectWinnings; } else if (gameState == GameState.Play) { // distribute battle piles into appropiate hands and hide message if (currentWinner == Player.Player1) { handPlayer1.AddCards(pilePlayer1); handPlayer1.AddCards(pilePlayer2); winnerPlayer1.Visible = false; } else if (currentWinner == Player.Player2) { handPlayer2.AddCards(pilePlayer1); handPlayer2.AddCards(pilePlayer2); winnerPlayer2.Visible = false; } else { handPlayer1.AddCards(pilePlayer1); handPlayer2.AddCards(pilePlayer2); } currentWinner = Player.None; //Otherwise //if (pilePlayer1.GetTopCard().WarValue > pilePlayer2.GetTopCard().WarValue) //{ // handPlayer1.AddCards(pilePlayer1); // handPlayer1.AddCards(pilePlayer2); // winnerPlayer1.Visible = false; //} //else if (pilePlayer1.GetTopCard().WarValue < pilePlayer2.GetTopCard().WarValue) //{ // handPlayer2.AddCards(pilePlayer1); // handPlayer2.AddCards(pilePlayer2); // winnerPlayer2.Visible = false; //} //else //{ // handPlayer1.AddCards(pilePlayer1); // handPlayer2.AddCards(pilePlayer2); //} // set flip button visibility flipCards.Visible = true; collectWinnings.Visible = false; //gameState = GameState.Play; // check for game over if (handPlayer1.Empty || handPlayer2.Empty) { flipCards.Visible = false; gameState = GameState.GameOver; if (handPlayer1.Empty) { winnerPlayer2.Visible = true; } else { winnerPlayer1.Visible = true; } } } //Otherwise //if (gameState == GameState.GameOver) //{ // collectWinnings.Visible = false; // flipCards.Visible = false; // if (handPlayer1.Empty) // { // winnerPlayer2.Visible = true; // } // else // { // winnerPlayer1.Visible = true; // } //} else if (gameState == GameState.Quit) { Exit(); } //base.Update(gameTime); }
public override void OnLeave(GameState nextState) { }
private void Update() { m_totalRewardLabel.text = string.Format("TOTAL REWARD: ${0:0.00}", GameState.Get().Currency); }
public void TestPlayRound() { var deck = new Deck(); deck.Clear(); var cardsToAdd = new List <Card>() { // Cards the game will deal to Owen new Card(Values.Jack, Suits.Spades), new Card(Values.Jack, Suits.Hearts), new Card(Values.Six, Suits.Spades), new Card(Values.Jack, Suits.Diamonds), new Card(Values.Six, Suits.Hearts), // Cards the game will deal to Brittney new Card(Values.Six, Suits.Diamonds), new Card(Values.Six, Suits.Clubs), new Card(Values.Seven, Suits.Spades), new Card(Values.Jack, Suits.Clubs), new Card(Values.Nine, Suits.Spades), // Two more cards in the deck for Owen to draw when he runs out new Card(Values.Queen, Suits.Hearts), new Card(Values.King, Suits.Spades), }; foreach (var card in cardsToAdd) { deck.Add(card); } var gameState = new GameState("Owen", new List <string>() { "Brittney" }, deck); var owen = gameState.HumanPlayer; var brittney = gameState.Opponents.First(); Assert.AreEqual("Owen", owen.Name); Assert.AreEqual(5, owen.Hand.Count()); Assert.AreEqual("Brittney", brittney.Name); Assert.AreEqual(5, brittney.Hand.Count()); var message = gameState.PlayRound(owen, brittney, Values.Jack, deck); Assert.AreEqual("Owen asked Brittney for Jacks" + Environment.NewLine + "Brittney has 1 Jack card", message); Assert.AreEqual(1, owen.Books.Count()); Assert.AreEqual(2, owen.Hand.Count()); Assert.AreEqual(0, brittney.Books.Count()); Assert.AreEqual(4, brittney.Hand.Count()); message = gameState.PlayRound(brittney, owen, Values.Six, deck); Assert.AreEqual("Brittney asked Owen for Sixes" + Environment.NewLine + "Owen has 2 Six cards", message); Assert.AreEqual(1, owen.Books.Count()); Assert.AreEqual(2, owen.Hand.Count()); Assert.AreEqual(1, brittney.Books.Count()); Assert.AreEqual(2, brittney.Hand.Count()); message = gameState.PlayRound(owen, brittney, Values.Queen, deck); Assert.AreEqual("Owen asked Brittney for Queens" + Environment.NewLine + "Owen drew a card", message); Assert.AreEqual(1, owen.Books.Count()); Assert.AreEqual(2, owen.Hand.Count()); }
public static bool LoadGameState(string path, GameState gameState) { string[] state = File.ReadAllLines(path); return(TryParseGameState(state, gameState)); }
protected override void OnExit(GameState prev, ExitReason reason) { }
public override void OnEnter(GameState previousState) { }
// Update is called once per frame void Update() { switch (gameState) { case GameState.play: //for (int i = 0; i < agentsSize; i++) //{ // //if(!isGroupEntityHypnotised[i]) // //{ // // break; // //} // //Debug.Log("WON"); //} //bool allHypnotized = true; //foreach (MoveBetweenPoints child in humanManager.transform) //{ // Debug.Log(child.name); // if (child.hypno == false) // { // allHypnotized = false; // } //} //if (allHypnotized) //{ // gameState = GameState.win; // Debug.Log("WIN"); //} //gameState = GameState.win; // make timer visible if (aliveCount == agentsSize) { gameState = GameState.win; } timer -= Time.deltaTime; if (timer < 0) { // time's up! timer = 30; gameState = GameState.lose; } // update UI TimeText.text = ((int)timer).ToString() + "s"; TimeBar.value = timer; break; case GameState.pause: // TODO: ??? break; case GameState.win: // TODO: show win screen/animation Debug.Log("WIN"); SceneManager.LoadScene("winScene"); break; case GameState.lose: // TODO: show lose screen/animation SceneManager.LoadScene("lossScene"); break; case GameState.exit: // TODO: exit game break; default: break; } }
private void Start() { gameState = FindObjectOfType <GameState>(); }
public DynamicNavProcessor() { gameState = Layer.Get <GameState>(); }
protected override void OnPrepare(GameState prev, object[] parms) { this.App.UI.LoadScreen("Profiles"); }
private void EnterState(GameState newState) { currentState = newState; switch (currentState) { case GameState.MENU_MAIN: { //Main menu prefab GameObject newObject = Instantiate(MainMenuPrefab, this.transform); newObject.transform.SetParent(this.transform); displayedGUI.Add(newObject); newObject = Instantiate(ConnectionStatusPrefab, this.transform); newObject.transform.SetParent(this.transform); newObject.name = connectionPanelName; displayedGUI.Add(newObject); SetStatus(); break; } case GameState.MENU_SETTINGS: { GameObject newObject = Instantiate(AudioMenuPrefab, this.transform); newObject.transform.SetParent(this.transform); displayedGUI.Add(newObject); break; } case GameState.MENU_HELP: { GameObject newObject = Instantiate(HelpMenuPrefab, this.transform); newObject.transform.SetParent(this.transform); displayedGUI.Add(newObject); break; } case GameState.MENU_LOGIN: { GameObject newObject = Instantiate(LoginMenuPrefab, this.transform); newObject.transform.SetParent(this.transform); displayedGUI.Add(newObject); break; } case GameState.CHARACTER_SELECT: { GameObject newObject = Instantiate(CharacterSelectPrefab, this.transform); newObject.transform.SetParent(this.transform); displayedGUI.Add(newObject); wsManager.RegisterReceiver(newObject.GetComponent <CharacterSelectScreen>()); //Retrieve character list wsManager.RequestCharacters(); StartCoroutine(LoadSpriteFromWeb(Constants.BASE_ASSET_URL + Constants.TEST_SPRITE)); break; } default: { ChangeState(GameState.MENU_MAIN); break; } } }
public void SetState(GameState state) { SetState(state, null); }
private readonly float _movementSpeed; // pixels per millisecond public PlayerInputSystem(string name, GameState gameState) : base(name, gameState) { _movementSpeed = 0.24f; }
public void setGameStateTo(GameState state) { this.State = state; Application.LoadLevel(this.State.ToString()); }
public void ChangeGameState(GameState newState) { currentGameState = newState; }
public void ChangeState(GameState newState) { LeaveState(); EnterState(newState); }
void BeginTargeting() { Debug.Log("Begin targeting"); gameState = GameState.CastingSpell; // Change buttons, disable card dragging }
public void ShowHighScore(GameState newState) { currentGameState = newState; }