Пример #1
0
        public static void HandleInput(GAMESTATE gameState)
        {
            for (int i = keysDown.Count() - 1; i >= 0; i--)
            {
                if (Keyboard.GetState().IsKeyUp(keysDown[i]))
                    keysDown.Remove(keysDown[i]);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !keysDown.Contains(Keys.Enter))
            {
                if (gameState == GAMESTATE.PLAYING)
                    Game1.gameState = GAMESTATE.PAUSED;
                else
                    Game1.gameState = GAMESTATE.PLAYING;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Space) && !keysDown.Contains(Keys.Space))
                Player.player.Fire();

            foreach (Keys k in Keyboard.GetState().GetPressedKeys())
            {
                keysDown.Add(k);
            }

            if (gameState == GAMESTATE.PLAYING)
                if (!Playing())
                    Game1.gameState = GAMESTATE.START_SCREEN;
        }
Пример #2
0
 void Start()
 {
     SoundManager.SOUNDS.playSound(SoundManager.UI_CLICK,CameraCollider.MATHIUS_EARTH_CAM);
     stats = MasterController.BRAIN.sm();
     gs = GAMESTATE.RESUME;
     MUI = gameObject.GetComponent<Mathius_UI>();
 }
Пример #3
0
	public void SetGameOver(int score){
		curState=GAMESTATE.GAMEOVER;
		curScore=score;
		if(curScore>PlayerPrefs.GetInt("HightScore",0)){
			PlayerPrefs.SetInt("HightScore",curScore);
		}
		StartCoroutine(UIAnimation());
		StartCoroutine(IESoundPitchDown());
	}
Пример #4
0
    void BuildingUi()
    {
        PlayerUi();

        Rect button = new Rect(Screen.width / 2 - 100, Screen.height - 60, 200, 50);

        GUI.Box(gameStateRect, onPlayer.name + " - BuildingSetting");

        if(GUI.Button(button, "Setting Done"))
        {
            BuildingManager.Instance().OffBuilding();
            gameState = GAMESTATE.TURN;
        }
    }
Пример #5
0
    public void SettingDone()
    {
        if(gameState == GAMESTATE.FIRSTBUILDING)
        {
            BuildingManager.Instance().OffBuilding();

            BuildingManager.Instance().OnStreet();
            gameState = GAMESTATE.FIRSTSTREET;
        }
        else if(gameState == GAMESTATE.FIRSTSTREET)
        {
            BuildingManager.Instance().OffStreet();
            gameState = GAMESTATE.FIRSTSETTING;
        }
    }
 private void canvasMain_Update(ICanvasAnimatedControl sender, CanvasAnimatedUpdateEventArgs args)
 {
     switch(State)
     {
         case GAMESTATE.ADDING_ROOMS:
             if (Rooms.Count < nMaxRooms)
             {
                 Rooms.Add(Room.CreateRandomRoom());
             }
             else
             {
                 State = GAMESTATE.SEPARATING_ROOMS;
             }
             break;
         case GAMESTATE.SEPARATING_ROOMS:
             break;
         case GAMESTATE.DONE:
             break;
     }
 }
Пример #7
0
 void FirstSetting()
 {
     if(turnNum == PlayerManager.Instance().playerNum * 2)
     {
         onPlayer = PlayerManager.Instance().GetPlayer(0);
         gameState = GAMESTATE.IDLE;
     }
     else if(turnNum >= PlayerManager.Instance().playerNum)
     {
         turnNum++;
         int num = (PlayerManager.Instance().playerNum * 2) - turnNum;
         Debug.Log(num);
         onPlayer = PlayerManager.Instance().GetPlayer(num);
         BuildingManager.Instance().OnBuilding();
         gameState = GAMESTATE.FIRSTBUILDING;
     }
     else
     {
         turnNum++;
         onPlayer = PlayerManager.Instance().GetPlayer(turnNum - 1);
         BuildingManager.Instance().OnBuilding();
         gameState = GAMESTATE.FIRSTBUILDING;
     }
 }
Пример #8
0
        public void Congrats()
        {
            congratsScreen = new CongratsScreen(this);
            gameState = GAMESTATE.FINISH;

            level1 = null;
            level2 = null;
            level3 = null;
        }
Пример #9
0
 protected private GAMESTATE StartTrading(bool vendorIsAlive, TradeMenu tradeMenu, Player player, Vendor vendor, GAMESTATE gameState, Inventory inventory) // attacks if colliding character is alive, else do nothing
 {
     if (vendorIsAlive)
     {
         gameState = tradeMenu.Begin(player, vendor, inventory);
     }
     return(gameState);
 }
Пример #10
0
 public void UnPause()
 {
     _state = GAMESTATE.PLAYING;
     Core.menus.GotToMenu("GameUI");
     Time.timeScale = 1.0f;
 }
Пример #11
0
 private void GetRestart()
 {
     GamePadState pad = GamePad.GetState(PlayerIndex.One);
     if (pad.IsButtonDown(Buttons.Start))
     {
         player.Position = GameConfig.PlayerStartPos;
         player.Update(cam, false);
         GameState = GAMESTATE.MainGame;
     }
 }
Пример #12
0
        /// <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)
        {
            KeyboardState keyState = Keyboard.GetState ();
            MouseState mouseState = Mouse.GetState ();
            Vector2 touchPos = new Vector2 (mouseState.X, mouseState.Y);
            bool touched = false;
            #if __MonoCS__
            TouchCollection touchCollection = TouchPanel.GetState ();

            if (touchCollection.Count > 0) {
                touchPos.X = touchCollection [0].Position.X;
                touchPos.Y = touchCollection [0].Position.Y;
                touched = true;
            }
            #endif

            if (mouseState.LeftButton == ButtonState.Pressed) {
                touched = true;
            }

            switch (gameState)
            {
                case GAMESTATE.START:
                {
                    int startAt = 200;
                    int border = 20;
                    highlighted = -1;
                    for (int i = 0; i < menuOptions.Count(); i++)
                    {
                        Vector2 textSize = spriteFont.MeasureString(menuOptions[0]);
                        Vector2 pos = new Vector2(50, startAt + ((textSize.Y + border) * i));
                        Rectangle textBounds = new Rectangle((int)pos.X, (int)pos.Y, (int)textSize.X, (int) textSize.Y);
                        Vector2 mousePos = new Vector2(mouseState.X, mouseState.Y);
                        if ((touchPos.X > textBounds.X) && (touchPos.X < textBounds.X + textBounds.Width)
                            && (touchPos.Y > textBounds.Y) && (touchPos.Y < textBounds.Y + textBounds.Height))
                        {
                            highlighted = i;
                        }
                    }

                    if (touched)
                    {
                        if (highlighted == 0)
                        {
                            leftScore = 0;
                            rightScore = 0;
                            rightBat.AiControlled = true;
                            leftBat.MouseControlled = true;
                            gameState = GAMESTATE.MIDDLE;
                            MediaPlayer.Stop();
                            ResetMouse();
                        }
                        if (highlighted == 1)
                        {
                            gameState = GAMESTATE.MIDDLE;
                            MediaPlayer.Stop();
                            ResetMouse();
                        }
                        if (highlighted == 2)
                        {
                            this.Exit();
                        }
                    }

                    break;
                }
                case GAMESTATE.MIDDLE:
                {
                    for (int i = 0; i < children.Count; i++)
                    {
                        children[i].Update(gameTime);
                    }
                    break;
                }
                case GAMESTATE.END:
                {
                    if (touched)
                    {
                        gameState = GAMESTATE.START;
                    }
                    break;
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            base.Update(gameTime);
        }
Пример #13
0
        public void ViewScore()
        {
            scoreScreen = new ScoreScreen(this);
            gameState = GAMESTATE.SCORE;

            congratsScreen = null;
        }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     m_eGameState = GAMESTATE.E_PLAY;
     GamePlay();
 }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     gameState = GAMESTATE.CHOOSING_SKILL;
 }
Пример #16
0
 public void SetState(GAMESTATE NewState)
 {
     m_GameState = NewState;
 }
Пример #17
0
 //-----------------------------------------------------------------------------------------
 /// <summary>
 /// GameStateをセット
 /// </summary>
 public void SetGameState(GAMESTATE aGAMESTATE)
 {
     mGameState = aGAMESTATE;
 }
Пример #18
0
 public static void SetGameState(GAMESTATE s)
 {
     State = s;
 }
Пример #19
0
        public void LevelOne()
        {
            level1 = new GamePlayLevel1(this);
            gameState = GAMESTATE.LEVEL1;
            GameIndex = 1;

            levelSelectionScreen = null;

            Ammo = 20;
            TimeLimit = 50f;
            EnemyCount = 10;
            Health = 100;
        }
Пример #20
0
 public void done_attacking_enemies()
 {
     cur_state = GAMESTATE.DONE_ATTACKING;
     shadow_cards_leave_play();
     begin_refresh_phase();
 }
Пример #21
0
        public void LevelThree()
        {
            level3 = new GamePlayLevel3(this);
            gameState = GAMESTATE.LEVEL3;
            GameIndex = 3;

            levelSelectionScreen = null;

            Ammo = 60;
            TimeLimit = 120f;
            EnemyCount = 25;
            Health = 100;
        }
Пример #22
0
 public void finish_committing()
 {
     cur_state = GAMESTATE.STAGING;
     do_staging();
 }
Пример #23
0
 public void RightBatScores()
 {
     winSound.Play();
     rightScore++;
     if (rightScore == maxScore)
     {
         gameState = GAMESTATE.END;
         MediaPlayer.Play(startSong);
     }
     else
     {
         ResetGame();
     }
 }
Пример #24
0
 public void ChangeState(GAMESTATE state)
 {
     m_State = state;
     OnGameStateChanged?.Invoke(m_State);
 }
Пример #25
0
        /// <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()
        {
            Width = graphics.GraphicsDevice.Viewport.Width;
            Height = graphics.GraphicsDevice.Viewport.Height;

            gameState = GAMESTATE.START_SCREEN;
            contentRef = Content;
            new Player();

            base.Initialize();
        }
Пример #26
0
    private void ChangeState(GAMESTATE state)
    {
        switch (_gameState)
        {
        case GAMESTATE.INITILIZE:
            break;

        case GAMESTATE.GAMEPLAY:
            break;

        case GAMESTATE.PAUSE:
            if (state == GAMESTATE.GAMEPLAY)
            {
                StartCoroutine(StartGame());
            }
            break;

        case GAMESTATE.GAMEOVER:
            break;
        }
        _gameState = state;
        switch (state)
        {
        case GAMESTATE.INITILIZE:
            gridManager.Initilize(GridSize);
            goto default;

        case GAMESTATE.INITILIZECOMPLETE:
            fruitObj         = gridManager.SetCollectObject(CollectPrefab, PoolManager.GetInstance().GetPoolContainer(false), true, out fruitNode);
            currentNode      = gridManager.GetRandomPosition(10, 10);
            currentDirection = (TraversalDirection)(Random.Range(1, 4));
            SetInitilialPositions(currentNode, currentDirection);
            if (currentDirection == TraversalDirection.LEFT)
            {
                currentDirection = TraversalDirection.RIGHT;
            }
            else if (currentDirection == TraversalDirection.RIGHT)
            {
                currentDirection = TraversalDirection.LEFT;
            }
            else if (currentDirection == TraversalDirection.BOTTOM)
            {
                currentDirection = TraversalDirection.TOP;
            }
            else if (currentDirection == TraversalDirection.TOP)
            {
                currentDirection = TraversalDirection.BOTTOM;
            }
            goto default;

        case GAMESTATE.GAMEPLAY:
            StartCoroutine(StartGame());
            goto default;

        case GAMESTATE.PAUSE:
            goto default;

        case GAMESTATE.GAMEEND:
            StartCoroutine(ChangeState(GAMESTATE.GAMEOVER, 1.0f));
            goto default;

        case GAMESTATE.GAMEOVER:
            if (OnGameStateChangeEvent != null)
            {
                OnGameStateChangeEvent(_gameState);
            }
            SoundManager.AudioPlayEvent(ConstantsList.Sfx_GameOver);
            Score = _score;
            break;

        default:
            if (OnGameStateChangeEvent != null)
            {
                OnGameStateChangeEvent(_gameState);
            }
            break;
        }
    }
Пример #27
0
 private void UpdateMenu()
 {
     GamePadState pad = GamePad.GetState(PlayerIndex.One);
     if (pad.Buttons.Start == ButtonState.Pressed)
     {
         GameState = GAMESTATE.MainGame;
         NewGame();
     }
 }
Пример #28
0
 public void SetGameState(GAMESTATE aGameState)
 {
     m_CurrentGameState = aGameState;
 }
Пример #29
0
 void begin_quest_phase()
 {
     new_phase_started(GAMEPHASE.QUEST);
     cur_state = GAMESTATE.COMMITTING_CHARACTERS;
 }
 public GAMESTATE Update(List <Enemy> enemies, Player player, Map map, Camera camera, HUD hud, Battle battle, Inventory inventory, GAMESTATE gameState) // update list of enemies in a for loop
 {
     for (int i = 0; i < enemies.Count; i++)
     {
         gameState = enemies[i].Update(player, map, camera, hud, battle, inventory, gameState);
     }
     return(gameState);
 }
Пример #31
0
    private IEnumerator ChangeState(GAMESTATE state, float gap)
    {
        yield return(new WaitForSeconds(gap));

        GameState = state;
    }
Пример #32
0
 public void finished_engaging_enemies()
 {
     cur_state = GAMESTATE.ENGAGEMENT_CHECKS;
     check_for_enemy_engagements();
 }
Пример #33
0
    void SetState(GAMESTATE gameState)
    {
        // ====================================
        // State initialisation
        // ====================================

        switch (gameState)
        {
        case GAMESTATE.FRONTEND:
            for (int i = 0; i < PlayerCursor.s_players.Count; ++i)
            {
                PlayerCursor.s_players[i].m_score = 0;
                m_scores[i] = 0;
            }
            break;

        case GAMESTATE.GAMEINTRO:
            m_gameIntroTimer = 1.5f;
            if (m_SFX_playClicked)
            {
                m_SFX_playClicked.PlayRandom();
            }
            break;

        case GAMESTATE.PLAYING:
            m_clustersSpawned = 0;
            m_timer           = m_gameTime;
            if (m_SFX_startGame)
            {
                m_SFX_startGame.PlayRandom();
            }
            break;

        case GAMESTATE.ENDSCORES:
            if (m_SFX_endGame)
            {
                m_SFX_endGame.PlayRandom();
            }
            m_scoresDisplayed = false;
            if (Victim.s_victims != null)
            {
                for (int i = 0; i < Victim.s_victims.Count; ++i)
                {
                    GameObject.Destroy(Victim.s_victims[i].gameObject);
                }
            }
            break;
        }

        // ====================================
        // Activate objects for specific states
        // ====================================

        m_frontEnd.SetActive(gameState == GAMESTATE.FRONTEND);
        m_hud.SetActive(gameState != GAMESTATE.FRONTEND);
        m_endScores.SetActive(gameState == GAMESTATE.ENDSCORES);

        if (PlayerCursor.s_players != null)
        {
            for (int i = 0; i < PlayerCursor.s_players.Count; ++i)
            {
                PlayerCursor.s_players[i].gameObject.SetActive(gameState == GAMESTATE.PLAYING);
            }
        }

        // ====================================

        m_gameState = gameState;
    }
Пример #34
0
 public void player_chose_enemy_to_attack(LOTRPlayer player, EnemyCard enemy)
 {
     defending_enemy        = enemy;
     cur_state              = GAMESTATE.DECLARING_ATTACKERS;
     attacking_player_cards = new List <PlayerCard>();
 }
Пример #35
0
 protected private GAMESTATE StartAttacking(bool victimIsAlive, Battle battle, Player player, Enemy enemy, GAMESTATE gameState, Inventory inventory) // attacks if colliding character is alive, else do nothing
 {
     if (victimIsAlive)
     {
         gameState = battle.Begin(player, enemy, inventory);
     }
     return(gameState);
 }
        /// <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();
            }
            if (!connected)
            {
                return;
            }

            MouseState mouse = Mouse.GetState();

            switch (CurrentGameState)
            {
            case GAMESTATE.MAINMENU:
                if (btnLogIn.isClicked == true)
                {
                    CurrentGameState = GAMESTATE.LOGIN;
                }

                btnLogIn.Update(mouse);
                break;


            case GAMESTATE.LOGIN:
                //Activates the login Keyboard
                CheckLogedInPlayers();

                if (InputEngine.IsKeyPressed(Keys.F10) && !loginKeyboard.Visible)
                {
                    loginKeyboard.Visible = true;
                    //Clears anything written before this point
                    InputEngine.ClearState();
                }

                if (loginKeyboard.Done)
                {
                    gamerTag = loginKeyboard.Name;
                    password = loginKeyboard.Password;
                    loginKeyboard.Clear();
                    InputEngine.ClearState();

                    //checks to see if the connection is connected
                    if (connection.State == ConnectionState.Connected)
                    {
                        if (gamerTag != null && password != null)
                        {
                            getPlayer();
                            subscribeToMessages();
                            CheckLogedInPlayers();
                            //getPlayerData();
                        }
                    }
                }

                if (loggedIn == true)
                {
                    if (allLogedInPlayers.Count >= 2)
                    {
                        if (btnSubmit.isClicked == true)
                        {
                            CurrentGameState = GAMESTATE.PLAYING;
                        }
                    }

                    btnSubmit.Update(mouse);
                }

                break;

            case GAMESTATE.PLAYING:

                if (Keyboard.GetState().IsKeyDown(Keys.Q))
                {
                    myPlayer = new speedyPlayer(new Texture2D[] { Content.Load <Texture2D>(@"Player Images\characterSpriteSheet1"),
                                                                  Content.Load <Texture2D>(@"Player Images\cherryPlayer") }, centreScreen, 2, 9f);
                    gameStart = true;
                    q         = true;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.W))
                {
                    myPlayer = new ladyPlayer(new Texture2D[] { Content.Load <Texture2D>(@"Player Images\character2SspriteSheet"),
                                                                Content.Load <Texture2D>(@"Player Images\cherryPlayer") }, centreScreen, 2, 6f);
                    gameStart = true;
                    w         = true;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.E))
                {
                    myPlayer = new healthyPlayer(new Texture2D[] { Content.Load <Texture2D>(@"Player Images\characterSpriteSheet3"),
                                                                   Content.Load <Texture2D>(@"Player Images\cherryPlayer") }, centreScreen, 2, 6f);
                    gameStart = true;
                    e         = true;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.R))
                {
                    myPlayer = new sneakPlayer(new Texture2D[] { Content.Load <Texture2D>(@"Player Images\character4SpriteSheet"),
                                                                 Content.Load <Texture2D>(@"Player Images\cherryPlayer") }, centreScreen, 2, 4.5f);
                    gameStart = true;
                    r         = true;
                }

                if (gameStart)     // play the game
                {
                    Vector2 StartingPos = myPlayer.position;

                    sendNewPlayerStartingPosition(centreScreen);

                    //updating the player
                    myPlayer.Update(gameTime);

                    sendNewPlayerPosition(myPlayer.position);
                    subscribeToMessages();

                    foreach (Player othPlayer in OtherPlayers)
                    {
                        othPlayer.Update(gameTime);
                    }

                    cherry.Update(gameTime);

                    if (cherry.visible == true)
                    {
                        if (myPlayer.collisionDetect(cherry))
                        {
                            cherry.visible      = false;
                            myPlayer.cherryform = true;
                        }
                    }

                    // no going through the walls
                    foreach (Wall w in walls)
                    {
                        if (w.visible)
                        {
                            if (w.collisionDetect(myPlayer))
                            {
                                if (myPlayer.sneaky == false)
                                {
                                    myPlayer.position = StartingPos;
                                }
                            }
                        }
                    }


                    //clamping the player to the border
                    myPlayer.position = Vector2.Clamp(myPlayer.position, Vector2.Zero,
                                                      (new Vector2(screenWidth, screenHeight)
                                                       - new Vector2(myPlayer.SpriteWidth, myPlayer.SpriteHeight)));

                    //updating the collectables
                    for (int i = 0; i < collectables.Count; i++)
                    {
                        collectables[i].Update(gameTime);
                    }

                    //updating the collectables collision detection
                    for (int i = 0; i < collectables.Count; i++)
                    {
                        if (myPlayer.collisionDetect(collectables[i]))
                        {
                            if (collectables[i].visible)
                            {
                                //    collectedAmount++;
                                myPlayer.score         += collectables[i].CollectableScore;
                                collectables[i].visible = false;
                            }
                        }
                    }

                    //updating collision detect for chasers
                    for (int i = 0; i < chasers.Length; i++)
                    {
                        if (myPlayer.collisionDetect(chasers[i]))
                        {
                            if (chasers[i].visible)
                            {
                                //   myPlayer.health -= Utility.NextRandom(40, 60);
                                myPlayer.score += Utility.NextRandom(25, 40);
                            }
                            chasers[i].visible = false;
                        }
                    }

                    //dealing with health when hitting enemies
                    if (myPlayer.health <= 0)
                    {
                        lives            -= 1;
                        myPlayer.position = centreScreen;
                        myPlayer.health   = 100;
                    }

                    //updating chasers
                    foreach (ChasingEnemy chaser in chasers)
                    {
                        chaser.follow(myPlayer);
                        chaser.Update(gameTime);

                        chaser.position = Vector2.Clamp(chaser.position, Vector2.Zero,
                                                        (new Vector2(screenWidth, screenHeight)
                                                         - new Vector2(chaser.SpriteWidth, chaser.SpriteHeight)));
                    }

                    //turning the score int into a string so we can write it
                    scoreMessage = Convert.ToString(myPlayer.score);

                    if (Keyboard.GetState().IsKeyDown(Keys.F12))
                    {
                        typeMessage();
                    }
                }

                break;
                // TODO: Add your update logic here
            }
            base.Update(gameTime);
        }
Пример #37
0
 public void StartGame()
 {
     this.state = GAMESTATE.START;
 }
Пример #38
0
 public void SetState(GAMESTATE test)
 {
     state = test;
 }
Пример #39
0
        public void GameOver()
        {
            for (int i = 0; i < Entities.Count(); i++)
                Entities[i].Alive = false;

            for (int i = 0; i < Enemies.Count(); i++)
                Enemies[i].Alive = false;

            for (int i = 0; i < CharacterBullets.Count(); i++)
                CharacterBullets[i].Alive = false;

            for (int i = 0; i < EnemyBullet.Count(); i++)
                EnemyBullet[i].Alive = false;

            gameOverScreen = new GameOverScreen(this);
            gameState = GAMESTATE.END;

            level1 = null;
            level2 = null;
            level3 = null;
        }
Пример #40
0
    // Update is called once per frame
    void Update()
    {
        if (GUIUtility.hotControl != 0)
        {
            return;
        }
#if !UNITY_EDITOR
        if (Input.touchCount > 0)
        {
            if (gameState == GAMESTATE.SHOOT)
            {
                return;
            }
            Vector2 touchPosition = Input.GetTouch(0).position;
            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                Vector2 delta   = Input.GetTouch(0).deltaPosition;
                Vector2 cuePos  = Camera.main.WorldToScreenPoint(transform.position);
                Vector2 prevPos = touchPosition - delta;
                float   angle   = Vector2.Angle(prevPos - cuePos, touchPosition - cuePos);
                Vector3 cross   = Vector3.Cross(touchPosition - cuePos, prevPos - cuePos);

                if (cross.z > 0)
                {
                    angle = 360 - angle;
                }
                cue.transform.Rotate(0, 0, angle);
                Vector3 v            = cueHead.transform.position - cue.transform.position;
                Vector3 t            = transform.position + v;
                Vector2 newScreenPos = Camera.main.WorldToScreenPoint(t);
                PlaceCue(newScreenPos);
            }
        }
#else
        if (Input.GetMouseButtonDown(0))
        {
            if (gameState == GAMESTATE.SHOOT)
            {
                return;
            }
            Vector2 touchPosition = Input.mousePosition;
            PlaceCue(touchPosition);
        }

        if (Input.GetMouseButtonDown(1))
        {
            Shot();
        }
#endif
        if (gameState == GAMESTATE.REPLAY)
        {
            if (updateBallsTimer <= 0)
            {
                updateBallsTimer  = DELAY;
                timeToUpdateBalls = 0;
                foreach (GameObject GO in GOS)
                {
                    Ball ball = GOSDict[GO.name];
                    if (ball.destx.Count > 0)
                    {
                        ball.destx.RemoveAt(0);
                        ball.desty.RemoveAt(0);
                        ball.orgx.RemoveAt(0);
                        ball.orgy.RemoveAt(0);
                        ball.st.RemoveAt(0);
                    }
                }
            }
            else
            {
                updateBallsTimer  -= Time.deltaTime;
                timeToUpdateBalls += Time.deltaTime;
                if (timeToUpdateBalls >= DELAY)
                {
                    timeToUpdateBalls = DELAY;
                }

                foreach (GameObject GO in GOS)
                {
                    GO.rigidbody2D.collider2D.enabled = false;
                }
                foreach (GameObject GO in GOS)
                {
                    Ball ball = GOSDict[GO.name];
                    if (ball.destx.Count > 0)
                    {
                        float[] dx     = ball.destx.ToArray();
                        float[] dy     = ball.desty.ToArray();
                        Vector2 newPos = new Vector2(dx[0], dy[0]);

                        float[] ox     = ball.orgx.ToArray();
                        float[] oy     = ball.orgy.ToArray();
                        Vector2 oldPos = new Vector2(ox[0], oy[0]);
                        Vector2 curPos = newPos - oldPos;
                        curPos *= timeToUpdateBalls / DELAY;
                        curPos += oldPos;
                        GO.rigidbody2D.MovePosition(curPos);

                        bool[] st = ball.st.ToArray();
                        GO.SetActive(st[0]);
                    }
                }
            }
            return;
        }
        else if (gameState != GAMESTATE.SHOOT)
        {
            return;
        }
        if (updateBallsTimer <= 0)
        {
            updateBallsTimer = DELAY;
            var jsonData = new JSONClass();
            jsonData ["evt"] = "balls";
            foreach (GameObject GO in GOS)
            {
                string ballname = GO.name;
                jsonData [ballname] = GO.name;
                float x  = GO.transform.position.x;
                float y  = GO.transform.position.y;
                bool  st = GO.activeInHierarchy;
                jsonData [ballname + "x"].AsFloat = x;
                jsonData [ballname + "y"].AsFloat = y;
                jsonData [ballname + "st"].AsBool = st;
            }
            cubeia.sendDataGame(jsonData);
        }
        else
        {
            updateBallsTimer -= Time.deltaTime;
//			Debug.Log(Time.deltaTime);
        }

        foreach (GameObject GO in GOS)
        {
            if (GO.activeInHierarchy && !GO.rigidbody2D.IsSleeping())
            {
                return;
            }
        }
        var jsonDataEnd = new JSONClass();
        jsonDataEnd ["evt"] = "endshoot";
        cubeia.sendDataGame(jsonDataEnd);

        gameState = GAMESTATE.AIM;
        foreach (GameObject GO in GOS)
        {
            if (GO.name == "CueBall")
            {
                continue;
            }
            if (!GO.activeInHierarchy)
            {
                continue;
            }
            Vector3 newPosition  = GO.transform.position;
            Vector2 newScreenPos = Camera.main.WorldToScreenPoint(newPosition);
            PlaceCue(newScreenPos);
                        #if AUTO_PLAY
            Invoke("Shot", 1);
                        #endif
            break;
        }
    }
Пример #41
0
        public void levelSelect()
        {
            levelSelectionScreen = new LevelSelectionScreen(this);
            gameState = GAMESTATE.SELECT;

            startScreen = null;
        }
Пример #42
0
 public void KillPlayer()
 {
     this.currentState = GAMESTATE.DEAD_PLAYER;
 }
Пример #43
0
        public void LevelTwo()
        {
            level2 = new GamePlayLevel2(this);
            gameState = GAMESTATE.LEVEL2;
            GameIndex = 2;

            levelSelectionScreen = null;

            Ammo = 40;
            TimeLimit = 80f;
            EnemyCount = 15;
            Health = 100;
        }
Пример #44
0
 private void setGameState(GAMESTATE state)
 {
     STATE = state;
     gameClock.Restart();
 }
Пример #45
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            startScreen = new StartScreen(this);
            gameState = GAMESTATE.START;
            Background = Content.Load<Texture2D>("GamePlay/floormap");
            spriteFont = Content.Load<SpriteFont>("Font/Arial");

            BackgroundRec = new Rectangle(-2, -2, (int)Background.Width + 4, (int)Background.Height + 4);

            base.LoadContent();
        }
Пример #46
0
 protected virtual void OnGameStateChange(GAMESTATE _state)
 {
 }
Пример #47
0
        /// <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.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            screenBounds = GraphicsDevice.Viewport.Bounds;

            textColour = Color.Cornsilk;
            highlightColour = Color.Red;

            base.Initialize();

            gameState = GAMESTATE.START;
            graphics.ToggleFullScreen();
        }
Пример #48
0
 void TimeOut()
 {
     gameBoard.CloseCard(firstCardPos);
     gameState = GAMESTATE.WAITING;
 }
Пример #49
0
 public static void ResetGame()
 {
     gameState = GAMESTATE.START_SCREEN;
     Actor.actors.Clear();
     new Player();
 }
Пример #50
0
 void GameOver()
 {
     gameState = GAMESTATE.GAMEOVER;
     VictoryScreen.victory(timer);
     LogHighscore();
 }
        private void TransitionState(GAMESTATE state)
        {
            switch (state)
            {
                case GAMESTATE.MAIN_MENU_DISPLAY:
                    ScreenMainMenu.Reset();
                    break;
                case GAMESTATE.GAME_INITIALIZE:
                    Reset();
                    break;
                case GAMESTATE.CUSTOMIZATION_DISPLAY:
                    break;
                case GAMESTATE.UI_DISPLAY:
                    ScreenMainGameUI.Initialize(canvasMain.Device, ScreenMapCustomization.World);
                    break;
            }

            State = state;
        }
Пример #52
0
 // Set the game current states
 public void SetGameState(GAMESTATE state)
 {
     currentGameState = state;
 }
Пример #53
0
 private void UpdateGameOver()
 {
     GamePadState pad = GamePad.GetState(PlayerIndex.One);
     if (pad.IsButtonDown(Buttons.A))
         GameState = GAMESTATE.MainMenu;
 }
Пример #54
0
 // Start is called before the first frame update
 void Start()
 {
     loginTime = System.DateTime.Now;
     state     = GAMESTATE.DAY;
     BGMManager.instance.Play(0);
 }
Пример #55
0
	void Start(){
		m_audio=GetComponent<AudioSource>();
		curState=GAMESTATE.START;
		m_audio.volume=PlayerPrefs.GetFloat("Sound",0.8f);
	}
Пример #56
0
    public void Scaling()
    {
        goblin.transform.localScale -= new Vector3(0.01f, 0.01f, 0);

        if(goblin.transform.localScale.x <= 0.31f && goblin.transform.localScale.y <= 0.31f)
        {
            beginScaling = false;
            gameState = GAMESTATE.GAME;
        }
    }
Пример #57
0
 public void changeMenuState(GAMESTATE state)
 {
     gs = state;
 }
Пример #58
0
 void Awake()
 {
     DontDestroyOnLoad(this);
     gameState = GAMESTATE.MENU;
 }
 private static void OnTransitionState(GAMESTATE state)
 {
     if (TransitionState != null) { TransitionState(state); }
 }
Пример #60
0
 private void ChangeStateByOtherModule(GAMESTATE _state)
 {
     GameState = _state;
 }