コード例 #1
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>();
            col      = new Managers.CollisionManager(100);
            int seed = 5; //Game.rng.Next();

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

            //initialize background entity
            background = new quad(Managers.WorldManager.worldTex);
            background.AddComponent(new cBackgroundManger());
            updaters.Add(background.update);

            //initialize player character entity
            playerCharacter = new quad("Content/roguelikeCharBeard_transparent.png");
            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));
            playerCharacter.tag = "Player";
            updaters.Add(playerCharacter.update);

            //initialize enemy manager
            eMan = new Managers.EnemyManager(playerCharacter, playerHealth, 1000);
            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);
            updaters.Add(gameover.update);

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

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

            uiPos = new Button("[0,0] {00,00}", Game.buttonBackground, "", OpenTK.Input.MouseButton.Left, this);
            uiPos.t.AddComponent(new cUIPosition(uiPos.t));
            updaters.Add(uiPos.update);
        }
コード例 #2
0
ファイル: TestState.cs プロジェクト: NullandKale/NullEngine
        public quad createEntity()
        {
            quad temp = new quad("Game/Content/bullet.png", this);

            temp.AddComponent(new Components.cBounce(temp));
            temp.pos.xScale = 0.75f;
            temp.pos.yScale = 0.75f;
            temp.pos.xPos   = Game.rng.Next(Game.windowRect.Left, Game.windowRect.Right);
            temp.pos.yPos   = Game.rng.Next(Game.windowRect.Top, Game.windowRect.Bottom);
            return(temp);
        }