コード例 #1
0
ファイル: SpinBox.cs プロジェクト: scorvi/dwarfcorp
        public SpinBox(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SpinMode mode)
            : base(gui, parent)
        {
            Increment = 1.0f;
            SpinValue = value;
            MinValue = minValue;
            MaxValue = maxValue;
            Mode = mode;
            Layout = new GridLayout(GUI, this, 1, 4);
            PlusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            MinusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            ValueBox = new LineEdit(GUI, Layout, value.ToString())
            {
                IsEditable = false
            };
            Layout.SetComponentPosition(ValueBox, 0, 0, 2, 1);
            Layout.SetComponentPosition(PlusButton, 3, 0, 1, 1);
            Layout.SetComponentPosition(MinusButton, 2, 0, 1, 1);

            PlusButton.OnClicked += PlusButton_OnClicked;
            MinusButton.OnClicked += MinusButton_OnClicked;
            OnValueChanged += SpinBox_OnValueChanged;
        }
コード例 #2
0
ファイル: SpinBox.cs プロジェクト: svifylabs/dwarfcorp
        public SpinBox(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SpinMode mode) :
            base(gui, parent)
        {
            Increment  = 1.0f;
            SpinValue  = value;
            MinValue   = minValue;
            MaxValue   = maxValue;
            Mode       = mode;
            Layout     = new GridLayout(GUI, this, 1, 4);
            PlusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            MinusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut))
            {
                KeepAspectRatio = true,
                DontMakeSmaller = true
            };
            ValueBox = new LineEdit(GUI, Layout, value.ToString())
            {
                IsEditable = false
            };
            Layout.SetComponentPosition(ValueBox, 0, 0, 2, 1);
            Layout.SetComponentPosition(PlusButton, 3, 0, 1, 1);
            Layout.SetComponentPosition(MinusButton, 2, 0, 1, 1);

            PlusButton.OnClicked  += PlusButton_OnClicked;
            MinusButton.OnClicked += MinusButton_OnClicked;
            OnValueChanged        += SpinBox_OnValueChanged;
        }
コード例 #3
0
    private void Update()
    {
        if (gunSystem.TriggerDown != lastFireState)
        {
            if (gunSystem.TriggerDown)
            {
                SpinUp();
            }
            else
            {
                SpinDown();
            }

            lastFireState = gunSystem.TriggerDown;
        }

        if (state == SpinMode.SpinUp)
        {
            if (elapsedTime < spinUpTime)
            {
                elapsedTime        += Time.deltaTime;
                currentRotationRate = Mathf.Lerp(startingRotationRate, rotationSpeedMultiplier, elapsedTime / spinUpTime);
            }
            else
            {
                currentRotationRate = rotationSpeedMultiplier;
                state = SpinMode.AtSpeed;
            }
        }
        else if (state == SpinMode.SpinDown)
        {
            if (elapsedTime < spinDownTime)
            {
                elapsedTime        += Time.deltaTime;
                currentRotationRate = Mathf.Lerp(startingRotationRate, 0, elapsedTime / spinDownTime);
            }
            else
            {
                currentRotationRate = 0;
                state = SpinMode.Stopped;
            }
        }

        rotaryPivot.Rotate(Vector3.forward, rotationIncrement * Time.deltaTime * currentRotationRate, Space.Self);

        //if (Input.GetKeyDown(KeyCode.Y))
        //    SpinUp();

        //if (Input.GetKeyDown(KeyCode.U))
        //    SpinDown();
    }
コード例 #4
0
ファイル: Inventory.cs プロジェクト: ktndrnl/unitystation
 /// <summary>
 /// Inventory move in which the object in the slot is thrown into the world from the location of its root storage
 /// </summary>
 /// <param name="fromSlot"></param>
 /// <param name="worldTargetVector">world space vector pointing from origin to targeted position to throw</param>
 /// <param name="spinMode"></param>
 /// <param name="aim">body part to target</param>
 /// <returns>true if successful</returns>
 public static bool ServerThrow(ItemSlot fromSlot, Vector2 worldTargetVector, SpinMode spinMode = SpinMode.CounterClockwise, BodyPartType aim = BodyPartType.Chest)
 {
     return(ServerPerform(InventoryMove.Throw(fromSlot, worldTargetVector, spinMode, aim)));
 }
コード例 #5
0
 /// <summary>
 /// Inventory move in which the object in the slot is thrown into the world from the location of its root storage
 /// </summary>
 /// <param name="fromSlot"></param>
 /// <param name="worldTargetVector">world space vector pointing from origin to targeted position to throw</param>
 /// <param name="spinMode"></param>
 /// <param name="aim">body part to target</param>
 /// <returns></returns>
 public static InventoryMove Throw(ItemSlot fromSlot, Vector2 worldTargetVector, SpinMode spinMode = SpinMode.CounterClockwise, BodyPartType aim = BodyPartType.Chest)
 {
     return(new InventoryMove(InventoryMoveType.Remove, fromSlot.Item, fromSlot, null, InventoryRemoveType.Throw, aim, worldTargetVector, spinMode));
 }
コード例 #6
0
 public void SpinDown()
 {
     elapsedTime          = currentRotationRate < rotationSpeedMultiplier ? (currentRotationRate / rotationSpeedMultiplier) * spinDownTime : 0;
     startingRotationRate = currentRotationRate;
     state = SpinMode.SpinDown;
 }
コード例 #7
0
 public void SpinUp()
 {
     elapsedTime          = currentRotationRate > 0 ? (currentRotationRate / rotationSpeedMultiplier) * spinUpTime : 0;
     startingRotationRate = currentRotationRate;
     state = SpinMode.SpinUp;
 }