DeenGames.Utils.Tower.Controls.TowerText.Colour C# (CSharp) Method

Colour() public method

public Colour ( int red, int green, int blue ) : void
red int
green int
blue int
return void
        public void Colour(int red, int green, int blue)
        {
            if (red < 0 || red > 255)
            {
                throw new ArgumentOutOfRangeException("Red component (" + red + ") must be in the range [0 .. 255]");
            }
            else if (green < 0 || green > 255)
            {
                throw new ArgumentOutOfRangeException("Green component (" + green + ") must be in the range [0 .. 255]");
            }
            else if (blue < 0)
            {
                throw new ArgumentOutOfRangeException("Blue component (" + blue + ") must be in the range [0 .. 255]");
            }
            else
            {
                // Validation passed!
                this._baseText.Red = (red / 255f);
                this._baseText.Green = (green / 255f);
                this._baseText.Blue = (blue / 255f);
            }
        }

Usage Example

Esempio n. 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);
                                }
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of DeenGames.Utils.Tower.Controls.TowerText::Colour