Example #1
0
        // If finger moved on screen
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);
            UITouch touch     = touches.AnyObject as UITouch;
            var     locationc = touch.LocationInNode(this);

            // get the node at touched location
            var nodeAtLocation = GetNodeAtPoint(locationc);

            // Release the info text if cancel icon is clicked
            if (nodeAtLocation.Name == "cancelSpark")
            {
                ReleaseInfoText();
            }
            else
            {
                // If the info icon is not clicked and the info text box is not visible get the location of touch and update the background color
                if (touch != null && infoTouch == false && nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel")
                {
                    // Enable the Physics field
                    fieldNode.Enabled = true;

                    // Get the latest X and Y coordinates
                    // 0 of X i on top
                    float offsetX = (float)(touch.LocationInView(View).X);

                    // other coordinate system
                    // 0 of Y is bottom
                    var checkX_Location = touch.LocationInNode(this).X;
                    var checkY_Location = touch.LocationInNode(this).Y;

                    fieldNode.Position = new CGPoint(checkX_Location, checkY_Location);


                    var manipulate = (checkY_Location / (Frame.Height + 100)) + 0.15f;
                    if (manipulate > 1)
                    {
                        manipulate = manipulate - 1;
                    }

                    // Background Calculating
                    BackgroundColor = UIColor.FromHSB(manipulate, 0.35f, 0.7f);

                    // Check to which part the finger is moved to and update the sparks
                    globalCenter = new CGPoint(checkX_Location, checkY_Location);
                    UpdateCenter(offsetX);
                }
            }
        }
Example #2
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);
            UITouch touch          = touches.AnyObject as UITouch;
            var     locationc      = touch.LocationInNode(this);
            var     nodeAtLocation = GetNodeAtPoint(locationc);

            if (touch != null)
            {
                if (nodeAtLocation.Name == "cancelSpark")
                {
                    ReleaseInfoText();
                }
                // If Info Text Box is not visible, revert center for the spark nodes
                else if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "info" && nodeAtLocation.Name != "navSprite" && nodeAtLocation.Name != "infoLabel")
                {
                    //Release the Changed center
                    RevertCenter();
                    fieldNode.Enabled = false;
                    infoTouch         = false;

                    // Check touch location
                    var checkX = touch.LocationInView(View).X;
                    var checkY = touch.LocationInView(View).Y;

                    // Update dimensions
                    SetDimensions(checkX, checkY);
                }
            }
        }
Example #3
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            // Called when a touch begins
            foreach (var touch in touches)
            {
                UITouch touchc = touches.AnyObject as UITouch;

                // Check click
                var locationc = touchc.LocationInNode(this);
                var checkX    = touchc.LocationInView(View).X;
                var checkY    = touchc.LocationInView(View).Y;

                // other coordinate system
                //var checkX = ((UITouch)touchc).LocationInNode(this).X;
                //var checkY = ((UITouch)touchc).LocationInNode(this).Y;

                // Get Sprite Node at current location
                var nodeAtLocation = GetNodeAtPoint(locationc);
                if (nodeAtLocation.Name == "cancelSpark")
                {
                    ReleaseInfoText();
                }
                else
                {
                    if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel")
                    {
                        // If the info button is clicked change background
                        if (nodeAtLocation.Name == "info" || nodeAtLocation.Name == "navSprite")
                        {
                            infoTouch = true;

                            // Activate information background
                            if (switchInfo == false)
                            {
                                //setInfoText();
                                container.Alpha = 1f;
                                switchInfo      = true;

                                SKAction seqTextureInfo = SKAction.SetTexture(SKTexture.FromImageNamed(("inforeverse")));
                                infoSprite.RunAction((seqTextureInfo));
                            }

                            // Deactivate information background
                            else
                            {
                                container.Alpha = 0f;
                                switchInfo      = false;

                                SKAction seqTextureInfoNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("info")));
                                infoSprite.RunAction((seqTextureInfoNormal));
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            if (MapClicked != null)
            {
                UITouch touch = (UITouch)touches.AnyObject;
                CoreGraphics.CGPoint point       = touch.LocationInNode(this);
                Map.Position         destination = map.PointToPosition(point);
                if (!map.PositionIsValid(destination))
                {
                    return;
                }
                MapClickedArgs args = new MapClickedArgs(destination);
                MapClicked(this, args);
            }
        }
Example #5
0
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            if (Heroes.Count < 1)
            {
                return;
            }

            UITouch touch = DefaultPlayer.MovementTouch;

            if (touch == null)
            {
                return;
            }

            if (touches.Contains(touch))
            {
                DefaultPlayer.TargetLocation = touch.LocationInNode(DefaultPlayer.Hero.Parent);
                if (!DefaultPlayer.FireAction)
                {
                    DefaultPlayer.MoveRequested = true;
                }
            }
        }