Example #1
0
        private void Initialize()
        {
            // Technical Points;
            mTechnicalPoints = kMaxTechnicalPoints;
            mRechargeTimer = 0;
            mRechargeTP = false;
            mWalkTimer = 0;
            mFiringDelay = 0;
            //mSkill1Available = true;
            //mSkill2Available = true;

            // Initialize name
            mName = "Arcanian";

            // Initialize Arcanian
            mCurrentState = ArcanianState.ArcanianInMenu;
            Velocity = kVelocity;
            mHealth = kHealth;
            mFacingLeft = false;
            mIsBlinking = false;
            mBlinkTimer = 0;
            mNumBlink = 0;
            mPlayShieldRegenCue = false;

            // Initialize aimer
            mAimerBar = new XNACS1Rectangle(Center, kAimerBarWidth, kAimerBarHeight);
            mAimerBar.Color = Color.Transparent;
            mAimerBar.RotateAngle = kAimerAngle;
            mAimer = new XNACS1Circle(Center, kAimerRadius);
            mAimer.Texture = "Arcanian/aimer";
            mAimer.RotateAngle = kAimerAngle;

            // Initialize bound
            mBoundMin = new XNACS1Rectangle(Center, kBoundWidth, kBoundHeight);
            mBoundMax = new XNACS1Rectangle(Center, kBoundWidth, kBoundHeight);
            mBoundMin.Texture = texBound;
            mBoundMax.Texture = texBound;
            mBoundMin.RemoveFromAutoDrawSet();
            mBoundMax.RemoveFromAutoDrawSet();

            // Initialize shield
            mShield = kShield;
            mShieldArt = new XNACS1Circle(Center, kShieldRadius);

            // Hide arcanian at menu/selection screen
            HideArcanian();

            // Temporary til we have a minimap view
            mMiniMapXPosition = World.World.WorldMax.X / 2;
        }
        protected override void UpdateWorld()
        {
            if (gameStarted && !gameOver) {
            int roomX = (int)theLevel.currentRoom.X;
            int roomY = (int)theLevel.currentRoom.Y;
            if (pauseScreen == null) {
                float x = theLevel.rooms[roomX, roomY].roomOrigin.X + 50f;
                float y = theLevel.rooms[roomX, roomY].roomOrigin.Y + 27f;
                pauseScreen = new XNACS1Rectangle(new Vector2(x, y), 100f, 54f);
                pauseScreen.Color = Color.Black;
            }

            if (GamePad.ButtonStartClicked())
                paused = paused ? false : true;

            if (!paused) {
                if (GamePad.ButtonBackClicked())
                    Exit();

                bool newLevel = false;
                newLevel = theLevel.updateLevel(GamePad.Buttons, GamePad.ThumbSticks);

                if (newLevel) {
                    if (currentLevel < totalLevels) {
                        currentLevel++;
                        theLevel.unloadLevel();

                        switch (currentLevel) {
                            case 1:
                                path = @"level1.txt";
                                break;
                            case 2:
                                path = @"level2.txt";
                                break;
                            case 3:
                                path = @"level3.txt";
                                break;
                            case 4:
                                path = @"level4.txt";
                                break;
                            default:
                                break;
                        }
                        s = new StreamReader(path);
                        theLevel = new Level(ref s);
                        theLevel.loadInitialRoom(difficulty);
                    }

                    else {
                        gameOver = true;
                    }
                }

                if (pauseScreen.IsInAutoDrawSet()) {
                    pauseScreen.RemoveFromAutoDrawSet();
                    pauseScreen = null;
                }
            }
            else {
                pauseScreen.AddToAutoDrawSet();
                pauseScreen.Label = "PAUSED";
                pauseScreen.LabelColor = Color.White;
            }
            gameOver = theLevel.hero.lives < 0;
            String message = "Number of Lives: " + theLevel.hero.lives + "   Level Number: " + currentLevel;
            SetTopEchoColor(Color.White);
            EchoToTopStatus(message);
            }
            else if (gameOver) {
            World.SetWorldCoordinate(new Vector2(0, 0), 100f);
            cover = new XNACS1Rectangle(new Vector2(0, 0), 200, 200);
            cover.Color = Color.Black;
            gameOverText = new XNACS1Rectangle(new Vector2(50, 40), 40, 10);
            gameOverText.Label = "GAME OVER \n X TO RESTART";
            gameOverText.Color = Color.Black;
            gameOverText.LabelColor = Color.White;

            if (GamePad.ButtonXClicked()) {
                gameOverText.RemoveFromAutoDrawSet();
                gameOverText = null;
                cover.RemoveFromAutoDrawSet();
                cover = null;
                this.InitializeWorld();
            }
            }
            else if (!gameStarted) {
            if (GamePad.ButtonXClicked()) {
                if (selected.Center == easy.Center)
                    difficulty = 1;
                else if (selected.Center == medium.Center)
                    difficulty = 2;
                else
                    difficulty = 3;

                theLevel.loadInitialRoom(difficulty);
                EchoToTopStatus(difficulty.ToString());
                gameStarted = true;
            }

            if (ticks > 0)
                ticks--;
            else {
                if (GamePad.ThumbSticks.Right.Y > 0) {
                    if (selected.Center != easy.Center)
                        if (selected.Center != medium.Center)
                            selected.Center = medium.Center;
                        else
                            selected.Center = easy.Center;
                    ticks = 8;
                }
                else if (GamePad.ThumbSticks.Right.Y < 0) {
                    if (selected.Center != hard.Center)
                        if (selected.Center != medium.Center)
                            selected.Center = medium.Center;
                        else
                            selected.Center = hard.Center;
                    ticks = 8;
                }
            }
            }
        }
 public override XNACS1Rectangle getNextPosition()
 {
     if (invisible)
     {
         XNACS1Rectangle dummy = new XNACS1Rectangle(new Vector2(50, -200), 0, 0);
         dummy.RemoveFromAutoDrawSet();
         return dummy;
     } else {
         return base.getNextPosition();
     }
 }