Beispiel #1
0
        private void Update(List <TouchLocation> touches, ref TouchLocation?touch)
        {
            foreach (var touchLocation in touches)
            {
                if (touchLocation.Id == Id)
                {
                    touch = touchLocation;
                    break;
                }

                TouchLocation earliestTouchLocation;
                if (!touchLocation.TryGetPreviousLocation(out earliestTouchLocation))
                {
                    earliestTouchLocation = touchLocation;
                }

                if (Id == -1)
                {
                    if (TouchArea.Contains(earliestTouchLocation.Position.ToPoint()))
                    {
                        touch = earliestTouchLocation;
                        break;
                    }
                }
            }

            if (touch.HasValue)
            {
                Id = touch.Value.Id;
            }
            else
            {
                Id = -1;
            }
        }
Beispiel #2
0
        public Window(int width, int height, NinePatch chrome)
        {
            Blocker             = new TouchArea(0, 0, PixelScene.uiCamera.CameraWidth, PixelScene.uiCamera.CameraHeight);
            Blocker.ClickAction = BlockerClickAction;
            Blocker.Camera      = PixelScene.uiCamera;
            Add(Blocker);

            Chrome = chrome;

            Width  = width;
            Height = height;

            chrome.X = -chrome.MarginLeft();
            chrome.Y = -chrome.MarginTop();
            chrome.Size(width - chrome.X + chrome.MarginRight(), height - chrome.Y + chrome.MarginBottom());
            Add(chrome);

            Camera   = new Camera(0, 0, (int)chrome.Width, (int)chrome.Height, PixelScene.defaultZoom);
            Camera.X = (int)(Game.Width - Camera.CameraWidth * Camera.Zoom) / 2;
            Camera.Y = (int)(Game.Height - Camera.CameraHeight * Camera.Zoom) / 2;
            Camera.Scroll.Set(chrome.X, chrome.Y);
            Camera.Add(Camera);

            Keys.Event.Add(this);
        }
 protected void OnTouchStartButton(TouchArea touchArea, Touch touch)
 {
     if (this.TitleSceneController)
     {
         PlayAudio();
         this.TitleSceneController.OnTouchStartButton(touchArea, touch);
     }
 }
Beispiel #4
0
 virtual public void OnTouchStartButton(TouchArea touchArea, Touch touch)
 {
     if (SceneNavigator.Instance && SceneNavigator.Instance.IsReady)
     {
         SagoBiz.Facade.OnSceneWillDisappear(true);
         DisableAllTouchAreas();
         BounceStartButton(touchArea.gameObject);
         StopMusicAndNavigateToNextScene();
     }
 }
Beispiel #5
0
        protected override void CreateChildren()
        {
            _image = new Image();
            Add(_image);
            var touchArea = new TouchArea(_image);

            touchArea.TouchDownAction = TouchDownAction;
            touchArea.TouchUpAction   = TouchUpAction;
            touchArea.ClickAction     = SimpleButtonClickAction;
            Add(touchArea);
        }
    private GameObject SpawnCircle(Touch t)
    {
        float      scale = Mathf.Max(GetTouchSize(t.radius), .3f) * 2f;
        GameObject c     = Instantiate(DebugCircle);
        TouchArea  ta    = c.GetComponent <TouchArea>();

        c.name = "Touch" + t.fingerId;
        c.transform.position   = GetTouchPosition(t.position);
        c.transform.localScale = new Vector3(scale, scale, 1f);
        ta.radius = Mathf.Max(GetTouchSize(t.radius), .3f);
        return(c);
    }
Beispiel #7
0
        public override void Create()
        {
            base.Create();

            var text = CreateMultiline(Txt, 8);

            text.MaxWidth = Math.Min(Camera.Main.CameraWidth, 120);
            text.Measure();
            Add(text);

            text.X = Align((Camera.Main.CameraWidth - text.Width) / 2);
            text.Y = Align((Camera.Main.CameraHeight - text.Height) / 2);

            var link = CreateMultiline(Lnk, 8);

            link.MaxWidth = Math.Min(Camera.Main.CameraWidth, 120);
            link.Measure();
            link.Hardlight(Window.TitleColor);
            Add(link);

            link.X = text.X;
            link.Y = text.Y + text.Height;

            var hotArea = new TouchArea(link);

            hotArea.ClickAction = HotAreaClickAction;
            Add(hotArea);

            var wata = Icons.WATA.Get();

            wata.X = Align(text.X + (text.Width - wata.Width) / 2);
            wata.Y = text.Y - wata.Height - 8;
            Add(wata);

            new Flare(7, 64).Color(0x112233, true).Show(wata, 0).AngularSpeed = +20;

            var archs = new Archs();

            archs.SetSize(Camera.Main.CameraWidth, Camera.Main.CameraHeight);
            AddToBack(archs);

            var btnExit = new ExitButton();

            btnExit.SetPos(Camera.Main.CameraWidth - btnExit.Width, 0);
            Add(btnExit);

            FadeIn();
        }
Beispiel #8
0
        private void SendTouchEvent(TouchState _state, TouchArea _area, Touch[] _touchs)
        {
            //HiDebug.Log("_state => ", _state);
            List <Action <TouchState, TouchArea, Touch[]> > _sends = ReceivingSetList[(int)_state];

            if (_sends != null)
            {
                for (int _i = 0; _i < _sends.Count; _i++)
                {
                    if (_sends[_i] != null)
                    {
                        _sends[_i](_state, _area, _touchs);
                    }
                }
            }
        }
Beispiel #9
0
 private void TouchDownProcess_2Point()
 {
     var _ob = this.UpdateAsObservable()
               .Select(_ => GetTouchCount(TouchState.TouchDrag_2Point))
               .Buffer(2, 1)
               .Where(_ => _.Last() >= 2 && _.First() != _.Last())
               .First()
               .Repeat()
               .Subscribe(_ =>
     {
         CurrentTouchs = StartTouchs = GetTouchs(TouchState.TouchDrag_2Point);
         CurrentArea   = StartArea = GetTouchArea(StartTouchs[0]);
         IsTouch       = true;
         //HiDebug.Log("TouchDownProcess_2Point=>StartTouchs => ", StartTouchs);
     });
 }
Beispiel #10
0
    public void ChangeTouchArea(TouchArea area)
    {
#if UNITY_EDITOR
        if (area == null)
        {
            Debug.LogWarning("TouchArea is null");
        }
#endif
        if (m_CurrentArea != null)
        {
            m_CurrentArea.Active(false);
        }
        m_CurrentArea = area == null ? m_DefaultArea : area;
        if (m_CurrentArea != null)
        {
            m_CurrentArea.Active(true);
        }
    }
Beispiel #11
0
        private void mainGrid_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Pointer      pointer  = e.Pointer;
            PointerPoint point    = e.GetCurrentPoint(this.mainGrid);
            Size         areaSize = new Size(mainGrid.ActualWidth, mainGrid.ActualHeight);

            if (point.Properties.PointerUpdateKind == PointerUpdateKind.LeftButtonReleased)
            {
                TouchArea area = getTouchArea(point.Position, areaSize);
                switch (area)
                {
                case TouchArea.Top:
                    touchEventTop(areaSize);
                    break;

                case TouchArea.TopLeft:
                    touchEventTopLeft();
                    break;

                case TouchArea.TopRight:
                    touchEventTopRight();
                    break;

                case TouchArea.BottomLeft:
                    touchEventBottomLeft();
                    break;

                case TouchArea.BottomRight:
                    touchEventBottomRight();
                    break;
                }
            }
            else if (point.Properties.PointerUpdateKind == PointerUpdateKind.XButton1Released)
            {
                if (this.Frame.CanGoBack)
                {
                    this.Frame.GoBack();
                    e.Handled = true;
                    return;
                }
            }

            e.Handled = false;
        }
Beispiel #12
0
        //터치 로그. (확인용)
        private void Test_Touch(TouchState _state, TouchArea _area, Touch[] _touch)
        {
            if (DebugText.text.Length > 800)
            {
                DebugText.text = "";
            }

            ////HiDebug.Log("+++++++++++++++++++++++++++++++++++");
            //GameObject _go = TouchGameObject(_touch[0].position);
            //if (_go != null)
            //{
            //	HiDebug.Log("터치 ::: ", "영역=", _area, "상태=" + _state, "Length=" + _touch.Length, "x=", _touch[0].position.x, "y=", _touch[0].position.y, _go.GetComponent<Block>().name);
            //	DebugText.text += "터치 ::: " + ",영역=" + _area + ",상태=" + _state + ",Length=" + _touch.Length + ",x=" + _touch[0].position.x + ",y=" + _touch[0].position.y + _go.GetComponent<Block>().name + "\n";
            //}
            //else
            //{
            //	HiDebug.Log("터치 ::: ", "영역=", _area, "상태=" + _state, "Length=" + _touch.Length, "x=", _touch[0].position.x, "y=", _touch[0].position.y, "null");
            //	DebugText.text += "터치 ::: " + ",영역=" + _area + ",상태=" + _state + ",Length=" + _touch.Length + ",x=" + _touch[0].position.x + ",y=" + _touch[0].position.y + "null" + "\n";
            //}
            ////HiDebug.Log("+++++++++++++++++++++++++++++++++++");
        }
Beispiel #13
0
        public WndStory(string text)
            : base(0, 0, sharpdungeon.Chrome.Get(sharpdungeon.Chrome.Type.SCROLL))
        {
            _tf          = PixelScene.CreateMultiline(text, 7);
            _tf.MaxWidth = WIDTH - MARGIN * 2;
            _tf.Measure();
            _tf.RA = bgR;
            _tf.Ga = bgG;
            _tf.Ba = bgB;
            _tf.Rm = -bgR;
            _tf.Gm = -bgG;
            _tf.Bm = -bgB;
            _tf.X  = MARGIN;
            Add(_tf);

            var touchArea = new TouchArea(Chrome);

            touchArea.ClickAction = (touch) => Hide();

            Resize((int)(_tf.Width + MARGIN * 2), (int)Math.Min(_tf.Height, 180));
        }
Beispiel #14
0
        public bool GetBooleanValue(List <TouchLocation> touches)
        {
            TouchLocation?touch = null;

            Update(touches, ref touch);

            bool result = false;

            if (!touch.HasValue)
            {
                result = false;
            }
            else if (touch.Value.State == TouchLocationState.Pressed)
            {
                result = true;
            }
            else if (touch.Value.State == TouchLocationState.Moved)
            {
                result = TouchArea.Contains(touch.Value.Position.ToPoint());
            }

            return(result);
        }
Beispiel #15
0
        //
        // Touch Handling
        //
        private void OnTouchUp(TouchArea touchArea, Touch touch)
        {
            if (touch.IsTap)
            {
                switch (this.State)
                {
                case HomeButton.States.Showing:
                    if (this.SkipArmedPhase)
                    {
                        this.FireFromShowing();
                    }
                    else
                    {
                        Arm();
                    }
                    break;

                case HomeButton.States.Armed:
                    Fire();
                    break;
                }
            }
        }
 private void OnReactTouchDown(TouchArea touchArea, Touch touch)
 {
     Debug.Log("Touch Down");
 }
 private void OnReactTouchUp(TouchArea touchArea, Touch touch)
 {
     Debug.Log("Touch Up");
 }
Beispiel #18
0
 private void OnReactTouchDown(TouchArea touchArea, Touch touch)
 {
     this.Transform.localScale = Vector3.one * 0.8f;
 }
Beispiel #19
0
 private void OnReactTouchUp(TouchArea touchArea, Touch touch)
 {
     this.Transform.localScale = Vector3.one;
 }
Beispiel #20
0
 public void OnTouchUp(TouchArea touchArea, Touch touch)
 {
     this.Touch = null;
 }
Beispiel #21
0
 public void OnTouchUp(TouchArea touchArea, Touch touch)
 {
     Debug.LogFormat("Touch Up: {0}", this);
 }
Beispiel #22
0
 private void OnTouchDismissArea(TouchArea touchArea, Touch touch)
 {
     Disarm();
 }
Beispiel #23
0
 public void OnTouchUp(TouchArea touchArea, Touch touch)
 {
     Debug.Log("Touch Up!", this);
 }
Beispiel #24
0
        protected override void CreateChildren()
        {
            _shield = new NinePatch(Assets.STATUS, 80, 0, 30 + 18, 0);
            Add(_shield);

            var touchArea = new TouchArea(0, 1, 30, 30);

            touchArea.ClickAction = touch =>
            {
                var sprite = Dungeon.Hero.Sprite;
                if (!sprite.Visible)
                {
                    Camera.Main.FocusOn(sprite);
                }
                GameScene.Show(new WndHero());
            };
            Add(touchArea);

            _btnMenu = new MenuButton();
            Add(_btnMenu);

            _avatar = HeroSprite.Avatar(Dungeon.Hero.heroClass, _lastTier);
            Add(_avatar);

            _blood = new Emitter();
            _blood.Pos(_avatar);
            _blood.Pour(BloodParticle.Factory, 0.3f);
            _blood.AutoKill = false;
            _blood.On       = false;
            Add(_blood);

            _compass = new Compass(Dungeon.Level.exit);
            Add(_compass);

            _hp = new Image(Assets.HP_BAR);
            Add(_hp);

            _exp = new Image(Assets.XP_BAR);
            Add(_exp);

            _level = new BitmapText(PixelScene.font1x);
            _level.Hardlight(0xFFEBA4);
            Add(_level);

            _depth = new BitmapText(Dungeon.Depth.ToString(CultureInfo.InvariantCulture), PixelScene.font1x);
            _depth.Hardlight(0xCACFC2);
            _depth.Measure();
            Add(_depth);

            Dungeon.Hero.Belongings.CountIronKeys();
            _keys = new BitmapText(PixelScene.font1x);
            _keys.Hardlight(0xCACFC2);
            Add(_keys);

            _danger = new DangerIndicator();
            Add(_danger);

            _loot = new LootIndicator();
            Add(_loot);

            _buffs = new BuffIndicator(Dungeon.Hero);
            Add(_buffs);
        }
Beispiel #25
0
 public void Reset()
 {
     m_Layer     = GetComponent <Layer>();
     m_TouchArea = GetComponent <TouchArea>();
 }
Beispiel #26
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
Beispiel #27
0
        // Touches

        public void OnTouchDown(TouchArea touchArea, Touch touch)
        {
            this.Touch = touch;
        }
Beispiel #28
0
        void Update()
        {
            if (StartArea == TouchArea.CanvasArea)
            {
                return;
            }

            if (IsTouch == true)
            {
                CurrentTouchs = GetTouchs(TouchState.None) ?? CurrentTouchs;
                CurrentArea   = GetTouchArea(CurrentTouchs[0]);
                //
                if (State == TouchState.None)
                {
                    State = TouchState.Touch;
                    SendTouchEvent(State, CurrentArea, CurrentTouchs);
                    LongTouchTime = HiUtile.GetPlayTime() + LongTouchCheckTime;
                }
                //
                if (State == TouchState.Touch)
                {
                    if (StartTouchs.Length >= 2 || CurrentTouchs.Length >= 2)
                    {
                        if (Math.Abs(StartTouchs[0].position.x - CurrentTouchs[0].position.x) >= TouchAreaSize ||
                            Math.Abs(StartTouchs[0].position.y - CurrentTouchs[0].position.y) >= TouchAreaSize)
                        {
                            State = TouchState.TouchDrag_2Point;
                        }
                    }
                    else
                    {
                        if (Math.Abs(StartTouchs[0].position.x - CurrentTouchs[0].position.x) >= TouchAreaSize ||
                            Math.Abs(StartTouchs[0].position.y - CurrentTouchs[0].position.y) >= TouchAreaSize)
                        {
                            State = TouchState.TouchDrag_1Point;
                        }

                        else if (LongTouchTime < HiUtile.GetPlayTime())
                        {
                            State = TouchState.Touch_Long;
                        }
                    }
                }
                //
                CurrentTouchs = GetTouchs(State) ?? CurrentTouchs;
                if (State == TouchState.TouchDrag_1Point)
                {
                    SendTouchEvent(State, CurrentArea, CurrentTouchs);
                }
                else if (State == TouchState.TouchDrag_2Point)
                {
                    SendTouchEvent(State, CurrentArea, CurrentTouchs);
                }
                else if (State == TouchState.Touch_Long)
                {
                    SendTouchEvent(State, CurrentArea, CurrentTouchs);
                    State = TouchState.TouchAndWait;
                }
            }
            else
            {
                if (State != TouchState.None)
                {
                    if (StartTouchs != null && CurrentTouchs != null)
                    {
                        if (Math.Abs(StartTouchs[0].position.x - CurrentTouchs[0].position.x) < TouchAreaSize &&
                            Math.Abs(StartTouchs[0].position.y - CurrentTouchs[0].position.y) < TouchAreaSize)
                        {
                            State = TouchState.TouchUp_Release;
                            SendTouchEvent(State, CurrentArea, CurrentTouchs);
                        }
                        State = TouchState.TouchUp;
                        SendTouchEvent(State, CurrentArea, CurrentTouchs);
                    }
                }
                State = TouchState.None;
            }
        }