private void check_game_over() { int lost; int i; do { i = 0; lost = 0; foreach (moving m in move_list) { if (m.is_none_t()) { lost = i; } } i++; if (lost != 0) { move_list.RemoveAt(lost); } } while (lost != 0); if (move_list.Count == 1) { current_state = game_state.finish_t; } }
public static void Revive() { Vector3 tempVel = new Vector3((float)(speed * 0.6), 0f, 0f); current_game_state = game_state.Playing; player.GetComponent <Rigidbody2D> ().velocity = tempVel; }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Bisque); // TODO: Add your drawing code here spriteBatch.Begin(); switch (gamestate) { case game_state.runnning_state: handle_screen.Draw(out exit_game, out restart_game, gameTime, this); if (exit_game) { gamestate = game_state.initial_state; Exit(); } if (this.restart_game) { restart_game = false; gamestate = game_state.initial_state; } break; } spriteBatch.End(); base.Draw(gameTime); }
public static void Start_Game() { Camera.main.GetComponent <Animator> ().Play("MainGame_Score_Raise"); Vector3 tempVel = new Vector3(speed, 0f, 0f); player.GetComponent <Rigidbody2D> ().velocity = tempVel; current_game_state = game_state.Playing; }
/// <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() { // TODO: Add your initialization logic here graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Title = "Sustainable Kid's Game"; // this.IsMouseVisible = true; this.pos.X = Mouse.GetState().X; this.pos.Y = Mouse.GetState().Y; gamestate = game_state.initial_state; base.Initialize(); }
void do_start() { current_level = 3; b = new breakout(); System.Console.WriteLine("inside main"); current_level = b.load_level(current_level); if (current_level == 0) { current_state = game_state.finish_t; } else { current_state = game_state.play_t; init_board(); } }
private void OnStateChange(game_state newGameState) { if (m_gameState != newGameState) { switch (newGameState) { case game_state.MAIN_MENU: break; case game_state.IN_GAME: Time.timeScale = 1; break; } m_gameState = newGameState; } }
public void RoundEnd(int winner, int damage) { Dictionary <byte, object> parameters = new Dictionary <byte, object>(); parameters[0] = 0; gamestate = game_state.purchase; if (winner != id) { playerHealth -= damage; parameters[0] = damage; } else { gold += 1; } RestoreBattleGround(); PhotonManager.Instance.OnOperationRequest((byte)OpCode.Battle, parameters, (byte)BattleCode.SendResult); }
public void SetCurrentState(string state_name) { game_state state = this.GetState(state_name); if (this.current_state != state) { if (this.current_state != null) { this.current_state.LeaveState(); } this.current_state = state; if (this.current_state != null) { this.current_state.EnterState(); } } }
public static void Game_Over() { if (score >= HighScore) { SaveManager.SetHighScore(HighScore); SaveManager.Save(); GPS.ReportHighScore(score); //scoreReadout.GetComponent<TextMesh>().color = colors["Gold"]; } //Destruction sound - Tyler AudioClip audiotemp = AudioManager.Destruction_Sound; AudioManager.Play_Audio(audiotemp); //Jays shit is below current_game_state = game_state.GameOver; player.GetComponent <Rigidbody2D> ().velocity = new Vector3(0f, 0f, 0f); line_number = 0; speed = 5; Camera.main.GetComponent <Animator> ().Play("MainGame_Camera_ZoomOut"); GameObject Colour_Particles = Instantiate(Resources.Load("Sprites/Ui/Particles/ColourParticles") as GameObject, new Vector3(Camera.main.transform.position.x, 4f, 11f), identity) as GameObject; }
/// <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(); } KeyboardState newState = Keyboard.GetState(); if (newState.IsKeyDown(Keys.Escape)) { graphics.IsFullScreen = false; graphics.ApplyChanges(); } else if (newState.IsKeyDown(Keys.F1)) { graphics.IsFullScreen = true; graphics.ApplyChanges(); } switch (gamestate) { case game_state.initial_state: create_object(); handle_screen.LoadContent(spriteBatch); gamestate = game_state.runnning_state; break; case game_state.runnning_state: handle_screen.Update(gameTime, this); break; } base.Update(gameTime); }
game_state GetState(string state_name) { game_state out_state = null; switch (state_name) { case "game": out_state = this.state_game; break; case "pause": out_state = this.state_pause; break; case "codex": out_state = this.state_codex; break; case "badges": out_state = this.state_badges; break; case "battle": out_state = this.state_battle; break; case "boss_battle": out_state = this.state_boss_battle; break; case "town": out_state = this.state_town; break; } return(out_state); }
void do_run(object sender, EventArgs args) { current_state = game_state.start_t; start_timer(); }
public void Changestate() { gamestate = game_state.battle; }
public void StartBattle() { print("getcalled"); gamestate = game_state.battle; }
// Use this for initialization void Start() { GPGS_Logged_In = Social.localUser.authenticated; Debug.Log(GPGS_Logged_In); HighScore = SaveManager.GetHighScore(); coins = SaveManager.GetCoins(); canReset = false; isFirstGame = SaveManager.IsFirstTime(); currentCharacter = SaveManager.GetCharacter(); //reset line_number = 0; speed = 5; score = 0; cameraSize.y = 2 * Camera.main.orthographicSize; cameraSize.x = cameraSize.y * Camera.main.aspect; //sets the root vector to appropriate x and y values, scaled to the size of the screen. root = new Vector3((float)(0 - cameraSize.x * starting_position_scaler), (float)(0 - (cameraSize.y * 0.6 - cameraSize.y / 2))); line_segment = Resources.Load("Sprites/Line/Prefabs/RoundedLine") as GameObject; line_segment_width = line_segment.GetComponent <SpriteRenderer> ().bounds.size.x + 2 * line_padding; Number_Of_Line_Segments = 0; //instantiate obstacle array Obstacle_Prefab_Array = new GameObject[number_of_obstacle_types]; //load in obstacles Obstacle_Prefab_Array[0] = Resources.Load("Sprites/Obstacles/Prefabs/Peaks_Purple") as GameObject; Obstacle_Prefab_Array[1] = Resources.Load("Sprites/Obstacles/Prefabs/Weight") as GameObject; Obstacle_Prefab_Array[2] = Resources.Load("Sprites/Obstacles/Prefabs/Pylon") as GameObject; Obstacle_Prefab_Array[3] = Resources.Load("Sprites/Obstacles/Prefabs/Bump") as GameObject; Obstacle_Prefab_Array[4] = Resources.Load("Sprites/Obstacles/Prefabs/Line") as GameObject; Obstacle_Prefab_Array[5] = Resources.Load("Sprites/Obstacles/Prefabs/Gear") as GameObject; destroyed_particle = Resources.Load("Sprites/Obstacles/Particles/Obstacle_Destroyed") as GameObject; //Instantiate array list All_Lines = new ArrayList(); All_Obstacles = new ArrayList(); All_Obstacles.Add(null); //using the root position, calculate how many lines can fit on the screen Max_Line_Segments = Mathf.RoundToInt((cameraSize.x - (cameraSize.x / 2 + root.x)) / line_segment_width); //recalulate a root, so that there is equal whitespace on both sides float whiteSpaceLeft = cameraSize.x / 2 + root.x; float whiteSpaceRight = cameraSize.x - Max_Line_Segments * line_segment_width; root.x = (float)(0 - cameraSize.x / 2 + (whiteSpaceRight + whiteSpaceLeft) / 2); //set the line gen position to root nextLinePos = root; nextObstaclePos = root; nextObstaclePos.y += (float)(1.5 * (line_segment.GetComponent <SpriteRenderer> ().bounds.size.y)); nextObstaclePos.x -= line_segment_width; nextLinePos.z = -1f; //position the car player = Resources.Load("Sprites/Player/Prefabs/" + currentCharacter) as GameObject; //Instantiate(Resources.Load("Sprites/Player/Prefabs/TarCar") as GameObject,new Vector3 ((float)(root.x + player.GetComponent<SpriteRenderer> ().bounds.size.x * 0.3), root.y + (player.GetComponent<SpriteRenderer> ().bounds.size.y/2)+ line_segment.GetComponent<SpriteRenderer>().bounds.size.y/2, 0f),identity) as GameObject;//GameObject.FindGameObjectWithTag ("Player"); player = Instantiate(player, new Vector3(0f, 0f, 0f), identity) as GameObject; player.GetComponent <Rigidbody2D> ().velocity = new Vector3(0f, 0f, 0f); scoreReadout = GameObject.FindGameObjectWithTag("Score"); scoreReadout.GetComponent <Animator> ().Play("MainGame_Score_In"); highScoreReadout = GameObject.FindGameObjectWithTag("HighScore"); highScoreReadout.GetComponent <TextMesh> ().text = HighScore.ToString(); speed = Mathf.RoundToInt((float)(6 + ((1.2 * HighScore) / 150))); max_speed = Mathf.RoundToInt((float)(16 + ((2 * HighScore) / 150))); coinReadout = GameObject.FindGameObjectWithTag("CoinBanner"); coinReadout.GetComponentInChildren <TextMesh> ().text = coins.ToString(); clickWall = GameObject.FindGameObjectWithTag("ClickWall"); player.transform.position = new Vector3((float)(root.x + player.GetComponentInChildren <SpriteRenderer> ().bounds.size.x * 0.3), root.y + (player.GetComponentInChildren <SpriteRenderer> ().bounds.size.y / 2) + line_segment.GetComponentInChildren <SpriteRenderer>().bounds.size.y / 2, 0f); starting_reference = Camera.main.transform.position.x - player.transform.position.x; AddLineSegments(false); current_game_state = game_state.PreStart; //Car's start up sound -Tyler AudioClip temp = AudioManager.Start_Sound; AudioManager.Play_Audio(temp); //testing git upload offset = Camera.main.transform.position.x - player.transform.position.x; }