예제 #1
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

#if UNITY_STANDALONE_OSX
#if UNITY_EDITOR_OSX
        HM10 socket = (HM10)target;

        if (Application.isPlaying)
        {
            if (socket.isSupport)
            {
                GUILayout.Label(string.Format("Device: {0}", socket.device.name));
                if (socket.IsOpen)
                {
                }
                else
                {
                    if (socket.isSearching)
                    {
                        EditorUtility.SetDirty(target);

                        if (GUILayout.Button("Stop Search"))
                        {
                            socket.StopSearch();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Start Search"))
                        {
                            socket.StartSearch();
                        }
                    }

                    if (socket.foundDevices.Count > 0)
                    {
                        EditorGUILayout.Foldout(true, "Found Devices");
                        List <string> names     = new List <string>();
                        int           selection = -1;
                        for (int i = 0; i < socket.foundDevices.Count; i++)
                        {
                            names.Add(socket.foundDevices[i].name);
                            if (socket.foundDevices[i].Equals(socket.device))
                            {
                                selection = i;
                            }
                        }

                        int newSelection = GUILayout.SelectionGrid(selection, names.ToArray(), 1);
                        if (selection != newSelection)
                        {
                            socket.device = new CommDevice(socket.foundDevices[newSelection]);
                        }
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This machine is not supported BLE", MessageType.Info);
            }
        }
#else
        EditorGUILayout.HelpBox("Inspector is not support on current OS.", MessageType.Warning);
#endif
#elif UNITY_ANDROID
        EditorGUILayout.HelpBox("Inspector is not support on current platform.", MessageType.Warning);
#else
        EditorGUILayout.HelpBox("This component is not supported on current platform.", MessageType.Warning);
#endif

        EditorGUILayout.PropertyField(searchTimeout, new GUIContent("searchTimeout"));
        EditorGUILayout.PropertyField(serviceUUID, new GUIContent("Service UUID"));
        EditorGUILayout.PropertyField(charUUID, new GUIContent("Characteristic UUID"));

        foldout = EditorGUILayout.Foldout(foldout, "Events");
        if (foldout)
        {
            EditorGUILayout.PropertyField(OnOpen, new GUIContent("OnOpen"));
            EditorGUILayout.PropertyField(OnClose, new GUIContent("OnClose"));
            EditorGUILayout.PropertyField(OnOpenFailed, new GUIContent("OnOpenFailed"));
            EditorGUILayout.PropertyField(OnErrorClosed, new GUIContent("OnErrorClosed"));
            EditorGUILayout.PropertyField(OnStartSearch, new GUIContent("OnStartSearch"));
            EditorGUILayout.PropertyField(OnStopSearch, new GUIContent("OnStopSearch"));
        }

        this.serializedObject.ApplyModifiedProperties();
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        isDead = false; // tells the collectables to stop reseting
        animator.SetBool("Dead", false);
        if (pauseMeter == false)
        {
            hungerLevel -= Time.deltaTime; // every second the hunger meter loses 1 point
        }

        //hunger level is increased by eating trash, code for that is on the trash objects
        if (lives == 3)// give the player back their lives on a level reset
        {
            life1.gameObject.SetActive(true);
            life2.gameObject.SetActive(true);
            life3.gameObject.SetActive(true);
        }

        //visual representation of hunger meter
        //TODO: Set HungerBar on TakeDamage not every frame to get rid of GC
        HM1.SetActive(hungerLevel >= 1 && !takeDamage);
        HM2.SetActive(hungerLevel >= 3 && !takeDamage);
        HM3.SetActive(hungerLevel >= 5 && !takeDamage);
        HM4.SetActive(hungerLevel >= 7 && !takeDamage);
        HM5.SetActive(hungerLevel >= 9 && !takeDamage);
        HM6.SetActive(hungerLevel >= 11 && !takeDamage);
        HM7.SetActive(hungerLevel >= 13 && !takeDamage);
        HM8.SetActive(hungerLevel >= 15 && !takeDamage);
        HM9.SetActive(hungerLevel >= 17 && !takeDamage);
        HM10.SetActive(hungerLevel >= 19 && !takeDamage);
        HM11.SetActive(hungerLevel >= 21 && !takeDamage);
        HM12.SetActive(hungerLevel >= 23 && !takeDamage);
        HM1_Red.SetActive(hungerLevel >= 1);
        HM2_Red.SetActive(hungerLevel >= 3);
        HM3_Red.SetActive(hungerLevel >= 5);
        HM4_Red.SetActive(hungerLevel >= 7);
        HM5_Red.SetActive(hungerLevel >= 9);
        HM6_Red.SetActive(hungerLevel >= 11);
        HM7_Red.SetActive(hungerLevel >= 13);
        HM8_Red.SetActive(hungerLevel >= 15);
        HM9_Red.SetActive(hungerLevel >= 17);
        HM10_Red.SetActive(hungerLevel >= 19);
        HM11_Red.SetActive(hungerLevel >= 21);
        HM12_Red.SetActive(hungerLevel >= 23);

        if (hungerLevel > (hungerLevelMax / 2))// change the face icon
        {
            happyFace.gameObject.SetActive(true);
            hungryFace.gameObject.SetActive(false);
        }
        else if (hungerLevel <= (hungerLevelMax / 2))//change the face icon
        {
            happyFace.gameObject.SetActive(false);
            hungryFace.gameObject.SetActive(true);
        }
        if (hungerLevel < 0 && !playerDying) // runs out of meter
        {
            lives -= 1;                      // lose one life
            isDead = true;                   // the player has died so the collectables need to be reset
            if (lives > 0)
            {
                playerDying = true;
                animator.SetTrigger("DeathAnim");
                faintSource.Play();
                StartCoroutine(RespawnPlayer());
            }
            else
            {
                playerDying = true;
                animator.SetTrigger("DeathAnim");
                StartCoroutine(KillPlayer());
            }
        }
    }