示例#1
0
    void Start()
    {
        m_ETCTouchPad   = gameObject.GetComponent <ETCTouchPad>();
        m_FPSController = GameObject.Find("FPSController").GetComponent <FirstPersonController>();

        m_ETCTouchPad.onMove.AddListener(OnMove);
        m_ETCTouchPad.onMoveEnd.AddListener(OnMoveEnd);
    }
示例#2
0
	public static ETCTouchPad GetControlTouchPad(string ctrlName){
		if (ETCInput.instance.controls.TryGetValue( ctrlName, out control)){
			if (control.GetType() == typeof(ETCTouchPad)){
				ETCTouchPad tmpctrl = (ETCTouchPad)control;
				return tmpctrl;
			}
		}
		
		return null;
	}
示例#3
0
    private void InitOject()
    {
        index   = JsonPlayerData.Instance.GetDataIndex();
        control = JsonPlayerData.Instance.GetDataControl();

        etcJoystick = GameObject.Find("Joystick").GetComponent <ETCJoystick>();
        etcTouchPad = GameObject.Find("TouchPad").GetComponent <ETCTouchPad>();


        button_Attack = GameObject.Find("Attack").GetComponent <ETCButton>();
        button_Parse  = GameObject.Find("GamingParseButton").GetComponent <Button>();

        starText = GameObject.Find("StarNumText").GetComponent <Text>();

        button_Parse.onClick.AddListener(UIStateController.Instance.ParseState);

        button_Attack.onDown.AddListener(PlayerController.Instance.PlayerAttack);
        button_Attack.onUp.AddListener(PlayerController.Instance.PlayerAttackEnd);


        etcJoystick.onMoveSpeed.AddListener(PlayerController.Instance.PlayerMove);
        etcTouchPad.onMoveSpeed.AddListener(PlayerController.Instance.PlayerMove);

        if (control == "0")
        {
            etcJoystick.gameObject.SetActive(false);
        }
        else
        {
            etcTouchPad.gameObject.SetActive(false);
        }

        string path = "Player/ship_" + index;

        PlayerController.Instance.InitPlayer(path);
    }
示例#4
0
 // Use this for initialization
 void Start()
 {
     touchPad = ETCInput.GetControlTouchPad("MainTouchPad");
 }
    public override void OnInspectorGUI()
    {
        ETCTouchPad t = (ETCTouchPad)target;

        EditorGUILayout.Space();

        t.gameObject.name = EditorGUILayout.TextField("TouchPad name", t.gameObject.name);

        t.activated = ETCGuiTools.Toggle("Activated", t.activated, true);
        t.visible   = ETCGuiTools.Toggle("Visible at runtime", t.visible, true);

        EditorGUILayout.Space();
        t.useFixedUpdate        = ETCGuiTools.Toggle("Use Fixed Updae", t.useFixedUpdate, true);
        t.isUnregisterAtDisable = ETCGuiTools.Toggle("Unregister at disabling time", t.isUnregisterAtDisable, true);

        #region Position & Size

        t.showPSInspector = ETCGuiTools.BeginFoldOut("Position & Size", t.showPSInspector);
        if (t.showPSInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                // Anchor
                t.anchor = (ETCBase.RectAnchor)EditorGUILayout.EnumPopup("Anchor", t.anchor);
                if (t.anchor != ETCBase.RectAnchor.UserDefined)
                {
                    t.anchorOffet = EditorGUILayout.Vector2Field("Offset", t.anchorOffet);
                }

                EditorGUILayout.Space();

                // Size
                float width = EditorGUILayout.FloatField("Width", t.rectTransform().rect.width);
                t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);

                float height = EditorGUILayout.FloatField("Height", t.rectTransform().rect.height);
                t.rectTransform().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
            }
            ETCGuiTools.EndGroup();
        }

        #endregion Position & Size

        #region Behaviour & axes

        t.showBehaviourInspector = ETCGuiTools.BeginFoldOut("Axes", t.showBehaviourInspector);
        if (t.showBehaviourInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                EditorGUILayout.Space();
                t.enableKeySimulation = ETCGuiTools.Toggle("Enable key simulation", t.enableKeySimulation, true);
                if (t.enableKeySimulation)
                {
                    t.allowSimulationStandalone = ETCGuiTools.Toggle("Allow simulation on standalone", t.allowSimulationStandalone, true);
                }
                EditorGUILayout.Space();

                t.isDPI      = ETCGuiTools.Toggle("DPI", t.isDPI, true);
                t.isSwipeIn  = ETCGuiTools.Toggle("Swipe in", t.isSwipeIn, true);
                t.isSwipeOut = ETCGuiTools.Toggle("Swipe out", t.isSwipeOut, true);

                EditorGUILayout.Space();

                ETCGuiTools.BeginGroup(5);
                {
                    ETCAxisInspector.AxisInspector(t.axisX, "Horizontal", ETCBase.ControlType.TouchPad, false, unityAxes);
                }
                ETCGuiTools.EndGroup();

                ETCGuiTools.BeginGroup(5);
                {
                    ETCAxisInspector.AxisInspector(t.axisY, "Vertical", ETCBase.ControlType.TouchPad, false, unityAxes);
                }
                ETCGuiTools.EndGroup();
            }
            ETCGuiTools.EndGroup();
        }

        #endregion Behaviour & axes

        #region Sprite

        t.showSpriteInspector = ETCGuiTools.BeginFoldOut("Sprites", t.showSpriteInspector);
        if (t.showSpriteInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                Sprite frameSprite = t.GetComponent <Image>().sprite;

                EditorGUILayout.BeginHorizontal();
                t.GetComponent <Image>().sprite = (Sprite)EditorGUILayout.ObjectField("Frame", t.GetComponent <Image>().sprite, typeof(Sprite), true, GUILayout.MinWidth(100));
                t.GetComponent <Image>().color  = EditorGUILayout.ColorField("", t.GetComponent <Image>().color, GUILayout.Width(50));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
                Rect spriteRect = new Rect(frameSprite.rect.x / frameSprite.texture.width,
                                           frameSprite.rect.y / frameSprite.texture.height,
                                           frameSprite.rect.width / frameSprite.texture.width,
                                           frameSprite.rect.height / frameSprite.texture.height);
                GUILayout.Space(8);
                Rect lastRect = GUILayoutUtility.GetLastRect();
                lastRect.x      = 20;
                lastRect.width  = 100;
                lastRect.height = 100;

                GUILayout.Space(100);

                ETCGuiTools.DrawTextureRectPreview(lastRect, spriteRect, t.GetComponent <Image>().sprite.texture, Color.white);
            }
            ETCGuiTools.EndGroup();
        }

        #endregion Sprite

        #region Events

        t.showEventInspector = ETCGuiTools.BeginFoldOut("Move Events", t.showEventInspector);
        if (t.showEventInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                serializedObject.Update();
                SerializedProperty moveStartEvent = serializedObject.FindProperty("onMoveStart");
                EditorGUILayout.PropertyField(moveStartEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveEvent = serializedObject.FindProperty("onMove");
                EditorGUILayout.PropertyField(moveEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveSpeedEvent = serializedObject.FindProperty("onMoveSpeed");
                EditorGUILayout.PropertyField(moveSpeedEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty moveEndEvent = serializedObject.FindProperty("onMoveEnd");
                EditorGUILayout.PropertyField(moveEndEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            }
            ETCGuiTools.EndGroup();
        }

        t.showTouchEventInspector = ETCGuiTools.BeginFoldOut("Touch Events", t.showTouchEventInspector);
        if (t.showTouchEventInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                serializedObject.Update();
                SerializedProperty touchStartEvent = serializedObject.FindProperty("onTouchStart");
                EditorGUILayout.PropertyField(touchStartEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty touchUpEvent = serializedObject.FindProperty("onTouchUp");
                EditorGUILayout.PropertyField(touchUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            }
            ETCGuiTools.EndGroup();
        }

        t.showDownEventInspector = ETCGuiTools.BeginFoldOut("Down Events", t.showDownEventInspector);
        if (t.showDownEventInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                serializedObject.Update();
                SerializedProperty downUpEvent = serializedObject.FindProperty("OnDownUp");
                EditorGUILayout.PropertyField(downUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downRightEvent = serializedObject.FindProperty("OnDownRight");
                EditorGUILayout.PropertyField(downRightEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downDownEvent = serializedObject.FindProperty("OnDownDown");
                EditorGUILayout.PropertyField(downDownEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty downLeftEvent = serializedObject.FindProperty("OnDownLeft");
                EditorGUILayout.PropertyField(downLeftEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            }
            ETCGuiTools.EndGroup();
        }

        t.showPressEventInspector = ETCGuiTools.BeginFoldOut("Press Events", t.showPressEventInspector);
        if (t.showPressEventInspector)
        {
            ETCGuiTools.BeginGroup();
            {
                serializedObject.Update();
                SerializedProperty pressUpEvent = serializedObject.FindProperty("OnPressUp");
                EditorGUILayout.PropertyField(pressUpEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressRightEvent = serializedObject.FindProperty("OnPressRight");
                EditorGUILayout.PropertyField(pressRightEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressDownEvent = serializedObject.FindProperty("OnPressDown");
                EditorGUILayout.PropertyField(pressDownEvent, true, null);
                serializedObject.ApplyModifiedProperties();

                serializedObject.Update();
                SerializedProperty pressLeftEvent = serializedObject.FindProperty("OnPressLeft");
                EditorGUILayout.PropertyField(pressLeftEvent, true, null);
                serializedObject.ApplyModifiedProperties();
            }
            ETCGuiTools.EndGroup();
        }

        #endregion Events

        if (t.anchor != ETCBase.RectAnchor.UserDefined)
        {
            t.SetAnchorPosition();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(t);
#if UNITY_5_3_OR_NEWER
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#endif
        }
    }
示例#6
0
    void LateUpdate()
    {
        if (follow == null)
        {
            follow = GameObject.FindWithTag("Player");
            if (follow)
            {
                Vector3 eulerAngles = follow.transform.eulerAngles;//当前物体的欧拉角
                this.eulerAngles_x = eulerAngles.y;

                this.eulerAngles_y = eulerAngles.x;
            }
        }

        if (follow != null && characterCon == null)
        {
            characterCon = follow.transform.GetComponent <CharacterController>();
        }


        if (!pad)
        {
            pad = ETCInput.GetControlTouchPad("FreeLookTouchPad");
        }
        if (follow != null)
        {
            if (pad)
            {
                if (Mathf.Abs(pad.axisX.axisValue) > 0)
                {
                    this.eulerAngles_x += (pad.axisX.axisValue * this.horizontalRotateSpeed) * Time.deltaTime;
                }
                if (Mathf.Abs(pad.axisY.axisValue) > 0)
                {
                    this.eulerAngles_y += (pad.axisY.axisValue * this.verticalRotateSpeed) * Time.deltaTime;
                    this.eulerAngles_y  = ClampAngle(this.eulerAngles_y, 5, 75);
                }

                Quaternion quaternion = Quaternion.Euler(this.eulerAngles_y, this.eulerAngles_x, (float)0);
                transform.rotation = target.transform.rotation = quaternion;
            }


            // set helper gameobject's position equal the follow gameobject  摄像机目标设置到头顶
            target.transform.position = follow.transform.position + follow.transform.up * distanceUp;

            // setting the target position to be the correct offset from the hovercraft
            targetPosition = target.transform.position - target.transform.forward * distanceAway;

            // making a smooth transition between it's current position and the position it wants to be in
            transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smooth);

            //transform.LookAt(target.transform);
        }

        // fix the camera rotation
        //if (transform.localEulerAngles.z != 0)
        //{
        //    transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, 0);
        //}
    }