Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        if (lastGameState != game.currentGameState)
        {
            switch (game.currentGameState)
            {
            case Game.GameState.GAMESTART:
                turnText.text = "Start!";
                break;

            case Game.GameState.CHOOSEMOVESPLAYER:
                turnText.text = "Player Turn!";
                break;

            case Game.GameState.CHOOSEMOVESENEMY:
                turnText.text = "Enemy Turn!";
                break;

            case Game.GameState.EVALUATEMOVES:
                turnText.text = "Evaluate Moves!";
                break;

            default:
                break;
            }

            lastGameState = game.currentGameState;
        }
    }
Ejemplo n.º 2
0
 //set focus
 public Game()
 {
     this.Paint += new PaintEventHandler(Screen_Paint);
     this.KeyDown += new KeyEventHandler(Screen_KeyDown);
     this.KeyUp += new KeyEventHandler(Screen_KeyUp);
     //Size = new System.Drawing.Size(900, 600);
     FormBorderStyle = FormBorderStyle.FixedSingle;
     //FormBorderStyle = FormBorderStyle.None;
     ClientSize = new System.Drawing.Size(900, 600); // make this non resizeable
     MaximizeBox = false;
     //DoubleBuffered = true;
     keysDown = new List<Keys>();
     keyHandler = new KeyHandler();
     paintHandler = new PaintHandler();
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     player = new Player();
     player.setGlobalLocation(100, 1000);
     zoneFactory = new ZoneFactory();
     stopwatch = new Stopwatch();
     stopwatch.Start();
     gameState = new GameState();
     menuFactory = new MenuFactory(gameState);
     gameLoop();
 }
Ejemplo n.º 3
0
        private PassCode pc; //passcode for case

        #endregion Fields

        #region Constructors

        /*
         * Gives each place in the Floor a Tile class
         *
         * See Tile for more information
         */
        public Floor(int number, PassCode pc, bool[] have, Coordinate[] elevators, GameState gs)
        {
            this.number = number;
            this.floor = new Tile[Globals.FLOOR_LENGTH, Globals.FLOOR_WIDTH];
            this.doorPC = null;
            this.elevators = new Coordinate[Constants.NUM_ELEVATORS];
            this.coordinates = new ArrayList();

            //Prevent certain items from overlapping on the same tile

            for (int i = 0; i < Globals.FLOOR_LENGTH; i++)
                for (int j = 0; j < Globals.FLOOR_WIDTH; j++)
                {
                    floor[i, j] = new Tile();
                    Constants.taken[i, j] = false;
                }

            for (int i = 0; i < Constants.NUM_ELEVATORS; i++)
            {
                Constants.taken[elevators[i].x, elevators[i].y] = true;
            }

            //Call a random architect function
            int x = Constants.randGen.Next(0, architect.GetUpperBound(0) + 1);
            architect[x](this, Constants.taken);

            if (number == 1) firstFloorSetup(Constants.taken);

            storeElevatorCoords(Constants.taken, elevators);
            setUpPassCode(pc);

            putItems(Constants.taken, have);
            putHourglasses(Constants.taken);
        }
Ejemplo n.º 4
0
        public void Draw(GameState game)
        {
            this.surfaces.ModelviewMatrix.Matrix = Matrix4.LookAt(
                new Vector3(0, 0, 50), new Vector3(0, 0, 0), new Vector3(0, 1, 0)
                );

            game.Render();
        }
Ejemplo n.º 5
0
        public override void Initialize()
        {
            startScreen = new StartScreen((TankGame)Game, "Fonts/LargeFont");
            startScreen.SetData(GameState.START);
            currentState = GameState.START;

            base.Initialize();
        }
Ejemplo n.º 6
0
        public void Draw(GameState game)
        {
            this.surfaces.ModelviewMatrix.Matrix =
                Matrix4.CreateRotationY((float)game.Time.NumericValue) *
                Matrix4.LookAt(
                new Vector3(0, 0, 30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)
                );

            game.Render();
        }
Ejemplo n.º 7
0
 public MeshInstance(GameState game,
     Surface meshSurface, Matrix4Uniform transformUniform, Vector3 position, float scale)
     : base(game)
 {
     this.instance = new MeshSurfaceInstance(meshSurface, transformUniform)
     {
         Translation = position,
         Scale = scale,
     };
 }
Ejemplo n.º 8
0
    public void Goto(Game.GameState gameState)
    {
        switch (gameState)
        {
        case Game.GameState.Title: {
            titleMesh.GetComponent <Renderer>().enabled    = true;
            startMesh.GetComponent <Renderer>().enabled    = true;
            scoreMesh.GetComponent <Renderer>().enabled    = false;
            messageMesh.GetComponent <Renderer>().enabled  = false;
            authorMesh.GetComponent <Renderer>().enabled   = true;
            watchOutMesh.GetComponent <Renderer>().enabled = false;
            break;
        }

        case Game.GameState.Playing: {
            titleMesh.GetComponent <Renderer>().enabled   = false;
            startMesh.GetComponent <Renderer>().enabled   = false;
            scoreMesh.GetComponent <Renderer>().enabled   = true;
            messageMesh.GetComponent <Renderer>().enabled = false;
            authorMesh.GetComponent <Renderer>().enabled  = false;
            break;
        }

        case Game.GameState.Transition: {
            titleMesh.GetComponent <Renderer>().enabled    = false;
            startMesh.GetComponent <Renderer>().enabled    = false;
            scoreMesh.GetComponent <Renderer>().enabled    = true;
            messageMesh.GetComponent <Renderer>().enabled  = true;
            authorMesh.GetComponent <Renderer>().enabled   = false;
            watchOutMesh.GetComponent <Renderer>().enabled = true;
            break;
        }

        case Game.GameState.Over: {
            titleMesh.GetComponent <Renderer>().enabled    = false;
            startMesh.GetComponent <Renderer>().enabled    = false;
            scoreMesh.GetComponent <Renderer>().enabled    = false;
            messageMesh.GetComponent <Renderer>().enabled  = true;
            authorMesh.GetComponent <Renderer>().enabled   = false;
            watchOutMesh.GetComponent <Renderer>().enabled = false;
            break;
        }

        case Game.GameState.Chilling: {
            titleMesh.GetComponent <Renderer>().enabled    = false;
            startMesh.GetComponent <Renderer>().enabled    = false;
            scoreMesh.GetComponent <Renderer>().enabled    = false;
            messageMesh.GetComponent <Renderer>().enabled  = false;
            authorMesh.GetComponent <Renderer>().enabled   = false;
            watchOutMesh.GetComponent <Renderer>().enabled = false;
            break;
        }
        }
    }
Ejemplo n.º 9
0
    protected void UpdateResultText(bool force)
    {
        if (!force && Game.Instance.State == lastShownState)
        {
            return;
        }

        ResultData rd = resultDataLookup[Game.Instance.State];

        resultText.text = rd.text;
        restartButton.gameObject.SetActive(rd.restartIsVisible);

        lastShownState = Game.Instance.State;
    }
Ejemplo n.º 10
0
 public void OnGameStateChanged(Game.GameState currState)
 {
     if (currState == Game.GameState.GET_READY)
     {
         GetReady();
     }
     else if (currState == Game.GameState.GAME)
     {
         StartGame();
     }
     else if (currState == Game.GameState.END)
     {
         EndGame();
     }
 }
Ejemplo n.º 11
0
        public void menuMove(MenuFactory menuFactory, GameState gs)
        {
            if (keysDown.Contains(Keys.W))
            {
                menuFactory.getCurrentMenu().moveUp();
            }
            else if (keysDown.Contains(Keys.A))
            {
                menuFactory.getCurrentMenu().moveLeft();
            }
            else if (keysDown.Contains(Keys.S))
            {
                menuFactory.getCurrentMenu().moveDown();

            }
            else if (keysDown.Contains(Keys.D))
            {
                menuFactory.getCurrentMenu().moveLeft();
            }
            else if (keysDown.Contains(Keys.Enter))
            {
                menuFactory.swapMenus();
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Updates the game world while in play.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected void UpdateGame(GameTime gameTime)
        {
            if (this.levelManager.IsPlayerDead)
            {
                this.PauseGame(true);
            }
            else
            {
                this.levelManager.Update(gameTime, this.inputManager.Commands);
                if (this.levelManager.Complete)
                {
                    this.gameState = GameState.InMenu;
                    this.menuManager.ActiveMenu = MenuType.LevelComplete;
                    if (!this.levelManager.CurrentLevelCustom)
                    {
                        if (this.levelManager.CurrentLevel < GameSettings.TotalLevels && this.levelManager.CurrentLevel == this.gameSettings.LevelsUnlocked)
                        {
                            this.gameSettings.LevelsUnlocked += 1;
                            this.menuManager.UpdateLevelsUnlocked(this.gameSettings.LevelsUnlocked);
                        }

                        this.menuManager.SetLevelCompleteMenuText(this.gameSettings.AddScore(this.levelManager.CurrentLevel, this.levelManager.PlayerScore), this.levelManager.PlayerScore, this.levelManager.GetRating());
                    }
                    else
                    {
                        this.menuManager.SetLevelCompleteMenuText(HighScoreType.Local, this.levelManager.PlayerScore, this.levelManager.GetRating());
                    }

                    this.levelManager.EndLevel();
                    AudioManager.PlayBackgroundMusic(this.gameState == GameState.InGame);
                }
                else
                {
                    this.headsUpDisplay.HealthPercentage = this.levelManager.PlayerHealthPercentage;
                    this.headsUpDisplay.Score = this.levelManager.PlayerScore;
                    this.headsUpDisplay.ActivePowerUp = this.levelManager.PlayerPowerUp;
                    if (this.inputManager.Update(gameTime, false, false))
                    {
                        // Commands are available.
                        foreach (InputCommand command in this.inputManager.Commands)
                        {
                            switch (command)
                            {
                                case InputCommand.Pause:
                                    this.PauseGame(false);
                                    break;
                                case InputCommand.Exit:
                                    this.PauseGame(false);
                                    break;
                                default:
                                    break;
                            }
                        }
                    }

                    if (this.inputManager.VoiceCommandAvailable)
                    {
                        if (this.inputManager.LastVoiceCommand.ToUpperInvariant() == MenuConstants.PauseCommandName)
                        {
                            this.PauseGame(false);
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates the level editor.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected void UpdateEditor(GameTime gameTime)
        {
            NotificationManager.AddNotification(NotificationType.Place);
            this.UpdateMenu(gameTime);
            if (this.menuManager.ActiveMenu == MenuType.CustomContent)
            {
                this.gameState = GameState.InMenu;
            }
            else if (this.menuManager.ActiveMenu == MenuType.EditorOverlayMain)
            {
                this.levelEditor.Update(gameTime, this.inputManager.HandPosition, this.inputManager.Commands);
            }

            if (this.levelEditor.LevelsCreated != this.gameSettings.TotalCustomLevels)
            {
                this.gameSettings.TotalCustomLevels = this.levelEditor.LevelsCreated;
                this.menuManager.UpdateLevelsCreated(this.gameSettings.TotalCustomLevels);
            }
        }
Ejemplo n.º 14
0
 /**
  * Resume the game scene
  * for test purposes
  */
 public void Resume()
 {
     pausedMenu.SetActive(false);
     paused = false;
     state = GameState.PLAY;
     Time.timeScale = 1.0f;
     leapControl.setPointerMode(false);
 }
Ejemplo n.º 15
0
        public override void Update(GameTime gameTime)
        {
            if (currentState == GameState.START)
            {
                gameOverShown = true;
                startScreen.SetData(GameState.START);
                currentState = GameState.START;
                //Music-------------------------------------------
                if (((TankGame)Game).soundManager.endingPlaying)
                    ((TankGame)Game).soundManager.stopEnd();
                if(!((TankGame)Game).soundManager.introPlaying)
                    ((TankGame)Game).soundManager.playIntro();
                //------------------------------------------------
            }

            if ((Keyboard.GetState().IsKeyDown(Keys.Enter) && !enterPressed) || GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A))
            {
                if (currentState == GameState.START)
                {
                    ChangeGameState(GameState.MOVEHINT);
                    hintScreen = new MoveHintScreen((TankGame)Game);
                    ((TankGame)Game).noDebug();
                    //Music---------------------------------------------
                    if (((TankGame)Game).soundManager.introPlaying)
                        ((TankGame)Game).soundManager.stopIntro();
                    if (!((TankGame)Game).soundManager.backgroundPlaying)
                        ((TankGame)Game).soundManager.playBackground();
                    //--------------------------------------------------
                    ((TankGame)Game).Components.Add(hintScreen);
                }
            }

            if((Keyboard.GetState().IsKeyDown(Keys.Z)) && !debugPressed)
            {
                ChangeGameState(GameState.PLAYER1);
                debugPressed = true;
                ((TankGame)Game).startDebug();
            }

            if (currentState == GameState.MOVEHINT)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.A) ||
                    Keyboard.GetState().IsKeyDown(Keys.D) ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1 ||
                    GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X == 1)
                {
                    ((TankGame)Game).Components.Remove(hintScreen);
                    startScreen.clearScreen();
                    ChangeGameState(GameState.PLAYER1);
                    doThings();
                }
            }

            if (((TankGame)Game).gameRunning && ((TankGame)Game).currentTank.moveLimit <= 1.5 && ((TankGame)Game).turnsTaken == 0 && hasShown)
            {
                ChangeGameState(GameState.POWERUPHINT);
                powerUpHintScreen = new PowerUpHint((TankGame)Game);
                ((TankGame)Game).Components.Add(powerUpHintScreen);
                hasShown = false; 
            }

            if (currentState == GameState.POWERUPHINT)
            {
                if (((TankGame)Game).currentTank.moveLimit <= 0.5 || Keyboard.GetState().IsKeyDown(Keys.Space))
                {
                    ((TankGame)Game).Components.Remove(powerUpHintScreen);
                    ChangeGameState(GameState.PLAYER1);
                    startScreen.clearScreen();
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER1 || currentState == GameState.START)
            {
                if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.PLAYER2)
            {
                if (GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.A) & !aPressed || Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    doThings();
                }
            }

            if (currentState == GameState.END && gameOverShown)
            {
                gameOverScreen = new GameOverScreen((TankGame)Game);
                //Music ----------------------------------------
                ((TankGame)Game).Components.Add(gameOverScreen);
                if (((TankGame)Game).soundManager.backgroundPlaying)
                    ((TankGame)Game).soundManager.stopBackground();
                if (!((TankGame)Game).soundManager.endingPlaying)
                    ((TankGame)Game).soundManager.playEnd();
                //----------------------------------------------
                gameOverShown = false; 
            }

            if (currentState == GameState.END)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.RightShift))
                {
                    ((TankGame)Game).Components.Remove(gameOverScreen);
                    gameOverScreen.stopConfetti();
                }
            }

            if (Keyboard.GetState().IsKeyUp(Keys.Enter))
            {
                enterPressed = false;
            }
            if (GamePad.GetState(PlayerIndex.One).IsButtonUp(Buttons.A))
                aPressed = false;

            base.Update(gameTime);
        }
Ejemplo n.º 16
0
        public void ChangeGameState(GameState state)
        {
            switch (state)
            {
                case GameState.POWERUPHINT:
                    currentState = GameState.POWERUPHINT;
                    startScreen.SetData(GameState.POWERUPHINT);
                    break;

                case GameState.MOVEHINT:
                    currentState = GameState.MOVEHINT;
                    startScreen.SetData(GameState.MOVEHINT);
                    break;

                case GameState.START:
                    currentState = GameState.START;
                    startScreen.SetData(GameState.START);
                    break;

                case GameState.PLAYER1:
                    currentState = GameState.PLAYER1;
                    startScreen.SetData(GameState.PLAYER1);
                    break;

                case GameState.PLAYER2:
                    currentState = GameState.PLAYER2;
                    startScreen.SetData(GameState.PLAYER2);
                    break;

                case GameState.END:
                    currentState = GameState.END;
                    startScreen.SetData(GameState.END);
                    break;
            }
        }
Ejemplo n.º 17
0
 public EventSwitchGameState(Game.GameState o, Game.GameState n)
 {
     Type     = EVENTTYPE;
     oldState = o;
     newState = n;
 }
Ejemplo n.º 18
0
        void Start()
        {
            // get network manager
            networkManager = Camera.mainCamera.GetComponent<NetworkManager>();

            // set network manager
            GameState.setNetworkManager(networkManager);

            //initializing states //
            for( int i=0; i<(int)enum_States.SIZE; i++)
            {
                switch(i)
                {
                    case (int)enum_States.LOGIN: States[i] = new GameState_Login(); break;
                    case (int)enum_States.LOBBY: States[i] = new GameState_Lobby(); break;
                    case (int)enum_States.ROOM: States[i] = new GameState_Room(); break;
                    case (int)enum_States.GAME: gameState = States[i] = new GameState_Game(); break;
                    case (int)enum_States.ACCOUNT: States[i] = new GameState_Account(); break;
                    default: States[i] = new GameState_Login(); break;
                }
                States[i].setStateMachine(this); // let them know statemachine
            }

            nextState = States[(int)enum_States.LOGIN];
        }
Ejemplo n.º 19
0
 //Init globals
 private void setupDifficulty(GameState gs)
 {
     difficulty = gs.difficulty;
     switch (difficulty)
     {
         case 0: //easy
             Globals.NUM_FLOORS = Constants.EASY_NUM_FLOORS;
             Globals.FLOOR_LENGTH = Constants.EASY_FLOOR_LENGTH;
             Globals.FLOOR_WIDTH = Constants.EASY_FLOOR_WIDTH;
             Globals.NUM_MONSTERS = Constants.EASY_NUM_MONSTERS;
             break;
         case 1: //medium
             Globals.NUM_FLOORS = Constants.MED_NUM_FLOORS;
             Globals.FLOOR_LENGTH = Constants.MED_FLOOR_LENGTH;
             Globals.FLOOR_WIDTH = Constants.MED_FLOOR_WIDTH;
             Globals.NUM_MONSTERS = Constants.MED_NUM_MONSTERS;
             break;
         case 2: //hard
             Globals.NUM_FLOORS = Constants.HARD_NUM_FLOORS;
             Globals.FLOOR_LENGTH = Constants.HARD_FLOOR_LENGTH;
             Globals.FLOOR_WIDTH = Constants.HARD_FLOOR_WIDTH;
             Globals.NUM_MONSTERS = Constants.HARD_NUM_MONSTERS;
             break;
     }
 }
Ejemplo n.º 20
0
        private void setupFloors(GameState gs)
        {
            floors = new Floor[Globals.NUM_FLOORS]; //Creating 10 foors

            Constants.taken = new bool[Globals.FLOOR_LENGTH, Globals.FLOOR_WIDTH];

            Coordinate[] elevCoord = new Coordinate[Constants.NUM_ELEVATORS];
            for (int i = 0; i < Globals.NUM_FLOORS; i++)
            {
                //Get the elevator coordinates, pass them to Floor constructor
                for (int j = 0; j < Constants.NUM_ELEVATORS; j++)
                {
                    if(j == 0) //Stored at index 0, the correct elevator
                        elevCoord[j] = correct_elevator[i].getCoord();
                    else
                        elevCoord[j] = wrong_elevator[i].getCoord();
                }

                if (gs.floorNumber == i + 1) //Only restore settings of one floor
                    floors[i] = new Floor(i + 1, gs.pc, gs.have, elevCoord, gs);
                else
                    floors[i] = new Floor(i + 1, null, null, elevCoord, gs);
            }
        }
Ejemplo n.º 21
0
 public MenuFactory(GameState gameState)
 {
     this.gameState = gameState;
     createMenus();
 }
Ejemplo n.º 22
0
        private void setupPlayer(GameState gs)
        {
            ArrayList items = new ArrayList();
            for (int i = 0; i < Constants.NUM_ITEMS; i++)
                if (gs.have[i])
                {
                    if (i == (int)iName.SECRETCASE)
                        items.Add(new Case(Constants.ITEMS[i], gs.caseHint, gs.pc, gs.caseLocked)); //get real hint form DB
                    else
                        items.Add(new Record(Constants.ITEMS[i], "Digit " + (i + 1) + " = " + gs.pc.code[i]));
                }

            player = new Player(gs.playerName, floors[gs.floorNumber - 1], gs.coord, items);
        }
Ejemplo n.º 23
0
        protected override void OnLoad(EventArgs e)
        {
            this.renderer = new GameRenderer();

            this.game = new GameState();
        }
Ejemplo n.º 24
0
        /**
         * Initialisation of the game
         * Generation of the scene from the level file
         */
        void Start()
        {
            //GameModel.Init();
            GameModel.resetDataBeforeLevel ();

            level = GameModel.ActualLevel;

            //Debug.Log (level.Name);

            //Debug.Log ("START Start GameController");

            //recupération des options
            handSide = HandSide.RIGHT_HAND;

            //lire fichier niveau
            //LevelParser parser = new LevelParser (FILE_PATH);

            //génération du héros

            //instanciate a hero using the class contained in the model
            Hero modelHero = GameModel.Hero;
            string heroClass = modelHero.GetType ().ToString ();

            if (heroClass == "Warrior")
            heroGameObject = Instantiate (warrior);
            else if (heroClass == "Monk")
            heroGameObject = Instantiate (monk);
            else if (heroClass == "Wizard")
            heroGameObject = Instantiate (wizard);
            else
            heroGameObject = Instantiate (warrior);

            //Debug.Log (heroGameObject);
            GameModel.HerosInGame.Add (heroGameObject.GetComponent<Hero> ());
            hero = GameModel.HerosInGame [0];
            float vitesseHeros = hero.MovementSpeed;
            hero.XpQuantity = modelHero.XpQuantity;

            //LEAP
            leapInstance = Instantiate (leapPrefab);
            //Debug.Log ("leapInstance : " + leapInstance);
            //the leap motion scene is child of camera so it follow the translation
            leapInstance.transform.parent = Camera.allCameras[0].transform;
            leapInstance.transform.position = new Vector3 (0f, 2.5f, 1.6f);
            //sets the "hand parent" field so the arms also are child of camera and don't flicker
            leapControl = leapInstance.GetComponent<HandController> ();
            leapControl.setModel(handSide, hero);
            leapControl.setGameController(this);

            leapControl.handParent = Camera.allCameras[0].transform;

            leapCanvas = Instantiate(leapCanvasPrefab);

            //Génération de terrain
            float longueurTerrain = vitesseHeros * tempsMusique;

            /*ter = Instantiate( terrain, new Vector3(0,0,0), Quaternion.identity) as GameObject;
            ter.transform.Rotate (0, -90, 0);
            ter.transform.localScale = new Vector3 (longueurTerrain, 1, 1);
            */
            ter = Instantiate (terrain, new Vector3 (-100, -2, 0), Quaternion.identity) as Terrain;
            //ter.terrainData.size = new Vector3 (1.0f, 1.0f, 1.0f);
            //ter.terrainData.size = new Vector3 (200, 200, 1);

            //génération des ennemis
            npcList = new List<GameObject> ();
            //Debug.Log (npcList);

            //List<Thing> ennemies = parser.getEnnemies ();
            List<Item> items = level.ItemList;
            //Debug.Log ("FINAL ITEM LIST COUNT : " + items.Count);

            foreach (Item item in items) {
            GameObject go = null;

            if (item.Type == "basicLancer")
                go = basicLancer;
            else if (item.Type == "fireLancer")
                go = fireLancer;
            else if (item.Type == "iceLancer")
                go = iceLancer;
            else if (item.Type == "basicDragonet")
                go = basicDragonet;
            else if (item.Type == "fireDragonet")
                go = fireDragonet;
            else if (item.Type == "iceDragonet")
                go = iceDragonet;
            else if (item.Type == "wall")
                go = wall;
            else if (item.Type == "cannon")
                go = canon;
            else if (item.Type == "assassin")
                go = assassin;
            else if (item.Type == "life")
                go = lifePotion;
            else if (item.Type == "power")
                go = powerPotion;
            else if (item.Type == "invincibility")
                go = invincibilityPotion;

            if (go != null){
                GameObject instance = Instantiate(go, new Vector3(item.PositionInX, go.transform.localScale.y/2, vitesseHeros*item.PositionInSeconds), Quaternion.identity) as GameObject;
                NPC npc = instance.GetComponent<NPC>();

                if (npc != null)
                    GameModel.NPCsInGame.Add(npc);
                //GameModel.NPCsInGame[GameModel.NPCsInGame.Count-1].transform.Rotate(0, 180, 0);
            }
            }

            //Génération du HUD
            hudMaster = Instantiate (hud).GetComponent<HudMaster>();
            //Debug.Log ("hudMaster : " + hudMaster);
            state = GameState.PLAY;

            Camera.main.transform.parent = heroGameObject.transform;
            Camera.main.transform.position = new Vector3 (0, 2.18f, 0);
            //Camera.main.transform.Translate(new Vector3(0, 2.18f, 0));

            pausedMenu = GameObject.Find("Canvas");
            pausedMenu.SetActive(false);
            paused = false;

            Time.timeScale = 1.0f;

            musicCanvas = Instantiate (musicCanvasPrefab);
            audioManager = musicCanvas.GetComponent<AudioManager> ();

            audioManager.SetMusicName (level.MusicPath);
            audioManager.Init ();

            //If leap is not connected, Pause game and show warning message
            if ( !leapControl.IsConnected())
            {
            //pause()
            audioManager.Pause();
            Time.timeScale = 0.0f;

            GameObject detectedCanvas = GameObject.Find("DetectedLeapCanvas");
            detectedCanvas.GetComponent<Canvas>().enabled = true;
            }

            //Debug.Log ("END Start GameController");

            //ADD TUTORIAL MANAGER

            if (level.Tutorial) {
            GameObject tutoGO = Resources.Load("prefabs/controllers/TutorialManager") as GameObject;
             	Instantiate (tutoGO);
            }
        }
Ejemplo n.º 25
0
        /**
         * Function called when the game state is "play"
         * Takes in count player actions on the leap
         * Makes the AI react
         * Updates the HUDs
         */
        void play()
        {
            //Gestion héros
            /*if (!bloque) {
            //faire avancer Héros
            //hero.Run(Time.deltaTime);
            GameModel.HerosInGame[0].Run(Time.deltaTime);
            //Camera.main.transform.position = new Vector3(0, 2.18f, hero.GetPosition().z);
            }*/

            Hero hero = GameModel.HerosInGame [0];

            //update hud state
            float currentHealthPercent = 100.0f*hero.HealthPoint/hero.MaxHealthPoint;
            float currentPowerPercent = 100.0f*hero.PowerQuantity/hero.MaxPowerQuantity;
            //Debug.Log("Life: " + currentHealthPercent);

            hudMaster.setLevel (HudMaster.HudType.Life, currentHealthPercent);
            hudMaster.setLevel (HudMaster.HudType.Special, currentPowerPercent);
            hudMaster.updateXP (hero.XpQuantity/hero.XpQuantityNextLevel*100.0f, (int)hero.Level + 1);

            //Debug.Log (GameModel.NPCsInGame.Count);
            if (GameModel.NPCsInGame.Count == 0) {
            //			Debug.Log (timerEnd);
            timerEnd += Time.deltaTime;
            if (timerEnd >= maxTimerEnd){
                NextLevel();
            }
            }

            if(currentHealthPercent <= 0)
            {
            Time.timeScale = 0;
            //Debug.Log("you are dead");
            state = GameState.DEAD;
            }

            audioManager.Play();

            if (Input.GetKeyDown(KeyCode.R)){
            Restart();
            }else if (Input.GetKey(KeyCode.Escape)){
            Quit ();
            } else if (Input.GetKeyDown(KeyCode.P)){
            state = GameState.PAUSE;
            }
        }
Ejemplo n.º 26
0
 public void changeState(enum_States newStates)
 {
     nextState = States[(int)newStates];
 }
Ejemplo n.º 27
0
 public void changeState(enum_States newStates, Dictionary<string,object> data  )
 {
     nextState = States[(int)newStates];
     nextState.setData(data) ;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SticKart"/> class.
 /// </summary>
 public SticKart()
 {
     this.notificationManager = null;
     this.gameState = GameState.InMenu;
     this.TargetElapsedTime = TimeSpan.FromSeconds(SticKart.FrameTime);
     this.screenDimensions = new Vector2(1360.0f, 768.0f);
     this.graphics = new GraphicsDeviceManager(this);
     this.graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
     this.graphics.PreferredBackBufferWidth = (int)this.screenDimensions.X;
     this.graphics.PreferredBackBufferHeight = (int)this.screenDimensions.Y;
     Camera2D.Initialize(this.screenDimensions);
     this.headsUpDisplay = new HeadsUpDisplay(this.screenDimensions);
     this.Content.RootDirectory = "Content";
     this.inputManager = new InputManager(this.screenDimensions, ControlDevice.Kinect, SticKart.DisplayColourStream);
     this.levelManager = new LevelManager(this.screenDimensions, SticKart.FrameTime);
     this.levelEditor = new Editor(this.screenDimensions);
     this.menuManager = new MenuManager(this.screenDimensions);
     this.menuManager.OnBeginLevelDetected += this.BeginLevel;
     this.menuManager.OnQuitGameDetected += this.QuitGame;
     this.menuManager.OnEditLevelSelected += this.EditLevel;
     this.menuManager.OnEditorSaveSelected += this.SaveCustomLevel;
     this.menuManager.OnEditorUndoSelected += this.EditorUndo;
     this.menuManager.OnEditorTypeSelected += this.EditorChangeType;
     this.menuManager.OnResumeGameDetected += this.UnpauseGame;
     this.handSprite = new Sprite();
     this.graphics.IsFullScreen = true; // TODO: set to true for release
 }
Ejemplo n.º 29
0
        // Update is called per one frame
        void Update()
        {
            if( nextState == null )
            {
                if( currentState != gameState )
                    currentState.Update();
            }
            else
            {
                if( currentState != null )
                    currentState.beforeChanging();

                currentState = nextState;
                nextState = null;

                currentState.afterChanged();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Event handler for a begin level event.
        /// </summary>
        /// <param name="value">The value passed from the sender.</param>
        protected void BeginLevel(int value)
        {
            if (value == 0 && this.levelManager.CurrentLevelCustom)
            {
                this.gameState = GameState.InMenu;
                this.menuManager.ActiveMenu = MenuType.CustomContent;
            }
            else
            {
                bool isCustom = value < 0;
                if (isCustom)
                {
                    value *= -1;
                }

                if (value == 0)
                {
                    value = this.levelManager.CurrentLevel + 1;
                }
                else if (value == int.MaxValue)
                {
                    value = this.levelManager.CurrentLevel;
                    isCustom = this.levelManager.CurrentLevelCustom;
                }

                Camera2D.Reset();
                this.levelManager.EndLevel();
                if (isCustom)
                {
                    if (value <= this.gameSettings.TotalCustomLevels)
                    {
                        this.inputManager.Reset();
                        this.gameState = GameState.InGame;
                        this.levelManager.BeginLevel(value, isCustom);
                    }
                }
                else
                {
                    if (value <= GameSettings.TotalLevels)
                    {
                        this.inputManager.Reset();
                        this.gameState = GameState.InGame;
                        this.levelManager.BeginLevel(value, isCustom);
                    }
                    else
                    {
                        this.menuManager.ActiveMenu = MenuType.About;
                        AudioManager.PlayBackgroundMusic(false);
                        this.gameState = GameState.InMenu;
                    }
                }
            }
        }
Ejemplo n.º 31
0
 private void errorCheck(GameState gs)
 {
     //TODO error check gs floor number, coord, and pass code digits
     //error check coord
     if (gs.coord.x < 0 ||
         gs.coord.y < 0)
         gs.coord = new Coordinate(0, 0); //change bad coord to default
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Event handler for an edit level event.
 /// </summary>
 /// <param name="value">The value passed from the sender.</param>
 protected void EditLevel(int value)
 {
     Camera2D.Reset();
     if (value == 0)
     {
         this.menuManager.ActiveMenu = MenuType.EditorOverlayMain;
         this.levelEditor.CreateNewLevel();
         this.gameState = GameState.InEditor;
     }
     else if (value > 0 && value <= GameSettings.MaxCustomLevels && value <= this.gameSettings.TotalCustomLevels)
     {
         this.menuManager.ActiveMenu = MenuType.EditorOverlayMain;
         this.levelEditor.LoadLevel(value);
         this.gameState = GameState.InEditor;
     }
 }
Ejemplo n.º 33
0
        public Graphic startGame(GameState gs)
        {
            condition = new PlayingCondition(this);
            errorCheck(gs);
            setupDifficulty(gs);
            setupElevators();
            setupFloors(gs);
            setupPlayer(gs);

            return new Graphic(player.Coord, null, "Find your way out!");
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Pauses the game.
 /// </summary>
 /// <param name="playerDied">A value indicating whether the player is dead or not.</param>
 protected void PauseGame(bool playerDied)
 {
     this.menuManager.UpdatePauseMenuTiles(playerDied);
     AudioManager.PauseBackgroundMusic();
     this.gameState = GameState.InMenu;
     this.menuManager.ActiveMenu = MenuType.Pause;
     AudioManager.PlayBackgroundMusic(this.gameState == GameState.InGame);
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Event handler for a resume game event.
 /// </summary>
 /// <param name="value">The value passed from the sender.</param>
 protected void UnpauseGame(bool value)
 {
     AudioManager.StopBackgroundMusic();
     AudioManager.PlayBackgroundMusic(true);
     this.gameState = GameState.InGame;
 }
Ejemplo n.º 36
0
 public HalloweenBot(Game.GameState state)
 {
     this.state = state;
 }