protected override void HandleMouseOver(DrawnActor2D uiObject, GameTime gameTime)
 {
     if (uiObject.Transform.Bounds.Contains(this.MouseManager.Bounds))
     {
         //Mouse is inside the bounds of the object - uiObject.ID
         if (this.MouseManager.IsLeftButtonClickedOnce())
         {
             HandleMouseClick(uiObject, gameTime);
         }
     }
 }
Example #2
0
        public override void Update(GameTime gameTime, IActor actor)
        {
            DrawnActor2D drawnActor = actor as DrawnActor2D;

            if (drawnActor != null)
            {
                drawnActor.Transform2D.RotationInDegrees += (float)(0.1f * gameTime.ElapsedGameTime.TotalMilliseconds);
            }

            base.Update(gameTime, actor);
        }
Example #3
0
 /// <summary>
 /// Applies an action to the FIRST actor found in the list based on a matching predicate (and action) defined in the eventData object
 ///
 /// Usage:
 ///    EventDispatcher.Publish(new EventData(
 ///         EventCategoryType.UI, EventActionType.OnApplyActionToFirstMatchActor,
 ///        (actor) => actor.StatusType = StatusType.Drawn,
 ///        (actor) => actor.ActorType == ActorType.UITextureObject
 ///       && actor.ID.Equals("green key"), null));
 ///
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void ApplyActionToActor(EventData eventData)
 {
     if (eventData.Predicate != null && eventData.Action != null)
     {
         DrawnActor2D actor = uiObjectList.Find(eventData.Predicate);
         if (actor != null)
         {
             eventData.Action(actor);
         }
     }
 }
        /// <summary>
        /// Adds a new actor to the list in a MenuScene object
        /// </summary>
        /// <param name="sceneID">SceneID (e.g. "main", "controls", "audio")</param>
        /// <param name="actor">DrawnActor2D (e.g. UITextureObject, UITextObject)</param>
        public void Add(string sceneID, DrawnActor2D actor)
        {
            //if this is the first time we are adding an actor to this new sceneID then make a MenuScene and add to dictionary
            if (!dictionary.ContainsKey(sceneID))
            {
                dictionary.Add(sceneID, new List <DrawnActor2D>());
            }

            //get the menu scene for this sceneID
            List <DrawnActor2D> list = dictionary[sceneID];

            //add the new actor to the scene
            list.Add(actor);
        }
        public override void Update(GameTime gameTime, IActor actor)
        {
            DrawnActor2D drawnActor = actor as DrawnActor2D;

            if (drawnActor != null)
            {
                //-1 to +1
                float lerpFactor = (float)Math.Sin(0.5f * MathHelper.ToRadians((float)gameTime.TotalGameTime.TotalMilliseconds));
                //0 to 1
                lerpFactor = lerpFactor * 0.5f + 0.5f;

                drawnActor.Color = GDLibrary.MathUtility.Lerp(this.startColor, this.endColor, lerpFactor);
            }

            base.Update(gameTime, actor);
        }
        public override void Update(GameTime gameTime, IActor actor)
        {
            DrawnActor2D drawnActor = actor as DrawnActor2D;

            if (drawnActor != null)
            {
                if (drawnActor.Transform2D.Bounds.Contains(mouseManager.Bounds))
                {
                    drawnActor.Color = colorActive;
                }
                else
                {
                    drawnActor.Color = colorInactive;
                }
            }

            base.Update(gameTime, actor);
        }
Example #7
0
        public override void Update(GameTime gameTime, IActor actor)
        {
            DrawnActor2D drawnActor = actor as DrawnActor2D;

            if (drawnActor != null)
            {
                if (drawnActor.Transform2D.Bounds.Contains(mouseManager.Bounds))
                {
                    //A * Sin(wT + phase)
                    float lerpFactor = trigonometricParameters.MaxAmplitude * (float)Math.Sin(MathHelper.ToRadians(trigonometricParameters.AngularSpeed * (float)gameTime.TotalGameTime.TotalMilliseconds + trigonometricParameters.PhaseAngleInDegrees));
                    drawnActor.Transform2D.Scale = drawnActor.Transform2D.OriginalScale + lerpFactor * drawnActor.Transform2D.OriginalScale;
                }
                else
                {
                    drawnActor.Transform2D.Scale = drawnActor.Transform2D.OriginalScale;
                }
            }

            base.Update(gameTime, actor);
        }
Example #8
0
        //add the code here to say how click events are handled by your code
        protected override void HandleMouseClick(DrawnActor2D uiObject, GameTime gameTime)
        {
            //notice that the IDs are the same as the button IDs specified when we created the menu in Main::AddMenuElements()

            switch (uiObject.ID)
            {
            case "startbtn":
                DoStart();
                break;

            case "exitbtn":
                DoExit();
                break;

            case "audiobtn":

                SetActiveList("audio menu");         //use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()

                break;

            case "volumeUpbtn":
            {             //curly brackets scope additionalParameters to be local to this case
                object[] additionalParameters = { 0.1f };
                EventDispatcher.Publish(new EventData(EventActionType.OnVolumeUp, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeDownbtn":
            {
                object[] additionalParameters = { 0.1f };
                EventDispatcher.Publish(new EventData(EventActionType.OnVolumeDown, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeMutebtn":
            {
                object[] additionalParameters = { 0.0f, "Xact category name for game sounds goes here..." };
                EventDispatcher.Publish(new EventData(EventActionType.OnMute, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeUnMutebtn":
            {
                object[] additionalParameters = { 0.5f, "Xact category name for game sounds goes here..." };
                EventDispatcher.Publish(new EventData(EventActionType.OnUnMute, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "backbtn":

                SetActiveList(prevMenu);     //use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()
                break;

            case "controlsbtn":

                SetActiveList("controls menu");         //use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()

                break;

            default:
                break;
            }

            //add event to play mouse click
            DoMenuClickSound();
        }
Example #9
0
 protected override void HandleMouseOver(DrawnActor2D uiObject, GameTime gameTime)
 {
     base.HandleMouseOver(uiObject, gameTime);
 }
Example #10
0
 public void Add(DrawnActor2D actor)
 {
     // if(!uiObjectList.Contains(actor))
     uiObjectList.Add(actor);
 }
        //Add the code here to say how click events are handled by your code
        protected override void HandleMouseClick(DrawnActor2D uiObject, GameTime gameTime)
        {
            //Notice that the IDs are the same as the button IDs specified when we created the menu in Main::AddMenuElements()
            switch (uiObject.ID)
            {
            case "startbtn":

                SetActiveList("begin menu");
                break;

            case "exitbtn":

                DoExit();
                break;

            case "audiobtn":

                //Use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()
                SetActiveList("audio menu");
                break;

            case "volumeUpbtn":
            {
                //Curly brackets scope additionalParameters to be local to this case
                object[] additionalParameters = { 0.1f, "Global" };
                EventDispatcher.Publish(new EventData(EventActionType.OnVolumeUp, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeDownbtn":
            {
                object[] additionalParameters = { 0.1f, "Global" };
                EventDispatcher.Publish(new EventData(EventActionType.OnVolumeDown, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeMutebtn":
            {
                object[] additionalParameters = { 0.0f, "Global" };
                EventDispatcher.Publish(new EventData(EventActionType.OnMute, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "volumeUnMutebtn":
            {
                object[] additionalParameters = { 0.5f, "Global" };
                EventDispatcher.Publish(new EventData(EventActionType.OnUnMute, EventCategoryType.GlobalSound, additionalParameters));
            }
            break;

            case "backbtn":

                //Use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()
                SetActiveList("main menu");
                break;

            case "controlsbtn":
                SetActiveList("controls menu");
                break;

            case "beginbtn":

                //Use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()
                DoStart();
                break;

            case "menubtn":

                //Use sceneIDs specified when we created the menu scenes in Main::AddMenuElements()
                SetActiveList("main menu");
                break;

            case "bindbtn":
                StateManager.IsKeyBinding = true;
                break;

            case "actionbtn":
                if (StateManager.IsKeyBinding)
                {
                    this.action = "action";
                }
                break;

            case "restartbtn":
                restartClicked = true;
                break;

            default:
                break;
            }

            //Add event to play mouse click
            DoMenuClickSound();
        }
Example #12
0
 /// <summary>
 /// Removes an actor from the list by adding to a batch remove list which is processed before each update
 /// </summary>
 /// <param name="actor"></param>
 public void Remove(DrawnActor2D actor)
 {
     removeList.Add(actor);
 }
Example #13
0
 /// <summary>
 /// Add an actor to the ui
 /// </summary>
 /// <param name="actor"></param>
 public void Add(DrawnActor2D actor)
 {
     uiObjectList.Add(actor);
 }