// --------------------
        override protected void OnCreatePressed(bool selectAfterwards)
        {
            ControlFreak2.TouchSteeringWheel newObj = (ControlFreak2.TouchSteeringWheel) this.CreateDynamicTouchControl(typeof(ControlFreak2.TouchSteeringWheel));

            newObj.wheelMode = TouchSteeringWheel.WheelMode.Turn;
            newObj.analogConfig.analogDeadZone = 0;
            newObj.centerOnDirectTouch         = false;
            newObj.centerWhenFollowing         = false;
            newObj.centerOnIndirectTouch       = false;

            newObj.pressBinding.CopyFrom(this.pressBinding);
            newObj.touchPressureBinding.CopyFrom(this.touchPressureBinding);

            if (this.touchPressureBinding.enabled)
            {
                newObj.emulateTouchPressure = this.emulateTouchPressure;
            }

            newObj.analogTurnBinding.CopyFrom(this.turnBinding);
            newObj.turnRightBinding.CopyFrom(this.turnRightBinding);
            newObj.turnLeftBinding.CopyFrom(this.turnLeftBinding);

            TouchControlWizardUtils.CreateWheelAnimator(newObj, "-Sprite", this.defaultSprite, 1.0f);

            Undo.RegisterCreatedObjectUndo(newObj.gameObject, "Create CF2 Wheel");

            if (selectAfterwards)
            {
                Selection.activeObject = newObj;
            }
        }
Ejemplo n.º 2
0
        // --------------------
        override protected void OnCreatePressed(bool selectAfterwards)
        {
            ControlFreak2.TouchSteeringWheel newObj = (ControlFreak2.TouchSteeringWheel) this.CreateDynamicTouchControl(typeof(ControlFreak2.TouchSteeringWheel));


            newObj.pressBinding.CopyFrom(this.pressBinding);
            newObj.analogTurnBinding.CopyFrom(this.turnBinding);
            newObj.turnRightBinding.CopyFrom(this.turnRightBinding);
            newObj.turnLeftBinding.CopyFrom(this.turnLeftBinding);

            TouchControlWizardUtils.CreateWheelAnimator(newObj, "-Sprite", this.defaultSprite, 1.0f);

            Undo.RegisterCreatedObjectUndo(newObj.gameObject, "Create CF2 Wheel");

            if (selectAfterwards)
            {
                Selection.activeObject = newObj;
            }
        }
Ejemplo n.º 3
0
        // ----------------------
        override protected void OnUpdateAnimator(bool skipAnim)
        {
            if ((this.sourceControl == null) || (this.image == null))
            {
                return;
            }

            TouchSteeringWheel wheel = (TouchSteeringWheel)this.sourceControl;


            SpriteConfig sprite = null;

            if (wheel.Pressed() && ((sprite == null) || !sprite.enabled))
            {
                sprite = this.spritePressed;
            }

            if (((sprite == null) || !sprite.enabled))
            {
                sprite = this.spriteNeutral;
            }



            if (!CFUtils.editorStopped && !this.IsIllegallyAttachedToSource())
            {
                this.extraRotation = CFUtils.SmoothTowardsAngle(this.extraRotation, -(wheel.GetValue() *
                                                                                      ((wheel.wheelMode == TouchSteeringWheel.WheelMode.Swipe) ? this.rotationRange : wheel.maxTurnAngle)),
                                                                this.rotationSmoothingTime, CFUtils.realDeltaTimeClamped, 0.001f);
            }
            else
            {
                this.extraRotation = 0;
            }


            this.BeginSpriteAnim(sprite, skipAnim);

            this.UpdateSpriteAnimation(skipAnim);
        }