Beispiel #1
0
        /// <summary>
        /// Ease out the current globe rotation
        /// </summary>
        public void EaseOut()
        {
            _currentMode = RotationMode.EaseOut;

            _mouseController.End();
            _easeOutController.Init(_mouseController.Axis, _mouseController.GetSpeed());
        }
Beispiel #2
0
        /// <summary>
        /// lets the robot rotate in a certain speed and a certain duration
        /// </summary>
        /// <param name="rotationMode"></param>
        public static void Rotate(RotationMode rotationMode, sbyte leftTrackSpeed, sbyte rightTrackSpeed)
        {
            Print($"rotating in mode {rotationMode}");

            if (rotationMode == RotationMode.TimerMode)
            {
                SetTrackSpeed(leftTrackSpeed, rightTrackSpeed);

                DateTime startTime = DateTime.Now;

                while (!TimerBreakCondition(startTime, Constants.ROTATION_DURATION))
                {
                }
            }
            else if (rotationMode == RotationMode.OtherMode)
            {
                SetTrackSpeed(Constants.DRIVE_BACKWARD_SPEED, Constants.DRIVE_BACKWARD_SPEED);
                Thread.Sleep(1500);
                SetTrackSpeed(leftTrackSpeed, rightTrackSpeed);

                while (AbyssDetected() || ObstacleDetected())
                {
                }

                Thread.Sleep(1000);
            }
            else if (rotationMode == RotationMode.HalfRotationMode)
            {
                SetTrackSpeed(leftTrackSpeed, rightTrackSpeed);

                Thread.Sleep(2500);
            }

            HaltTracks();
        }
Beispiel #3
0
    public void Rotate(Vector2 direction, RotationMode rotationMode)
    {
        switch (rotationMode)
        {
        case RotationMode.LeftRight:

            RotateLeftRight(direction.x);

            if (rotatingTransform.eulerAngles.z != 0)
            {
                rotatingTransform.eulerAngles = new Vector3(rotatingTransform.eulerAngles.x, rotatingTransform.eulerAngles.y, 0);
            }
            break;

        case RotationMode.LeftRightDown:

            RotateLeftRight(direction.x);

            if (direction.y != 0)
            {
                float z = rotatingTransform.localScale.x * direction.y * 90;
                rotatingTransform.eulerAngles = new Vector3(rotatingTransform.eulerAngles.x, rotatingTransform.eulerAngles.y, z);
            }
            break;

        default: break;
        }
    }
Beispiel #4
0
    private void EllipticalMovement()
    {
        switch (CurRotationMode)
        {
        case RotationMode.LEFT:
            if (angle >= 2 * Mathf.PI)
            {
                CurRotationMode = RotationMode.RIGHT;
                angle           = 0f;
                RightRotate();
            }
            else
            {
                LeftRotate();
            }
            break;

        case RotationMode.RIGHT:
            if (angle <= -2 * Mathf.PI)
            {
                CurRotationMode = RotationMode.LEFT;
                angle           = 0f;
                LeftRotate();
            }
            else
            {
                RightRotate();
            }
            break;
        }
    }
        public override void OnInspectorGUI()
        {
            bool dirty = false;

            EditorGUILayout.LabelField("Edge Mode Options", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Toggle(rotationMode == RotationMode.Global, "Global", "Button") &&
                rotationMode != RotationMode.Global)
            {
                dirty        = true;
                rotationMode = RotationMode.Global;
            }
            else if (GUILayout.Toggle(rotationMode == RotationMode.Local, "Local", "Button") &&
                     rotationMode != RotationMode.Local)
            {
                dirty        = true;
                rotationMode = RotationMode.Local;
            }
            else if (GUILayout.Toggle(rotationMode == RotationMode.Normal, "Normal", "Button") &&
                     rotationMode != RotationMode.Normal)
            {
                dirty        = true;
                rotationMode = RotationMode.Normal;
            }
            EditorGUILayout.EndHorizontal();

            if (dirty)
            {
                EditorPrefs.SetInt(RotationModePrefs, (int)rotationMode);
                controller.ForceRepaintSceneGUI();
            }
        }
Beispiel #6
0
 public GameObject(Texture2D texture, Vector2 position, Vector2 velocity, RotationMode mode)
 {
     Texture         = texture;
     _center         = position;
     Velocity        = velocity;
     TexturePosition = new Vector2(Center.X - Texture.Width / 2, Center.Y - Texture.Height / 2);
     Hitbox          = texture.Bounds;
     Hitbox.Offset(TexturePosition);
     RotationCenter = new Vector2(Texture.Width / 2, Texture.Height / 2);
     Rotation       = new Vector2(0, -1);
 }
 public WormholeSettings(Vector3 up, Vector3 forward, Vector3 origin, RotationMode mode, int resolution, int length, float radius, float rotationMax, float noiseSampleInterval, float ringDistanceMultiplier)
 {
     Up                     = up.normalized;
     Forward                = forward.normalized;
     Origin                 = origin;
     Mode                   = mode;
     Resolution             = resolution;
     Length                 = length;
     Radius                 = radius;
     RotationMax            = rotationMax;
     NoiseSampleInterval    = noiseSampleInterval;
     RingDistanceMultiplier = ringDistanceMultiplier;
 }
Beispiel #8
0
        public static ITween To(
            Tweener <Vector3> .Getter currValueGetter,
            Tweener <Vector3> .Setter setter,
            Tweener <Vector3> .Getter finalValueGetter,
            RotationMode rotationMode,
            float duration,
            Tweener <Vector3> .Validation validation = null
            )
        {
            InterpolationTween tween = new InterpolationTween();

            tween.Add(new Vector3RotationTweener(currValueGetter, setter, finalValueGetter, rotationMode, duration, validation));
            return(tween);
        }
Beispiel #9
0
        /// <summary>
        /// Apply the given angle to the current rotation. (Not from Origin).
        /// </summary>
        /// <param name="angle">The angle to apply</param>
        /// <param name="mode">Whether the given angle value is in Degrees or Radians. Degrees will be converted to Radians.</param>
        public void Rotate(float angle, RotationMode mode)
        {
            switch (mode)
            {
            // If angle is in Degrees, convert it to Radians because Rotation is ALWAYS in Radians
            case RotationMode.Degrees:
                Rotation += angle * (float)Math.PI / 180;
                break;

            case RotationMode.Radians:
                Rotation += angle;
                break;
            }
        }
Beispiel #10
0
        public Cglp(NitroFile file, Colour[][,] glyphs, byte boxWidth, byte boxHeight,
		            byte glyphWidth, byte glyphHeight, byte depth, RotationMode rotation)
            : base(file)
        {
            this.BoxWidth = boxWidth;
            this.BoxHeight = boxHeight;
            this.GlyphWidth = glyphWidth;
            this.GlyphHeight = glyphHeight;
            this.Depth = (byte)depth;
            this.Rotation = (byte)rotation;
            this.glyphs = new List<Colour[,]>(glyphs);

            int boxSize = this.BoxWidth * this.BoxHeight * this.Depth;
            this.Size = 0x08 + 0x08 + (int)Math.Ceiling(boxSize / 8.0) * this.glyphs.Count;
        }
        public void UpdateMessageAddress(string messageaddress)
        {
            MessageAddress = messageaddress;

            FileSelector.UpdateMessageAddress(MessageAddress);
            TranslateMode.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(TranslateMode)));
            ScaleMode.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(ScaleMode)));
            RotationMode.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(RotationMode)));

            Translate.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(Translate)));
            Scale.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(Scale)));
            Rotation.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(Rotation)));
            Counter.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(Counter)));
            GeometryFX.UpdateMessageAddress(String.Format("{0}{1}/", messageaddress, nameof(GeometryFX)));
        }
Beispiel #12
0
    // receive thread
    private void ReceiveData()
    {
        port   = 8051;
        client = new UdpClient(port);
        if (multicastGroupAddress != null)
        {
            client.JoinMulticastGroup(multicastGroupAddress);
        }
        print("Starting Server");
        while (receiveThread != null)
        {
            try
            {
                IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
                byte[]     data  = client.Receive(ref anyIP);

                String device = System.Text.Encoding.Default.GetString(data, 0, 31);
                if (device.IndexOf(deviceFilter) >= 0)
                {
                    rotationMode  = (RotationMode)data[31];
                    translation.x = (float)BitConverter.ToDouble(data, 32 + 0 * 8);
                    translation.y = (float)BitConverter.ToDouble(data, 32 + 1 * 8);
                    translation.z = (float)BitConverter.ToDouble(data, 32 + 2 * 8);

                    switch (rotationMode)
                    {
                    case RotationMode.ROTATION_MODE_EULER:
                        eulerRotation.x = (float)BitConverter.ToDouble(data, 32 + 3 * 8);
                        eulerRotation.y = (float)BitConverter.ToDouble(data, 32 + 4 * 8);
                        eulerRotation.z = (float)BitConverter.ToDouble(data, 32 + 5 * 8);

                        break;

                    case RotationMode.ROTATION_MODE_QUATERNION:
                        quaternion.w = (float)BitConverter.ToDouble(data, 32 + 3 * 8);
                        quaternion.x = (float)BitConverter.ToDouble(data, 32 + 4 * 8);
                        quaternion.y = (float)BitConverter.ToDouble(data, 32 + 5 * 8);
                        quaternion.z = (float)BitConverter.ToDouble(data, 32 + 6 * 8);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                print(err.ToString());
            }
        }
    }
 public static ITween TweenLocalRotation(
     this Transform transform,
     Vector3 to,
     float duration,
     RotationMode mode
     )
 {
     return(Tween.To(
                () => transform.localRotation.eulerAngles,
                current => transform.localRotation = Quaternion.Euler(current),
                () => to,
                mode,
                duration,
                () => transform != null
                ));
 }
 public OutputDescription(string deviceName, int desktopCoordinatesLeft, int desktopCoordinatesTop, int desktopCoordinatesRight, int desktopCoordinatesBottom, bool isAttachedToDesktop, RotationMode rotation, IntPtr hMonitor)
 {
     Validate.IsNotNull <string>(deviceName, "deviceName");
     if (deviceName.Length >= 0x20)
     {
         ExceptionUtil.ThrowArgumentException("deviceName.Length must be less than 32", "deviceName");
     }
     this.deviceName               = deviceName;
     this.desktopCoordinatesLeft   = desktopCoordinatesLeft;
     this.desktopCoordinatesTop    = desktopCoordinatesTop;
     this.desktopCoordinatesRight  = desktopCoordinatesRight;
     this.desktopCoordinatesBottom = desktopCoordinatesBottom;
     this.isAttachedToDesktop      = isAttachedToDesktop;
     this.rotation = rotation;
     this.hMonitor = hMonitor;
 }
Beispiel #15
0
    public void UpdateRotation(Quaternion rot, RotationMode rotationMode)
    {
        switch (rotationMode)
        {
        case RotationMode.Set:
            Rotation = rot;

            break;

        case RotationMode.Multiply:
            Rotation *= rot;

            break;

        default: throw new ArgumentOutOfRangeException(nameof(rotationMode), rotationMode, null);
        }
    }
Beispiel #16
0
 public Vector3RotationTweener(
     Getter currValueGetter,
     Setter setter,
     Getter finalValueGetter,
     RotationMode rotationMode,
     float duration,
     Validation validation
     )
     : base(
         currValueGetter,
         setter,
         finalValueGetter,
         duration,
         new Vector3RotationInterpolator(rotationMode),
         validation
         )
 {
 }
Beispiel #17
0
        }//eom

        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = WindowWidth;
            graphics.PreferredBackBufferHeight = WindowHeight;
            graphics.ApplyChanges();
            //Setup Camera
            camTarget        = new Vector3(0f, 0f, 0f);
            camPosition      = new Vector3(-10f, 10f, -10f);
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
                MathHelper.ToRadians(45f),
                GraphicsDevice.DisplayMode.AspectRatio, 1f, 100f);
            viewMatrix   = Matrix.CreateLookAt(camPosition, camTarget, Vector3.Up);// Y up
            worldMatrix  = Matrix.CreateWorld(camTarget, Vector3.Forward, Vector3.Up);
            airplane     = new Airplane(Vector3.Zero, Matrix.Identity);
            gameState    = GameState.Initialize;
            rotationMode = RotationMode.Matrix;
            base.Initialize();
        }//eom
Beispiel #18
0
        /// <summary>
        /// Set rotation mode
        /// </summary>
        /// <param name="rm">Mode</param>
        public void SetRotaionMode(RotationMode rm)
        {
            switch (rm)
            {
            case RotationMode.snap:
                faceMe = false;
                useContinuousRotation = false;
                break;

            case RotationMode.facePlacer:
                useContinuousRotation = false;
                faceMe = true;
                break;

            case RotationMode.continuous:
                faceMe = false;
                useContinuousRotation = true;
                break;
            }
        }
        // -------------------
        public TouchJoystickSpriteAnimator() : base(typeof(TouchJoystick))
        {
            this.animateTransl = false;
            this.moveScale     = new Vector2(0.5f, 0.5f);

            this.rotationMode          = RotationMode.Disabled;
            this.rotationSmoothingTime = 0.01f;
            this.simpleRotationRange   = 45.0f;
            this.lastSafeCompassAngle  = 0;

            this.spriteNeutralPressed = new SpriteConfig(true, false, 1.2f);
            this.spriteUp             = new SpriteConfig(false, false, 1.2f);
            this.spriteUpRight        = new SpriteConfig(false, false, 1.2f);
            this.spriteRight          = new SpriteConfig(false, false, 1.2f);
            this.spriteDownRight      = new SpriteConfig(false, false, 1.2f);
            this.spriteDown           = new SpriteConfig(false, false, 1.2f);
            this.spriteDownLeft       = new SpriteConfig(false, false, 1.2f);
            this.spriteLeft           = new SpriteConfig(false, false, 1.2f);
            this.spriteUpLeft         = new SpriteConfig(false, false, 1.2f);
        }
    /// <summary>
    /// Checks if all the gears are putted up in the gear placements.
    /// </summary>
    /// <returns> Returns false if even one are being moved or isn't in place. </returns>
    private bool AllGearsPositioned()
    {
        if (currentGear_ >= 0)
        {
            return(false);
        }

        for (int i = 0; i < gears.Length; i++)
        {
            if (gears[i].origin.location != GearLocation.WorldPlacement || gears[i].destiny.location == GearLocation.SlotUI)
            {
                return(false);
            }
        }

        // If all is setted up, then change the balloon text and the rotation mode.
        balloon.text  = textCompleted;
        rotationMode_ = RotationMode.TaskCompleted;
        return(true);
    }
Beispiel #21
0
 public void SetItem(int x, int y, RotationMode rotationMode)
 {
     var jx = 0;
     var jy = 0;
     switch (rotationMode) {
         case RotationMode.Floor:
             jx = x;
             jy = y;
             break;
         case RotationMode.LeftWall:
             jx = y;
             jy = 15 - x;
             break;
         case RotationMode.Ceiling:
             jx = x;
             jy = 15 - y;
             break;
         case RotationMode.RightWall:
             jx = y;
             jy = x;
             break;
     }
     Items[jx] = 16 - jy;
 }
Beispiel #22
0
        private void Import(string xmlInfo, string glyphs)
        {
            Bitmap image = (Bitmap)Image.FromFile(glyphs);
            XDocument doc = XDocument.Load(xmlInfo);
            XElement root = doc.Element("NFTR");

            this.MagicStamp = "NFTR";
            this.VersionS   = root.Element("Version").Value;

            this.errorChar    = ushort.Parse(root.Element("ErrorChar").Value);
            this.lineGap      = byte.Parse(root.Element("LineGap").Value);
            this.boxWidth     = byte.Parse(root.Element("BoxWidth").Value);
            this.boxHeight    = byte.Parse(root.Element("BoxHeight").Value);
            this.glyphWidth   = byte.Parse(root.Element("GlyphWidth").Value);
            this.glyphHeight  = byte.Parse(root.Element("GlyphHeight").Value);
            this.depth        = byte.Parse(root.Element("Depth").Value);
            this.defaultWidth = GWidth.FromXml(root.Element("DefaultWidth"));
            this.rotation     = (RotationMode)Enum.Parse(typeof(RotationMode), root.Element("Rotation").Value);
            this.encoding     = (EncodingMode)Enum.Parse(typeof(EncodingMode), root.Element("Encoding").Value);

            // Gets Width regions
            XElement xwidths = root.Element("Widths");
            Cwdh.WidthRegion[] widthRegs = new Cwdh.WidthRegion[xwidths.Elements("Region").Count()];

                // ... gets the data from the xml
            foreach (XElement xreg in xwidths.Elements("Region")) {
                int id = int.Parse(xreg.Element("Id").Value);

                widthRegs[id] = new Cwdh.WidthRegion(this.defaultWidth);
                widthRegs[id].Id = id;
                widthRegs[id].FirstChar = Convert.ToUInt16(xreg.Element("FirstChar").Value, 16);
                widthRegs[id].LastChar  = Convert.ToUInt16(xreg.Element("LastChar").Value,  16);
            }

                // ... assign the next region
            for (int i = 0; i < widthRegs.Length; i++) {
                if (i + 1 == widthRegs.Length)
                    widthRegs[i].NextRegion = null;
                else
                    widthRegs[i].NextRegion = widthRegs[i + 1];
            }

            // Gets Cmap regions
            XElement xcmaps = root.Element("Maps");
            this.cmaps = new Cmap[xcmaps.Elements("Map").Count()];

            foreach (XElement xmap in xcmaps.Elements("Map")) {
                int id = int.Parse(xmap.Element("Id").Value);

                this.cmaps[id] = new Cmap(this);
                this.cmaps[id].Id = id;
                this.cmaps[id].Type      = Convert.ToUInt32(xmap.Element("Type").Value);
                this.cmaps[id].FirstChar = Convert.ToUInt16(xmap.Element("FirstChar").Value, 16);
                this.cmaps[id].LastChar  = Convert.ToUInt16(xmap.Element("LastChar").Value,  16);
            }

            // Gets Glyphs
            XElement xglyphs = root.Element("Glyphs");
            this.glyphs = new List<Glyph>(xglyphs.Elements("Glyph").Count());
            for (int i = 0; i < xglyphs.Elements("Glyph").Count(); i++)
                this.glyphs.Add(new Glyph());

            // Reversing the glyphs, there are more probability to have high char codes first
            // ... so there will be less array resizing in InsertWidth and InsertChar
            foreach (XElement xglyph in xglyphs.Elements("Glyph").Reverse()) {
                int id = int.Parse(xglyph.Element("Id").Value);

                Glyph g = new Glyph();
                g.Id       = id;
                g.Width    = GWidth.FromXml(xglyph.Element("Width"));
                g.Image    = this.CharFromMap(image, id);
                g.IdMap    = int.Parse(xglyph.Element("IdMap").Value);
                g.CharCode = Convert.ToUInt16(xglyph.Element("Code").Value, 16);

                this.glyphs[id] = g;
                if (g.Width.IdRegion >= 0)
                    widthRegs[g.Width.IdRegion].InsertWidth(g.CharCode, g.Width, g.Id);
                this.cmaps[g.IdMap].InsertCharCode(g.Id, g.CharCode);
            }

            this.CreateStructure(widthRegs[0]);
        }
Beispiel #23
0
        public static void DrawItemProperty(TSSItem item, string propertyName, string displayPropertyName = null, GUILayoutOption displayPropertyOption = null, bool shortCheckBox = false, bool alternative = false)
        {
            GUI.color           = Color.white;
            GUI.backgroundColor = Color.white;

            if (!ItemPropertyIsValid(propertyName))
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox(string.Format(invalidPropertyName.text, propertyName), MessageType.Warning);
                EditorGUILayout.EndHorizontal();
                return;
            }

            if (string.IsNullOrEmpty(displayPropertyName))
            {
                displayPropertyName = propertyName;
            }
            if (displayPropertyOption == null)
            {
                displayPropertyOption = TSSEditorUtils.max100pxWidth;
            }

            Type propertyType = GetItemPropertyType(propertyName);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(TSSText.GetHumanReadableString(displayPropertyName), displayPropertyOption);

            if (propertyType == typeof(float))
            {
                float displayedValue      = GetItemValue <float>(item, propertyName);
                bool  itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <float>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                float enteredValue = Mathf.Clamp(EditorGUILayout.FloatField(displayedValue), 0, float.MaxValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(bool))
            {
                bool displayedValue      = GetItemValue <bool>(item, propertyName);
                bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <bool>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                bool enteredValue = EditorGUILayout.Toggle(displayedValue, shortCheckBox ? TSSEditorUtils.max18pxWidth : TSSEditorUtils.max120pxWidth);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(string))
            {
                string displayedValue      = GetItemValue <string>(item, propertyName);
                bool   itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <string>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                string enteredValue = EditorGUILayout.TextField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(int))
            {
                int  displayedValue      = GetItemValue <int>(item, propertyName);
                bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <int>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                int enteredValue = EditorGUILayout.IntField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(ChainDirection))
            {
                ChainDirection displayedValue      = GetItemValue <ChainDirection>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ChainDirection>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ChainDirection enteredValue = (ChainDirection)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(RotationMode))
            {
                RotationMode displayedValue      = GetItemValue <RotationMode>(item, propertyName);
                bool         itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <RotationMode>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                RotationMode enteredValue = (RotationMode)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(MaterialMode))
            {
                MaterialMode displayedValue      = GetItemValue <MaterialMode>(item, propertyName);
                bool         itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <MaterialMode>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                MaterialMode enteredValue = (MaterialMode)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(AnimationCurve))
            {
                AnimationCurve displayedValue      = GetItemValue <AnimationCurve>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <AnimationCurve>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                AnimationCurve enteredValue = (AnimationCurve)EditorGUILayout.CurveField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(TSSProfile))
            {
                TSSProfile displayedValue      = GetItemValue <TSSProfile>(item, propertyName);
                bool       itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <TSSProfile>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                TSSProfile enteredValue = (TSSProfile)EditorGUILayout.ObjectField(displayedValue, typeof(TSSProfile), false);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                    if (enteredValue != null && EditorUtility.DisplayDialog(confirmRevertTitle.text, string.Format(confirmRevertMessage.text, item.profile.name), "Yes", "No"))
                    {
                        TSSProfile.ProfileRevert(item, item.profile);
                    }
                }
            }
            else if (propertyType == typeof(ActivationMode))
            {
                if (alternative)
                {
                    ItemLoopModePattern displayedValue = ActivationModeToLoopPattern(GetItemValue <ActivationMode>(item, propertyName));
                    bool itemValuesIdentical           = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName));
                    if (!itemValuesIdentical)
                    {
                        EditorGUI.showMixedValue = true;
                    }
                    ItemLoopModePattern enteredValue = (ItemLoopModePattern)EditorGUILayout.EnumPopup(displayedValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        SelectedItemsSetValue(propertyName, LoopPatternToActivationMode(enteredValue));
                    }
                }
                else
                {
                    ActivationMode displayedValue      = GetItemValue <ActivationMode>(item, propertyName);
                    bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName));
                    if (!itemValuesIdentical)
                    {
                        EditorGUI.showMixedValue = true;
                    }
                    ActivationMode enteredValue = (ActivationMode)EditorGUILayout.EnumPopup(displayedValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        SelectedItemsSetValue(propertyName, enteredValue);
                    }
                }
            }
            else if (propertyType == typeof(ButtonDirection))
            {
                ButtonDirection displayedValue      = GetItemValue <ButtonDirection>(item, propertyName);
                bool            itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ButtonDirection>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ButtonDirection enteredValue = (ButtonDirection)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(ItemUpdateType))
            {
                ItemUpdateType displayedValue      = GetItemValue <ItemUpdateType>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ItemUpdateType>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ItemUpdateType enteredValue = (ItemUpdateType)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(PathNormal))
            {
                PathNormal displayedValue      = GetItemValue <PathNormal>(item, propertyName);
                bool       itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <PathNormal>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                PathNormal enteredValue = (PathNormal)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }


            EditorGUILayout.EndHorizontal();

            EditorGUI.showMixedValue = false;
        }
 private static extern void WearableListenForRotationData(bool isEnabled, RotationMode mode);
Beispiel #25
0
        protected override void Read(Stream strIn, int size)
        {
            base.Read(strIn, size);

            this.finf  = this.Blocks.GetByType<Finf>(0);
            this.cglp  = this.Blocks.GetByType<Cglp>(0);
            this.cwdh  = this.Blocks.GetByType<Cwdh>(0);
            this.cmaps = this.Blocks.GetByType<Cmap>().ToArray();

            this.errorChar    = this.finf.ErrorCharIndex;
            this.encoding     = this.finf.Encoding;
            this.lineGap      = this.finf.LineGap;
            this.defaultWidth = this.finf.DefaultWidth;
            this.glyphHeight  = this.cglp.GlyphHeight;
            this.glyphWidth   = this.cglp.GlyphWidth;
            this.boxWidth     = this.cglp.BoxWidth;
            this.boxHeight    = this.cglp.BoxHeight;
            this.depth        = this.cglp.Depth;
            this.rotation     = (RotationMode)this.cglp.Rotation;

            // Get glyphs info
            this.glyphs = new List<Glyph>();
            for (int i = 0, idx = 0; i < this.cglp.NumGlyphs; i++) {
                int idMap;
                ushort charCode = this.SearchCharByImage(i, out idMap);
                if (idMap == -1) {
                    this.cglp.GetGlyphImage(i).Save("Unvalid char " + i.ToString() + ".png");
                    continue;
                }

                Glyph g = new Glyph();
                g.Id       = idx++;
                g.Image    = this.cglp.GetGlyph(i);
                g.Width    = this.cwdh.GetWidth(charCode, g.Id);
                g.CharCode = charCode;
                g.IdMap    = idMap;

                this.glyphs.Add(g);
            }

            #if DEBUG
            this.PrintInfo();
            #endif
        }
Beispiel #26
0
 public GameObject(Texture2D texture, Vector2 position, Vector2 velocity, RotationMode mode)
 {
     Texture = texture;
     _center = position;
     Velocity = velocity;
     TexturePosition = new Vector2(Center.X - Texture.Width / 2, Center.Y - Texture.Height / 2);
     Hitbox = texture.Bounds;
     Hitbox.Offset(TexturePosition);
     RotationCenter = new Vector2(Texture.Width / 2, Texture.Height / 2);
     Rotation = new Vector2(0, -1);
 }
Beispiel #27
0
        private SensorM GetBestSensor(SensorM sensor1, SensorM sensor2, RotationMode mode)
        {
            if (sensor1 == null && sensor2 == null) return null;

            if (sensor1 == null) return sensor2;
            if (sensor2 == null) return sensor1;

            switch (mode) {
                case RotationMode.Floor:
                    return sensor1.Value < sensor2.Value ? sensor1 : sensor2;
                case RotationMode.LeftWall:
                    return sensor1.Value > sensor2.Value ? sensor1 : sensor2;
                case RotationMode.Ceiling:
                    return sensor1.Value > sensor2.Value ? sensor1 : sensor2;
                case RotationMode.RightWall:
                    return sensor1.Value < sensor2.Value ? sensor1 : sensor2;
            }
            return null;
        }
Beispiel #28
0
 public Vector3RotationInterpolator(RotationMode rotationMode)
 {
     this.rotationMode = rotationMode;
 }
 public override void Init()
 {
     rotationMode = (RotationMode)EditorPrefs.GetInt(RotationModePrefs, (int)DefaultRotationMode);
 }
Beispiel #30
0
        private void AvoidGimic()
        {
            if (target_ == null)
            {
                return;
            }

            if (wait_time_ > 0f)
            {
                wait_time_ -= Time.deltaTime;
            }

            float new_rotation_x = CalculateRotation();

            // 新しい回転と位置でraycastする
            Ray     ray     = new Ray();
            Vector3 forward = Quaternion.Euler(new_rotation_x, 0f, 0f) * Vector3.forward;

            ray.origin    = target_position_ + kOffset + forward * -1f * kDistance;
            ray.direction = forward;
            Debug.DrawLine(ray.origin, ray.origin + ray.direction * kDistance, Color.yellow);
            if (Physics.Raycast(ray, kDistance, default_layer_))
            {// 当たった場合
                print("hit new");
                switch (rotation_mode_)
                {
                case RotationMode.kWait:
                {        // 待ち状態なら上昇
                    rotation_mode_ = RotationMode.kRaise;
                    break;
                }

                case RotationMode.kRaise:
                {        // 上昇状態なら何もしない
                    break;
                }

                case RotationMode.kFall:
                {        // 降下状態なら止まる
                         // そして新しい回転をなしにする
                    wait_time_     = kWaitTime;
                    rotation_mode_ = RotationMode.kWait;
                    new_rotation_x = transform.rotation.eulerAngles.x;
                    break;
                }
                }
            }
            else
            {// 当たってない場合
                switch (rotation_mode_)
                {
                case RotationMode.kWait:
                {        // 待ち状態なら降下状態にする
                    if (wait_time_ <= 0f)
                    {
                        rotation_mode_ = RotationMode.kFall;
                    }
                    break;
                }

                case RotationMode.kRaise:
                {        // 上昇状態なら止まる
                    wait_time_     = kWaitTime;
                    rotation_mode_ = RotationMode.kWait;
                    break;
                }

                case RotationMode.kFall:
                {        // 降下状態なら何もしない
                    break;
                }
                }
            }

            new_rotation_x     = Mathf.Lerp(transform.rotation.eulerAngles.x, new_rotation_x, 0.5f);
            transform.rotation = Quaternion.Euler(new_rotation_x, 0f, 0f);
        }
Beispiel #31
0
    void Update()
    {
        //锁定光标时
        if (Cursor.lockState == CursorLockMode.Locked)
        {
            if (Input.GetKeyUp(KeyCode.LeftAlt))
            {
                m_Axes = RotationMode.MouseY;
            }
            if (Input.GetKey(KeyCode.LeftAlt))
            {
                if (m_Axes != RotationMode.MouseXAndY)
                {
                    m_Axes = RotationMode.MouseXAndY; m_RotationX = 0f;
                }
            }
            else
            {
                //恢复视角
                if (transform.localEulerAngles.y > 0 & transform.localEulerAngles.y <= 180)
                {
                    transform.localEulerAngles = Vector3.SmoothDamp(transform.localEulerAngles, Vector3.zero, ref m_Velocity, 0.2f);
                }
                else if (transform.localEulerAngles.y > 180)
                {
                    Vector3 temp_01 = new Vector3(transform.localEulerAngles.x, 360f - transform.localEulerAngles.y, 0);
                    Vector3 temp_02 = Vector3.SmoothDamp(temp_01, Vector3.zero, ref m_Velocity, 0.2f);
                    transform.localEulerAngles = new Vector3(temp_02.x, 360f - temp_02.y, 0);
                }
            }

            //旋转XY轴
            if (m_Axes == RotationMode.MouseXAndY)
            {
                //实时同步跟随的目标位置
                transform.position = m_Target.position + m_Target.up * m_TargetDistanceZ + -m_Target.right * m_TargetDistanceY;
                //检测XY轴视角旋转
                m_RotationX += Input.GetAxis("Mouse X") * m_SensitivityX;
                m_RotationX  = Mathf.Clamp(m_RotationX, m_MinimumX, m_MaximumX);
                m_RotationY += Input.GetAxis("Mouse Y") * m_SensitivityY;
                m_RotationY  = Mathf.Clamp(m_RotationY, m_MinimumY, m_MaximumY);
                transform.localEulerAngles = new Vector3(-m_RotationY, m_RotationX, 0);
            }
            //旋转X轴
            else if (m_Axes == RotationMode.MouseX)
            {
                //检测X轴视角旋转
                transform.Rotate(0, Input.GetAxis("Mouse X") * m_SensitivityX, 0);
            }
            //旋转Y轴
            else
            {
                //实时同步跟随的目标位置
                transform.position = m_Target.position + m_Target.up * m_TargetDistanceZ + -m_Target.right * m_TargetDistanceY;
                //检测Y轴视角旋转
                m_RotationY += Input.GetAxis("Mouse Y") * m_SensitivityY;
                m_RotationY  = Mathf.Clamp(m_RotationY, m_MinimumY, m_MaximumY);
                transform.localEulerAngles = new Vector3(-m_RotationY, transform.localEulerAngles.y, 0);
            }
        }
    }
 public static ITween TweenRotationX(this Transform transform, float to, float duration, RotationMode mode)
 {
     return(Tween.To(
                () => transform.rotation.eulerAngles.x,
                current => transform.rotation = Quaternion.Euler(current, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z),
                () => to,
                duration,
                () => transform != null
                ));
 }
    private IEnumerator Reseting()
    {
        // Prevents from executing while there's something moving
        yield return(new WaitWhile(() => lock_));

        List <int> freeSlots = new List <int>();

        // Check if it's viable to reset
        bool canReset = false;

        for (int i = 0; i < gears.Length; i++)
        {
            freeSlots.Add(i);

            if (gears[i].origin.location == GearLocation.WorldPlacement)
            {
                canReset = true;
            }
        }

        // If it isn't, just leave, but, otherwise, if it indeed is, then lock the inputs while resetting
        if (!canReset)
        {
            yield break;
        }
        lock_ = true;

        // Check if the gears are rotating and, if they do, then revert the rotation before resetting the position
        if (rotationMode_ != RotationMode.None)
        {
            rotationMode_ = RotationMode.BackToDefault;
            SetRotationTimer();

            for (int i = 0; i < gears.Length; i++)
            {
                gears[i].currentRotation = gears[i].world.transform.rotation;
            }

            yield return(new WaitUntil(() => rotationMode_ == RotationMode.None));

            yield return(new WaitForSeconds(completedToResetWaitTime));
        }

        // Get the free slots and the gears on the world
        List <int> placedGears = new List <int>();

        for (int i = 0; i < gears.Length; i++)
        {
            if (gears[i].origin.location == GearLocation.SlotUI)
            {
                freeSlots.Remove(gears[i].origin.index);
            }
            else
            {
                placedGears.Add(i);
            }
        }

        // Puts each world gear in a random free slot
        do
        {
            int g = placedGears[Random.Range(0, placedGears.Count)];

            gears[g].destiny.location = GearLocation.SlotUI;
            gears[g].destiny.index    = freeSlots[Random.Range(0, freeSlots.Count)];

            placedGears.Remove(g);
            freeSlots.Remove(gears[g].destiny.index);

            gears[g].StartScaling(GearLocation.SlotUI);
            gears[g].StartMoving();

            gears[g].VisibleGear(true);
        } while (freeSlots.Count > 0);

        // Revert the balloon text to its default
        balloon.text = textDefault;

        yield break;
    }
    // Only world gears can be rotated
    private void Rotate()
    {
        // Checks in which rotation mode the game currently is
        switch (rotationMode_)
        {
        // Case: No rotation mode, just leave
        case RotationMode.None:
            return;

        // Case: Task completed mode, then rotate indefinitely on a constant speed
        case RotationMode.TaskCompleted:

            // Verifies if all gears are still in place, if they are, then keep spinning, else, change to reverse rotation mode and sets the rotation timer
            if (AllGearsPositioned())
            {
                for (int i = 0; i < gears.Length; i++)
                {
                    Transform gear = gears[i].world.transform;

                    Vector3 eulers = gear.rotation.eulerAngles;
                    eulers.z += (gears[i].origin.index % 2 == 0f ? -constantRotationSpeed : constantRotationSpeed) * Time.deltaTime;

                    gear.rotation = new Quaternion()
                    {
                        eulerAngles = eulers
                    };
                }
            }
            else
            {
                for (int i = 0; i < gears.Length; i++)
                {
                    gears[i].currentRotation = gears[i].world.transform.rotation;
                }

                rotationMode_ = RotationMode.BackToDefault;
                SetRotationTimer();
            }
            break;

        // Case: Reverse rotation mode, then get gears rotation back to default on the smooth rotation time
        case RotationMode.BackToDefault:

            // Decrements rotation timer
            timer_.rotation -= Time.deltaTime;

            // If rotation timer has run out, sets all gears to the default rotation
            if (timer_.rotation <= 0f)
            {
                timer_.rotation = 0f;

                for (int i = 0; i < gears.Length; i++)
                {
                    gears[i].world.transform.rotation = worldGearsRotation_;
                }

                rotationMode_ = RotationMode.None;
            }
            else
            {
                // Gets the percentage to use on Lerp
                float percentage = Mathf.InverseLerp(smoothTimer.rotation, 0f, timer_.rotation);

                // Get new euler angles using the Lerp and set a new rotation using them
                for (int i = 0; i < gears.Length; i++)
                {
                    Vector3 eulers = Vector3.Lerp(gears[i].currentRotation.eulerAngles, worldGearsRotation_.eulerAngles, percentage);

                    gears[i].world.transform.rotation = new Quaternion()
                    {
                        eulerAngles = eulers
                    };
                }
            }
            break;
        }
    }
Beispiel #35
0
        public override void WriteXml(XmlWriter writer)
        {
            base.WriteXml(writer);
            writer.WriteElementString("RotationMode", RotationMode.ToString());
            writer.WriteElementString("LoopMode", LoopMode.ToString());
            writer.WriteStartElement("BlendMode");

            if (BlendMode == BlendState.Additive)
            {
                writer.WriteValue("ADDITIVE");
            }
            else if (BlendMode == BlendState.AlphaBlend)
            {
                writer.WriteValue("ALPHA");
            }
            else if (BlendMode == BlendState.NonPremultiplied)
            {
                writer.WriteValue("ALPHANP");
            }
            else if (BlendMode == BlendState.Opaque)
            {
                writer.WriteValue("OPAQUE");
            }
            else
            {
                throw new InvalidOperationException("ParticleSystem: Unrecognized BlendMode");
            }

            writer.WriteEndElement();

            WriteVector3(writer, Offset, "Offset");
            WriteVector3(writer, RandAngle, "RandAngle");
            WriteVector3(writer, Wind, "Wind");
            WriteVector3(writer, WindVariation, "WindVariation");
            WriteVector3(writer, PositionOffset, "PositionOffset");
            WriteVector3(writer, PositionOffsetVariation, "PositionOffsetVariation");
            WriteVector3(writer, ParticleRotation, "ParticleRotation");
            WriteVector3(writer, ParticleRotationVariation, "ParticleRotationVariation");
            WriteVector3(writer, ParticleColor, "ParticleColor");
            WriteVector3(writer, ParticleColorVariation, "ParticleColorVariation");
            WriteVector2(writer, ParticleSize, "ParticleSize");
            WriteVector2(writer, ParticleSizeVariation, "ParticleSizeVariation");

            writer.WriteStartElement("Textures");
            foreach (Texture2D texture in Textures)
            {
                writer.WriteElementString("TexturePath", ResourceManager.Instance.Textures.FirstOrDefault(x => x.Value == texture).Key);
            }
            writer.WriteEndElement();

            writer.WriteElementString("LifeSpanSec", XmlConvert.ToString(LifespanSec));
            writer.WriteElementString("LifeSpanSecVariation", XmlConvert.ToString(LifespanSecVariation));
            writer.WriteElementString("FadeInTime", XmlConvert.ToString(FadeInTime));
            writer.WriteElementString("FadeInTimeVariation", XmlConvert.ToString(FadeInTimeVariation));
            writer.WriteElementString("FadeOutTime", XmlConvert.ToString(FadeOutTime));
            writer.WriteElementString("FadeOutTimeVariation", XmlConvert.ToString(FadeOutTime));
            writer.WriteElementString("Speed", XmlConvert.ToString(Speed));
            writer.WriteElementString("SpeedVariation", XmlConvert.ToString(SpeedVariation));
            writer.WriteElementString("DelayMs", XmlConvert.ToString(DelayMs));
            writer.WriteElementString("DelayMsVariation", XmlConvert.ToString(DelayMsVariation));
            writer.WriteElementString("Mass", XmlConvert.ToString(Mass));
            writer.WriteElementString("MassVariation", XmlConvert.ToString(MassVariation));
            writer.WriteElementString("ParticleCount", XmlConvert.ToString(ParticleCount));
            writer.WriteElementString("IgnoreScale", XmlConvert.ToString(IgnoreScale));
            writer.WriteElementString("Stopped", XmlConvert.ToString(Stopped));
            writer.WriteElementString("UseGravity", XmlConvert.ToString(UseGravity));
        }
 public static ITween TweenLocalRotationZ(this Transform transform, float to, float duration, RotationMode mode)
 {
     return(Tween.To(
                () => transform.localRotation.eulerAngles.z,
                current => transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, current),
                () => to,
                duration,
                () => transform != null
                ));
 }