Colour() public method

public Colour ( int red, int green, int blue ) : void
red int
green int
blue int
return void
Example #1
0
        public override void Activity(bool firstTimeCalled)
        {
            base.Activity(firstTimeCalled);

            removeDeadSprites();
            removeDeadText();
            undoColourOperationsOnFadedInTiles();

            if (model.GameState == CoreModel.GameStates.GameOver)
            {
                if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
                {
                    this.FadeOutComplete += new FadeEventDelegate(CoreGameScreen_MoveToMainMenuFadeOutComplete);
                    this.FadeOut();
                }
            }
            else if (model.GameState == CoreModel.GameStates.GameComplete)
            {
                if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
                {
                    this.FadeOut();
                }
            }
            else
            {
                if (this._tutorialPanelShowing == false)
                {
                    Tile t = findTileMouseIsOver();

                    if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
                    {
                        // Left mouse button pushed - down this frame, not down last frame.
                        if (t != null && t.IsEmpty())
                        {
                            t.Atom = model.NextAtom;
                            model.PickNextAtom();

                            this.drawTile(t);
                            AudioManager.Instance.PlaySound(CoreModel.SOUND_FILE_PATH + "atom-placed.mp3");
                            this.drawNextAtom();

                            this.updateAtomsLeftOrPointsCounter();

                            BackgroundWorker reactionComputingThread = new BackgroundWorker();
                            reactionComputingThread.DoWork += new DoWorkEventHandler(reactionComputingThread_DoWork);
                            reactionComputingThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(reactionComputingThread_RunWorkerCompleted);
                            reactionComputingThread.RunWorkerAsync(t);
                        }
                    }

                    else
                    {
                        if (t != null && !t.IsEmpty())
                        {
                            if (this._startHoverTime == DateTime.MinValue)
                            {
                                this._startHoverTime = DateTime.Now;
                            }
                            else
                            {
                                TimeSpan time = (DateTime.Now - this._startHoverTime);
                                if (time.TotalMilliseconds >= 500)
                                {
                                    infoPanel.Show(t.Atom);
                                }
                            }
                        }
                        else if (InputManager.Mouse.IsOn3D(this._nextAtom, false))
                        {
                            infoPanel.Show(model.NextAtom);
                        }
                        else
                        {
                            infoPanel.Hide();
                            this._startHoverTime = DateTime.MinValue;
                        }
                    }

                    if (model.IsLevelOver())
                    {
                        if (model.CurrentLevel != CoreModel.AVALANCHE_LEVEL && model.CurrentLevel != CoreModel.TRICKLE_LEVEL)
                        {
                            this.FadeOutHalf();
                        }
                        else
                        {
                            // Show random "good work" message, and add 1000 points
                            string message = this._greatWorkMessages[model.RandomGenerator.Next() % this._greatWorkMessages.Length] + " (+1000 points)";
                            model.Points += 1000;
                            this.updateAtomsLeftOrPointsCounter();
                            AudioManager.Instance.PlaySound(CoreModel.SOUND_FILE_PATH + "ulimited-mode-atoms-cleared.mp3");

                            TowerText messageText = new TowerText(this.AddText(message));
                            messageText.YVelocity = 15;
                            messageText.AlphaRate = -0.05f;
                            messageText.Scale = 48;
                            messageText.AddShadow();
                            messageText.Colour(255, 225, 64);

                            this._reactionText.Add(messageText.BaseText);
                            this._reactionText.Add(messageText.EffectText);

                            // Generate 40 tiles on the board.
                            int numGenerated = 0;
                            while (numGenerated < 40)
                            {
                                IList<Tile> tiles = model.SpewOutAtomsFromMachine();
                                numGenerated += tiles.Count;
                                foreach (Tile tile in tiles)
                                {
                                    drawTile(tile);
                                    fadeTileIn(tile);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public override void Initialize()
        {
            this.FadeOutImmediately();

            this.AddSprite("Content/Menus/menu-screen.jpg");
            Sprite title = this.AddSprite("Content/Menus/select-level.png");

            const int VERTICAL_OFFSET = 160;
            const int HORIZONTAL_OFFSET_FROM_SCREEN = 30;
            const int VERTICAL_PADDING_BETWEEN_ROWS = 10;

            int SQUARE_WIDTH = 0;
            int SQUARE_HEIGHT = 0;

            // Start Y of levels, plus our height, plus 8-16 padding
            title.Y = VERTICAL_OFFSET + title.Texture.Height + 16;

            int currentLevel = CoreModel.Instance.MaxLevelReached;

            // 12 normal levels
            for (int i = 1; i <= CoreModel.NUMBER_OF_LEVELS; i++)
            {
                TowerSprite square;
                if (i <= currentLevel)
                {
                    square = new TowerSprite(this, "Content/Menus/normal-level.png");
                }
                else
                {
                    square = new TowerSprite(this, "Content/Menus/inactive-level.png");
                }

                SQUARE_WIDTH = square.Width;
                SQUARE_HEIGHT = square.Height;

                square.X = -300 + HORIZONTAL_OFFSET_FROM_SCREEN +
                    (((i - 1) % 3) * square.Width);

                square.Y = VERTICAL_OFFSET -
                    (((i - 1) / 3) * (VERTICAL_PADDING_BETWEEN_ROWS + square.Height) );

                square.Click += new TowerSprite.ClickedDelegate(levelSquare_Click);

                TowerText t = new TowerText(this.AddText(i.ToString()));
                t.X = square.X;

                if (i <= currentLevel)
                {
                    t.Colour(0, 0, 0);
                    t.Y = square.Y + 3;
                }
                else
                {
                    t.Colour(255, 255, 255);
                    t.Y = square.Y - 10;
                }

                t.Z = square.Z + 1;
                t.AttachTo(square, true);
            }

            currentLevel -= CoreModel.NUMBER_OF_LEVELS;

            // 12 puzzle levels
            for (int i = 1; i <= CoreModel.NUMBER_OF_LEVELS; i++)
            {
                TowerSprite square;
                if (i <= currentLevel)
                {
                    square = new TowerSprite(this, "Content/Menus/puzzle-level.png");
                }
                else
                {
                    square = new TowerSprite(this, "Content/Menus/inactive-level.png");
                }

                square.X = (square.Width / 2) +
                    (((i - 1) % 3) * square.Width);

                square.Y = VERTICAL_OFFSET -
                    (((i - 1) / 3) * (VERTICAL_PADDING_BETWEEN_ROWS + square.Height));

                square.Click += new TowerSprite.ClickedDelegate(levelSquare_Click);

                TowerText t = new TowerText(this.AddText(string.Format("P{0}", i)));
                t.X = square.X;

                if (i <= currentLevel)
                {
                    t.Colour(0, 0, 0);
                    t.Y = square.Y + 3;
                }
                else
                {
                    t.Colour(255, 255, 255);
                    t.Y = square.Y - 10;
                }

                t.Z = square.Z + 1;

                t.AttachTo(square, true);
            }

            Tower3SliceButton backButton = new Tower3SliceButton(this, "Back", "bubble", 18, -5);
            backButton.X = 340;//;HORIZONTAL_OFFSET_FROM_SCREEN + (1.25f * SQUARE_WIDTH);
            backButton.Y = -275; //;VERTICAL_OFFSET - (4 * SQUARE_HEIGHT) - (6 * VERTICAL_PADDING_BETWEEN_ROWS);
            backButton.Click += new TowerBaseButton.ClickedDelegate(backButton_Click);

            if (CoreModel.Instance.MaxLevelReached >= CoreModel.AVALANCHE_LEVEL)
            {
                TowerSprite avalanche = new TowerSprite(this, "Content/Menus/avalanche-level.png");
                avalanche.X = -325 + HORIZONTAL_OFFSET_FROM_SCREEN + (0.5f * SQUARE_WIDTH);
                avalanche.Y = VERTICAL_OFFSET - (4 * SQUARE_HEIGHT) - (6 * VERTICAL_PADDING_BETWEEN_ROWS);
                avalanche.Click += new TowerSprite.ClickedDelegate(avalanche_Click);

                TowerText avalancheText = new TowerText(this.AddText("Avalanche"));
                avalancheText.X = avalanche.X;
                avalancheText.Y = avalanche.Y + 5;
                avalancheText.Z = avalanche.Z + 1;
                avalancheText.Colour(0, 0, 0);
                avalancheText.AttachTo(avalanche, true);

                TowerSprite trickle = new TowerSprite(this, "Content/Menus/trickle-level.png");
                trickle.X = avalanche.X + SQUARE_WIDTH + 50;
                trickle.Y = avalanche.Y;
                trickle.Click += new TowerSprite.ClickedDelegate(trickle_Click);

                TowerText trickleText = new TowerText(this.AddText("Trickle"));
                trickleText.X = trickle.X;
                trickleText.Y = trickle.Y + 9;
                trickleText.Z = trickle.Z + 1;
                trickleText.AttachTo(trickle, true);
            }

            base.Initialize();

            this.FadeIn();
        }
Example #3
0
        public override void Initialize()
        {
            model.SetGameStateToNormal();

            this.FadeOutImmediately();
            this.initializeLevelTutorials();

            this.removeOldSprites();
            model.CreateBoard();
            this._levelText = new TowerText(this.AddText(string.Format("Puzzle: {0}", model.CurrentLevel)));

            performPerLevelPreSetup();

            Sprite background = this.AddSprite("Content/metal-background.jpg");

            Sprite statusBar = this.AddSprite("Content/status-bar.png");
            statusBar.Y = -275; // bottom of the screen = 300, half us = 25

            Sprite board = this.AddSprite("Content/metal-board.jpg");
            board.Y = 25;

            Sprite frieze = this.AddSprite("Content/frieze.png");
            frieze.Y = 25;

            #region status-bar
            this._levelText.X = -375;
            this._levelText.Y = statusBar.Y;
            this._levelText.HorizontalAlignment = FlatRedBall.Graphics.HorizontalAlignment.Left;
            this._levelText.Colour(0, 0, 0);
            this._levelText.Scale = 24;

            if (model.CurrentLevel >= CoreModel.FIRST_PUZZLE_LEVEL && model.CurrentLevel <= CoreModel.LAST_PUZZLE_LEVEL)
            {
                // Puzzle mode; add atom counter
                this._atomOrPointCountText = new TowerText(this.AddText(string.Format("Atoms Left: {0}", model.Toolbox.NumAtomsLeft)));
                this._atomOrPointCountText.Scale = this._levelText.Scale;
                this._atomOrPointCountText.Y = this._levelText.Y;
                this._atomOrPointCountText.X = this._levelText.X + 350;
                this._atomOrPointCountText.Colour(0, 0, 0);
            }
            else if (model.CurrentLevel == CoreModel.AVALANCHE_LEVEL || model.CurrentLevel == CoreModel.TRICKLE_LEVEL)
            {
                this._atomOrPointCountText = new TowerText(this.AddText(string.Format("Points: {0}", model.Points)));
                this._atomOrPointCountText.Scale = this._levelText.Scale;
                this._atomOrPointCountText.Y = this._levelText.Y;
                this._atomOrPointCountText.X = this._levelText.X + 300;
                this._atomOrPointCountText.Colour(0, 0, 0);
            }

            TowerText nextText = new TowerText(this.AddText("Next: "));
            nextText.X = 300;
            nextText.Y = statusBar.Y;
            nextText.Colour(0, 0, 0);
            nextText.Scale = this._levelText.Scale;

            this._nextAtom = this.AddSprite("Content/Atoms/" + model.NextAtom.Element + ".png");
            _nextAtom.X = nextText.X + 50;
            _nextAtom.Y = nextText.Y;

            this._nextAtomText = new TowerText(this.AddText(model.NextAtom.Element));
            _nextAtomText.X = _nextAtom.X;
            _nextAtomText.Y = _nextAtom.Y;

            this._timeText = new TowerText(this.AddText("Time: ∞"));
            this._timeText.X = this._nextAtomText.X - 200;
            this._timeText.Y = statusBar.Y;
            this._timeText.Colour(0, 0, 0);
            this._timeText.Scale = this._levelText.Scale;
            #endregion

            for (int x = 0; x < Model.CoreModel.BOARD_WIDTH; x++)
            {
                for (int y = 0; y < Model.CoreModel.BOARD_HEIGHT; y++)
                {
                    Sprite tile = this.AddSprite("Content/tile.png");
                    tile.X = (x * 50) - CENTER_OF_BOARD_X;
                    tile.Y = (y * -50) + CENTER_OF_BOARD_Y;
                    tile.Alpha = 0.75f;
                    model.Board[x, y].Sprite = tile;
                }
            }

            infoPanel.InitializeToScreen(this);

            // Clear out old event handlers because they carry over
            model.ClearEventHandlers();
            model.MachineCreatesAtoms += new DeenGames.Valence.Model.CoreModel.MachineCreatesAtomsDelegate(model_MachineCreatesAtoms);
            model.MachineTicks += new DeenGames.Valence.Model.CoreModel.MachineTicksDelegate(model_MachineTicks);
            model.GameOver += new DeenGames.Valence.Model.CoreModel.GameOverOccuredDelegate(model_GameOver);

            // Avalanche and Trickle mode NEVER end. Evar.
            if (model.CurrentLevel != CoreModel.AVALANCHE_LEVEL && model.CurrentLevel != CoreModel.TRICKLE_LEVEL)
            {
                this.FadeOutComplete += new FadeEventDelegate(CoreGameScreen_LevelCompleteBlackOutComplete);
            }

            performPerLevelPostSetup();
            this._levelText.DisplayText = model.LevelName;
            this.updateAtomsLeftOrPointsCounter();

            this.FadeIn();
            base.Initialize();
        }