示例#1
0
文件: GuiButton.cs 项目: bsimser/CoM
        public override void DrawContents()
        {
            base.DrawContents();
            if (Image != null)
            {
                var origonalTransform = Image.ColorTransform;

                ColorTransform effectTranform = ColorTransform.Identity;

                if (IsMouseOver)
                {
                    effectTranform = ColorTransform.Multiply(new Color(1.3f, 1.3f, 1.2f));
                }
                if (Depressed)
                {
                    effectTranform = ColorTransform.Multiply(new Color(0.8f, 0.8f, 0.8f));
                }
                if (!Enabled)
                {
                    effectTranform = ColorTransform.BlackAndWhite;
                }

                if (!effectTranform.IsIdentity)
                {
                    Image.ColorTransform = Image.ColorTransform + effectTranform;
                }

                Image.Update();
                Image.Draw();

                Image.ColorTransform = origonalTransform;
            }
        }
示例#2
0
文件: UIStyle.cs 项目: bsimser/CoM
 /** Styles a component with a red tint suitable for warnings. */
 public static void RedWarning(GuiComponent component)
 {
     Util.Assert(component != null, "Component must not be null.");
     component.ColorTransform  = ColorTransform.BlackAndWhite;
     component.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f);
     component.Color           = new Color(1f, 0.4f, 0.3f);
 }
示例#3
0
        /** Syncs control with character */
        private void Sync()
        {
            if (Character != null)
            {
                DragDropEnabled = true;
                _ddContent      = this;             // use ourselves as our dragable content
                portrait.Sprite = Character.Portrait;

                levelIcon.Visible = Character.CurrentMembership.ReqXP <= 0 && (!Character.CurrentMembership.IsPinned);
                pinIcon.Visible   = Character.CurrentMembership.IsPinned;

                hpBar.Progress = (float)Character.Hits / Character.MaxHits;
                spBar.Progress = (float)Character.Spells / Character.MaxSpells;

                stats.Caption =
                    "HP " + Character.Hits + " / " + Character.MaxHits + "\n" + "SP " + Character.Spells;

                var selectedColor = isSelected ? Colors.CharacterInfoPanelSelected : Colors.CharacterInfoPanel;

                var effectTransform = ColorTransform.Identity;

                if (Character.Poisoned)
                {
                    effectTransform = ColorTransform.BlackAndWhite + ColorTransform.Multiply(new Color(0.5f, 0.75f, 0.5f));
                }
                if (Character.Diseased)
                {
                    effectTransform = ColorTransform.BlackAndWhite + ColorTransform.Multiply(new Color(0.75f, 0.75f, 0.5f));
                }
                if (Character.IsDead)
                {
                    effectTransform = ColorTransform.BlackAndWhite + ColorTransform.Multiply(new Color(1f, 1f, 1f));
                }

                if (Feedback != DDFeedback.Normal)
                {
                    effectTransform += ColorTransform.Multiply(new Color(1.5f, 1.5f, 1.5f));
                }

                Color = selectedColor;
                portrait.ColorTransform  = effectTransform;
                levelIcon.ColorTransform = effectTransform;
                pinIcon.ColorTransform   = effectTransform;
            }
            else
            {
                DragDropEnabled = false;
                Color           = Color.clear;
                _ddContent      = null;
                portrait.Sprite = null;
                stats.Caption   = "";
                hpBar.Progress  = 0;
                spBar.Progress  = 0;
            }
        }
示例#4
0
        public override void Draw()
        {
            CompositeColorTransform = ColorTransform.Identity;

            if (IsMouseOver && MouseOverComponent != editButton)
            {
                CompositeColorTransform = ColorTransform.Multiply(new Color(1.3f, 1.3f, 1.2f));
            }

            if (Depressed)
            {
                CompositeColorTransform = ColorTransform.Multiply(new Color(0.8f, 0.8f, 0.8f));
            }

            base.Draw();
        }
示例#5
0
文件: TownState.cs 项目: bsimser/CoM
        public TownState()
            : base("TownState")
        {
            GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town"));

            Background.BestFit(ContentsFrame);
            Add(Background, 0, 0);

            GuiWindow window = new GuiWindow(400, 260, "Town");

            window.Background.Color = Colors.BackgroundGray;
            Add(window, 0, 0);

            GuiButton MainMenuButton = new GuiButton("Exit", 150);

            MainMenuButton.ColorTransform  = ColorTransform.BlackAndWhite;
            MainMenuButton.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f);
            MainMenuButton.Color           = new Color(1f, 0.4f, 0.3f);

            GuiButton storeButton  = new GuiButton("General Store", 150);
            GuiButton templeButton = new GuiButton("Temple", 150);
            GuiButton guildButton  = new GuiButton("Guild", 150);

            GuiButton tavernButton  = new GuiButton("Tavern", 150);
            GuiButton libraryButton = new GuiButton("Library", 150);
            GuiButton bankButton    = new GuiButton("Bank", 150);
            GuiButton dungeonButton = new GuiButton("Dungeon", 150);

            int buttonY = 25;

            window.Add(MainMenuButton, 0, buttonY - 5);

            window.Add(storeButton, 20, buttonY + 40 * 1);
            window.Add(templeButton, 20, buttonY + 40 * 2);
            window.Add(guildButton, 20, buttonY + 40 * 3);

            window.Add(tavernButton, -20, buttonY + 40 * 1);
            window.Add(libraryButton, -20, buttonY + 40 * 2);
            window.Add(bankButton, -20, buttonY + 40 * 3);

            window.Add(dungeonButton, 0, -20);

            storeButton.OnMouseClicked += delegate {
                Engine.PushState(new StoreState());
            };

            guildButton.OnMouseClicked += delegate {
                Engine.PushState(new GuildState());
            };

            templeButton.OnMouseClicked += delegate {
                Engine.PushState(new TempleState());
            };

            bankButton.OnMouseClicked += delegate {
                Engine.PushState(new BankState());
            };

            libraryButton.OnMouseClicked += delegate {
                Engine.PushState(new LibraryState());
            };


            MainMenuButton.OnMouseClicked += CoM.ReturnToMainMenu;

            OnStateShow += delegate {
                SoundManager.PlayMusicPlaylist("City");
            };

            // these are not implemented yet.
            tavernButton.SelfEnabled = false;
            bankButton.SelfEnabled   = false;

            dungeonButton.OnMouseClicked += delegate {
                if (CoM.Party.LivingMembers == 0)
                {
                    Engine.ShowModal("Can Not Enter Dungeon.", "All party memebers are dead.");
                }
                else
                {
                    CoM.Party.Depth = 1;
                    PartyController.Instance.SyncCamera();
                    Engine.PopState();
                }
            };
        }
示例#6
0
文件: Engine.cs 项目: bsimser/CoM
    /**
     * Updates the active states of the game.
     *
     * Usualy only the topmost state is draw and updated.  However any state with backgroundUpdate enabled will be updated even if not topmost.
     *
     */
    public virtual void DoUpdate()
    {
        GameTime += Time.deltaTime;

        Mouse.Update();

        bool ctrl  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
        bool alt   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
        bool shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

        processKeys(ctrl, alt, shift);

        FPSCounter.addSample(Time.deltaTime);

        if (notificationDelayTimer > 0)
        {
            notificationDelayTimer -= Time.deltaTime;
        }

        // add any notifications, 1 at a time.
        if ((notificationDelayTimer <= 0) && (pendingNotifications.Count >= 1))
        {
            var notification = new GuiNotification(pendingNotifications[0].Message, pendingNotifications[0].Sprite);
            var soundName    = pendingNotifications[0].SoundName;

            foreach (var existingNotification in notificationList)
            {
                existingNotification.PushDown();
            }
            notificationList.Add(notification);

            if (!string.IsNullOrEmpty(soundName))
            {
                SoundManager.Play(soundName);
            }

            pendingNotifications.RemoveAt(0);
            notificationDelayTimer = NotificationDelay;
        }

        if (StateList.Count == 0)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            ComponentClickedDownOn = StateList[0].GetComponentAtPosition(Mouse.Position);
        }

        if (DragDrop != null)
        {
            DragDrop.Update();
        }

        // Remove disabled states.
        for (int lp = 0; lp < StateList.Count; lp++)
        {
            if (StateList[lp].Active == false)
            {
                StateList.RemoveAt(lp);
                lp--;
                continue;
            }
        }

        // Remove disabled notifications.
        for (int lp = 0; lp < notificationList.Count; lp++)
        {
            if (notificationList[lp].Active == false)
            {
                notificationList.RemoveAt(lp);
                lp--;
                continue;
            }
        }

        // Update topmost state and any background update states.

        StateList[0].Update();

        for (int lp = 1; lp < StateList.Count; lp++)
        {
            var state = StateList[lp];
            if (state.BackgroundUpdate)
            {
                state.Update();
            }
        }

        // Apply global fx (note: I should probably render all UI to a texture and do this once.
        for (int lp = 0; lp < StateList.Count; lp++)
        {
            var state = StateList[lp];

            switch (FXStyle)
            {
            case RenderFXStyle.Normal:
                state.CompositeColorTransform = ColorTransform.Identity;
                state.Color = Color.white;
                break;

            case RenderFXStyle.Retro:
                var a = ColorTransform.Saturation(0.25f);
                var b = ColorTransform.Multiply(new Color(255 / 255f, 235 / 255f, 215 / 255f));
                var c = ColorTransform.Identity;
                c.Matrix = a.Matrix * b.Matrix;
                state.CompositeColorTransform = c;
                break;

            case RenderFXStyle.Sketch:
                a             = ColorTransform.Saturation(0f);
                b             = ColorTransform.Multiply(3f, 3f, 3f);
                c             = ColorTransform.Identity;
                c.Matrix      = a.Matrix * b.Matrix;
                c.ColorOffset = new Vector3(-0.3f, -0.3f, -0.3f);
                state.CompositeColorTransform = c;
                break;

            case RenderFXStyle._Clay:
                state.CompositeColorTransform = ColorTransform.Bronze;
                state.Color = Color.white;
                break;
            }
        }

        // Show FPS label
        if (Time.time - lastFpsUpdate > 0.5f)
        {
            lastFpsUpdate = Time.time;

            FPSLabel.Caption = Settings.Advanced.ShowFPSDetails ? getAdvancedFPSDetails() : getFPSDetails();

            FPSLabel.Width = Settings.Advanced.ShowFPSDetails ? -1 : 100;
        }

        if (Input.GetMouseButtonUp(0))
        {
            ComponentClickedDownOn = null;
        }
    }