Inheritance: Behavior, ITouchable
Exemplo n.º 1
0
 /// <summary>
 /// And wait a tap to the touch gesture.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="touchGestures">The touch gestures.</param>
 /// <returns>The action</returns>
 public static IGameAction AndWaitTap(this IGameAction parent, TouchGestures touchGestures)
 {
     return new TapGameAction(parent, touchGestures);
 }
Exemplo n.º 2
0
        private void Create_Towers_Bar()
        {
            var touchGestures = new TouchGestures();
               var x = WaveServices.Platform.ScreenWidth / 2;
               var y = WaveServices.Platform.ScreenHeight - 150;
               var sprite = "Content/Other/TowerBar/Bar_Background.wpk";
               TowersBar = Static.Functions.Create_entity("Tower_Bar", x, y, sprite);

               x = 0;
               y = 0;
               sprite = "Content/Other/TowerBar/Tower1_Sprite.wpk";

               Tower1Button = Static.Functions.Create_entity("Tower1",x,y,sprite);
               Tower1Button.AddComponent(new RectangleCollider())
            .AddComponent(touchGestures);
               Tower1Button.FindComponent<Transform2D>().ParentDependencyObject = null;
               Tower1Button.FindComponent<Transform2D>().DrawOrder = 0;

            sprite = "Content/Other/TowerBar/Chandler_Icon.wpk";
            var Chandler_tower = Static.Functions.Create_entity("Chandler_tower", Static.Const.Tower_Position["Chandler_tower"].Item1
                ,Static.Const.Tower_Position["Chandler_tower"].Item2,sprite);
            Chandler_tower.FindComponent<Transform2D>().ParentDependencyObject = null;
            Chandler_tower.FindComponent<Transform2D>().DrawOrder = 0;
            Chandler_tower.AddComponent(new RectangleCollider());
            Chandler_tower.AddComponent(new TouchGestures());

            touchGestures.TouchMoved += touchGestures_TouchMoved;
            touchGestures.TouchReleased += touchGestures_TouchReleased;

            Chandler_tower.FindComponent<TouchGestures>().TouchMoved += touchGestures_TouchMoved;
            Chandler_tower.FindComponent<TouchGestures>().TouchReleased += touchGestures_TouchReleased;

            TowersBar.AddChild(Chandler_tower);
            TowersBar.AddChild(Tower1Button);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates the wait tap task.
 /// </summary>
 /// <param name="scene">The scene.</param>
 /// <param name="touchGestures">The touch gestures.</param>
 /// <returns>The action</returns>
 public static IGameAction CreateWaitTapGameAction(this Scene scene, TouchGestures touchGestures)
 {
     return new TapGameAction(touchGestures, scene);
 }
Exemplo n.º 4
0
        protected override void Update(TimeSpan gameTime)
        {
            var totalWidth = this.virtualScreenManager.RightEdge - this.virtualScreenManager.LeftEdge;
            var totalHeight = this.virtualScreenManager.BottomEdge - this.virtualScreenManager.TopEdge;
            this.viewportActionableArea = new RectangleF(
                (this.actionableArea.X * totalWidth) + this.virtualScreenManager.LeftEdge,
                (this.actionableArea.Y * totalHeight) + this.virtualScreenManager.TopEdge,
                (this.actionableArea.Z * totalWidth),
                (this.actionableArea.W * totalHeight)
            );

            if (this.backgroundEntityPath != null)
            {
                this.backgroundEntity = this.EntityManager.Find(this.backgroundEntityPath);
                this.backgroundEntity.IsVisible = false;
                if (backgroundEntity != null)
                {
                    this.backgroundTransform = this.backgroundEntity.FindComponent<Transform2D>();
                }
            }

            if (this.thumbEntityPath != null)
            {
                this.thumbEntity = this.EntityManager.Find(this.thumbEntityPath);
                this.thumbEntity.IsVisible = false;
                if (thumbEntity != null)
                {
                    this.thumbTransform = this.thumbEntity.FindComponent<Transform2D>();
                }
            }

            var actionableTouchGestures = new TouchGestures();
            var actionableEntity = new Entity()
                .AddComponent(new Transform2D()
                {
                    X = this.viewportActionableArea.X,
                    Y = this.viewportActionableArea.Y,
                    Rectangle = new RectangleF(0, 0, this.viewportActionableArea.Width, this.viewportActionableArea.Height)
                })
                .AddComponent(new RectangleCollider2D())
                .AddComponent(actionableTouchGestures);
            actionableTouchGestures.TouchPressed += this.ActionableTouchGesturesTouchPressed;
            actionableTouchGestures.TouchMoved += this.ActionableTouchGesturesTouchMoved;
            actionableTouchGestures.TouchReleased += this.ActionableTouchGesturesTouchReleased;

            this.EntityManager.Add(actionableEntity);

            this.IsActive = false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Button" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public PressedButton(string name)
        {
            this.backToBackgroundImage = false;

            var touchGestures = new TouchGestures();
            this.entity = new Entity(name)
                           .AddComponent(new Transform2D())
                           .AddComponent(new RectangleCollider())
                           .AddComponent(touchGestures)
                           .AddComponent(new ButtonBehavior())
                           .AddComponent(new PanelControl(DefaultWidth, DefaultHeight))
                           .AddComponent(new PanelControlRenderer())
                           .AddComponent(new BorderRenderer())
                           .AddChild(new Entity("TextEntity")
                                .AddComponent(new Transform2D()
                                {
                                    DrawOrder = 0.4f
                                })
                                .AddComponent(new AnimationUI())
                                .AddComponent(new TextControl()
                                {
                                    Text = "Button",
                                    Margin = this.defaultMargin,
                                    HorizontalAlignment = HorizontalAlignment.Center,
                                    VerticalAlignment = VerticalAlignment.Center
                                })
                                .AddComponent(new TextControlRenderer()));

            // Event
            touchGestures.TouchReleased += this.Button_TouchReleased;

            touchGestures.TouchPressed += touchGestures_TouchPressed;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TapGameAction" /> class.
 /// </summary>
 /// <param name="parent">The parent task.</param>
 /// <param name="touchGestures">The TouchGestures instances.</param>
 public TapGameAction(IGameAction parent, TouchGestures touchGestures)
     : base(parent, "ActionGameAction" + instances++)
 {
     this.touchGestures = touchGestures;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TapGameAction" /> class.
 /// </summary>
 /// <param name="touchGestures">The TouchGestures instances.</param>
 /// <param name="scene">The associated scene.</param>
 public TapGameAction(TouchGestures touchGestures, Scene scene = null)
     : base("TapGameAction" + instances++, scene)
 {
     this.touchGestures = touchGestures;
 }