private void InitializeOptionMenu() { Transform2D transform = null; UITextureObject textureObject = null; transform = new Transform2D(1.5f * Vector2.One); textureObject = new UITextureObject("op1", ActorType.UITexture, StatusType.Drawn | StatusType.Update, transform, Color.White, SpriteEffects.None, 1, this.textureDictionary["ice"]); this.menuManager.Add("options", textureObject); transform = new Transform2D(new Vector2(200, 300), 0, new Vector2(1, 0.5f), Vector2.Zero, new Integer2(600, 160)); textureObject = new UITextureObject("slider1", ActorType.UITexture, StatusType.Drawn | StatusType.Update, transform, Color.White, SpriteEffects.None, 0.5f, this.textureDictionary["sliderBar"]); this.menuManager.Add("options", textureObject); transform = new Transform2D(new Vector2(300, 290), 0, new Vector2(1, 0.7f), Vector2.Zero, new Integer2(180, 150)); textureObject = new UITextureObject("tracker1", ActorType.UITexture, StatusType.Drawn | StatusType.Update, transform, Color.White, SpriteEffects.None, 0, this.textureDictionary["sliderTracker"]); this.menuManager.Add("options", textureObject); }
private void InitUiArchetypes() { Texture2D texture = Textures["bStart"]; Integer2 dimensions = new Integer2(texture.Width, texture.Height); Transform2D transform2D = new Transform2D(Vector2.Zero, 0, Vector2.One, Vector2.Zero, dimensions); UITextureObject uiTextureObject = new UITextureObject("texture", ActorType.UITextureObject, StatusType.Drawn | StatusType.Update, transform2D, Color.White, 0.6f, SpriteEffects.None, texture, new Rectangle(0, 0, texture.Width, texture.Height)); string text = ""; dimensions = new Integer2(Fonts["Arial"].MeasureString(text)); transform2D = new Transform2D(Vector2.Zero, 0, Vector2.One, Vector2.Zero, dimensions); UITextObject uiTextObject = new UITextObject("text", ActorType.UIText, StatusType.Drawn | StatusType.Update, transform2D, Color.Black, 0.1f, SpriteEffects.None, text, Fonts["Arial"]); text = ""; texture = Textures["bStart"]; dimensions = new Integer2(texture.Width, texture.Height); Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f); transform2D = new Transform2D(Vector2.Zero, 0, Vector2.One, origin, dimensions); UIButtonObject uiButtonObject = new UIButtonObject("button", ActorType.UIButtonObject, StatusType.Update | StatusType.Drawn, transform2D, Color.White, 0.5f, SpriteEffects.None, texture, new Rectangle(0, 0, texture.Width, texture.Height), text, Fonts["Arial"], Vector2.One, GameConstants.colorGold, Vector2.Zero); uiButtonObject.ControllerList.Add(new UiScaleLerpController("USC", ControllerType.Ui, mouseManager, new TrigonometricParameters(0.05f, 0.1f, 180))); UiArchetypes.Add("button", uiButtonObject); UiArchetypes.Add("texture", uiTextureObject); UiArchetypes.Add("text", uiTextObject); }
public UiCoffeeWarningEventHandler(EventCategoryType eventCategoryType, IActor parent, Texture2D textureToSwitch) : base(eventCategoryType, parent) { this.textureToSwitch = textureToSwitch; uiTextureObject = parent as UITextureObject; if (uiTextureObject != null) { initialTexture = uiTextureObject.Texture; } EventManager.RegisterListener <CoffeeEventInfo>(HandleEvent); }
public override void Update(GameTime gameTime, IActor actor) { UITextureObject drawnActor = actor as UITextureObject; if (drawnActor != null) { UpdateSourceRectangle(drawnActor); } base.Update(gameTime, actor); }
/// <summary> /// Uses the currentValue to set the source rectangle width of the parent UITextureObject /// </summary> /// <param name="drawnActor">Parent to which this controller is attached</param> private void UpdateSourceRectangle(UITextureObject drawnActor) { //how much of a percentage of the width of the image does the current value represent? float widthMultiplier = (float)currentValue / maxValue; //now set the amount of visible rectangle using the current value drawnActor.SourceRectangleWidth = (int)(widthMultiplier * drawnActor.OriginalSourceRectangle.Width); //drawnActor.SourceRectangleHeight // = (int)(widthMultiplier * drawnActor.OriginalSourceRectangle.Height); }
private void InitializeMainMenu() { Transform2D transform = null; UITextureObject menuObject = null; Vector2 midPoint = Vector2.Zero; midPoint = new Vector2(this.textureDictionary["menuButton"].Width / 2.0f, this.textureDictionary["menuButton"].Height / 2.0f); transform = new Transform2D(new Vector2(500, 300), 0, 0.5f * Vector2.One, midPoint, new Integer2(1000, 367)); menuObject = new UITextureObject("menu1", ActorType.UITexture, StatusType.Drawn | StatusType.Update, transform, Color.White, SpriteEffects.None, 0, this.textureDictionary["menuButton"]); menuObject.AttachController( new MouseButtonController("mbc1", ControllerType.UIMouse, this.mouseManager)); //add to manager - menu manager this.menuManager.Add(AppData.MenuMainID, menuObject); midPoint = new Vector2(this.textureDictionary["exitButton"].Width / 2.0f, this.textureDictionary["exitButton"].Height / 2.0f); transform = new Transform2D(new Vector2(500, 500), 0, 0.5f * Vector2.One, midPoint, new Integer2(1000, 367)); menuObject = new UITextureObject("exit1", ActorType.UITexture, StatusType.Drawn | StatusType.Update, transform, Color.White, SpriteEffects.None, 0, this.textureDictionary["exitButton"]); menuObject.AttachController( new MouseButtonController("mbc1", ControllerType.UIMouse, this.mouseManager)); //add to manager - menu manager this.menuManager.Add(AppData.MenuMainID, menuObject); //set active menu // this.menuManager.SetActiveMenu(AppData.MenuMainID); }
public override void Dispose() { objectManager = null; playerTile = null; pressSpace = null; }
public override void Dispose() { parent = null; EventManager.UnregisterListener <CoffeeEventInfo>(HandleCoffeeEventInfo); }