Beispiel #1
0
 public static void setMenu()
 {
     Time.timeScale = 1;
     EffectRainEggs.run = true; //start raining
     status = gameMode.Menu;
     MoveCamera(1);
 }
Beispiel #2
0
    void ManageSceneStuff(Scene scene, LoadSceneMode mode)
    {
        if (scene.name == "CharacterSelect")
        {
            currentMode = gameMode.selectCharacter;
        }
        else if (scene.name == "EarthAndMoon" || scene.name == "Earth" || scene.name == "FireAndIce" || scene.name == "AllFourPlanets")
        {
            currentMode = gameMode.battle;
            InitGame();
        }
        else if (scene.name == "WinScreen")
        {
            currentMode = gameMode.winScreen;
            int        winningPlayer = getWinningPlayer();
            GameObject prefab        = characterMap[winningPlayer].m_Prefab;
            GameObject temp          = (GameObject)Instantiate(prefab, new Vector2(0, 0), Quaternion.identity);
            temp.GetComponent <MeshRenderer> ().material = characterMap [winningPlayer].m_Material;
            temp.transform.localScale = new Vector3(3, 3, 3);

            GameObject winText = Instantiate(textPrefab, new Vector2(-4, 5), Quaternion.identity);
            TextMesh   text    = winText.GetComponent <TextMesh> ();
            text.text     = "Player " + winningPlayer + " wins!";
            text.fontSize = 50;
        }
        else
        {
            currentMode = gameMode.none;
        }
    }
Beispiel #3
0
    //The game has states Downtime, Cutscene, Gametime
    //Gametime can link to different game modes longJump, highJump, race

    void Start()
    {
        currentGameMode = gameMode.longjump;
        currentState    = gameState.downtime;
        jumpManager     = FindObjectOfType <JumpManager>();
        UpdateGameStateText();
    }
 public void DelayCancel()
 {
     delayStartButton.SetActive(true);
     delayCancelButton.SetActive(false);
     selectedGameMode = gameMode.none;
     PhotonNetwork.LeaveRoom();
 }
 public void PrivateCancel()
 {
     quickStartButton.SetActive(true);
     quickCancelButton.SetActive(false);
     selectedGameMode = gameMode.none;
     PhotonNetwork.LeaveRoom();
 }
 public void DelayStart()
 {
     delayStartButton.SetActive(false);
     delayCancelButton.SetActive(true);
     selectedGameMode = gameMode.delay;
     PhotonNetwork.JoinRandomRoom();
     currentGameMode = FindObjectOfType <CurrentGameMode>();
 }
 public void PrivateStart()
 {
     quickStartButton.SetActive(false);
     quickCancelButton.SetActive(true);
     selectedGameMode = gameMode.quick;
     PhotonNetwork.JoinRandomRoom();
     Debug.Log("Started");
 }
Beispiel #8
0
    public void setCurrentGameMode(gameMode gameMode)
    {
        currentGameMode = gameMode;
        switch (currentGameMode)
        {
        case gameMode.normal:
            Debug.Log("NormalMode Set");
            GameObject.Find("UI").GetComponent <CountdownTimer>().timerIsPaused = false;
            Time.timeScale = 1f;
            FeverOverlay.SetActive(false);
            FreezeOverlay.SetActive(false);
            SpawnPPC();

            float currentSpeedRed = GameObject.Find("RedCup").GetComponent <cup>()._speed;
            if (currentSpeedRed == 40)
            {
                GameObject.Find("RedCup").GetComponent <cup>()._speed /= 2;
            }
            else if (currentSpeedRed == 68)
            {
                GameObject.Find("RedCup").GetComponent <cup>()._speed /= 2;
            }

            if (GameObject.Find("BlueCup"))
            {
                float currentSpeedBlue = GameObject.Find("BlueCup").GetComponent <cup2>()._speed;
                if (currentSpeedBlue == 40)
                {
                    GameObject.Find("BlueCup").GetComponent <cup2>()._speed /= 2;
                }
                else if (currentSpeedBlue == 68)
                {
                    GameObject.Find("BlueCup").GetComponent <cup2>()._speed /= 2;
                }
            }
            break;

        case gameMode.getMore:
            Debug.Log("GetMoreMode Set");
            FeverOverlay.SetActive(true);
            GetMoreMode();
            Invoke("setGetMoreMode", 10.0f);
            break;

        case gameMode.freeze:
            Debug.Log("FreezeMode Set");
            Time.timeScale = 0.5f;
            GameObject.Find("UI").GetComponent <CountdownTimer>().timerIsPaused = true;
            FreezeOverlay.SetActive(true);
            Invoke("setGetMoreMode", 5.0f);
            GameObject.Find("RedCup").GetComponent <cup>()._speed *= 2;
            if (GameObject.Find("BlueCup"))
            {
                GameObject.Find("BlueCup").GetComponent <cup2>()._speed *= 2;
            }
            break;
        }
    }
 public void JoinLobbyOnClick()
 {
     selectedGameMode       = gameMode.priv;
     PhotonNetwork.NickName = playerNameInput.text;
     PlayerPrefs.SetString("NickName", playerNameInput.text);
     mainPanel.SetActive(false);
     lobbyPanel.SetActive(true);
     PhotonNetwork.JoinLobby();
 }
Beispiel #10
0
    public static void setInGame(bool reset = false)
    {
        if (reset)
            resetVar();

        Time.timeScale = 1;
        EffectRainEggs.run = false; //stop raining
        status = gameMode.inGame;
        MoveCamera(2);
    }
Beispiel #11
0
 void EndPowerUp()
 {
     // Exact timing is missing from PacMan Dossier
     powerUpTimeLeft = 0f;
     currentGameMode = gameMode.kNormalGameMode;
     blinky.GetComponent <ControlledObject> ().EndPowerup();
     inky.GetComponent <ControlledObject> ().EndPowerup();
     pinky.GetComponent <ControlledObject> ().EndPowerup();
     clyde.GetComponent <ControlledObject> ().EndPowerup();
 }
Beispiel #12
0
 void StartPowerUp()
 {
     // Exact timing is missing from PacMan Dossier
     powerUpTimeLeft = 10f;
     currentGameMode = gameMode.kPowerUpGameMode;
     blinky.GetComponent <ControlledObject> ().StartPowerup();
     inky.GetComponent <ControlledObject> ().StartPowerup();
     pinky.GetComponent <ControlledObject> ().StartPowerup();
     clyde.GetComponent <ControlledObject> ().StartPowerup();
     pacman.GetComponent <ControlledObject> ().StartPowerup();
 }
Beispiel #13
0
        public Engine(gameMode mode, MazeLevel mazeMode, int length = mazeRenderLength, int width = mazeRenderWidth)
        {
            mazeLength      = length;
            mazeWidth       = width;
            currentGameMode = mode;
            gameSound       = new GameSound();
            this.mazeMode   = mazeMode;

            score         = new Score(this.mazeMode);
            foodGenerator = new FoodGenerator();
            newAI         = new AI(new Random());
            newSmartAI    = new AI(new Random());
        }
Beispiel #14
0
 public void setGameMode(gameMode gm)
 { // Show the cursor only in interface mode
     gameMode = gm;
     if (gameMode == gameMode.free)
     {
         Cursor.lockState = CursorLockMode.Locked;
     }
     else
     {
         // TODO : Show GUI
         Cursor.lockState = CursorLockMode.Confined;
     }
 }
 public static int HighestScore(gameMode gameMode, 
     gameDifficulty gameDifficulty)
 {
     OrderGameScore();
     int type = ModeDifficultyToInt(gameMode, gameDifficulty);
     if (type > 0)
     {
         return highScore[type][0].Value;
     }
     else
     {
         return 0;
     }
 }
Beispiel #16
0
    //cycles between the game modes on button clicks
    private string getNextMode()
    {
        if (currMode == gameMode.Player)
        {
            currMode = gameMode.Terrain;
            playerScript.isModeActive  = false;
            terrainScript.isModeActive = true;
            return("Terrain");
        }

        currMode = gameMode.Player;
        playerScript.isModeActive  = true;
        terrainScript.isModeActive = false;
        return("Player");
    }
Beispiel #17
0
        static void initialMenuLoad()
        {
            Style.menuImage();
            do
            {
                try
                {
                    currentGameMode = (gameMode)Convert.ToInt32(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine();
                }

                if (currentGameMode == gameMode.basic)
                {
                    gameSelected = true;
                }
            }while (gameSelected == false);
        }
Beispiel #18
0
 void CheckPacmanCollision(xyLoc ghost, ControlledObject obj)
 {
     if (!obj.IsAlive())
     {
         return;
     }
     if ((pacmanLoc.x + 4) / 8 == (ghost.x + 4) / 8 && (pacmanLoc.y + 4) / 8 == (ghost.y + 4) / 8)
     {
         if (currentGameMode == gameMode.kPowerUpGameMode)
         {
             obj.Kill();
             GetSound(gameSound.kEatGhost).Play();
         }
         else
         {
             currentGameMode = gameMode.kLifeOver;
             elapsedTime     = 0;
             GetSound(gameSound.kBackgroundSound).Stop();
             GetSound(gameSound.kDieSound).Play();
         }
     }
 }
Beispiel #19
0
    // Use this for initialization
    void Start()
    {
        gameScore            = 0;
        gameOver             = false;
        gameOverText.enabled = false;

        showBuildOptions(true);
        //i want to load all this from a text file of enemy data



        phases.Add(new Phase(1, 50, new enemyData(3, 0, 0, 30)));
        phases.Add(new Phase(2, 50, new enemyData(5, 2, 0, 50)));
        phases.Add(new Phase(3, 50, new enemyData(5, 4, 0, 50)));
        phases.Add(new Phase(4, 20, new enemyData(18, 2, 0, 50)));
        phases.Add(new Phase(5, 20, new enemyData(5, 5, 2, 80)));
        phases.Add(new Phase(6, 20, new enemyData(17, 6, 3, 80)));
        phases.Add(new Phase(7, 20, new enemyData(30, 10, 2, 80)));
        phases.Add(new Phase(8, 20, new enemyData(25, 0, 2, 80)));
        phases.Add(new Phase(9, 20, new enemyData(5, 5, 5, 80)));
        phases.Add(new Phase(10, 20, new enemyData(35, 0, 10, 80)));
        phases.Add(new Phase(10, 20, new enemyData(35, 0, 10, 80)));


        //list of all the build buttons

        phaseNo   = 0;
        maxPhase  = phases.Count;
        currPhase = phases[0];
        changeMode.onClick.AddListener(() => { onClickChangeMode(); });
        currMode = gameMode.Build;
        changeMode.GetComponentInChildren <Text>().text = getNextMode();


        buildButtons[0].onClick.AddListener(() => { playerManager.buildPoisonBush(); });
        buildButtons[1].onClick.AddListener(() => { playerManager.buildFireTree(); });
        buildButtons[2].onClick.AddListener(() => { playerManager.throwRollingBall(); });
        buildButtons[3].onClick.AddListener(() => { playerManager.createASCannon(); });
    }
    //把下載完的xml讀取到遊戲的
    void loadGameSetting(string stageId)
    {

        //從GameSetting.xml取得遊戲設定資訊
        XmlNode itemNodeRoot = m_xmlSettingList.SelectSingleNode("/Setting/stage[@sceneName='" + stageId+"']");
        XmlNode itemNode = itemNodeRoot.SelectSingleNode("width");
        width = int.Parse(itemNode.InnerText);
        Debug.Log("width =: " + width);

        itemNode = itemNodeRoot.SelectSingleNode("height");
        height = int.Parse(itemNode.InnerText);

        Debug.Log("height =: " + height);

        itemNode = itemNodeRoot.SelectSingleNode("mode");
        m_gameMode = (gameMode)int.Parse(itemNode.InnerText);

        if (m_gameMode == gameMode.STORY_MODE)
        {
            itemNode = itemNodeRoot.SelectSingleNode("startPosX");
            startPosX = int.Parse(itemNode.InnerText);

            itemNode = itemNodeRoot.SelectSingleNode("startPosY");
            startPosY = int.Parse(itemNode.InnerText);

            itemNode = itemNodeRoot.SelectSingleNode("endPosX");
            endPosX = int.Parse(itemNode.InnerText);

            itemNode = itemNodeRoot.SelectSingleNode("endPosY");
            endPosY = int.Parse(itemNode.InnerText);
        }
        else
        {
            startPosX = 0;
            startPosY = 0;
            endPosX = 0;
            endPosY = 0;
        }
    }
Beispiel #21
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()
        {
            // initialization logic

            initPosition();

            currentBoardVsGoat = new Board();
            currentBoardVsTiger = new Board();
            currentBoardTwoPlayer = new Board();

            fetchSavedState();
            fetchSavedSettings();

            currentBoard = currentBoardVsGoat;
            goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount();
            gameStateVsGoat = new GameState();
            gameStateVsTiger = new GameState();
            gameStateTwoPlayer = new GameState();

            winner = nodeState.none;

            newMoveDone = false;
            puckTouched = false;
            currentMode = gameMode.vsTiger;
            currentScreen = gameScreens.mainMenuScreen;
            //currentMode = gameMode.vsGoat;

            helpSection = new ScrollContainer();
            creditsection = new CreditsSection();

            onePlayerBtnGoat = new gButton(470, 97);
            onePlayerBtnTiger = new gButton(485, 197);
            twoPlayerBtn = new gButton(475,297);
            settingsBtn = new gButton(555,20);
            helpBtn = new gButton(480, 20);
            creditsBtn = new gButton(630, 20);
            rateBtn = new gButton(465, 400);

            sfxOnBtn = new gButton(380,175);
            sfxOffBtn = new gButton(380,175);
            undoBtn = new gButton(648, 403);

            //level
            levelBtn1 = new gButton(378, 265);
            levelBtn2 = new gButton(458, 265);
            levelBtn3 = new gButton(538, 265);

            menuBtn = new gButton(280,240);
            newGameBtn = new gButton(440, 240);

            resumeBtn = new gButton(440,240);
            okBtn = new gButton(552,320);

            //settings level
            switch (level)
            {
                case 1: levelBtn1.pressed = true; break;
                case 2: levelBtn2.pressed = true; break;
                case 3: levelBtn3.pressed = true; break;
                default: levelBtn1.pressed = true; break;

            }

            base.Initialize();
        }
Beispiel #22
0
        void mainScreenTouchHanlder()
        {
            TouchCollection touches = TouchPanel.GetState();

            if (/*!touching &&*/ touches.Count > 0)
            {
                touching = true;
                TouchLocation touch = touches.First();
                System.Diagnostics.Debug.WriteLine("X" + touch.Position.X + "Y" + touch.Position.Y);
                //make a move by computer

                // twoPlayerBtn.setPos(400,200);
                twoPlayerBtn.handeTouch(touch);
                onePlayerBtnGoat.handeTouch(touch);
                onePlayerBtnTiger.handeTouch(touch);
                settingsBtn.handeTouch(touch);
                helpBtn.handeTouch(touch);
                creditsBtn.handeTouch(touch);
                rateBtn.handeTouch(touch);

            }
            else
            {
                if (twoPlayerBtn.pressed)
                {
                    twoPlayerBtn.pressed = false;
                    currentMode = gameMode.twoPlayers;

                    gameState = gameStateTwoPlayer;
                    currentBoard = currentBoardTwoPlayer;
                    goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount();
                    newMoveDone = true;//to check who won
                    switchToGamePlayScreen();

                }
                if (onePlayerBtnGoat.pressed)
                {
                    onePlayerBtnGoat.pressed = false;
                    currentMode = gameMode.vsGoat;

                    System.Diagnostics.Debug.WriteLine("current screen" + currentMode);
                    gameState = gameStateVsGoat;
                    currentBoard = currentBoardVsGoat;
                    goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount();
                    newMoveDone = true;//to check who won
                    switchToGamePlayScreen();
                }
                if (onePlayerBtnTiger.pressed)
                {
                    onePlayerBtnTiger.pressed = false;
                    currentMode = gameMode.vsTiger;

                    gameState = gameStateVsTiger;
                    currentBoard = currentBoardVsTiger;
                    goatsCaptured = currentBoard.mGoatsIntoBoard - getGoatCount();
                    newMoveDone = true;//to check who won
                    switchToGamePlayScreen();
                }
                if (settingsBtn.pressed)
                {
                    System.Diagnostics.Debug.WriteLine("settings press");
                    settingsBtn.pressed = false;
                    showSettingsOverlay();
                }
                if(helpBtn.pressed){
                    System.Diagnostics.Debug.WriteLine("help button press");
                    helpBtn.pressed = false;
                    showHelpScreen();
                }
                if (creditsBtn.pressed)
                {
                    System.Diagnostics.Debug.WriteLine("credits button press");
                    creditsBtn.pressed = false;
                    showCreditsScreen();
                }
                if (rateBtn.pressed)
                {
                    System.Diagnostics.Debug.WriteLine("credits button press");
                    rateBtn.pressed = false;
                    showRateScreen();
                }

            }
        }
Beispiel #23
0
        private IEnumerator updatePresenceAfterFrame()
        {
            yield return(true);

            _mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault();
            _gameplaySetup       = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;

            if (BS_Utils.Plugin.LevelData.IsSet)
            {
                if (_gameplaySetup != null)
                {
                    _mainSetupData =
                        _gameplayCoreSceneSetupDataField.GetValue(_gameplaySetup) as GameplayCoreSceneSetupData;
                }

                // Check if every required object is found
                if (_mainSetupData == null || _gameplaySetup == null || _mainFlowCoordinator == null)
                {
                    Presence.details = "Playing";
                    DiscordRpc.UpdatePresence(Presence);
                    yield break;
                }

                // Set presence main values
                var diff = _mainSetupData.difficultyBeatmap;

                Presence.details = $"{diff.level.songName} | {diff.difficulty.Name()}";
                Presence.state   = "";

                if (diff.level.levelID.Contains('∎'))
                {
                    Presence.state += "Custom | ";
                }

                if (_mainSetupData.practiceSettings != null)
                {
                    Presence.state += "Practice | ";
                }

                Presence.state += getFlowTypeHumanReadable() + " ";

                // Update gamemode (Standard / One Saber / No Arrow)
                if (_mainSetupData.gameplayModifiers.noArrows || diff.parentDifficultyBeatmapSet.beatmapCharacteristic
                    .ToString().ToLower().Contains("noarrow"))
                {
                    _gamemode = gameMode.NoArrows;
                }
                else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic ==
                         (BeatmapCharacteristicSO)_oneColorBeatmapCharacteristic.GetValue(_gameplaySetup))
                {
                    _gamemode = gameMode.OneSaber;
                }
                else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic.ToString().ToLower()
                         .Contains("90degree"))
                {
                    _gamemode = gameMode.NinetyDegree;
                }
                else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic.ToString().ToLower()
                         .Contains("360degree"))
                {
                    _gamemode = gameMode.ThreeSixtyDegree;
                }
                else
                {
                    _gamemode = gameMode.Standard;
                }

                var gameplayModeText = _gamemode == gameMode.OneSaber ? "One Saber" :
                                       _gamemode == gameMode.NoArrows ? "No Arrow" :
                                       _gamemode == gameMode.NinetyDegree ? "90º" :
                                       _gamemode == gameMode.ThreeSixtyDegree ? "360º" : "Standard";
                Presence.state += gameplayModeText;

                // Set music speak
                if (_mainSetupData.practiceSettings != null)
                {
                    if (Math.Abs(_mainSetupData.practiceSettings.songSpeedMul - 1.0f) > 9999999)
                    {
                        Presence.state += " | Speed x" + _mainSetupData.practiceSettings.songSpeedMul;
                    }
                }
                else
                {
                    if (Math.Abs(_mainSetupData.gameplayModifiers.songSpeedMul - 1.0f) > 99999999)
                    {
                        Presence.state += " | Speed x" + _mainSetupData.gameplayModifiers.songSpeedMul;
                    }
                }

                // Set common gameplay modifiers
                if (_mainSetupData.gameplayModifiers.noFailOn0Energy)
                {
                    Presence.state += " | No Fail";
                }
                if (_mainSetupData.gameplayModifiers.instaFail)
                {
                    Presence.state += " | Instant Fail";
                }
                if (_mainSetupData.gameplayModifiers.disappearingArrows)
                {
                    Presence.state += " | Disappearing Arrows";
                }
                if (_mainSetupData.gameplayModifiers.ghostNotes)
                {
                    Presence.state += " | Ghost Notes";
                }


                Presence.largeImageKey  = "default";
                Presence.largeImageText = "Beat Saber";
                Presence.smallImageKey  = getFlowTypeHumanReadable() == "Party" ? "party" :
                                          _gamemode == gameMode.OneSaber ? "one_saber" :
                                          _gamemode == gameMode.NoArrows ? "no_arrows" :
                                          _gamemode == gameMode.NinetyDegree ? "90" :
                                          _gamemode == gameMode.ThreeSixtyDegree ? "360" : "solo";
                Presence.smallImageText = gameplayModeText;
                Presence.startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;

                // Set startTimestamp offset if we are in training mode
                if (_mainSetupData.practiceSettings != null)
                {
                    if (_mainSetupData.practiceSettings.startInAdvanceAndClearNotes)
                    {
                        Presence.startTimestamp -=
                            (long)Mathf.Max(0f, _mainSetupData.practiceSettings.startSongTime - 3f);
                    }
                    else
                    {
                        Presence.startTimestamp -= (long)_mainSetupData.practiceSettings.startSongTime;
                    }
                }

                DiscordRpc.UpdatePresence(Presence);
            }
        }
Beispiel #24
0
    xyLoc HandleAction(xyLoc currLoc, ControlledObject obj, bool canEat)
    {
        GameMaze m = board.GetComponent <BoardController> ().GetMaze();

        GameController.direction act = obj.GetAction(m, this, currLoc);
        switch (act)
        {
        case direction.kUp:
            if (CanMove(currLoc, direction.kUp))
            {
                currLoc.y++;
                if (canEat)
                {
                    pacmanLastMove = direction.kUp;
                }
            }
            break;

        case direction.kDown:
            if (CanMove(currLoc, direction.kDown))
            {
                currLoc.y--;
                if (canEat)
                {
                    pacmanLastMove = direction.kDown;
                }
            }
            break;

        case direction.kRight:
            if (CanMove(currLoc, direction.kRight))
            {
                currLoc.x++;
                if (canEat)
                {
                    pacmanLastMove = direction.kRight;
                }
            }
            break;

        case direction.kLeft:
            if (CanMove(currLoc, direction.kLeft))
            {
                currLoc.x--;
                if (canEat)
                {
                    pacmanLastMove = direction.kLeft;
                }
            }
            break;
        }
        if (currLoc.x < 0)
        {
            currLoc.x = pixelWidth - 9;
        }
        if (currLoc.x >= pixelWidth - 8)
        {
            currLoc.x = 0;
        }
        if (AtGridCenter(currLoc) && canEat)
        {
            bool powerUp, dot;
            eatenDots += board.GetComponent <BoardController> ().ClearCell(currLoc.x / 8, currLoc.y / 8, out dot, out powerUp);
            if (powerUp)
            {
                StartPowerUp();
                GetSound(gameSound.kEatPowerup).Play();
            }
            else if (dot)
            {
                GetSound(gameSound.kEatDot).Play();
            }
            if (eatenDots == 244)
            {
                eatenDots       = 0;
                currentGameMode = gameMode.kLevelComplete;
                GetSound(gameSound.kBackgroundSound).Stop();
            }
        }
        return(currLoc);
    }
Beispiel #25
0
    // Update is called once per frame
    void Update()
    {
        elapsedTime   += Time.deltaTime;
        pacmanElapsed += pacman.GetComponent <ControlledObject>().GetSpeed() * Time.deltaTime;
        pinkyElapsed  += pinky.GetComponent <ControlledObject>().GetSpeed() * Time.deltaTime;
        inkyElapsed   += inky.GetComponent <ControlledObject>().GetSpeed() * Time.deltaTime;
        blinkyElapsed += blinky.GetComponent <ControlledObject>().GetSpeed() * Time.deltaTime;
        clydeElapsed  += clyde.GetComponent <ControlledObject>().GetSpeed() * Time.deltaTime;
        switch (currentGameMode)
        {
        case gameMode.kWaitStart:
        {
            if (elapsedTime < 1 && !GetSound(gameSound.kStartSound).isPlaying)
            {
                GetSound(gameSound.kStartSound).Play();
            }
            if (elapsedTime > 4)
            {
                elapsedTime     = 0;
                currentGameMode = gameMode.kNormalGameMode;
                GetSound(gameSound.kBackgroundSound).loop = true;
                GetSound(gameSound.kBackgroundSound).Play();
            }
            break;
        }

        case gameMode.kPowerUpGameMode:
        {
            powerUpTimeLeft -= Time.deltaTime;
            if (powerUpTimeLeft <= 0)
            {
                EndPowerUp();
            }
            DoGamePlayLogic();
            break;
        }

        case gameMode.kNormalGameMode:
        {
            DoGamePlayLogic();
            break;
        }

        case gameMode.kLifeOver:
        {
            if (elapsedTime > 3)
            {
                elapsedTime = 0;

                currentGameMode = gameMode.kWaitStart;
                ResetCharacterLocations();
                pacman.transform.localScale = Vector3.one;
            }
            else
            {
                pacman.transform.localScale = Vector3.one * ((3.0f - elapsedTime) / 3.0f);
            }
            break;
        }

        case gameMode.kLevelComplete:
        {
            if (elapsedTime > 3)
            {
                elapsedTime = 0;

                currentGameMode = gameMode.kWaitStart;
                ResetCharacterLocations();
                board.GetComponent <BoardController> ().Reset();
            }
            break;
        }
        }
        SetInitialLocations();
    }
        public static void PutHighScore(string playerName, int gameScore, 
            gameMode gameMode, gameDifficulty gameDifficulty)
        {
            int type = ModeDifficultyToInt(gameMode, gameDifficulty);
            if (type == -1)
                return;

            if (IsInHighscores(gameScore, type))
            {
                highScore[type][highscorePlaces - 1] =
                    new KeyValuePair<string, Int32>(playerName,
                        gameScore);
                OrderGameScore();
            }
        }
 private static int ModeDifficultyToInt(gameMode gameMode,
     gameDifficulty gameDifficulty)
 {
     if (gameMode == gameMode.Classic &&
         gameDifficulty == gameDifficulty.Easy)
     {
         return 0;
     }
     if (gameMode == gameMode.Classic &&
         gameDifficulty == gameDifficulty.Hard)
     {
         return 1;
     }
     if (gameMode == gameMode.Arcade &&
         gameDifficulty == gameDifficulty.Easy)
     {
         return 2;
     }
     if (gameMode == gameMode.Arcade &&
         gameDifficulty == gameDifficulty.Hard)
     {
         return 3;
     }
     return -1;
 }
        /// <summary>
        /// Event handler for when the Ungulate menu entry is selected.
        /// </summary>
        void gameModeMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentGameMode++;

            if (currentGameMode > gameMode.Arcade)
                currentGameMode = 0;

            SetMenuEntryText();
        }
Beispiel #29
0
 public void startPlayWithFriend()
 {
     gMode = gameMode.playWithFriend;
     PhotonNetwork.ConnectUsingSettings();
 }
Beispiel #30
0
 public void startQuickGame()
 {
     gMode = gameMode.quickPlay;
     PhotonNetwork.ConnectUsingSettings();
 }
Beispiel #31
0
 public static void setGameOver()
 {
     status = gameMode.GameOver;
     GameObject.Find("button_back").renderer.enabled = false;
     MoveCamera(3);
 }
Beispiel #32
0
        static void Main(string[] args)
        {
            initialMenuLoad();
            currentGameMode = gameMode.basic;
            MazeLevel mazeMode = ChooseMazeMode();

            using (Engine gameEngine = new Engine(gameMode.basic, mazeMode))
            {
                Elements[,] Maze = gameEngine.initializeGame();

                Elements[,] updateMaze = Maze;

                Draw(Maze);

                do
                {
                    int score = gameEngine.getScore();
                    drawScore(score);

                    ConsoleKeyInfo keyInfo = keyListner.ReadKey(GameStepMilliseconds);
                    switch (keyInfo.Key)
                    {
                    case ConsoleKey.UpArrow:
                        updateMaze = gameEngine.updateGame(Direction.Up);
                        break;

                    case ConsoleKey.DownArrow:
                        updateMaze = gameEngine.updateGame(Direction.Down);
                        break;

                    case ConsoleKey.RightArrow:
                        updateMaze = gameEngine.updateGame(Direction.Right);
                        break;

                    case ConsoleKey.LeftArrow:
                        updateMaze = gameEngine.updateGame(Direction.Left);
                        break;

                    case ConsoleKey.Q:
                        ExitGame = true;
                        break;

                    default:
                        updateMaze = gameEngine.updateGame(Direction.Unchanged);
                        break;
                    }

                    if (updateMaze[0, 0] == Elements.snakeDeath)
                    {
                        ExitGame = true;
                    }
                    Console.Clear();
                    Draw(updateMaze);
                }while (ExitGame == false);

                Console.Write("Please enter your name: ");
                string highScoreName = keyListner.ReadKey(Int32.MaxValue).KeyChar.ToString() + Console.ReadLine();

                gameEngine.setName(highScoreName);
                gameEngine.handleHighSCore();

                EndGame(gameEngine.getScore(), gameEngine.getHighScoreList());
            }
        }
Beispiel #33
0
    void OnGUI()
    {
        //游戏标题
        GUIStyle labelstyle = new GUIStyle();

        labelstyle.normal.background = null;
        labelstyle.normal.textColor  = Color.red;
        labelstyle.fontSize          = 60;
        GUI.Label(new Rect(345, 20, 100, 50), "TicTacToe", labelstyle);


        if (GUI.Button(new Rect(200, 150, 80, 70), "重置游戏"))
        {
            initGame();
        }
        if (GUI.Button(new Rect(200, 230, 80, 70), "挑战玩家"))
        {
            initGame();
            mode = gameMode.player;
        }

        if (GUI.Button(new Rect(200, 310, 80, 70), "挑战电脑"))
        {
            initGame();
            mode = gameMode.computer;
        }
        //玩家模式
        if (mode == gameMode.player)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    //空白格子被点击
                    if (GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), ""))
                    {
                        //游戏未结束
                        if (isWin() == 0)
                        {
                            if (turn == 1)
                            {
                                map [i, j] = 1;
                            }
                            else
                            {
                                map [i, j] = 2;
                            }
                            turn = 1 - turn;
                        }
                    }
                    if (map [i, j] == 1)
                    {
                        GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), white);
                    }
                    if (map [i, j] == 2)
                    {
                        GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), black);
                    }
                }
            }
        }

        if (mode == gameMode.computer)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (map [i, j] == 1)
                    {
                        GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), white);
                    }
                    if (map [i, j] == 2)
                    {
                        GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), black);
                    }
                    //空白格子被点击
                    if (GUI.Button(new Rect(370 + i * 70, 160 + j * 70, 70, 70), "") && turn == 1)
                    {
                        //游戏未结束
                        if (isWin() == 0)
                        {
                            map[i, j] = 1;
                            turn      = 1 - turn;
                        }
                    }
                    else if (turn == 0)
                    {
                        Invoke("GoAI", (float)(0.3));//延迟0.3秒后调用AI函数
                        //GoAI();//AI走棋
                        turn = 1 - turn;
                    }
                }
            }
        }

        //显示结果
        GUIStyle resStyle = new GUIStyle();

        resStyle.normal.background = null;
        resStyle.normal.textColor  = Color.red;
        resStyle.fontSize          = 40;
        if (isWin() == 1)
        {
            GUI.Label(new Rect(385, 110, 100, 50), "白方获胜", resStyle);
        }
        else if (isWin() == 2)
        {
            GUI.Label(new Rect(385, 110, 100, 50), "黑方获胜", resStyle);
        }
        else if (isWin() == 3)
        {
            GUI.Label(new Rect(390, 110, 100, 50), "平局", resStyle);
        }
        if (mode == gameMode.player)
        {
            GUI.Label(new Rect(370, 400, 100, 50), "正在挑战玩家", resStyle);
        }
        else
        {
            GUI.Label(new Rect(370, 400, 100, 50), "正在挑战电脑", resStyle);
        }
    }
Beispiel #34
0
        public DualModePage(gameMode[] modeSels) : base()
        {
            // layout definition
            InitializeComponent();

            p1mode = modeSels[0];
            p2mode = modeSels[1];
            // game grid definition
            outerGrid.Width  = Styles.WindowSizeGenerator.screenWidth;
            outerGrid.Height = Styles.WindowSizeGenerator.screenHeight;

            ColumnDefinition aCol = new ColumnDefinition();

            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualGameModuleRight,
                                        GridUnitType.Pixel);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualAdditionModuleWidth,
                                        GridUnitType.Star);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualGameModuleRight,
                                        GridUnitType.Pixel);
            outerGrid.ColumnDefinitions.Add(aCol);

            Border border1 = new Border();

            border1.BorderBrush     = new SolidColorBrush(Colors.Gray);
            border1.BorderThickness = new Thickness(2, 2, 2, 2);

            Border border2 = new Border();

            border2.BorderBrush     = new SolidColorBrush(Colors.Gray);
            border2.BorderThickness = new Thickness(2, 2, 2, 2);

            games = t.NewDuelGame(
                p1mode.player == 1?"":PlayersName.getName(0),
                p2mode.player == 1?"":PlayersName.getName(1)
                );
            int[] gridSize = new int[2]
            {
                games.Item1.Height, games.Item1.Width
            };


            // game grid
            GameGrid gameGrid1 = new GameGrid(gridSize);

            border1.Child = gameGrid1;
            outerGrid.Children.Add(border1);
            border1.SetValue(Grid.RowProperty, 1);
            border1.SetValue(Grid.ColumnProperty, 1);

            GameGrid gameGrid2 = new GameGrid(gridSize);

            border2.Child = gameGrid2;
            outerGrid.Children.Add(border2);
            border2.SetValue(Grid.RowProperty, 1);
            border2.SetValue(Grid.ColumnProperty, 3);

            games.Item1.AddDisplay(gameGrid1);
            games.Item2.AddDisplay(gameGrid2);


            // set score board and next block board
            Grid scoreNextBlockGrid = new Grid();

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            RowDefinition aRow = new RowDefinition();

            aRow.Height = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(Styles.WindowSizeGenerator.screenHeight / 30,
                                         GridUnitType.Pixel);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            outerGrid.Children.Add(scoreNextBlockGrid);

            scoreNextBlockGrid.SetValue(Grid.ColumnProperty, 2);
            scoreNextBlockGrid.SetValue(Grid.RowProperty, 1);

            double scoreHeight = Styles.WindowSizeGenerator.scoreBoardHeight;
            double scoreWidth  = Styles.WindowSizeGenerator.scoreBoardWidth;

            ScoreGrid score1 = new ScoreGrid(scoreHeight, scoreWidth);
            ScoreGrid score2 = new ScoreGrid(scoreHeight, scoreWidth);

            // set next block board
            double    nextBlockHeight = Styles.WindowSizeGenerator.nextBoardHeight;
            double    nextBlockWidth  = Styles.WindowSizeGenerator.nextBoardWidth;
            NextBlock nextBlock1      = new NextBlock(nextBlockHeight, nextBlockWidth);
            NextBlock nextBlock2      = new NextBlock(nextBlockHeight, nextBlockWidth);

            scoreNextBlockGrid.Children.Add(nextBlock1);
            nextBlock1.SetValue(Grid.ColumnProperty, 1);
            nextBlock1.SetValue(Grid.RowProperty, 2);
            nextBlock1.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            nextBlock1.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            scoreNextBlockGrid.Children.Add(nextBlock2);
            nextBlock2.SetValue(Grid.ColumnProperty, 3);
            nextBlock2.SetValue(Grid.RowProperty, 2);
            nextBlock2.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            nextBlock2.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            games.Item1.AddDisplay(nextBlock1);
            games.Item2.AddDisplay(nextBlock2);

            scoreNextBlockGrid.Children.Add(score1);
            scoreNextBlockGrid.Children.Add(score2);

            score1.SetValue(Grid.ColumnProperty, 1);
            score1.SetValue(Grid.RowProperty, 0);
            score1.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            score1.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            score2.SetValue(Grid.ColumnProperty, 3);
            score2.SetValue(Grid.RowProperty, 0);
            score2.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            score2.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            score1.DataContext = games.Item1.ScoreSystem;
            score2.DataContext = games.Item2.ScoreSystem;

            // set background pictures.

            PicGen pic = new Cat3Gen();

            double picSizeRatio = 1.1;

            PicGenGrid pg1 = new PicGenGrid(pic, SquareGenerator.picSquareSize / picSizeRatio);

            aCanvas.Children.Add(pg1);
            pg1.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetLeft(pg1, (Styles.WindowSizeGenerator.screenWidth -
                                 pg1.getPicSize()[1] * SquareGenerator.picSquareSize / picSizeRatio) / 2);
            Canvas.SetBottom(pg1, Styles.WindowSizeGenerator.gameModuleTop +
                             (-1 * pg1.getPicSize()[0] *
                              SquareGenerator.picSquareSize / picSizeRatio) / 2.2);

            aRect1        = new Rectangle();
            aRect1.Fill   = new SolidColorBrush(Colors.Transparent);
            aRect1.Width  = gameGrid1.getGameGridSize()[1];
            aRect1.Height = gameGrid1.getGameGridSize()[0];
            outerGrid.Children.Add(aRect1);
            aRect1.SetValue(Grid.ColumnProperty, 1);
            aRect1.SetValue(Grid.RowProperty, 1);
            //game.GameEndEvent += gameEnd;
            games.DuelGameEndEvent += gameEndEffect;

            // set the mask rect (used when game is over)
            aRect2        = new Rectangle();
            aRect2.Fill   = new SolidColorBrush(Colors.Transparent);
            aRect2.Width  = gameGrid1.getGameGridSize()[1];
            aRect2.Height = gameGrid1.getGameGridSize()[0];
            outerGrid.Children.Add(aRect2);
            aRect2.SetValue(Grid.ColumnProperty, 3);
            aRect2.SetValue(Grid.RowProperty, 1);
        }
Beispiel #35
0
 public static void setPause()
 {
     Time.timeScale = 0;
     status = gameMode.Pause;
     MoveCamera(3);
 }