コード例 #1
0
ファイル: hordeUtils.cs プロジェクト: Slvr11/horde
        public static IEnumerator updateWeaponName(Entity player, string weapon)
        {
            if (!player.HasField("hud_created"))
            {
                yield break;
            }
            HudElem weaponName = player.GetField <HudElem>("hud_weaponName");

            weaponName.FadeOverTime(0);
            weaponName.Alpha = 0;
            weaponName.SetText(getWeaponName(weapon));
            weaponName.MoveOverTime(0);
            weaponName.X = -240;
            weaponName.FadeOverTime(.5f);
            weaponName.Alpha = 1;
            weaponName.MoveOverTime(.5f);
            weaponName.X = -180;
            yield return(Wait(1));

            weaponName.FadeOverTime(1);
            weaponName.Alpha = 0;
        }
コード例 #2
0
ファイル: menuTest.cs プロジェクト: Slvr11/mouseTest
    private static bool trackMouseMovement(Entity player)
    {
        HudElem cursor       = player.GetField <HudElem>("cursor");
        Vector3 lastPos      = player.GetField <Vector3>("lastCursorPos");
        Vector3 lastAngles   = player.GetField <Vector3>("lastAngles");
        Vector3 newAngles    = player.GetPlayerAngles() * 2;
        Vector3 newCursorPos = lastPos + (newAngles - lastAngles);

        newCursorPos.Z = 0;
        if (newCursorPos.X > 640)
        {
            newCursorPos.X = 640;
        }
        if (newCursorPos.Y > 480)
        {
            newCursorPos.Y = 480;
        }

        cursor.MoveOverTime(.05f);
        cursor.X = -newCursorPos.Y + 360;
        cursor.Y = newCursorPos.X;
        player.SetField("lastAngles", newAngles);
        player.SetField("lastCursorPos", newCursorPos);

        if (!player.HasField("hoveredButton"))
        {
            foreach (Button button in Button.menuButtons)
            {
                if (button.isHovered || button.hud == null)
                {
                    continue;
                }

                if (isCursorHoveringButton(player, button))
                {
                    button.onHover();
                    player.PlayLocalSound("mouse_over");
                    player.SetField("hoveredButton", new Parameter(button));
                    OnInterval(50, () => watchCursorHoverOnButton(player, button));
                }
            }
        }

        if (!player.GetField <bool>("menuOpen"))
        {
            return(false);
        }
        return(true);
    }