示例#1
0
 /// <summary>
 /// 管理Ui界面的切换
 /// </summary>
 ///
 public void statechangge(gamestate state)
 {
     m_state = state;                //存储状态
     if (m_state == gamestate.start) //当界面为开始界面
     {
         start_ui.SetActive(true);   //界面设置显示与否
         game_ui.SetActive(false);
         end_ui.SetActive(false);
         //用标志符不允许手臂运动
         m_weapon.canmove = false;
         //刚进入时候停止播放音乐
         music.Stop();
     }
     else if (m_state == gamestate.game) //当界面为游戏界面
     {
         start_ui.SetActive(false);      //界面设置显示与否
         game_ui.SetActive(true);
         end_ui.SetActive(false);
         m_weapon.canmove = true;
         starttime();
         music.Play();
         m_feipanmanger.creat();
     }
     else if (m_state == gamestate.end) //当界面为结束界面
     {
         start_ui.SetActive(false);     //界面设置显示与否
         game_ui.SetActive(false);
         end_ui.SetActive(true);
         m_weapon.canmove = false;
         music.Stop();
         m_feipanmanger.stopcreat();
         m_feipanmanger.removefeipan();
     }
 }
示例#2
0
    /*
     * Un minimax classique, renvoie la note du plateau
     */
    static int minmax(gamestate g)
    {
        eval0(g);
        if (g.ended)
        {
            return(g.note);
        }
        int maxNote = -10000;

        if (!g.firstToPlay)
        {
            maxNote = 10000;
        }
        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                if (can_move_xy(x, y, g))
                {
                    apply_move_xy(x, y, g);
                    int currentNote = minmax(g);
                    cancel_move_xy(x, y, g);
                    //  Minimum ou Maximum selon le coté ou l'on joue
                    if (currentNote > maxNote == g.firstToPlay)
                    {
                        maxNote = currentNote;
                    }
                }
            }
        }
        return(maxNote);
    }
示例#3
0
    /*
     * Renvoie le coup de l'IA
     */
    static move play(gamestate g)
    {
        move minMove = new move();

        minMove.x = 0;
        minMove.y = 0;
        int minNote = 10000;

        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                if (can_move_xy(x, y, g))
                {
                    apply_move_xy(x, y, g);
                    int currentNote = minmax(g);
                    Console.Write(x + ", " + y + ", " + currentNote + "\n");
                    cancel_move_xy(x, y, g);
                    if (currentNote < minNote)
                    {
                        minNote   = currentNote;
                        minMove.x = x;
                        minMove.y = y;
                    }
                }
            }
        }
        Console.Write("" + minMove.x + minMove.y + "\n");
        return(minMove);
    }
示例#4
0
 public static void Main(String[] args)
 {
     for (int i = 0; i < 2; i++)
     {
         gamestate state = init0();
         move      c     = new move();
         c.x = 1;
         c.y = 1;
         apply_move(c, state);
         move d = new move();
         d.x = 0;
         d.y = 0;
         apply_move(d, state);
         while (!state.ended)
         {
             print_state(state);
             apply_move(play(state), state);
             eval0(state);
             print_state(state);
             if (!state.ended)
             {
                 apply_move(play(state), state);
                 eval0(state);
             }
         }
         print_state(state);
         Console.Write(state.note + "\n");
     }
 }
示例#5
0
 //  On affiche l'état
 static void print_state(gamestate g)
 {
     Console.Write("\n|");
     for (int y = 0; y < 3; y++)
     {
         for (int x = 0; x < 3; x++)
         {
             if (g.cases[x][y] == 0)
             {
                 Console.Write(" ");
             }
             else if (g.cases[x][y] == 1)
             {
                 Console.Write("O");
             }
             else
             {
                 Console.Write("X");
             }
             Console.Write("|");
         }
         if (y != 2)
         {
             Console.Write("\n|-|-|-|\n|");
         }
     }
     Console.Write("\n");
 }
示例#6
0
 // 釦押下時
 public void OnClickGameMain()
 {
     level  = 1;
     gstate = gamestate.MAIN;
     LogoCreate();
     TitlePanel.SetActive(false);
     GameOverPanel.SetActive(false);
 }
示例#7
0
 // Use this for initialization
 void Start()
 {
     gameObject.layer = 8;
     anim             = GetComponent <Animator>();
     state            = gamestate.Instance;
     isAttacking      = false;
     isAttacking      = false;
     musicIsPlaying   = false;
 }
 // Update is called once per frame
 void Update()
 {
     if (Input.anyKey)
     {
         gamestarted  = true;
         StateMachine = gamestate.playing;
         Destroy(gameObject);
     }
 }
        public static @event TriggerRegisterGameStateEvent(trigger whichTrigger, gamestate whichState, limitop opcode, real limitval)
        {
            @event triEvent = new @event()
            {
                gamestateEvent = whichState
            };

            whichTrigger.events.Add(triEvent);
            return(triEvent);
        }
    IEnumerator IntroCountdown(float secs)
    {
        yield return(new WaitForSeconds(secs));

        GameStartPanel.gameObject.GetComponentInChildren <Text>().text = "Go!";
        yield return(new WaitForSeconds(.5f));

        GameStartPanel.gameObject.SetActive(false);
        gstate = gamestate.WAITINGFORTILE;
    }
示例#11
0
 void Start()
 {
     elevatorSpeed = 5.0f;
     state         = gamestate.Instance;
     floor         = 2;
     floor1Y       = GameObject.Find("Floor1").transform.position.y;
     floor2Y       = GameObject.Find("Floor2").transform.position.y;
     floor3Y       = GameObject.Find("Floor3").transform.position.y;
     direction     = "down";
 }
示例#12
0
    //  On applique un mouvement
    static void apply_move_xy(int x, int y, gamestate g)
    {
        int player = 2;

        if (g.firstToPlay)
        {
            player = 1;
        }
        g.cases[x][y] = player;
        g.firstToPlay = !g.firstToPlay;
    }
示例#13
0
 public void Transition(gamestate newstate)
 {
     if (states.Contains(new KeyValuePair <gamestate, gamestate>(state, newstate)))
     {
         state = newstate;
     }
     else
     {
         Debug.Log("Transition does not exist");
     }
 }
示例#14
0
        protected override void Initialize()
        {
            int currentwidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;

            if (currentwidth == 1920)
            {
                wide = true;
            }
            else
            {
                wide = false;
            }
            // start in windowed mode
            full = false;
            if (wide)
            {
                vwidth  = 960;
                vheight = 540;
                graphics.PreferredBackBufferWidth  = vwidth;
                graphics.PreferredBackBufferHeight = vheight;
            }
            else
            {
                vwidth  = 640;
                vheight = 512;
                graphics.PreferredBackBufferWidth  = vwidth;
                graphics.PreferredBackBufferHeight = vheight;
            }
            graphics.ApplyChanges();

            spritebatch = new SpriteBatch(GraphicsDevice);
            gamecontent = new GameContent(Content.ServiceProvider, wide);

            r = new Random();

            fx_volume = 1.0f;
            fx_pitch  = -1.0f;
            fx_pan    = 0.0f;

            editor       = new Editor(gamecontent, spritebatch, vwidth, vheight, wide, full);
            currentstate = gamestate.WaitingBall;

            score     = 0;
            ballsleft = 5;
            level     = new Level(0, "Game Level", vwidth, vheight, wide, full, gamecontent);
            level.Load();

            MediaPlayer.Play(gamecontent.music);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume      = fx_volume;

            base.Initialize();
        }
 public void getHit()
 {
     vida -= 1;
     heartController();
     if (vida <= 0)
     {
         playerTransform.gameObject.SetActive(false);
         painelGameOver.SetActive(true);
         currentState = gamestate.GAMEOVER;
         trocarMusica(musicaFase.GAMEOVER);
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (currentState == gamestate.TITULO && Input.GetKeyDown(KeyCode.Space))
     {
         currentState = gamestate.GAMEPLAY;
         painelTitulo.SetActive(false);
     }
     else if (currentState == gamestate.GAMEOVER && Input.GetKeyDown(KeyCode.Space))
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
     else if (currentState == gamestate.END && Input.GetKeyDown(KeyCode.Space))
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
 }
    public void OpenInventory()
    {
        currentGamestate = gamestate.inventory;
        inventoryScreen.SetActive(true);

        for (int i = 0; i < inventoryScreen.transform.Find("Item Holder").childCount; i++)
        {
            if (i < inventory.Count && inventory[i].itemID > 0)
            {
                inventoryScreen.transform.Find("Item Holder").GetChild(i).gameObject.SetActive(true);
                inventoryScreen.transform.Find("Item Holder").GetChild(i).GetComponent <Image>().sprite = inventory[i].itemSprite;
            }
            else
            {
                inventoryScreen.transform.Find("Item Holder").GetChild(i).gameObject.SetActive(false);
            }
        }
    }
示例#18
0
 void merge_correct()
 {
     empty_list.Clear();
     foreach (tile_behaviour t in all_list)
     {
         t.merged = false;
         if (t.number == 0)
         {
             empty_list.Add(t);
         }
         if (t.number == 2048 && count == 0)
         {
             game = gamestate.not_playing;
             screen.SetActive(false);
             gamewon.SetActive(true);
             count += 1;
         }
     }
 }
示例#19
0
        protected override void LoadContent()
        {
            state = gamestate.startmenu;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            TreeEntLeft          = Content.Load <Texture2D>("Tree2Left");
            TreeEntRight         = Content.Load <Texture2D>("Tree2Right");
            TreeEntPunchLeft     = Content.Load <Texture2D>("treeattackleft");
            TreeEntPunchRight    = Content.Load <Texture2D>("treeattackright");
            HippieLeft           = Content.Load <Texture2D>("IdleLeftH3");
            HippieRight          = Content.Load <Texture2D>("IdleRightH3");
            HippiePunchLeft      = Content.Load <Texture2D>("HippieWeaponLeft");
            HippiePunchRight     = Content.Load <Texture2D>("HippieWeaponRight");
            SyrupLoverLeft       = Content.Load <Texture2D>("IdleLeftH");
            SyrupLoverRight      = Content.Load <Texture2D>("IdleRightH");
            SyrupLoverPunchLeft  = Content.Load <Texture2D>("Maple_Syrus");
            SyrupLoverPunchRight = Content.Load <Texture2D>("Maple_Syrus");
            lumberJackLeft       = Content.Load <Texture2D>("Right_PunchH2");
            lumberJackRight      = Content.Load <Texture2D>("Left_PunchH2");
            lumberJackPunchLeft  = Content.Load <Texture2D>("Axe_Left");
            lumberJackPunchRight = Content.Load <Texture2D>("Axe_Right");
            powerup        = Content.Load <Texture2D>("Maple_Syrus");
            background     = Content.Load <Texture2D>("ground");
            bar            = Content.Load <Texture2D>("lifeBar");
            GameOver       = Content.Load <Texture2D>("GameOver");
            UnknownSoldier = Content.Load <Texture2D>("punchingCage");

            menu = new SimpleMenu("MainMenu");
            menu.LoadContent(Content);
            menu.CenterElement(750, 800);
            menu.MoveElement(50, 150);
            playerRand = Content.Load <Texture2D>("RandomPlayer");

            playerReady = Content.Load <Texture2D>("Ready");

            MainMenu = Content.Load <Texture2D>("MainMenu");

            Player1BodyLeft = SyrupLoverLeft;
            Player2BodyLeft = SyrupLoverRight;
        }
示例#20
0
        protected void gameplayUpdate()
        {
            KeyboardState keystate = Keyboard.GetState();

            playerMechanics(keystate, 0);
            playerMechanics(keystate, 1);
            hitDetection();
            if (isDead(0) || isDead(1))
            {
                state = gamestate.gameover;
                //endgame player 2 win
            }
            List <powerup> powerupRemove = new List <powerup>();

            foreach (powerup item in powerupRemove)
            {
                if (item.PowerUpRect.Y >= Window.ClientBounds.Bottom)
                {
                    powerupRemove.Add(item);
                }
            }

            foreach (powerup item in powerupRemove)
            {
                listOfPowerups.Remove(item);
            }
            powerupRemove.Clear();

            player1Avatar.X = players[0].bodyRectangle.X;
            player1Avatar.Y = players[0].bodyRectangle.Y;
            player2Avatar.X = players[1].bodyRectangle.X;
            player2Avatar.Y = players[1].bodyRectangle.Y;
            player1fist.X   = players[0].fistRectangle.X;
            player1fist.Y   = players[0].fistRectangle.Y;
            player2fist.X   = players[1].fistRectangle.X;
            player2fist.Y   = players[1].fistRectangle.Y;

            foreach (powerup p in listOfPowerups)
            {
                p.rectangleYPos = p.Velocity;
            }
        }
示例#21
0
    static gamestate init0()
    {
        int[][] cases = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            int[] tab = new int[3];
            for (int j = 0; j < 3; j++)
            {
                tab[j] = 0;
            }
            cases[i] = tab;
        }
        gamestate a = new gamestate();

        a.cases       = cases;
        a.firstToPlay = true;
        a.note        = 0;
        a.ended       = false;
        return(a);
    }
示例#22
0
    // Initialize timer and human players game status
    private void init()
    {
        Gamestate = gamestate.start_to_join;
        Winstate  = winstate.none;
        p1Reticle.SetActive(false);
        p2Reticle.SetActive(false);
        p1JoinText.SetActive(true);
        p2JoinText.SetActive(true);
        timer = human_playtime;

        timer_TMP.gameObject.SetActive(false);
        winner_TMP.gameObject.SetActive(false);
        empires_fall_TMP.gameObject.SetActive(false);
        sea_levels_rose_TMP.gameObject.SetActive(false);

        // Init region unit count
        foreach (region Region in region.allRegions)
        {
            Region.units = region.base_units;
        }
    }
示例#23
0
    // タッチクリック時
    private void TouchAct(Vector2 pos)
    {
        Vector2 worldPoint = Camera.main.ScreenToWorldPoint(pos);

        foreach (RaycastHit2D hit in Physics2D.RaycastAll(worldPoint, Vector2.zero))
        {
            // ターゲットを見つけた時
            if (hit && hit.collider.tag == "Target")
            {
                LogoDelete();
                level++;
                LogoCreate();
                return;
            }
        }

        // 失敗
        gstate = gamestate.OVER;
        GameOverPanel.SetActive(true);
        naichilab.RankingLoader.Instance.SendScoreAndShowRanking(level);
    }
示例#24
0
        protected void gameOverUpdate()
        {
            players[0].XVelocity  = 0;
            players[0].YVelocity  = 0;
            players[1].XVelocity  = 0;
            players[1].YVelocity  = 0;
            players[0].IsHit      = false;
            players[0].IsJumping  = false;
            players[0].IsPunching = false;
            players[0].IsSlamming = false;
            players[1].IsHit      = false;
            players[1].IsJumping  = false;
            players[1].IsPunching = false;
            players[1].IsSlamming = false;

            KeyboardState keystate = Keyboard.GetState();

            if (keystate.IsKeyDown(Keys.Enter))
            {
                state = gamestate.startmenu;
            }
        }
示例#25
0
    public IEnumerator move(direction movement)
    {
        game           = gamestate.not_playing;
        move_available = false;
        for (int i = 0; i < 4; i++)
        {
            switch (movement)
            {
            case direction.up:
                StartCoroutine(coroutine_move_up(column[i], i));
                break;

            case direction.down:
                StartCoroutine(coroutine_move_down(column[i], i));
                break;

            case direction.right:
                StartCoroutine(coroutine_move_down(row[i], i));
                break;

            case direction.left:
                StartCoroutine(coroutine_move_up(row[i], i));
                break;
            }
        }
        while (!(all_directions[0] && all_directions[1] && all_directions[2] && all_directions[3]))
        {
            yield return(null);
        }
        game = gamestate.playing;
        if (move_available)
        {
            merge_correct();
            generate_empty();
        }

        StopAllCoroutines();
    }
示例#26
0
 void gameStateChangedHandlerFunction(gamestate GS)
 {
     if (GS == gamestate.LoadPlayer)
     {
         loadPlayer();
     }
     else if (GS == gamestate.StartUpdate)
     {
         if (!LockCreepValuesUpdate)
         {
             InvokeRepeating("FetchCreepCount", 0.1f, 0.1f);
         }
     }
     else if (GS == gamestate.StopUpdate)
     {
         CancelInvoke("FetchCreepCount");
     }
     else if (GS == gamestate.InGameCreatingMap)
     {
         UIManager.gs = UIManager.guistate.InGameLearning;
         StageSpawner.spawnEnabled = true;
     }
 }
示例#27
0
        private void newTurn()
        {
            gstate = gamestate.WAIT;
            czarplayerid++;
            if (czarplayerid == players.Count())
            {
                czarplayerid = 0;
            }

            fillHands();
            foreach (int card in playedthisturn)
            {
                whtdeck.discard.Add(card);
            }

            playedthisturn.Clear();
            foreach (CardsAgainstHumanityPlayer player in players)
            {
                player.unplay();
            }

            blkcard = blkdeck.drawFrom();
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

             switch (currentgamestate)
            {
                case gamestate.startscreen:
                    Start.Update(gameTime);
                    ViewHighScore.Update(gameTime);
                    break;
                case gamestate.playingGame:
                    BatPl.Update(gameTime);
                   elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                   if (elapsed >= WaveLengthOne)
                    {
                        elapsed = 0f;
                        currentgamestate = gamestate.startscreen;
                    }
                    for (int i = 0; i < WaveOneList.Count; i++)
                   {
                            WaveOneList[i].Update(gameTime);
                        //if(WaveOneList[i].intersectWith(BatPl))
                        //{
                            //WaveOneList[i].Stop = true;
                        //}
                        if (WaveOneList[i].position.Y >= BatPl.position.Y  && (WaveOneList[i].position.X >= BatPl.position.X && WaveOneList[i].position.X <= BatPl.position.X + 150))
                        {

                            //Fruit.position = BatPl.position;
                        }
                    }

                    break;
                case gamestate.highScore:
                    BackButton.Update(gameTime);
                    break;
                case gamestate.ScoreEntry:
                    TextEntry.Update(gameTime);
                    SubmitButton.Update(gameTime);
                    break;
                default:
                    break;
            }

            base.Update(gameTime);
        }
示例#29
0
 // Sets the instance to null when the application quits
 public void OnApplicationQuit()
 {
     instance = null;
 }
示例#30
0
文件: Game1.cs 项目: aslone/Team18
        /// <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)
        {
            //Get keyboard state
            keystate = Keyboard.GetState();

            if (state == gamestate.menu)
            {
                // Allows the game to exit
                if ((keystate.IsKeyDown(Keys.Escape) == true)
                    && (lastKeyState.IsKeyUp(Keys.Escape) == true))
                    this.Exit();

                if ((keystate.IsKeyDown(Keys.Space) == true)
                    && (lastKeyState.IsKeyUp(Keys.Space) == true))
                {
                    state = gamestate.play;
                }
            }
            else if (state == gamestate.play)
            {
                if ((keystate.IsKeyDown(Keys.Escape) == true)
                    && (lastKeyState.IsKeyUp(Keys.Escape) == true))
                    state = gamestate.menu;

                player.Update(gameTime);
            }

            lastKeyState = keystate;
            base.Update(gameTime);
        }
 private void HighScoreBackButton_Clicked(object sender, EventArgs e)
 {
     currentgamestate = gamestate.startscreen;
     LoadContent();
 }
        private void SubmitButton_Clicked(object sender, EventArgs e)
        {
            string PersonName = TextEntry.Text;
            int Score = 300;
            PeopleList.Add(new PersonDetails(PersonName, Score));

            PersonDetails temp = null;

            for (int write = 0; write < PeopleList.Count; write++)
            {
                for (int sort = 0; sort < PeopleList.Count - 1; sort++)
                {
                    if (PeopleList[sort].ScoreGetSet < PeopleList[sort + 1].ScoreGetSet)
                    {
                        temp = PeopleList[sort + 1];
                        PeopleList[sort + 1] = PeopleList[sort];
                        PeopleList[sort] = temp;
                    }
                }
            }

            PeopleList.Remove(PeopleList[5]);
            HighScoreList.GetSetTopFivePeople = PeopleList;
            HighScoreList.SavePeople();
            HighScoreList.LoadPeople();
            currentgamestate = gamestate.startscreen;
        }
 private void StartButton_Clicked(object sender, EventArgs e)
 {
     currentgamestate = gamestate.playingGame;
     LoadContent();
 }
示例#34
0
 static bool can_move_xy(int x, int y, gamestate g)
 {
     return(g.cases[x][y] == 0);
 }
示例#35
0
 static bool can_move(move m, gamestate g)
 {
     return(can_move_xy(m.x, m.y, g));
 }
示例#36
0
 static void cancel_move(move m, gamestate g)
 {
     cancel_move_xy(m.x, m.y, g);
 }
 private void ViewHighScoresButton_Clicked(object sender, EventArgs e)
 {
     currentgamestate = gamestate.highScore;
     LoadContent();
 }
示例#38
0
文件: Game1.cs 项目: csce3513/Team18
        /// <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)
        {
            //Get keyboard state
            keystate = Keyboard.GetState();

            //At Menu screen
            if (state == gamestate.menu)
            {
                //play "in-game" audio
                audioHomeInst.Volume = 0.5f;
                audioHomeInst.Play();
                audioInGameInst.Stop();
                audioCollisionInst.Stop();
                audioGameLostInst.Stop();
                audioScene2Inst.Stop();
                audioVictoryInst.Stop();

                // Allows the game to exit
                if ((keystate.IsKeyDown(Keys.Escape) == true)
                    && (lastKeyState.IsKeyUp(Keys.Escape) == true))
                    this.Exit();

                // Go to playing state
                if ((keystate.IsKeyDown(Keys.Space) == true)
                    && (lastKeyState.IsKeyUp(Keys.Space) == true))
                {
                    state = gamestate.story1;

                    //Load First Map
                    MapState = gamemap.start;
                    previousMapState = MapState;

                    //Healthy. Default state of player
                    Action.PlayerState = ActionHandler.CharacterStatus.Play;
                    player.status = 6;

                    //StartMap Load
                    StartMap_Load();
                }

                //get player to help menu
                if ((keystate.IsKeyDown(Keys.F1) == true)
                    && (lastKeyState.IsKeyUp(Keys.F1) == true))
                {
                    state = gamestate.help;
                }
            }

            // allow player to quit help screen
            else if (state == gamestate.help)
            {
                if ((keystate.IsKeyDown(Keys.Escape) == true)
                    && (lastKeyState.IsKeyUp(Keys.Escape) == true))
                    state = gamestate.menu;

            }

            else if (state == gamestate.story1)
            {
                player.CharacterUpdate(gameTime);
                player.HandleSourceRect(gameTime);

                if ((keystate.IsKeyDown(Keys.Space) == true)
                   && (lastKeyState.IsKeyUp(Keys.Space) == true))
                    state = gamestate.play;
            }

            else if (state == gamestate.story2)
            {
                player.CharacterUpdate(gameTime);
                player.HandleSourceRect(gameTime);
                Zelda.ZeldaUpdate(gameTime);
                Zelda.HandleSourceRect(gameTime);

                if ((keystate.IsKeyDown(Keys.Space) == true)
                   && (lastKeyState.IsKeyUp(Keys.Space) == true))
                    state = gamestate.play;
            }

            //At playing screen
            else if (state == gamestate.play)
            {

                // GO to Menu state
                if ((keystate.IsKeyDown(Keys.Escape) == true)
                    && (lastKeyState.IsKeyUp(Keys.Escape) == true))
                    state = gamestate.menu;

                //Default state of Character
                Action.PlayerState = ActionHandler.CharacterStatus.Play;

                //Enemy and Player action has to be called here
                if (MapState == gamemap.lose)
                {
                    audioInGameInst.Stop();
                    audioCollisionInst.Stop();
                    audioScene2Inst.Stop();
                    audioScene3Inst.Stop();
                    audioScene4Inst.Stop();
                    audioScene5Inst.Stop();
                    audioGameLostInst.Volume = 0.7f;
                    audioGameLostInst.Play();
                    player.CharacterUpdate(gameTime);
                    player.HandleSourceRect(gameTime);
                    Zelda.ZeldaUpdate(gameTime);
                    Zelda.HandleSourceRect(gameTime);
                }
                else if (MapState == gamemap.win)
                {
                    audioInGameInst.Stop();
                    audioCollisionInst.Stop();
                    audioScene2Inst.Stop();
                    audioScene3Inst.Stop();
                    audioScene4Inst.Stop();
                    audioScene5Inst.Stop();
                    audioVictoryInst.Volume = 0.7f;
                    audioVictoryInst.Play();
                    player.CharacterUpdate(gameTime);
                    player.HandleSourceRect(gameTime);
                    Zelda.ZeldaUpdate(gameTime);
                    Zelda.HandleSourceRect(gameTime);
                    player.status = 5;//Indicate WIN
                    Zelda.status = 5;
                }
                //First(default) map setting
                else if (MapState == gamemap.start)
                {
                    audioHomeInst.Pause();
                    audioInGameInst.Volume = 0.7f;
                    audioInGameInst.Play();

                    //StartMap Update
                    CollisionUpdate(gameTime);

                    //This means Move to Next map
                    //Replace Objects for the New Map
                    if (Action.PlayerState == ActionHandler.CharacterStatus.Next)
                    {
                        MapState = gamemap.second;

                        //SecondMap Loading
                        SecondMap_Load();

                    }
                    //Lose killed by Enemy
                    else if (Action.PlayerState == ActionHandler.CharacterStatus.Lose)
                        MapState = gamemap.lose;

                }
                //Second Map basically same as First except Enamy2 added here
                else if (MapState == gamemap.second)
                {
                    audioScene2Inst.Volume = 0.5f;
                    audioScene2Inst.Play();
                    audioInGameInst.Stop();
                    audioHomeInst.Stop();

                    //Second Map Update
                    CollisionUpdate(gameTime);

                    if (Action.PlayerState == ActionHandler.CharacterStatus.Lose)
                        MapState = gamemap.lose;
                    else if (Action.PlayerState == ActionHandler.CharacterStatus.Next)
                    {
                        previousMapState = MapState;
                        MapState = gamemap.third;
                        //Final Map loading
                        ThirdMap_Load();

                    }
                }
                else if (MapState == gamemap.third)
                {
                    audioScene3Inst.Volume = 0.5f;
                    audioScene3Inst.Play();
                    audioScene2Inst.Stop();
                    audioHomeInst.Stop();

                    //Third Map Collision and Update
                    CollisionUpdate(gameTime);

                    if (Action.PlayerState == ActionHandler.CharacterStatus.Save)
                    {
                        previousMapState = MapState;
                        MapState = gamemap.Escape1;
                        //Escape map loaded
                        state = gamestate.story2;
                        player.status = 6;//Stop moving for story
                        Zelda.status = 5;
                        Escape1_Load();
                    }
                    else if (Action.PlayerState == ActionHandler.CharacterStatus.Lose)
                        MapState = gamemap.lose;
                }
                else if (MapState == gamemap.Escape1)
                {
                    audioScene4Inst.Volume = 0.5f;
                    audioScene4Inst.Play();
                    audioScene3Inst.Stop();
                    audioHomeInst.Stop();

                    //Escape1 Map Collision and Update
                    CollisionUpdate(gameTime);

                    if (Action.PlayerState == ActionHandler.CharacterStatus.Next)
                    {
                        previousMapState = MapState;
                        MapState = gamemap.Escape2;
                        Escape2_Load();
                    }
                    else if (Action.PlayerState == ActionHandler.CharacterStatus.Lose)
                        MapState = gamemap.lose;

                }
                else if (MapState == gamemap.Escape2)
                {
                    audioScene5Inst.Volume = 0.5f;
                    audioScene5Inst.Play();
                    audioScene4Inst.Stop();
                    audioHomeInst.Stop();

                    //Escape2 Map Collision and Update
                    CollisionUpdate(gameTime);

                    if (Action.PlayerState == ActionHandler.CharacterStatus.Next)
                    {
                        MapState = gamemap.win;
                        player.updatePos(new Vector2(450, 100));
                        Zelda.updatePos(new Vector2(410, 100));
                    }
                    else if (Action.PlayerState == ActionHandler.CharacterStatus.Lose)
                        MapState = gamemap.lose;

                }

            }

            lastKeyState = keystate;
            base.Update(gameTime);
        }
示例#39
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            float time = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            petime += elapsed;
            if (Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit();

            if (game == gamestate.unpause)
            {
                UpdateCamera(gameTime);
               //mipSys.solver(gameTime);////euler solver
               mipSys.updateParticles(gameTime);////simple solver
                if (petime >= pdelay)
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.P))
                    {
                        game = gamestate.pause;
                        petime = 0.0f;
                        cameraRotation += time * 0.05f;
                    }
                }
            }
            else
            {

                if (petime >= pdelay)
                {
                    if (Keyboard.GetState().IsKeyDown(Keys.P))
                    {
                        game = gamestate.unpause;
                        petime = 0.0f;
                    }

                }
            }

            base.Update(gameTime);
        }
示例#40
0
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {

            if(nowState == gamestate.Preface)
            {

                targetObject.transform.rotation = playerObject.transform.rotation;
                targetObject.transform.Rotate(Vector3.up, (float)TargetRotation[index].x);
                targetObject.transform.Rotate(Vector3.right, (float)TargetRotation[index].y);
                targetObject.transform.Rotate(Vector3.forward, (float)TargetRotation[index].z);

                textCamera.SetActive(false);
                isEvaluateTextAppear = 0;
                nowState = gamestate.Playing;
                recordManagerObject.startTask(targetObject,playerObject);

            }else if(nowState == gamestate.End)
            {
                Debug.Log("Ends");
                //doing nothing. Closed manually.
            }else if(nowState == gamestate.Playing){

        //				A old method with bias....
        //				double difference = (eulerAngleXRealigned(targetObject.transform.eulerAngles.x,playerObject.transform.eulerAngles.x))
        //									*(eulerAngleXRealigned(targetObject.transform.eulerAngles.x,playerObject.transform.eulerAngles.x))
        //									+(eulerAngleXRealigned(targetObject.transform.eulerAngles.y,playerObject.transform.eulerAngles.y))
        //						  			*(eulerAngleXRealigned(targetObject.transform.eulerAngles.y,playerObject.transform.eulerAngles.y))
        //									+(eulerAngleXRealigned(targetObject.transform.eulerAngles.z,playerObject.transform.eulerAngles.z))
        //						  			*(eulerAngleXRealigned(targetObject.transform.eulerAngles.z,playerObject.transform.eulerAngles.z));
        //
        //				difference = Math.Pow(difference,0.5);

                float difference = Quaternion.Angle( targetObject.transform.rotation, playerObject.transform.rotation );

                int errorType = -1;

                SetListActive(VisibleTextList,false);

                if(difference < 17){
                    errorType = 0;
                    VisibleTextList[4].SetActive(true);
                }else if(difference >= 17 && difference < 34){
                    errorType = 1;
                    VisibleTextList[5].SetActive(true);
                }else if(difference >= 34){
                    errorType = 2;
                    VisibleTextList[6].SetActive(true);
                }

                recordManagerObject.endTask(errorType,difference);

                int overallTaskIndex = index - startPoint;

                evaluateCamera.SetActive(true);
                evaluateTextAppearTargetTime = Time.time + 1;
                isEvaluateTextAppear = 1;

                if((overallTaskIndex+1) >= 12){
                    VisibleTextList[3].SetActive(true);
                    textCamera.SetActive(true);
                    nowState = gamestate.End;
                    recordManagerObject.endDeviceTask();

                }else{//new round
                    index ++;
                    targetObject.transform.rotation = playerObject.transform.rotation;
                    targetObject.transform.Rotate(Vector3.up, (float)TargetRotation[index].x);
                    targetObject.transform.Rotate(Vector3.right, (float)TargetRotation[index].y);
                    targetObject.transform.Rotate(Vector3.forward, (float)TargetRotation[index].z);

                    recordManagerObject.startTask(targetObject,playerObject);

                }

            }
        }

        //		Debug.Log(playerObject.transform.eulerAngles.x+","+playerObject.transform.eulerAngles.y+","+playerObject.transform.eulerAngles.z);

        if(isEvaluateTextAppear == 1){// in the text showed process
            double timeDifference = evaluateTextAppearTargetTime - Time.time ;
            if(timeDifference <=0){// End text
                isEvaluateTextAppear = 0;
                VisibleTextList[4].SetActive(false);
                VisibleTextList[5].SetActive(false);
                VisibleTextList[6].SetActive(false);
                evaluateCamera.SetActive(false);
            }
        }
        {//test
            float angle = Quaternion.Angle( targetObject.transform.rotation, playerObject.transform.rotation );

            // get a "forward vector" for each rotation
            Vector3 forwardA = targetObject.transform.rotation * Vector3.forward;
            Vector3 forwardB = playerObject.transform.rotation * Vector3.forward;

            // get a numeric angle for each vector, on the X-Z plane (relative to world forward)
            float angleA = Mathf.Atan2(forwardA.x, forwardA.z) * Mathf.Rad2Deg;
            float angleB = Mathf.Atan2(forwardB.x, forwardB.z) * Mathf.Rad2Deg;

            // get the signed difference in these angles
            float angleDiff = Mathf.DeltaAngle( angleA, angleB );

            Debug.Log(""+angle);

        }

        //		{
        //
        //		double difference = (eulerAngleXRealigned(targetObject.transform.eulerAngles.x,playerObject.transform.eulerAngles.x))
        //			*(eulerAngleXRealigned(targetObject.transform.eulerAngles.x,playerObject.transform.eulerAngles.x))
        //				+(eulerAngleXRealigned(targetObject.transform.eulerAngles.y,playerObject.transform.eulerAngles.y))
        //				*(eulerAngleXRealigned(targetObject.transform.eulerAngles.y,playerObject.transform.eulerAngles.y))
        //				+(eulerAngleXRealigned(targetObject.transform.eulerAngles.z,playerObject.transform.eulerAngles.z))
        //				*(eulerAngleXRealigned(targetObject.transform.eulerAngles.z,playerObject.transform.eulerAngles.z));
        //
        //		//			double difference = (targetObject.rotation.eulerAngles.x - playerObject.rotation.eulerAngles.x)
        //		//					*(targetObject.rotation.eulerAngles.x - playerObject.rotation.eulerAngles.x)
        //		//					+(targetObject.rotation.eulerAngles.y - playerObject.rotation.eulerAngles.y)
        //		//					*(targetObject.rotation.eulerAngles.y - playerObject.rotation.eulerAngles.y)
        //		//					+(targetObject.rotation.eulerAngles.z - playerObject.rotation.eulerAngles.z)
        //		//					*(targetObject.rotation.eulerAngles.z - playerObject.rotation.eulerAngles.z);
        //
        //
        //
        //		difference = Math.Pow(difference,0.5);
        //
        //			Debug.Log(difference);
        //		}
    }
示例#41
0
文件: Game1.cs 项目: aslone/Team18
        /// <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

            //Game starts with the menu
            state = gamestate.menu;

            //Player that can move around
            player = new Character();

            //Backgrounds
            menu = new Sprite();
            BG0 = new Sprite();

            base.Initialize();
        }
示例#42
0
文件: Game1.cs 项目: csce3513/Team18
        /// <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

            //Game starts with the menu
            state = gamestate.menu;

            //Game play starts with start map
            MapState = gamemap.start;
            previousMapState = MapState;

            //Player that can move around
            player = new Character();

            //ID number 0 indicate character that is only one exist.
            player.SpriteID = 0;

            //ID number 2xx indicate Enemy
            Enemy1 = new EnemyCharacter();
            Enemy1.SpriteID = 201;
            Dragon1 = new Dragon();
            Dragon1.SpriteID = 202;
            Enemy2 = new EnemyCharacter();
            Enemy2.SpriteID = 203;
            Enemy3 = new EnemyCharacter();
            Enemy3.SpriteID = 204;
            Enemy4 = new EnemyCharacter();
            Enemy4.SpriteID = 205;

            //ID number 1 indicate PrincessZelda
            Zelda = new PrincessZelda();
            Zelda.SpriteID = 1;

            //Backgrounds
            menu = new Sprite();
            help = new Sprite();
            BG0 = new Sprite();
            Blood = new Sprite();
            Thanks = new Sprite();
            Story1 = new Sprite();
            Story2 = new Sprite();

            //ID 9xx indicate non object sprite
            menu.SpriteID = 901;

            //ID 1xx indicate stationary object
            tree1 = new Sprite(101);
            tree2 = new Sprite(102);
            tree3 = new Sprite(103);
            tree4 = new Sprite(104);
            tree5 = new Sprite(105);

            //ID 5xx indicate Key acition abject that cause some action
            Arrow = new Sprite(501);

            //Action Handling including Collision Detection and EnemySight
            Action = new Collision();

            base.Initialize();
        }