Ejemplo n.º 1
0
        // --------------------
        override protected void OnCreatePressed(bool selectAfterwards)
        {
            TouchJoystick newObj = (TouchJoystick)this.CreateDynamicTouchControl(typeof(ControlFreak2.TouchJoystick));


            newObj.stickyMode = true;

            newObj.pressBinding.CopyFrom(this.pressBinding);
            //newObj.joyNameBinding.CopyFrom(this.joyNameBinding);
            newObj.joyStateBinding.horzAxisBinding.CopyFrom(this.horzAxisBinding);
            newObj.joyStateBinding.vertAxisBinding.CopyFrom(this.vertAxisBinding);


            if (this.animatorStyle == AnimatorStyle.Simple)
            {
                TouchControlWizardUtils.CreateTouchJoystickSimpleAnimator(newObj, "-Sprite", this.defaultSprite, 1.0f, 0.0f);
            }
            else
            {
                TouchControlWizardUtils.CreateTouchJoystickAnalogAnimators(newObj, this.baseSprite, this.hatSprite, this.hatScale);
            }


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

            if (selectAfterwards)
            {
                Selection.activeObject = newObj;
            }
        }
Ejemplo n.º 2
0
        // -------------------
        static public TouchJoystickSpriteAnimator CreateTouchJoystickSimpleAnimator(
            TouchJoystick target,
            string nameSuffix,
            Sprite sprite,
            float scale,
            float moveScale,
            string undoLabel = null)
        {
            RectTransform subObj = CreateSubRectTr(target.transform, target.name + nameSuffix, scale);

            // Setup sprite animator...

            TouchJoystickSpriteAnimator sprAnimator = subObj.gameObject.AddComponent <TouchJoystickSpriteAnimator>();

            sprAnimator.autoConnectToSource = true;
            sprAnimator.SetSourceControl(target);

            sprAnimator.animateTransl = (moveScale > 0.0001f);
            sprAnimator.moveScale     = Vector2.one * moveScale;

            sprAnimator.spriteNeutralPressed.enabled = true;

            sprAnimator.SetStateSprite(TouchJoystickSpriteAnimator.ControlState.Neutral, sprite);

            SetImagePreserveAspectRatio(subObj.gameObject, true);



            if (undoLabel != null)
            {
                Undo.RegisterCreatedObjectUndo(subObj.gameObject, undoLabel);
            }

            return(sprAnimator);
        }
Ejemplo n.º 3
0
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchJoystick c = (TouchJoystick)this.target;

            this.DrawWarnings(c);

            // Joystick GUI...


            GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerJoystick, GUILayout.ExpandWidth(true));

            // Steering Wheel specific inspector....

            InspectorUtils.BeginIndentedSection(new GUIContent("Joystick Settings"));

            this.joyConfigInsp.DrawGUI(c.config);

            InspectorUtils.EndIndentedSection();


            InspectorUtils.BeginIndentedSection(new GUIContent("Joystick Bindings"));


            this.pressBindingInsp.Draw(c.pressBinding, c.rig);

            this.joyStateBindingInsp.Draw(c.joyStateBinding, c.rig);

            InspectorUtils.EndIndentedSection();



            // Draw Shared Dynamic Control Params...

            this.DrawDynamicTouchControlGUI(c);
        }
Ejemplo n.º 4
0
 // -------------------
 static public void CreateTouchJoystickAnalogAnimators(
     TouchJoystick joystick,
     Sprite baseSprite,
     Sprite hatSprite,
     float hatScale)
 {
     CreateTouchJoystickSimpleAnimator(joystick, "-Base", baseSprite, 1, 0);
     CreateTouchJoystickSimpleAnimator(joystick, "-Hat", hatSprite, hatScale, 0.5f);
 }
        // ---------------
        public override void OnInspectorGUI()
        {
            TouchJoystick c = (TouchJoystick)this.target;

            this.emulateTouchPressure = c.emulateTouchPressure;

            this.DrawWarnings(c);

            // Joystick GUI...


            GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerJoystick, GUILayout.ExpandWidth(true));

            // Steering Wheel specific inspector....

            InspectorUtils.BeginIndentedSection(new GUIContent("Joystick Settings"));

            this.joyConfigInsp.DrawGUI(c.config);

            InspectorUtils.EndIndentedSection();


            InspectorUtils.BeginIndentedSection(new GUIContent("Joystick Bindings"));


            this.pressBindingInsp.Draw(c.pressBinding, c.rig);
            this.touchPressureBindingInsp.Draw(c.touchPressureBinding, c.rig);

            this.joyStateBindingInsp.Draw(c.joyStateBinding, c.rig);

            InspectorUtils.EndIndentedSection();


            // Register Undo...

            if ((this.emulateTouchPressure != c.emulateTouchPressure))
            {
                CFGUI.CreateUndo("Dynamic Touch Control modification.", c);

                c.emulateTouchPressure = this.emulateTouchPressure;

                CFGUI.EndUndo(c);
            }


            // Draw Shared Dynamic Control Params...

            this.DrawDynamicTouchControlGUI(c);
        }
Ejemplo n.º 6
0
 void Start()
 {
     gamePlay = FindObjectOfType <GamePlay>();
     rb2D     = GetComponent <Rigidbody2D>();
     joystick = FindObjectOfType <TouchJoystick>();
 }