Exemplo n.º 1
0
 private void checkStates()
 {
     if (pState == null || mState == null)
     {
         mState = GameStateManager.man.mState;
         pState = GameStateManager.man.pState;
     }
 }
Exemplo n.º 2
0
        public GameState()
        {
            //get a reference to pause state
            pState = GameStateManager.man.pState;
            mState = GameStateManager.man.mState;

            //initialize list of entity updaters and the collision manager singleton
            updaters = new List <Action>();
            int seed = 5; //Game.rng.Next();

            wMan           = new Managers.WorldManager(seed, 10, 100, 10d, 64, Game.colMan, new Point(0, 0), this);
            Game.worldMaxX = wMan.worldMaxX;
            Game.worldMaxY = wMan.worldMaxY;
            LastWorldPos   = new Point(Game.worldCenterX, Game.worldCenterY);

            //initialize background entity
            background = new quad(Managers.WorldManager.worldTex, this);
            background.AddComponent(new cBackgroundManager());

            //initialize player character entity
            playerCharacter = new quad("Game/Content/roguelikeCharBeard_transparent.png", this);
            playerCharacter.AddComponent(new cFollowCamera(playerCharacter));
            cCollider  playerCollider  = new cCollider(playerCharacter);
            cMouseFire playerBulletMan = new cMouseFire(playerCharacter);

            playerHealth = new cHealth(10, playerCharacter, this, 30);
            playerCharacter.AddComponent(playerHealth);
            playerCharacter.AddComponent(playerCollider);
            playerCharacter.AddComponent(new cKeyboardMoveandCollide(5, 1.5f, playerCollider));
            playerCharacter.AddComponent(playerBulletMan);
            playerCharacter.pos.xPos = Game.window.Width / 2 + 10;
            playerCharacter.pos.yPos = Game.window.Height / 2 + 10;
            playerCharacter.AddComponent(new cDEBUG_POS());
            playerCharacter.AddComponent(new cRangedWeapon(playerCharacter, playerBulletMan, 10, this));
            playerCharacter.tag = "Player";

            //initialize enemy manager
            eMan = new Managers.EnemyManager(playerCharacter, playerHealth, 1000, this);
            updaters.Add(eMan.update);

            //initialize UI entities
            gameover = new Button("Game Over. Click to go to Main Menu", Game.buttonBackground, toMenuState, OpenTK.Input.MouseButton.Left, this);
            gameover.SetActive(false);

            uiHealth = new Button("Health: 00", Game.buttonBackground, "", OpenTK.Input.MouseButton.Left, this);
            uiHealth.t.AddComponent(new cUIHealth(uiHealth.t, playerHealth));

            uiLevel = new Button("Level 00", Game.buttonBackground, "", OpenTK.Input.MouseButton.Left, this);
            uiLevel.t.AddComponent(new cUILevel(uiLevel.t));

            uiPos = new Button("[0,0] {00,00}", Game.buttonBackground, "", OpenTK.Input.MouseButton.Left, this);
            uiPos.t.AddComponent(new cUIPosition(uiPos.t));
        }
Exemplo n.º 3
0
        public GameStateManager() : base()
        {
            if (man == null)
            {
                man = this;
            }

            Debug.Text(OpenTK.Audio.OpenAL.Alc.GetString(IntPtr.Zero, OpenTK.Audio.OpenAL.AlcGetString.DefaultAllDevicesSpecifier));

            //create each state
            mState = new MenuState();
            pState = new PauseState();
            gState = new GameState();

            if (debugEnabled)
            {
                dState = new DebugState();
                Debug.Text("Debug is enabled, loading debugState");
            }
        }