void Update()
    {
        switch (gamestate)
        {
        case (gameStates.WORLD_STATE):
            if (isWalking)
            {
                RandomEncounter();
            }
            if (gotEncountered)
            {
                gamestate = gameStates.BATTLE_STATE;
            }

            break;

        case (gameStates.TOWN_STATE):

            break;

        case (gameStates.BATTLE_STATE):
            //load battle scene
            startBattle();
            gamestate = gameStates.IDLE;
            //go to idle
            break;

        case (gameStates.IDLE):

            break;
        }
    }
Example #2
0
    void Update()
    {
        switch (gameState)
        {
        //While during gameplay
        case gameStates.Playing:
            if (playerHealth.isAlive == false)
            {
                // update gameState
                gameState = gameStates.Death;

                // set the end game score
                gameOverScoreDisplay.text = mainScoreDisplay.text;

                // switch which GUI is showing
                mainCanvas.SetActive(false);
                gameOverCanvas.SetActive(true);
            }
            else if (canBeatLevel && score >= beatLevelScore)
            {
                // update gameState
                gameState = gameStates.BeatLevel;

                // hide the player so game doesn't continue playing
                player.SetActive(false);

                // switch which GUI is showing
                mainCanvas.SetActive(false);
                beatLevelCanvas.SetActive(true);
            }
            break;

        //When Gameplay Ends
        case gameStates.Death:
            //backgroundMusic.volume -= 0.01f;
            //if (backgroundMusic.volume <= 0.0f)
            //{
            //    AudioSource.PlayClipAtPoint(gameOverSFX, gameObject.transform.position);

            //    gameState = gameStates.GameOver;
            //}
            break;

        //When you sucessfully beat level
        case gameStates.BeatLevel:
            //backgroundMusic.volume -= 0.01f;
            //if (backgroundMusic.volume <= 0.0f)
            //{
            //    AudioSource.PlayClipAtPoint(beatLevelSFX, gameObject.transform.position);

            //     gameState = gameStates.GameOver;
            //}
            break;

        //Generic. Gameover could mean you either won or lost
        case gameStates.GameOver:
            // nothing
            break;
        }
    }
Example #3
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (currentGameState == gameStates.start)
            {
            }
            if (currentGameState == gameStates.gamePlay)
            {
                gamep.Update(gameTime);
            }
            if (currentGameState == gameStates.mapSelector)
            {
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                if (currentGameState == gameStates.gamePlay)
                {
                    currentGameState = gameStates.mapSelector;
                }
                else
                {
                    currentGameState = gameStates.gamePlay;
                }
            }

            base.Update(gameTime);
        }
Example #4
0
    // this is the main game event loop
    void Update()
    {
        //calculating the time from the start
        currentTime = Time.time - startTime;
        // displaying only the int value
        timeToDisplay         = Mathf.RoundToInt(currentTime);
        mainTimerDisplay.text = timeToDisplay.ToString();
        switch (gameState)
        {
        case gameStates.Playing:
            if (playerHealth.isAlive == false)
            {
                // update gameState
                gameState = gameStates.GameOver;

                // set the end game score
                gameOverScreenText.text = currentTime.ToString();

                // switch which GUI is showing
                mainCanvas.SetActive(false);
                gameOverCanvas.SetActive(true);
                playAgainButtonGameObject.SetActive(true);
            }
            break;

        case gameStates.GameOver:

            break;
        }
    }
Example #5
0
    void Update()
    {
        switch (gameState)
        {
            case gameStates.Playing:
                if (levelBeaten) {
                    // update gameState
                    gameState = gameStates.BeatLevel;

                    // hide the player so game doesn't continue playing
                    player.SetActive(false);

                    // switch which GUI is showing
                    beatLevelCanvas.SetActive (true);
                }
                break;
            case gameStates.BeatLevel:
                backgroundMusic.volume -= 0.01f;
                if (backgroundMusic.volume<=0.0f) {
                    AudioSource.PlayClipAtPoint (beatLevelSFX,gameObject.transform.position);

                    gameState = gameStates.GameOver;
                }
                break;
            case gameStates.GameOver:
                // nothing
                break;
        }
    }
Example #6
0
    public void ReatartGame(string TYPE = "stop")
    {
        GAME_STATE = gameStates.stop;

        Debug.Log("restartGame:" + TYPE);

        if (TYPE == "stop" && Saves.inst.CHAMP_IS_CHAMP == 0) //если чемпионат и прерывание то обнуляем
        {
            UiChamp.inst.SetChamp(0);
        }

        if (TYPE == "end" && Saves.inst.CHAMP_IS_CHAMP == 1)
        {
            if (SCORE1 > SCORE2)
            {
                UiChamp.inst.NextLevel();
            }
            else
            {
                UiChamp.inst.SetChamp(0);
                //TODO: прогиграл
            }
        }

        EventController("restartGame");
        UiMainMenu.inst     = null;
        UiInGamePanel.inst  = null;
        UiEndGamePanel.inst = null;
        UiChamp.inst        = null;
        UiPlashka.inst      = null;
        Scene scene = SceneManager.GetActiveScene();

        SceneManager.LoadScene(scene.name);
        /* */
    }
Example #7
0
    void Update()
    {
        switch (gameState)
        {
        case gameStates.Menu:

            break;

        case gameStates.Playing:
            realTimeLeft     -= Time.deltaTime;
            timeLeft          = (int)(realTimeLeft);
            timerDisplay.text = (int)(timeLeft / 60) + ":" + timeLeft % 60;
            if (realTimeLeft < 0.0f)
            {
                mainCanvas.SetActive(false);
                gameOverCanvas.SetActive(true);
                gameState = gameStates.GameOver;
            }
            if (winBox.playerEntered)
            {
                gameState = gameStates.BeatLevel;
                showBeatLevel();
            }
            break;
        }
    }
Example #8
0
        public void Update()
        {
            if (state == gameStates.menu)
            {
                if (IsKeyPressed(rl.KeyboardKey.KEY_SPACE))
                {
                    state = gameStates.play;
                }
            }
            else if (state == gameStates.play)
            {
                world.Update();
            }
            else if (state == gameStates.player1Victory || state == gameStates.player2Victory)
            {
                //Remove all bullets from the game
                for (int i = 0; i < world.Children.Count; i++)
                {
                    if (world.Children[i].name == "Bullet")
                    {
                        world.RemoveChild(world.GetChild(i));
                    }
                }
                if (IsKeyPressed(rl.KeyboardKey.KEY_SPACE))
                {
                    state = gameStates.play;
                    Reset();
                }
            }

            if (IsKeyPressed(rl.KeyboardKey.KEY_F1))
            {
                Program.debug = !Program.debug;
            }
        }
Example #9
0
 // Update is called once per frame
 void Update()
 {
     switch (gameState)
     {
         case gameStates.Playing:
             if( Input.GetKeyDown(KeyCode.Escape))
             {
                 //Change the game state.
                 gameState = gameStates.Pause;
                 //Pause the game.
                 Time.timeScale = 0;
                 //Show the Pause Menu.
                 pauseMenuCanvas.SetActive(true);
             }
             break;
         case gameStates.Pause:
             if (Input.GetKeyDown(KeyCode.Escape))
             {
                 //Change the game state.
                 gameState = gameStates.Playing;
                 //Hide the pause menu.
                 pauseMenuCanvas.SetActive(false);
                 //Unpause the game.
                 Time.timeScale = 1;
             }
             break;
         case gameStates.Menu:
             //nothing
             break;
     }
 }
Example #10
0
 public void movetoNextState(gameStates st)
 {
     if (st != currentState)
     {
         nextState = st;
     }
 }
Example #11
0
 /// ////////
 /// Called every tick. Checks if game is paused, and if not calls all the needed game ticks.
 /// Renders everything.
 /// ///////
 private void gameTick()
 {
     //Game has ended if no livse
     if (_lives == 0)
     {
         _gameState = gameStates.gameOver;
     }
     //If the game is on, check if it should be paused
     if (_control.pause && _gameState == gameStates.gameOn)
     {
         //Check to pause/unpause on only a new press of the key
         if (_pauseCheck)
         {
             _pause      = !_pause;
             _pauseCheck = false;
         }
     }
     else
     {
         _pauseCheck = true;
     }
     //If not paused, check controls and tick the game
     if (!_pause)
     {
         checkControls();
         gameTicks();
     }
     //Render everything
     gameRender();
 }
Example #12
0
    void trimStackr(trimDirection dir, int trimSize)
    {
        // Check if lose condition
        if (trimSize >= tilemap.size.x)
        {
            Debug.Log("Triggering gameover state");
            gameState = gameStates.gameOver;
            // Set floating blocks to red
            tilemap.color = Color.red;
            return;
        }
        Vector3Int trimTarget;

        if (dir == trimDirection.left)
        {
            // Trim from origin
            for (int i = 0; i < trimSize; i++)
            {
                trimTarget = new Vector3Int(tilemap.origin.x + i, tilemap.origin.y, tilemap.origin.z);
                tilemap.SetTile(trimTarget, null);
                spawnAndTriggerFall(tilemap.GetCellCenterWorld(trimTarget));
            }
        }
        else
        {
            // Trim from origin + size, backwards
            for (int i = 1; i <= trimSize; i++)
            {
                trimTarget = new Vector3Int(tilemap.origin.x + tilemap.size.x - i, tilemap.origin.y, tilemap.origin.z);
                tilemap.SetTile(trimTarget, null);
                spawnAndTriggerFall(tilemap.GetCellCenterWorld(trimTarget));
            }
        }
    }
Example #13
0
    public IEnumerator restartAfterGoal2()
    {
        yield return(new WaitForSeconds(1F));

        GAME_STATE = gameStates.game;
        Hub.inst.PushHub();
    }
Example #14
0
    public IEnumerator startGameDelay()
    {
        yield return(new WaitForSeconds(1F));

        GAME_STATE = gameStates.game;
        Hub.inst.PushHub();
    }
Example #15
0
    // Use this for initialization
    void Start()
    {
        size              = 10;
        abstractGamePlan  = new GamePlan(size, numberOfCharacters);
        actualGameState   = gameStates.makingTurnWaiting;
        highlightedPlanes = new List <PlaneSquareScript> ();
        plane             = new GameObject[size, size];
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                plane [i, j] = UnityEngine.Object.Instantiate(PlaneSquarePrefab, new Vector3(10 * i, 0, 10 * j), Quaternion.identity) as GameObject;

                var script = plane [i, j].GetComponent <PlaneSquareScript> ();
                script.position.x = i;
                script.position.y = j;
                script.GM         = this;
                script.SquareToSelectChild.GetComponent <SquareToSelect> ().GM = this;
            }
        }
        createCharacterAtPos(0, 1, new Fighter(0, 1, true));
        createCharacterAtPos(0, 5, new Fighter(0, 5, true));
        createCharacterAtPos(0, 8, new Fighter(0, 8, true));
        createCharacterAtPos(9, 1, new Fighter(9, 1, false));
        createCharacterAtPos(9, 8, new Fighter(9, 8, false));
        createCharacterAtPos(9, 5, new Fighter(9, 5, false));


        turnPlaner = new TurnPlaner(abstractGamePlan.alliedCharacters);
    }
Example #16
0
    private void NextGameState()
    {
        switch (currentGameState)
        {
        case gameStates.Start:
            currentGameState = gameStates.Preflop;
            break;

        case gameStates.Preflop:
            currentGameState = gameStates.Flop;
            break;

        case gameStates.Flop:
            currentGameState = gameStates.Turn;
            break;

        case gameStates.Turn:
            currentGameState = gameStates.River;
            break;

        case gameStates.River:
            currentGameState = gameStates.Showdown;
            break;

        case gameStates.Showdown:
            currentGameState = gameStates.Start;
            break;

        default:
            break;
        }
    }
Example #17
0
    public void ClickedOnAlliedCharacter(GameObject go, AllyUnitScript aus)
    {
        if (actualGameState != gameStates.makingTurnWaiting)
        {
            return;
        }
        var chr = aus.ThisCharacter;

        actualGameState    = gameStates.makingTurnSelectingMovement;
        selectedCharacter  = aus;
        selectedAllyObject = go;
        aus.AlliedUnitCanvas.SetActive(true);
        go.layer = 2;        //make unclickable
        Color c = selectedAllyObject.GetComponent <Renderer>().material.color;

        c.a = 0.5f;
        selectedAllyObject.GetComponent <Renderer>().material.color = c;
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                if (Math.Abs(i - chr.actualPosition.x) + Math.Abs(j - chr.actualPosition.y) <= chr.movementRange)
                {
                    highlightedPlanes.Add(plane [i, j].GetComponent <PlaneSquareScript> ());
                    highlightedPlanes [highlightedPlanes.Count - 1].Highlight();
                }
            }
        }
        var actuallySelectedIndex = Array.IndexOf(alliedUnits, go);
        var actualOrderOfSelected = turnPlaner.getOrder(aus.ThisCharacter);

        GameInformText.text = String.Format("Selected Char: {0} Selected order: {1}", actuallySelectedIndex.ToString(), actualOrderOfSelected.ToString());
        //Debug.Log (String.Format ("Selected Char: {0} Selected order: {1}", actuallySelectedIndex.ToString (), actualOrderOfSelected.ToString ()));
    }
Example #18
0
 public void NewRound()
 {
     NewRoundButton.SetActive(false);
     currentGameState = gameStates.Start;
     sidepotValue     = 0;
     communityCards.RpcMakeSidepotValueTextInactive();
     //Reset text about Hand Types or Winner.
     foreach (Player el in players)
     {
         if (el.currentPlayerState != Player.playerState.Eliminated)
         {
             el.currentPlayerState = Player.playerState.Uncalled;
             el.GetComponent <ShowCards>().RpcMakeTextInactive(3);
             el.GetComponent <ShowCards>().RpcMakeTextInactive(4);
             el.GetComponent <ShowCards>().RpcChangeText(2, "");
             el.GetComponent <ShowCards>().RpcDeactivateTurnButton();
         }
     }
     loneCaller    = null;
     lastBetPlayer = null;
     //Set Next Dealer & Current Player
     NextDealer();
     SetPlayersTurn(currentDealerPlayer);
     NextPlayersTurn();
     currentBet = 0;
     curMinBet  = minBet;
     dealer.ResetRound();
     roundActive = true;
     StartCoroutine(RunRound());
 }
Example #19
0
 //this is the function that is called when the Start Button is clicked
 //it calls the event and sets it's bool to true, which is carried over into each script subscribed to this event
 public void CallStartEvent()
 {
     startEvent(true);
     //after the start Event is triggered, we shift the state engine into start phase
     myState = gameStates.start;
     Debug.Log("Game has begun");
 }
Example #20
0
 void StartGame()
 {
     gameState          = gameStates.NotStarted;
     currentState       = startingState;
     textComponent.text = currentState.GetStoryState();
     pathText.text      = currentState.GetPath();
 }
Example #21
0
    public void PlayGame()
    {
        HideMenu();
        HUDCanvas.SetActive(true);

        if (timedLevel)
        {
            currentTime            = startTime;
            timerTitleDisplay.text = timerTitle;
        }

        if (beatLevelScore >= 0)
        {
            scoreValueDisplay.text = score.ToString();
            scoreTitleDisplay.text = scoreTitle;
        }

        if (defaultLives >= 0)
        {
            livesValueDisplay.text = defaultLives.ToString();
            livesTitleDisplay.text = livesTitle;
        }

        gameStarted = true;
        gameState   = gameStates.Playing;

        playerIsDead = false;
        SceneManager.LoadScene(playAgainLevelToLoad, LoadSceneMode.Additive);

        Scene currentLevel = SceneManager.GetActiveScene();

        playAgainLevelToLoad = currentLevel.name;
    }
Example #22
0
    void Update()
    {
        switch (gameState)
        {
        case gameStates.Playing:
            if (playerHealth.isAlive == false)
            {
                // update gameState
                gameState = gameStates.Death;

                // set the end game score
                gameOverScoreDisplay.text = mainScoreDisplay.text;

                // switch which GUI is showing
                mainCanvas.SetActive(false);
                gameOverCanvas.SetActive(true);
            }
            else if (canBeatLevel && score >= beatLevelScore)
            {
                // update gameState
                gameState = gameStates.BeatLevel;

                // hide the player so game doesn't continue playing
                player.SetActive(false);

                // switch which GUI is showing
                mainCanvas.SetActive(false);
                beatLevelCanvas.SetActive(true);
            }
            break;

        case gameStates.Death:
            backgroundMusic.volume -= 0.01f;
            if (backgroundMusic.volume <= 0.0f)
            {
                backgroundMusic.Stop();

                backgroundMusic.volume = 1;

                backgroundMusic.PlayOneShot(gameOverSFX);

                gameState = gameStates.GameOver;
            }
            break;

        case gameStates.BeatLevel:
            backgroundMusic.volume -= 0.01f;
            if (backgroundMusic.volume <= 0.0f)
            {
                AudioSource.PlayClipAtPoint(beatLevelSFX, gameObject.transform.position);

                gameState = gameStates.GameOver;
            }
            break;

        case gameStates.GameOver:
            // nothing
            break;
        }
    }
Example #23
0
 private void Restart()
 {
     _gameSpeed    = 5f;
     _speedUpTimer = 0;
     _score        = 0;
     SpawnBall();
     _gameState = gameStates.game;
 }
Example #24
0
 public void Start()
 {
     currentState = gameStates.login;
     //loginscreen.Initialize();
     loginScreen.Initialize(Screen.height, Screen.width, buttonHeight, buttonWidth, fieldHeight, fieldWidth);
     gameMenu.Initialize(Screen.height, Screen.width, buttonHeight, buttonWidth, fieldHeight, fieldWidth);
     //profiletest.Initialize (Screen.height,Screen.width,buttonHeight,buttonWidth,fieldHeight,fieldWidth);
 }
Example #25
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     gamep            = new GamePlayState();
     mapsel           = new MapSelectorState();
     currentGameState = gameStates.gamePlay;
 }
Example #26
0
 /// <summary>
 /// This function switches only to player 2, used for testing purposes.
 /// </summary>
 public void SwitchToPlayer2()
 {
     if (currentState == gameStates.PLAYL)
     {
         turnPrompt.text = "Player 2's Turn!";
         currentState    = gameStates.TRANSITTOR;
     }
 }
Example #27
0
 public void GameIsLose(bool lose)
 {
     currentState = "lose";
     myState      = gameStates.lose;
     Debug.Log("You Lose!");
     Cursor.visible = true;
     GameObject.FindGameObjectWithTag("Player").GetComponent <playerMovement>().inputActive = false;
     GameObject.FindGameObjectWithTag("MainCamera").GetComponent <mouseMove>().inputActive  = false;
 }
Example #28
0
 public void GameIsWin(bool win)
 {
     currentState = "win";
     myState      = gameStates.win;
     Debug.Log("You win!");
     Cursor.visible = true;
     GameObject.FindGameObjectWithTag("Player").GetComponent <playerMovement>().inputActive = false;
     GameObject.FindGameObjectWithTag("MainCamera").GetComponent <mouseMove>().inputActive  = false;
 }
Example #29
0
 /// <summary>
 /// Start the Main menu background simulation
 /// </summary>
 public void MenuBackGroundGame()
 {
     Reset();
     gameState = gameStates.MenuMode;
     SC.SetGameState(gameStates.MenuMode);
     ResetObjectPools();
     StartCoroutine(asteroidCoroutine);
     StartCoroutine(menuMissileCoroutine);
 }
Example #30
0
 private void DoSomething(string v, gameStates gs)
 {
     print("The game is " + v);
     if (gs != gameStates.Ending)
     {
         Start();
     }
     currentState = gs;
 }
Example #31
0
 public void changeState( gameStates newState )
 {
     switch( newState ){
         default:
         {
             break;
         }
     }
 }
Example #32
0
 //oyunu başlatıyoruz
 private void StartGame()
 {
     if (gameState == gameStates.start)
     {
         if (Input.GetMouseButtonDown(0))
         {
             gameState = gameStates.run;
         }
     }
 }
Example #33
0
    public void StopGame()//endgame
    {
        GAME_STATE = gameStates.end;
        Hub.inst.StopHub();

        // Advertisement.Show();

        UiEndGamePanel.inst.ControlPanel("end");
        EventController("endGame");
    }
    void Update()
    {
        switch (gameState)
        {
            case gameStates.Playing:
                if (playerHealth.isAlive == false)
                {
                    // update gameState
                    gameState = gameStates.Death;

                    // set the end game score
                    gameOverScoreDisplay.text = gameOverScoreDisplay.text + mainScoreDisplay.text;

                    // switch which GUI is showing
                    mainCanvas.SetActive (false);
                    gameOverCanvas.SetActive (true);
                } else if (canBeatLevel && score>=beatLevelScore) {
                    // update gameState
                    gameState = gameStates.BeatLevel;

                    // hide the player so game doesn't continue playing
                    player.SetActive(false);

                    // switch which GUI is showing
                    mainCanvas.SetActive (false);
                    beatLevelCanvas.SetActive (true);
                }
                break;
            case gameStates.Death:
                backgroundMusic.volume -= 0.01f;
                if (backgroundMusic.volume<=0.0f) {
                    AudioSource.PlayClipAtPoint (gameOverSFX,gameObject.transform.position);

                    gameState = gameStates.GameOver;
                }
                break;
            case gameStates.BeatLevel:
                backgroundMusic.volume -= 0.01f;
                if (backgroundMusic.volume<=0.0f) {
                    AudioSource.PlayClipAtPoint (beatLevelSFX,gameObject.transform.position);

                    gameState = gameStates.GameOver;
                }
                break;
            case gameStates.GameOver:
                // nothing
                break;
        }
    }
 public void callGameOver()
 {
     currentState = gameStates.GAMEOVER;
 }
        private void UpdatePlay(GameTime gameTime)
        {
            if (isPaused)
                return;

            inGameTotalTime.ElapsedGameTime += gameTime.ElapsedGameTime;

            //demo code
            if (!(ResourceManager.Instance.ActivePlayerList.Count == 0))
            {
                if(gameTime.TotalGameTime.TotalMilliseconds % 4000 <= 5) 
                    SpawnEnemy();
            }

            // TODO: Add your update logic here
            ResourceManager.Instance.Update(gameTime);

            if (ResourceManager.Instance.ActivePlayerList.Count == 0)
            {
                this.GameState = gameStates.GameOver;
            }

            base.Update(gameTime);
        }
Example #37
0
	//Sets game state to Playing
	public void ResumeGame(){
		//Debug.Log ("Game Manager RestartGame");
		pauseCanvas.gameObject.SetActive (false);
		inGameCanvas.gameObject.SetActive (true);
		gameState = gameStates.Playing;
		Time.timeScale = 1;
	}
Example #38
0
	//Sets game state to Paused
	public void PauseGame(){
		//Debug.Log ("Game Manager PauseGame");
		inGameCanvas.gameObject.SetActive (false);
		pauseCanvas.gameObject.SetActive (true);
		gameState = gameStates.Paused;
		Time.timeScale = 0;
	}
Example #39
0
	//As kitty gets destroyed when crushed thus reinstantiate it after game over
	//Sets game state to GameOver
	public void GameOver(){
		//Debug.Log ("Game Manager GameOver");
		Debug.Log("Game score = " + score);
		Debug.Log("Multiplier = " + multiplier);
		Debug.Log("Next milestone = " + milestone);
		Debug.Log("crushed count = " + crushedCount);

		inGameCanvas.gameObject.SetActive (false);
		gameOverCanvas.gameObject.SetActive (true);
		gameState = gameStates.GameOver;

		//update the number of games played in var and PlayerPrefs THEN
		//Check for gamesPlayed based achievements
		gamesPlayed++;
		PlayerPrefs.SetInt (GooglePlayManager.instance.currentAccount + "_gamesPlayed", gamesPlayed);
		if (gamesPlayed >= 10) {
			GooglePlayManager.instance.UnlockAchievement (GPConstants.GPGSIds.achievement_10_games);
		}
		if (gamesPlayed >= 50) {
			GooglePlayManager.instance.UnlockAchievement (GPConstants.GPGSIds.achievement_50_games);
		}
		if (gamesPlayed >= 100) {
			GooglePlayManager.instance.UnlockAchievement (GPConstants.GPGSIds.achievement_100_games);
		}

		//Set score and fish count in UI and Vars
		gameOverScoreText.text = score.ToString ();
		fishCount += gameFishCount;
		gameOverFishCountText.text = fishCount.ToString ();

		//if high score is made : update bestScore and add it to leaderboards
		if (score > bestScore) {
			bestScore = score;

			GooglePlayManager.instance.OnAddScoreToLeaderBorad ();
		}
		gameOverBestScoreText.text = "Best Score " + bestScore.ToString();

		//Set BestScore and Fish Cont in Player Prefs
		PlayerPrefs.SetInt (GooglePlayManager.instance.currentAccount + "_bestScore", bestScore);
		PlayerPrefs.SetInt (GooglePlayManager.instance.currentAccount + "_fishCount", fishCount);

		resetGame ();
		Time.timeScale = 0;
		Instantiate (kitty);
	}
Example #40
0
	public void CreditsPage(){
		mainMenuCanvas.gameObject.SetActive (false);
		creditsCanvas.gameObject.SetActive (true);
		gameState = gameStates.Credits;
	}
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
            case gameStates.START:
                player.position = startPosPlayer;
                currentState = gameStates.WAIT;
                pontos = 0;
                break;

            case gameStates.WAIT:
                player.position = startPosPlayer;

                break;
            case gameStates.INGAME:
                setScoreText(pontos.ToString());

                break;
            case gameStates.GAMEOVER:

                currentTime += Time.deltaTime;

                if (currentTime >= timeToRestart)
                {
                    currentTime = 0;
                    currentState = gameStates.RANKING;
                    setScoreVisible(false);
                    resetGame();
                }
                break;
            case gameStates.RANKING:
                player.position = startPosPlayer;
                setScoreVisible(false);
                break;
        }
    }
Example #42
0
    void Update()
    {
        killCount.text = "<color=#" + ColorUtility.ToHtmlStringRGB(new Color(0.87f, 0.541f, 0, 1)) + ">Kill Count</color>\n<color=#" + ColorUtility.ToHtmlStringRGB(Color.white) + ">HealBots:</color> " + healBotKillCount + "\n<color=#" + ColorUtility.ToHtmlStringRGB(Color.white) + ">FightBots:</color> " + fightBotKillCount;

        if (targets.Count == 0)
        {
            gameState = gameStates.GameOver;
        }
        if (waveTextDisplay != null)
        {
            waveTextDisplay.text = (WaveManager.wm.currentWave).ToString();
        }
        switch (gameState)
        {
            case gameStates.Playing:

                if (!isAnyTarget())
                {
                    // update gameState
                    gameState = gameStates.Death;
                }
                /*if (playerHealth.isAlive == false)
                {
                    // update gameState
                    gameState = gameStates.Death;

                    // set the end game score
                    gameOverScoreDisplay.text = mainScoreDisplay.text;

                    // switch which GUI is showing
                    mainCanvas.SetActive (false);
                    gameOverCanvas.SetActive (true);
                } else if (canBeatLevel && score>=beatLevelScore) {
                    // update gameState
                    gameState = gameStates.BeatLevel;

                    // hide the player so game doesn't continue playing
                    player.SetActive(false);

                    // switch which GUI is showing
                    mainCanvas.SetActive (false);
                    beatLevelCanvas.SetActive (true);
                }*/
                break;
            case gameStates.WaitingWave:
                break;
            case gameStates.Death:
                if (backgroundMusic != null)
                {
                    backgroundMusic.volume -= 0.01f;
                    if (backgroundMusic.volume <= 0.0f)
                    {
                        AudioSource.PlayClipAtPoint(gameOverSFX, gameObject.transform.position);

                        gameState = gameStates.GameOver;
                    }
                }
                break;
            case gameStates.BeatLevel:
                if (backgroundMusic != null)
                {
                    backgroundMusic.volume -= 0.01f;
                    if (backgroundMusic.volume <= 0.0f)
                    {
                        AudioSource.PlayClipAtPoint(beatLevelSFX, gameObject.transform.position);

                        gameState = gameStates.GameOver;
                    }
                }
                break;
            case gameStates.GameOver:
                gameOverCanvas.SetActive(true);
                gameOverScoreDisplay.text = "<color=#" + ColorUtility.ToHtmlStringRGB(new Color(0.87f, 0.541f, 0, 1)) + ">Bot Score: </color>" + Mathf.Round(finalScore * Time.timeSinceLevelLoad);
                mainCanvas.GetComponent<TimerController>().enabled = false;
                backgroundMusic.pitch = 0.25f;

                Time.timeScale = 0.0f;
                break;
        }
    }
 private void gameOverTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     gameOverTimer.Stop();
     GameState = gameStates.Menu;
 }
 private void ParseMenuAction()
 {
     if (this.MenuState == MenuStates.Main)
     {
         if (MenuIndex == 0)
         {
             //Start game
             GameState = gameStates.Play;
         }
         else if (MenuIndex == 1)
         {
             //About page
             this.MenuState = MenuStates.About;
         }
         else if (MenuIndex == 2)
         {
             //Exit
             this.Exit();
         }
     }
     else if (this.MenuState == MenuStates.About)
     {
         MenuIndex = 1;
         this.MenuState = MenuStates.Main;
     }
 }
Example #45
0
File: Boss.cs Project: SeiZon/Fade
    void die()
    {
        //turn white

        if (colorCode >= 1)
        {
            //destroy gameobject
            Instantiate(bossDieParticle, transform.position, Quaternion.identity);
            GetComponent<MeshRenderer>().enabled = false;
            GetComponent<BoxCollider>().enabled = false;

            if (particleSystemDying.isPlaying) particleSystemDying.Stop();

            audio_misc.PlayOneShot(sndDie);

            gameState = gameStates.ending;
        }
        else
        {
            if (!particleSystemDying.isPlaying)
            {
                audio_misc.PlayOneShot(sndDying);
                particleSystemDying.Play();
            }

            colorCode += 0.002F;
            myMaterial.SetColor("_Color", new Color(colorCode, colorCode, colorCode, 255));
        }
    }
 public void startGame()
 {
     currentState = gameStates.INGAME;
     setScoreVisible(true);
 }
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            fontPosition = new Vector2(_position.X - 720, _position.Y - 380);   // Font position set to follow player

            MouseState mouse = Mouse.GetState();
            IsMouseVisible = true;

            //rotation = (float)Math.Atan2(distance.Y, distance.X);     Set for player to look at mouse and rotate with it accordingly



            if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                rotation -= 0.1f;       // Rotates ship to the left when A is pressed
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                rotation += 0.1f;       // Rotates ship to the right when D is pressed
            }


            _rectangle = new Rectangle((int)_position.X, (int)_position.Y, _texture.Width, _texture.Height);    // Rectangle is set to player position and texture size
            _position = _velocity + _position;
            _origin = new Vector2(_rectangle.Width / 2, _rectangle.Height / 2); // Center of player texture



            switch (currentGameState)
            {
                case gameStates.Waiting:

                    camera.center = new Vector2(0, 0);

                    if (Keyboard.GetState().IsKeyDown(Keys.D1))  // If 1 is pressed in character selection menu
                    {
                        currentGameState = gameStates.InGame;
                        _texture = Content.Load<Texture2D>("Sprites/Player");   // Sets player texture to this
                        ammoFont = 15;  // This is there to keep count of current ammo
                        _position = new Vector2(300, 250);
                    }

                    if (Keyboard.GetState().IsKeyDown(Keys.D2)) // If 2 is pressed in character selection menu
                    {
                        currentGameState = gameStates.InGame;
                        _texture = Content.Load<Texture2D>("Sprites/Player2");  // Sets player texture to this
                        ammoFont = 10;
                        _position = new Vector2(400, 350);  // Sets position
                    }
                    if (Keyboard.GetState().IsKeyDown(Keys.D3))
                    {
                        currentGameState = gameStates.InGame;
                        _texture = Content.Load<Texture2D>("Sprites/Player3");
                        ammoFont = 3;
                        _position = new Vector2(500, 450);
                    }
                    if (Keyboard.GetState().IsKeyDown(Keys.D4))
                    {
                        currentGameState = gameStates.InGame;
                        _texture = Content.Load<Texture2D>("Sprites/Player4");
                        ammoFont = 30;
                        _position = new Vector2(600, 550);
                    }
                    break;

                case gameStates.InGame:

                    if (Keyboard.GetState().IsKeyDown(Keys.W))
                    {
                        _velocity.X = (float)Math.Cos(rotation) * tangentialVelocity;   // Lets the player move forward according to the direction it is facing
                        _velocity.Y = (float)Math.Sin(rotation) * tangentialVelocity;
                    }
                    else if (_velocity != Vector2.Zero)
                    {
                        Vector2 i = _velocity;

                        _velocity = i -= friction * i; // Lets the ship drift for a while after W key has been let go
                    }
                    if (Keyboard.GetState().IsKeyDown(Keys.Space) && pastKey.IsKeyUp(Keys.Space))
                    {
                        ammoFont--;
                        if (ammoFont <= 0)      // Changes ammo count for font
                        {
                            ammoFont = 0;
                        }
                        Shooting(); // Updates the Shooting method
                    }
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                    {
                        currentGameState = gameStates.Pause;
                    }
                    break;

                case gameStates.Pause:

                    pauseMenu.Update(gameTime, this);
                    break;

                case gameStates.Main:

                    mainMenu.Update(this);
                    break;
            }


            pastKey = Keyboard.GetState();  // Updates the variable
            UpdateProjectiles();

            camera.Update(gameTime, this);

            #region Boundaries
            if (_position.X < -275)
            {
                _position.X = -275;
            }
            if (_position.Y < -510)          // Keeps the player from going off screen
            {
                _position.Y = -510;
            }

            if (_position.X > 2525)
            {
                _position.X = 2525;
            }

            if (_position.Y > 1500)
            {
                _position.Y = 1500;
            }
            #endregion

            base.Update(gameTime);
        }
Example #48
0
	public void OpenAvatarStore(){
		mainMenuCanvas.gameObject.SetActive (false);
		avatarStoreCanvas.gameObject.SetActive (true);

		gameState = gameStates.AvatarStore;

		//Set Avatar Store login info and GameOver login info
		if (Social.localUser.authenticated) {
			AvatarSelector.instance.avatarStoreLoginInfo.text = "Logged in as: " + GooglePlayManager.instance.userName;
			AvatarSelector.instance.gameOverLoginInfo.text = "Logged in as: " + GooglePlayManager.instance.userName;
		}
		else {
			if (GooglePlayManager.instance.userName.Equals ("Local")) {
				AvatarSelector.instance.avatarStoreLoginInfo.text = "Login to connect with Google Play Services";
				AvatarSelector.instance.gameOverLoginInfo.text = "Login to connect with Google Play Services";
			} else {
				AvatarSelector.instance.avatarStoreLoginInfo.text = "Logged in as: " +  GooglePlayManager.instance.userName + "(Locally)";
				AvatarSelector.instance.gameOverLoginInfo.text = "Logged in as: " +  GooglePlayManager.instance.userName + "(Locally)";
			}
		}
	}
Example #49
0
	//Sets game state to MainMenu
	public void MainMenu(){
		if (gameState == gameStates.Paused) {
			//Destroy(CatController.instance.gameObject);
			Destroy(KittyController.instance.gameObject);
			Instantiate (kitty);
		}
		resetGame ();

		//Debug.Log ("Game Manager MainMenu");
		gameOverCanvas.gameObject.SetActive (false);
		pauseCanvas.gameObject.SetActive (false);
		avatarStoreCanvas.gameObject.SetActive (false);
		mainMenuCanvas.gameObject.SetActive (true);
		creditsCanvas.gameObject.SetActive (false);
		gameState = gameStates.MainMenu;

		//set bestScore and fishCount UI Texts
		bestScore = PlayerPrefs.GetInt(GooglePlayManager.instance.currentAccount + "_bestScore");
		fishCount = PlayerPrefs.GetInt(GooglePlayManager.instance.currentAccount + "_fishCount");

		mainMenuBestScoreText.text = "Best Score " + bestScore.ToString ();
		mainMenuFishCountText.text = fishCount.ToString ();
		AvatarSelector.instance.avatarStoreFishCountText.text = fishCount.ToString ();
		Time.timeScale = 0;
	}
Example #50
0
        public GameScene()
        {
            try
            {
                //licence from server -- position x and y -- and then send back
                //the damage
                tcpclnt = new TcpClient();
                tcpclnt.Connect ("192.168.1.103", 8001);
                ns = tcpclnt.GetStream ();
                sw = new StreamWriter (ns);
                sr = new StreamReader (ns);

                //set up your own id and send to server
            //				if(!isSendIdToServer)
            //				{
            //					ID = "0";
            //					sw.WriteLine(ID);
            //					sw.Flush();
            //					isSendIdToServer = true;
            //				}

                text = sr.ReadLine (); // id + x + y;
                positionArray = text.Split (',');
                ID = positionArray [0]; //

                //Console.WriteLine("first time read =" + text);
                //incoming();
                listen = new Thread (new ThreadStart (incoming));
                listen.Start ();
            }
            catch
            {
                //ID = "1";
            }

            Initialize ();
            loop = true;
            currentState = gameStates.gamePlay;

            while (loop) {
                SystemEvents.CheckEvents ();
                Update ();
                Render ();
            }
        }
Example #51
0
	public void TutsPage(){
		mainMenuCanvas.gameObject.SetActive (false);
		tutsCanvas.gameObject.SetActive (true);
		gameState = gameStates.Tutorials;
	}
Example #52
0
 public void onMenuLoginButton()
 {
     disableAllGUI();
     gameState = gameStates.login;
 }
Example #53
0
	//Sets game state to Playing
	public void RestartGame(){
		//Debug.Log ("Game Manager RestartGame");
		gameOverCanvas.gameObject.SetActive (false);
		inGameCanvas.gameObject.SetActive (true);
		Time.timeScale = 1;
		gameState = gameStates.Playing;
		ObstacleGenerator.instance.StartGenerator();
	}
Example #54
0
        protected override void Update(GameTime gameTime)
        {
            switch (gameState)
            {
                case (gameStates.mainMenu):
                {
                    IsMouseVisible = true;
                    mouseOldState = mouseNewState;
                    mouseNewState = Mouse.GetState();

                    if (mouseNewState.LeftButton == ButtonState.Released && mouseOldState.LeftButton == ButtonState.Pressed)
                    {
                        if (startButton.rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y))
                        {
                            gameState = gameStates.playing;
                            reset();
                        }

                        else if (exitButton.rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y))
                        {
                            this.Exit();
                        }

                        else if (highscoresButton.rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y))
                        {
                            gameState = gameStates.highScores;
                        }
                    }
                    break;
                }

                case (gameStates.playing):
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                    {
                        gameState = gameStates.mainMenu;
                    }

                    if (!this.IsActive)
                    {
                        gameState = gameStates.paused;
                    }

                    IsMouseVisible = false;

                    if (player.lives < 0)
                    {
                        gameState = gameStates.gameOver;
                    }

                    keyOldState = keyNewState;
                    keyNewState = Keyboard.GetState();
                    if (ball.started)
                    {
                        ball.checkBrickCollisions();
                        ball.checkPlayerCollision(player);
                    }

                    ball.update(gameTime);

                    foreach (Brick element in bricks) //damaging the bricks after updating the ball to avoid multiple collisions
                    {
                        element.calculateBallDamage();
                    }

                    powerUps.RemoveAll(e => e.alive == false);
                    powerUps.ForEach(e => e.update());

                    shieldTimer.update(gameTime);
                    tripleShotTimer.update(gameTime);

                    player.update(gameTime);
                    if (keyNewState.IsKeyDown(Keys.Space) && keyOldState.IsKeyUp(Keys.Space) && ball.started == true)
                    {
                        player.shoot();
                    }

                    bullets.RemoveAll(e => e.alive == false);
                    bullets.ForEach(e => e.update());

                    explosions.RemoveAll(e => e.index >= 7);
                    explosions.ForEach(e => e.Update(gameTime));

                    fadingText.RemoveAll(e => e.color.A <= 40);
                    fadingText.ForEach(e => e.update());

                    if (levelClear())
                    {
                        nextLevel();
                    }
                    break;
                }

                case (gameStates.highScores):
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                    {
                        gameState = gameStates.mainMenu;
                    }
                    break;
                }

                case (gameStates.paused):
                {
                    if(this.IsActive)
                    {
                        gameState = gameStates.playing;
                    }
                    break;
                }

                case (gameStates.gameOver):
                {
                    keyOldState = keyNewState;
                    keyNewState = Keyboard.GetState();

                    Keys[] pressedKeys;
                    pressedKeys = keyNewState.GetPressedKeys();

                    foreach (Keys key in pressedKeys)
                    {
                        if (keyOldState.IsKeyUp(key))
                        {
                            if (key == Keys.Back && name.Length > 0)
                            {
                                name = name.Remove(name.Length - 1, 1);
                            }
                            else if (key == Keys.Space)
                            {
                                name = name.Insert(name.Length, " ");
                            }
                            else if (key == Keys.Enter)
                            {
                                highscores.Add(new HighScore(name, player.score));
                                sortHighScores();
                                gameState = gameStates.mainMenu;
                            }
                            else if(name.Length < 10 && key.ToString().Length == 1)
                            {
                                name += key.ToString();
                            }
                        }
                    }
                    break;

                }
            }

            base.Update(gameTime);
        }
Example #55
0
	//Sets game state to Playing
	public void StartGame(){
		//Debug.Log ("Game Manager StartGame");
		avatarStoreCanvas.gameObject.SetActive(false);
		mainMenuCanvas.gameObject.SetActive (false);
		inGameCanvas.gameObject.SetActive (true);
		gameState = gameStates.Playing;
		Time.timeScale = 1;

		ChangeAvatar ();
		ObstacleGenerator.instance.StartGenerator();

		AudioManager.instance.backgroundMusicSource.Play ();
		AudioManager.instance.crusherSource.Play ();
	}
Example #56
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            IsFixedTimeStep = false;
            graphics.SynchronizeWithVerticalRetrace = true;
            Window.AllowUserResizing = false;

            Content.RootDirectory = "Content";

            this.graphics.PreferredBackBufferWidth = 1000;
            this.graphics.PreferredBackBufferHeight = 650;
            graphics.ApplyChanges();
            gameState = gameStates.mainMenu;
        }
Example #57
0
	//Sets game state to MainMenu
	public void resetGame(){
		//Debug.Log ("Game Manager resetGame");
		//RESET SPEEDS: obstacles, belt, crusher
		Mover.speed = 2;
		ConveyerBeltMover.instance.speed = 0.2f;
		crusherAnimator.speed = 1.5f;
		AudioManager.instance.crusherSource.pitch = 1.25f;

		//start game with freezed time as we don't want things to move while in main menu state
		Time.timeScale = 0;

		//SET BACK THE GAME STATE TO MAIN MENU
		if(gameState != gameStates.GameOver)
			gameState = gameStates.MainMenu;

		//SET SCORE RELATED COUNTS BACK TO ORIGINAL VALUES
		score = 0;
		gameFishCount = 0;
		multiplier = 1;
		milestone = 10;
		crushedCount = 0;

		if(AudioManager.instance != null)
			AudioManager.instance.crusherSource.pitch = 1;

		//SET THE IN GAME UI TEXTS
		scoreText.text = score.ToString ();
		multiplierText.text = "x" + multiplier.ToString ();

		//DESTROY ANY REMAINING OBSTACLES
		if (ObstacleGenerator.instance != null && ObstacleGenerator.instance.generatedObstacles != null && ObstacleGenerator.instance.generatedObstacles.Count > 0) {
			foreach(GameObject go in ObstacleGenerator.instance.generatedObstacles) {
				Destroy (go);
			}
		}

		//ONLY FOR TESTING
		string consoleString = "Next milestone = " + milestone;
		consoleString += "       speed = " + Mover.speed;
		consoleString += "       count = " + crushedCount;
		consoleText.text = consoleString;
	}
        /// <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();

            KeyboardManager.Instance.Update(gameTime);
            MobSpawner.Instance.Update(gameTime);

            playerPosition = player1.Position;

            switch (GameState)
            {
                case gameStates.Menu:
                    UpdateMenu(gameTime);
                    break;
                case gameStates.Play:
                    UpdatePlay(gameTime);
                    if (player1.isGameOver)
                        GameState = gameStates.GameOver;
                    break;
                case gameStates.GameOver:
                    UpdateGameOver(gameTime);
                    break;
            }

            base.Update(gameTime);
        }
Example #59
0
 public void onMenuCreateAccountButton()
 {
     disableAllGUI();
     gameState = gameStates.createAccount;
 }
Example #60
0
        public void Update()
        {
            #region game state play
            if(currentState == gameStates.gamePlay)
            {
                //start time count down, when reach to 0, then jump to winning
                timer.Start();
                if(timer.ElapsedMilliseconds > 1000f)
                {
                    //if time count to 0, win the game
                    if(Int32.Parse(timeCount.Text) > 0)
                    {
                        timeCount.Text = (Int32.Parse(timeCount.Text) - 1).ToString();
                        timer.Reset();
                    }
                    else
                    {
                        currentState = gameStates.gameWin;
                        timer.Stop();
                    }
                }

                //if the health count to 0, lose the game
                if(healthFourDelete && healthThreeDelete && healthTwoDelete && healthOneDelete)
                {
                    timer.Stop();
                    currentState = gameStates.gameOver;
                }

                foreach (var touchData in Touch.GetData(0)) {
                    if (touchData.Status == TouchStatus.Down) {
                        X = (int)((touchData.X + 0.5f) * 960.0);
                        Y = (int)((touchData.Y + 0.5f) * 544.0);
                        x = X.ToString ();
                        y = Y.ToString ();
            //						xy = x + "," + y;
            //						if (xy != z) {
            //							sw.WriteLine (xy);
            //							sw.Flush ();
            //						}
                        //check whether the touch in the dots areas
                        foreach(var eachDot in dots)
                        {
                            if((System.Math.Abs(eachDot.Position.X - X)<40) && (System.Math.Abs(eachDot.Position.Y - Y)<40))
                            {
                                //remove the code, add score, explosion happen
                                eachDot.isAlive = false;
                                var scoreInt = Int32.Parse(score.Text);
                                scoreInt += 1;
                                totalScore = scoreInt;
                                score.Text = scoreInt.ToString();
                                ex = new Explosion(explosionPic,new Vector3(eachDot.Position.X, eachDot.Position.Y, eachDot.Position.Z));
                                Support.SoundSystem.Instance.Play("explosionMissile.wav");
                                currentState = gameStates.explosion;
                            }
                        }
                    }
                }

                //this reads from hits list. Checks to see what ID it has; based on this it will draw a differtn color dot.
                if (hits.Count != 0) {
                    for (int i = hits.Count - 1; i >=0; --i) {
                        if (hits.Count != count) {
                            if (hits [i].Xpos > 340 && hits [i].Xpos < 390) {
                                if (hits [i].Ypos > 120 && hits [i].Ypos < 170) {
                                    hits [i].ID = "1";
                                }
                            }

                            if (hits [i].Xpos > 105 && hits [i].Xpos < 130) {
                                if (hits [i].Ypos > 165 && hits [i].Ypos < 197) {
                                    hits [i].ID = "2";
                                }
                            }

                            if (hits [i].Xpos > 190 && hits [i].Xpos < 215) {
                                if (hits [i].Ypos > 155 && hits [i].Ypos < 180) {
                                    hits [i].ID = "3";
                                }
                            }

                            if (hits [i].Xpos > 170 && hits [i].Xpos < 190) {
                                if (hits [i].Ypos > 176 && hits [i].Ypos < 196) {
                                    hits [i].ID = "4";
                                }
                            }

                            if (hits [i].ID == ID) {
                                    var randomGenerateX = generator.Next (lower, upper);
                                    // Console.WriteLine("dotsX =" + randomGenerateX);
                                    if(randomGenerateX < 490)
                                    {
                                        dots.Add (new SimpleSprite (AppMain.graphics, texture2_left));
                                    }

                                    if(randomGenerateX > 490)
                                    {
                                        dots.Add (new SimpleSprite (AppMain.graphics, texture2_right));
                                    }

                                    if(randomGenerateX == 490)
                                        dots.Add (new SimpleSprite (AppMain.graphics, texture2));

                                    dots [count_2].Position.X = randomGenerateX;
                                    dots [count_2].starting_x_pos = randomGenerateX;
                                    dots [count_2].rec = new Rectangle (dots [count_2].Position.X, dots [count_2].Position.Y, texture2.Width, texture2.Height);
                                    dots [count_2].Position.Y = 1;
                                    //Console.WriteLine("dotsX =" + dots[count_2].Position.X + " Y =" + dots[count_2].Position.Y);
                                    count_2++;
                            }
                            /*if (hits [i].ID != ID) {

                                dots_2.Add (new SimpleSprite (graphics, texture3));
                                dots_2 [count_3].Position.X = hits [i].Xpos - 10.0f;
                                dots_2 [count_3].Position.Y = hits [i].Ypos - 10.0f;

                                count_3++;
                            }*/

                            count = hits.Count;
                        }
                    }
                }
                /*foreach(Hits h in hits)
                {
                    if(h.ID == ID)
                    {
                        dots.Add (new SimpleSprite (graphics, texture2));
                        dots [count_2].Position.X = h.Xpos - 10.0f;
                        dots [count_2].Position.Y = h.Ypos - 10.0f;
                        //count_2++;
                    }

                    else
                    {
                        dots_2.Add (new SimpleSprite (graphics, texture3));

                    }

                }
                */

                foreach (SimpleSprite s in dots) {
                    if (dots.Count > 0) {
                        //if((skyline_1.X + skyline_1.Width) < s.Position.X || (s.rec.X + s.rec.Width) < skyline_1.X || (skyline_1.Y + skyline_1.Height) < s.rec.Y || (s.rec.Y + s.rec.Height) < skyline_1.Y)
                        if (s.Position.Y > 410 && s.Position.X < 240) {
                            s.isAlive = false;
                            if(firstTime_1 == true)
                            {
                                skyline_1_isHit = true;
                                //Support.SoundSystem.Instance.Play("missileBroken.wav");
                                if(!healthFourDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_04);
                                   healthFourDelete = true;
                                    totalScore -= 10;
                                }
                                else if(!healthThreeDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_03);
                                   healthThreeDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthTwoDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_02);
                                   healthTwoDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthOneDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_01);
                                   healthOneDelete = true;
                                     totalScore -= 10;
                                }

                                sw.WriteLine(ID);//if the image change, send to server
                                sw.Flush();
                            if (skyline_1_isHit == true) {
                                firstTime_1 = false;
                                play_Sky_Line_1 = Fire_skyline_1;
                                play_Sky_Line_1.Position.X = 0;
                                play_Sky_Line_1.Position.Y = 0;
                            }
                        }

                        }
                        if (s.Position.Y > 410 && s.Position.X > 240 && s.Position.X < 480) {
                            s.isAlive = false;
                            if(firstTime_2 == true)
                            {
                                skyline_2_isHit = true;
                                //Support.SoundSystem.Instance.Play("missileBroken.wav");
                                if(!healthFourDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_04);
                                   healthFourDelete = true;
                                    totalScore -= 10;
                                }
                                else if(!healthThreeDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_03);
                                   healthThreeDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthTwoDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_02);
                                   healthTwoDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthOneDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_01);
                                   healthOneDelete = true;
                                     totalScore -= 10;
                                }

                                sw.WriteLine(ID);
                                sw.Flush();
                                if (skyline_2_isHit == true) {
                                    firstTime_2 = false;
                                    play_Sky_Line_2 = Fire_skyline_2;
                                    play_Sky_Line_2.Position.X = 240;
                                    play_Sky_Line_2.Position.Y = 0;
                                }
                            }

                        }

                        if (s.Position.Y > 410 && s.Position.X > 480 && s.Position.X < 720) {
                            s.isAlive = false;
                            if(firstTime_3 == true)
                            {
                                skyline_3_isHit = true;
                                //Support.SoundSystem.Instance.Play("missileBroken.wav");
                                if(!healthFourDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_04);
                                   healthFourDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthThreeDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_03);
                                   healthThreeDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthTwoDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_02);
                                   healthTwoDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthOneDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_01);
                                   healthOneDelete = true;
                                     totalScore -= 10;
                                }

                                sw.WriteLine(ID);
                                sw.Flush();
                                if (skyline_3_isHit == true) {
                                    firstTime_3 = false;
                                    play_Sky_Line_3 = Fire_skyline_3;
                                    play_Sky_Line_3.Position.X = 480;
                                    play_Sky_Line_3.Position.Y = 0;
                                }
                            }

                        }

                        if (s.Position.Y > 410 && s.Position.X > 720) {
                            s.isAlive = false;
                            if(firstTime_4 == true)
                            {
                                skyline_4_isHit = true;

                                if(!healthFourDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_04);
                                   healthFourDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthThreeDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_03);
                                   healthThreeDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthTwoDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_02);
                                   healthTwoDelete = true;
                                     totalScore -= 10;
                                }
                                else if(!healthOneDelete)
                                {
                                   _uiScene.RootWidget.RemoveChild(healthbar_01);
                                   healthOneDelete = true;
                                     totalScore -= 10;
                                }

                                sw.WriteLine(ID);
                                sw.Flush();
                                if (skyline_4_isHit == true) {
                                    firstTime_4 = false;
                                    play_Sky_Line_4 = Fire_skyline_4;
                                    play_Sky_Line_4.Position.X = 720;
                                    play_Sky_Line_4.Position.Y = 0;
                                }
                            }
                        }

                    }
                }

                //REMOVE THE DOTS WHEN OFF THE SCREEN
            //				for (int i = dots.Count - 1; i > 0; i--)
            //	            {
            //	                SimpleSprite o = dots[i];
            //	                if (!o.isAlive)
            //	                {
            //	                    dots.Remove(o);
            //	                }
            //	            }
            }
            #endregion

            #region game state game over
            if(currentState == gameStates.gameOver)
            {
                if(Director.Instance.CurrentScene.IsRunning)
                {
             			   Director.Instance.ReplaceScene(new LoseScene());
                }
            }
            #endregion

            #region game state winning
            if(currentState == gameStates.gameWin)
            {
                if(Director.Instance.CurrentScene.IsRunning)
                {
                    Director.Instance.ReplaceScene(new WinningScene());
                }
            }
            #endregion

            #region game state explosion
            if(currentState == gameStates.explosion)
            {
                var explosionAliveDetection = ex.getSpriteAlive();
                if(explosionAliveDetection == true)
                    ex.Update();
                else
                    currentState = gameStates.gamePlay;
            }
            #endregion

            //Director.Instance.Update();
            //Console.WriteLine("hits ==" + hits.Count);
        }