Exemplo n.º 1
0
    void Start()
    {
        transform = gameObject.transform;
        gyro      = new Vector3(0, 0, 0);
        accel     = new Vector3(0, 0, 0);

        handState        = HandState.Idle;
        materialOffset   = material.mainTextureOffset;
        materialOffset.y = -0.5f;

        material.mainTextureOffset = materialOffset;

        hover1 = frontCloud.GetComponent <Hover>();
        hover2 = backCloud.GetComponent <Hover>();

        hover1.UpdateRotation = false;
        hover2.UpdateRotation = false;

        // get the public Joycon array attached to the JoyconManager in scene
        joycons = JoyconManager.Instance.j;

        //if (joycons.Count < jc_ind + 1)
        //{
        //    Destroy(gameObject);
        //}
    }
Exemplo n.º 2
0
 /// <summary>
 /// Belongs to InitalizeEventTrigger().
 ///
 /// Author: Steven Johnson, David Askari
 /// </summary>
 /// <param name="data">Information about the event.</param>
 public void OnPointerExitDelegate(PointerEventData data)
 {
     if (!Hover.IsActive())
     {
         TowerInformation.Reset();
     }
 }
Exemplo n.º 3
0
        public void Read(AssetStream stream)
        {
            StyleName = stream.ReadStringAligned();
            Normal.Read(stream);
            Hover.Read(stream);
            Active.Read(stream);
            Focused.Read(stream);
            OnNormal.Read(stream);
            OnHover.Read(stream);
            OnActive.Read(stream);
            OnFocused.Read(stream);
            Border.Read(stream);
            Margin.Read(stream);
            Padding.Read(stream);
            Overflow.Read(stream);
            Font.Read(stream);
            FontSize  = stream.ReadInt32();
            FontStyle = stream.ReadInt32();
            Alignment = stream.ReadInt32();
            WordWrap  = stream.ReadBoolean();
            RichText  = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);

            TextClipping  = stream.ReadInt32();
            ImagePosition = stream.ReadInt32();
            ContentOffset.Read(stream);
            FixedWidth    = stream.ReadSingle();
            FixedHeight   = stream.ReadSingle();
            StretchWidth  = stream.ReadBoolean();
            StretchHeight = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);
        }
Exemplo n.º 4
0
        public async Task CanSendHoverRequestAsync()
        {
            Skip.If(IsLinux, "This depends on the help system, which is flaky on Linux.");
            string filePath = NewTestFile("Write-Host");

            Hover hover = await PsesLanguageClient.TextDocument.RequestHover(
                new HoverParams
            {
                TextDocument = new TextDocumentIdentifier
                {
                    Uri = DocumentUri.FromFileSystemPath(filePath)
                },
                Position = new Position(line: 0, character: 1)
            }).ConfigureAwait(false);

            Assert.True(hover.Contents.HasMarkedStrings);
            Assert.Collection(hover.Contents.MarkedStrings,
                              str1 =>
            {
                Assert.Equal("function Write-Host", str1.Value);
            },
                              str2 =>
            {
                Assert.Equal("markdown", str2.Language);
                Assert.Equal("Writes customized output to a host.", str2.Value);
            });
        }
Exemplo n.º 5
0
    void Start()
    {
        if (GameObject.FindGameObjectWithTag("leftHand").Equals(this.gameObject))
        {
            currentSource = SteamVR_Input_Sources.LeftHand;
        }
        else
        {
            if (GameObject.FindGameObjectWithTag("rightHand").Equals(this.gameObject))
            {
                currentSource = SteamVR_Input_Sources.RightHand;
            }
            else
            {
                print("This script is not on right or left hand");
            }
        }

        pose  = GetComponent <SteamVR_Behaviour_Pose>();
        hover = GetComponent <Hover>();

        currentActionSet  = SteamVR_Input.GetActionSet("MySet");
        gripClickAction   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("MySet", "GripClick", false, false);
        triggerPullAction = SteamVR_Input.GetAction <SteamVR_Action_Single>("MySet", "Teleport", false, false);
        joyStickAction    = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("MySet", "Move", false, false);

        //Sword specific actions that need to be defined (They won't do anything until we activate the correct action set)
        detachAction       = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "Detach", false, false);
        triggerClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false);
    }
Exemplo n.º 6
0
        //<< Fields

        protected override void Serialize(IDictionary <string, object> json)
        {
            //>> Serialization

            var stroke = Stroke.ToJson();

            if (stroke.Any())
            {
                json["stroke"] = stroke;
            }

            var hover = Hover.ToJson();

            if (hover.Any())
            {
                json["hover"] = hover;
            }

            if (StartCap.HasValue())
            {
                json["startCap"] = StartCap;
            }

            if (EndCap.HasValue())
            {
                json["endCap"] = EndCap;
            }

            //<< Serialization
        }
        public override async Task <TooltipItem> GetItem(
            TextEditor editor,
            DocumentContext ctx,
            int offset,
            CancellationToken token = default(CancellationToken))
        {
            try {
                // DocumentContext is null so get the document information again.
                Document doc = IdeApp.Workbench.ActiveDocument;
                if (doc == null)
                {
                    return(null);
                }

                LanguageClientSession session = LanguageClientServices.Workspace.GetSession(doc, false);

                if (session != null)
                {
                    DocumentLocation location = editor.OffsetToLocation(offset);
                    Hover            result   = await session.Hover(doc.FileName, location, token);

                    return(CreateTooltipItem(editor, result));
                }
            } catch (OperationCanceledException) {
                // Ignore.
            } catch (Exception ex) {
                LanguageClientLoggingService.LogError("TooltipProvider error.", ex);
            }

            return(null);
        }
Exemplo n.º 8
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add("m_Name", Name);
            node.Add("m_Normal", Normal.ExportYAML(container));
            node.Add("m_Hover", Hover.ExportYAML(container));
            node.Add("m_Active", Active.ExportYAML(container));
            node.Add("m_Focused", Focused.ExportYAML(container));
            node.Add("m_OnNormal", OnNormal.ExportYAML(container));
            node.Add("m_OnHover", OnHover.ExportYAML(container));
            node.Add("m_OnActive", OnActive.ExportYAML(container));
            node.Add("m_OnFocused", OnFocused.ExportYAML(container));
            node.Add("m_Border", Border.ExportYAML(container));
            node.Add("m_Margin", Margin.ExportYAML(container));
            node.Add("m_Padding", Padding.ExportYAML(container));
            node.Add("m_Overflow", Overflow.ExportYAML(container));
            node.Add("m_Font", Font.ExportYAML(container));
            node.Add("m_FontSize", FontSize);
            node.Add("m_FontStyle", (int)FontStyle);
            node.Add("m_Alignment", (int)Alignment);
            node.Add("m_WordWrap", WordWrap);
            node.Add("m_RichText", RichText);
            node.Add("m_TextClipping", (int)TextClipping);
            node.Add("m_ImagePosition", (int)ImagePosition);
            node.Add("m_ContentOffset", ContentOffset.ExportYAML(container));
            node.Add("m_FixedWidth", FixedWidth);
            node.Add("m_FixedHeight", FixedHeight);
            node.Add("m_StretchWidth", StretchWidth);
            node.Add("m_StretchHeight", StretchHeight);
            return(node);
        }
Exemplo n.º 9
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add(NameName, Name);
            node.Add(NormalName, Normal.ExportYAML(container));
            node.Add(HoverName, Hover.ExportYAML(container));
            node.Add(ActiveName, Active.ExportYAML(container));
            node.Add(FocusedName, Focused.ExportYAML(container));
            node.Add(OnNormalName, OnNormal.ExportYAML(container));
            node.Add(OnHoverName, OnHover.ExportYAML(container));
            node.Add(OnActiveName, OnActive.ExportYAML(container));
            node.Add(OnFocusedName, OnFocused.ExportYAML(container));
            node.Add(BorderName, Border.ExportYAML(container));
            node.Add(MarginName, Margin.ExportYAML(container));
            node.Add(PaddingName, Padding.ExportYAML(container));
            node.Add(OverflowName, Overflow.ExportYAML(container));
            node.Add(FontName, Font.ExportYAML(container));
            node.Add(FontSizeName, FontSize);
            node.Add(FontStyleName, (int)FontStyle);
            node.Add(AlignmentName, (int)Alignment);
            node.Add(WordWrapName, WordWrap);
            node.Add(RichTextName, RichText);
            node.Add(TextClippingName, (int)TextClipping);
            node.Add(ImagePositionName, (int)ImagePosition);
            node.Add(ContentOffsetName, ContentOffset.ExportYAML(container));
            node.Add(FixedWidthName, FixedWidth);
            node.Add(FixedHeightName, FixedHeight);
            node.Add(StretchWidthName, StretchWidth);
            node.Add(StretchHeightName, StretchHeight);
            return(node);
        }
Exemplo n.º 10
0
        public void InvokeHover(Point screenPosition, float scale, ISymbolCache symbolCache)
        {
            if (Hover == null)
            {
                return;
            }
            if (HoverLayers.Count == 0)
            {
                return;
            }
            var mapInfo = InfoHelper.GetMapInfo(Viewport, screenPosition, scale, HoverLayers, symbolCache);

            if (mapInfo?.Feature != _previousHoverEventArgs?.MapInfo.Feature) // only notify when the feature changes
            {
                var mapInfoEventArgs = new MapInfoEventArgs
                {
                    MapInfo = mapInfo,
                    NumTaps = 0,
                    Handled = false
                };

                _previousHoverEventArgs = mapInfoEventArgs;
                Hover?.Invoke(this, mapInfoEventArgs);
            }
        }
Exemplo n.º 11
0
        public void HoverSignalEmit()
        {
            tlog.Debug(tag, $"HoverSignalEmit START");
            var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
            var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;

            tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");

            var testingTarget = new HoverSignal();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <HoverSignal>(testingTarget, "Should be an Instance of HoverSignal!");

            try
            {
                using (View view = new View())
                {
                    using (Hover hover = new Hover())
                    {
                        testingTarget.Emit(view, hover);
                    }
                }
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception: Failed!");
            }

            testingTarget.Dispose();

            tlog.Debug(tag, $"HoverSignalEmit END (OK)");
        }
        public override Task <Hover> Handle(HoverParams request, CancellationToken cancellationToken)
        {
            RhetosDocument rhetosDocument;

            // Visual Studio may issue hover before DidOpen if hover happens before solution is fully loaded
            try
            {
                rhetosDocument = rhetosWorkspace.GetRhetosDocument(request.TextDocument.Uri);
            }
            catch (InvalidOperationException)
            {
                log.LogWarning($"Trying to resolve hover on document that is not opened '{request.TextDocument.Uri}'.");
                return(Task.FromResult <Hover>(null));
            }

            var descInfo = rhetosDocument.GetHoverDescriptionAtPosition(request.Position.ToLineChr());

            if (string.IsNullOrEmpty(descInfo.description))
            {
                return(Task.FromResult <Hover>(null));
            }

            var response = new Hover()
            {
                Range    = new Range(descInfo.startPosition.ToPosition(), descInfo.endPosition.ToPosition()),
                Contents = new MarkedStringsOrMarkupContent(descInfo.description)
            };

            return(Task.FromResult(response));
        }
Exemplo n.º 13
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("font");
            // Special Drawing
            drawBattle = new DrawBattle(spriteBatch, font);

            // Menu objects
            MenuBackground         = Content.Load <Texture2D>("MenuBase.png");
            BattleButtonBackground = Content.Load <Texture2D>("MoveSelector.png");
            HP_Bar   = Content.Load <Texture2D>("HP_Bar.png");
            InfoBack = Content.Load <Texture2D>("InfoBox.png");
            // Characters
            GuardTex  = Content.Load <Texture2D>("MartialGrunt.png");
            PlayerTex = Content.Load <Texture2D>("Player.png");
            AllyTex   = Content.Load <Texture2D>("Ally.png");

            // Songs
            BattleTheme = Content.Load <Song>("battleground_final");
            Hover       = Content.Load <SoundEffect>("hover2");
            Click       = Content.Load <SoundEffect>("click4");

            // Logic for beginning music (needs to be after music is loaded, but only once)
            //MediaPlayer.Play(BattleTheme);
            //MediaPlayer.IsRepeating = true;
            //MediaPlayer.Volume = 0.7F;
            hover = Hover.CreateInstance();
            click = Click.CreateInstance();
        }
Exemplo n.º 14
0
 void Start()
 {
     all_action_names = new HashSet <string> {
         "Deform", "Select", "Move", "Zoom"
     };
     hover = new DelegatingHover(reversed_priority: 20, buttonDown: OnButtonDown);
 }
        public async Task CanSendHoverRequest()
        {
            string filePath = NewTestFile("Write-Host");

            Hover hover = await PsesLanguageClient.TextDocument.RequestHover(
                new HoverParams
            {
                TextDocument = new TextDocumentIdentifier
                {
                    Uri = DocumentUri.FromFileSystemPath(filePath)
                },
                Position = new Position(line: 0, character: 1)
            });

            Assert.True(hover.Contents.HasMarkedStrings);
            Assert.Collection(hover.Contents.MarkedStrings,
                              str1 =>
            {
                Assert.Equal("function Write-Host", str1.Value);
            },
                              str2 =>
            {
                Assert.Equal("markdown", str2.Language);
                Assert.Equal("Writes customized output to a host.", str2.Value);
            });
        }
Exemplo n.º 16
0
        public void SerializeHover()
        {
            var obj  = new Hover(new MarkupContent(MarkupKind.Markdown, "some markdown"));
            var json = SerializeObject(obj);

            Assert.Equal(@"{""contents"":{""kind"":""markdown"",""value"":""some markdown""}}", json);
        }
Exemplo n.º 17
0
 private void GridContent_MouseLeave(object sender, MouseEventArgs e)
 {
     if (Config.HoverEnabled)
     {
         var anim = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(Config.HoverHideDelay)));
         Hover.BeginAnimation(OpacityProperty, anim);
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Set currently selected tower and activate hovering effect for this tower.
 /// </summary>
 /// <param name="towerBtn">TowerBtn to select.</param>
 public static void SelectTowerAndHover(TowerBtn towerBtn)
 {
     Hover.Activate(towerBtn.TowerPrefab.GetComponent <Tower>().Range, towerBtn.TowerHoverSprite);
     GameManager.SelectedTower = towerBtn.TowerPrefab.GetComponent <Tower>();
     GameManager.rangeIndicatorRenderer.transform.localScale = new Vector3(SelectedTower.Range * .66f, SelectedTower.Range * .66f, 1);
     GameManager.rangeIndicatorRenderer.transform.position   = SelectedTower.transform.position;
     GameManager.rangeIndicatorRenderer.enabled = true;
 }
Exemplo n.º 19
0
 public void Reset()
 {
     Hover.Reset();
     Platform1.Reset();
     Platform2.Reset();
     Obstacle1.Reset();
     Obstacle2.Reset();
 }
Exemplo n.º 20
0
 public virtual bool OnHover(object sender, MouseEventArgs args)
 {
     hovering = true;
     if (Hover != null)
     {
         return(Hover.Invoke(sender, args));
     }
     return(true);
 }
Exemplo n.º 21
0
        public ActionResult <Position> Get(int x, int y, string direction, string commandSequence)
        {
            var position = new PositionStruct {
                Coordinate = new Coordinate(x, y), Direction = direction.ToDirection()
            };

            var finalPosition = Hover.BatchMove(position, commandSequence);

            return(Ok(finalPosition.ToPositionModel()));
        }
Exemplo n.º 22
0
        public void HoverGetPointCount()
        {
            tlog.Debug(tag, $"HoverGetPointCount START");
            /* TEST CODE */
            Hover hover = new Hover();

            Assert.AreEqual(0, hover.GetPointCount(), "Should be equals to the origin value of pointCount");
            tlog.Debug(tag, $"HoverGetPointCount END (OK)");
            Assert.Pass("HoverGetPointCount");
        }
Exemplo n.º 23
0
        public void HoverGetCPtr()
        {
            tlog.Debug(tag, $"HoverGetCPtr START");
            Hover hover = new Hover();

            Hover.getCPtr(hover);
            Assert.Pass("HoverGetCPtr");
            tlog.Debug(tag, $"HoverGetCPtr END (OK)");
            Assert.Pass("HoverGetCPtr");
        }
Exemplo n.º 24
0
        public override Hover FindHover(ControllerSnapshot snapshot)
        {
            Hover hover = base.FindHover(snapshot);

            if (hover == null && IsPressingButton(snapshot))
            {
                return(new DelegatingHover(buttonDown: (a, s) => { RemoveLine(); Destroy(dialog); }));
            }
            return(hover);
        }
Exemplo n.º 25
0
        public void HoverGetDeviceId()
        {
            tlog.Debug(tag, $"HoverGetDeviceId START");
            /* TEST CODE */
            Hover hover = new Hover();

            Assert.AreEqual(-1, hover.GetDeviceId(0), "Should be equals to the origin value of DeviceId");
            hover.Dispose();
            tlog.Debug(tag, $"HoverGetDeviceId END (OK)");
            Assert.Pass("HoverGetDeviceId");
        }
Exemplo n.º 26
0
        public void HoverGetState()
        {
            tlog.Debug(tag, $"HoverGetState START");
            /* TEST CODE */
            Hover hover = new Hover();

            Assert.AreEqual(PointStateType.Finished, hover.GetState(0), "Should be equals to the origin value of state");
            hover.Dispose();
            tlog.Debug(tag, $"HoverGetState END (OK)");
            Assert.Pass("HoverGetState");
        }
Exemplo n.º 27
0
    // Use this for initialization
    void Start()
    {
        m_Agent   = GetComponent <NavMeshAgent>();                       // nav mesh agent
        m_Capsule = GetComponent <CapsuleCollider>();                    //collision

        m_Player           = GameObject.FindGameObjectWithTag("Player"); // player
        m_PlayerMoveScript = m_Player.GetComponent <ClickToMove>();      // player move script

        highlightCircle = GameObject.FindGameObjectWithTag("Highlight"); //highlight game object
        hoverScript     = highlightCircle.GetComponent <Hover>();        //highlight script
    }
Exemplo n.º 28
0
        public void HoverGetHitView()
        {
            tlog.Debug(tag, $"HoverGetHitView START");
            /* TEST CODE */
            Hover hover = new Hover();

            Assert.IsNotInstanceOf <View>(hover.GetHitView(0), "non-existent point returns an empty handle");
            hover.Dispose();
            tlog.Debug(tag, $"HoverGetHitView END (OK)");
            Assert.Pass("HoverGetHitView");
        }
Exemplo n.º 29
0
        private void _onHover(float p)
        {
            _pickList[this] = p;

            Hover?.Invoke(this);

            if (Mouse.Pressed(MouseButton.Left))
            {
                _isPicked = true;
            }
        }
Exemplo n.º 30
0
        public void HoverTime()
        {
            tlog.Debug(tag, $"HoverTime START");
            /* TEST CODE */
            Hover hover = new Hover();

            Assert.AreEqual(0u, hover.Time, "Should be equals to the origin value of Time");
            hover.Dispose();
            tlog.Debug(tag, $"HoverTime END (OK)");
            Assert.Pass("HoverTime");
        }
    private void HandleItemSelected(Hover.Common.Items.ISelectableItem pItem)
    {
        // Assign the current time to the selected one.
        if (pItem == selItem1) {
            timeLastPi1Selection = Time.time;
        }
        else if (pItem == selItem2) {
            timeLastPi2Selection = Time.time;
        }

        // Check if the diff. of time between both is less or equal to the time limit.
        if (Mathf.Abs(timeLastPi1Selection - timeLastPi2Selection) <= matchingTimeLimit &&
            Mathf.Abs(Time.time - lastMatchTime) > minimumTimeBetweeMatches) {

            lastMatchTime = Time.time;

            // TakeOff or land.
            dronController.TakeOffOrLand();
            Debug.Log("Time matched");
        }

        //if (pItem.Label == "^") {
        //    return;
        //}

        //if (pItem.Label.Length == 1) {
        //    vEnviro.AddLetter(pItem.Label[0]);
        //    vTextField.AddLetter(pItem.Label[0]);
        //    return;
        //}

        //if (pItem.Label.ToLower() == "back") {
        //    vEnviro.RemoveLatestLetter();
        //    vTextField.RemoveLatestLetter();
        //}

        //if (pItem.Label.ToLower() == "enter") {
        //    vTextField.ClearLetters();
        //}
    }
Exemplo n.º 32
0
        public void Update(GameTime gameTime)
        {
            if (gameState.Input.Inside(storyBox))
                hover = Hover.Story;
            else if (gameState.Input.Inside(freeBox))
                hover = Hover.Free;
            else if (gameState.Input.Inside(exitBox))
                hover = Hover.Exit;
            else
                hover = Hover.None;

            if (hover != lastHover && hover != Hover.None)
                TitleMove.Play();

            if (gameState.Input.Confirm)
            {
                switch (hover)
                {
                    case Hover.Story:
                        TitleSelect.Play();
                        gameState.CurrentScreen = DataTypes.Screens.WorldMap;
                        break;
                    case Hover.Free:
                        TitleSelect.Play();
                        gameState.CurrentScreen = DataTypes.Screens.SelectLevel;
                        break;
                    case Hover.Exit:
                        TitleSelect.Play();
                        game.Exit();
                        break;
                }

            }
            lastHover = hover;
        }
Exemplo n.º 33
0
    public void Inititalize(int number, MatchManager manager)
    {
        // player info
        player_num = number;
        player_name = GameSettings.Instance.player_name[number - 1];
        player_color = GameSettings.Instance.GetPlayerColor(number);

        // player_state
        hearts = GameSettings.Instance.GetNumHearts();
        crystals = GameSettings.Instance.GetNumCrystals();

        // Player controller
        if (GameSettings.Instance.IsAIControlled(number))
        {
            gameObject.AddComponent<AIPlayerController>();
            GetComponent<AIPlayerController>().Initialize(this, opponent, manager);
        }
        else
        {
            gameObject.AddComponent<HumanPlayerController>();
            GetComponent<HumanPlayerController>().Initialize(
                GameSettings.Instance.GetHumanControlScheme(number));
        }
        this.pc = GetComponent<PlayerController>();

        // input events
        pc.InputCast += OnCastSpell;
        pc.InputSpellCodeA += OnSpellCodeA;
        pc.InputSpellCodeB += OnSpellCodeB;
        pc.InputSpellCodeX += OnSpellCodeX;
        pc.InputSpellCodeY += OnSpellCodeY;

        // other references
        rb = GetComponent<Rigidbody2D>();
        hover = GetComponent<Hover>();

        // sprites
        SetGraphicsNormal();
        spriterenderer_highlights.color = player_color;

        // spells
        spellmanager = FindObjectOfType<SpellManager>();
        if (spellmanager == null) Debug.LogError("SpellManager not found");

        mana_slots = new List<ManaSlot>(GameSettings.Instance.GetNumSlots());
        for (int i = 0; i < GameSettings.Instance.GetNumSlots(); ++i)
            mana_slots.Add(new ManaSlot());
    }
Exemplo n.º 34
0
 public void setEdgeOwner(Hover h, int owner)
 {
     setEdgeOwner(h.x, h.y, h.direction, owner);
 }
Exemplo n.º 35
0
 public int getEdgeOwner(Hover h)
 {
     return getEdgeOwner(h.x, h.y, h.direction);
 }
Exemplo n.º 36
0
 public Hover findHover(int rx, int ry)
 {
     int fieldWidth = getFieldWidth();
     int fieldHeight = getFieldHeight();
     rx += fieldWidth / 2;
     ry += fieldHeight / 2;
     Hover h = new Hover();
     int edgeWidth = (int)(EdgeThreshold * boxWidth);
     int edgeHeight = (int)(EdgeThreshold * boxHeight);
     int dx = rx + edgeWidth / 2, dy = ry + edgeHeight / 2;
     if (dx < 0 || dx > fieldWidth + edgeWidth
         || dy < 0 || dy > fieldHeight + edgeHeight)
     {
         h.hoverType = Hover.HoverType.NONE;
         return h;
     }
     dx %= boxWidth;
     dy %= boxHeight;
     if (Math.Abs(dx) > edgeWidth && Math.Abs(dy) > edgeHeight)
     {
         h.hoverType = Hover.HoverType.BOX;
         h.x = rx / boxWidth;
         h.y = ry / boxHeight;
         return h;
     }
     h.hoverType = Hover.HoverType.EDGE;
     h.x = (rx / boxWidth);
     h.y = (ry / boxHeight);
     dx = (rx) % boxWidth;
     dy = (ry) % boxHeight;
     dy = (int)(dy * boxWidth * 1.0f / boxHeight);
     dx -= boxWidth / 2;
     dy -= boxWidth / 2;
     if (Math.Abs(dx) > Math.Abs(dy))
     {
         h.direction = dx < 0 ? Direction.WEST : Direction.EAST;
         if (rx >= fieldWidth)
             h.direction = Direction.EAST;
     }
     else
     {
         h.direction = dy < 0 ? Direction.NORTH : Direction.SOUTH;
         if (ry >= fieldHeight)
             h.direction = Direction.SOUTH;
     }
     if (h.x >= col)
         h.x--;
     if (h.y >= row)
         h.y--;
     return h;
 }