예제 #1
0
    void hpRecovery()
    {
        // 一番最初のみ、ヘルスバーへの参照を取得する処理.
        if (hpIncriment == 1)
        {
            healthBar = GameObject.Find("HealthBar").GetComponent <MonoHealthbar>();
        }

        // hpが10回復するまで処理を繰り返す.
        if (hpIncriment <= recoveryVolume)
        {
            // ヘルスバーに1ずつ加算.
            healthBar.Health += 1;
        }

        // 10加算したら、処理を終了して初期化.
        if (hpIncriment == recoveryVolume)
        {
            hpRecoveryBool = false;
            hpIncriment    = 1;
            return;
        }

        hpIncriment += 1;
    }
예제 #2
0
    void hpDecrease()
    {
        // 一番最初のみ、ヘルスバーへの参照を取得する処理.
        if (damageIncriment == 1)
        {
            healthBar = GameObject.Find("HealthBar").GetComponent <MonoHealthbar>();
            gameOverJudge();
        }

        // ダメージが10加わるまで処理を繰り返す.
        if (damageIncriment <= damageVolume)
        {
            // ヘルスバーから1ずつ減算.
            healthBar.Health -= 1;
        }

        // 10減算したら、addDamageTurnの数を1減らす.
        if (damageIncriment == damageVolume)
        {
            addDamageTurn  -= 1;
            damageIncriment = 1;
            return;
        }

        damageIncriment += 1;
    }
예제 #3
0
    void energyRecovery()
    {
        if (energyIncriment == 1)
        {
            EnergyBar = GameObject.Find("EnergyBar").GetComponent <MonoHealthbar>();
        }

        if (energyIncriment % 4 == 0)
        {
            EnergyBar.Health += 1;
        }

        energyIncriment += 1;

        if (energyIncriment == 400)
        {
            energyMaxBool    = true;
            energyIncriment  = 0;
            audioSource.clip = audioClip_5;
            audioSource.Play();
        }
    }
예제 #4
0
    void hpRecovery()
    {
        // 一番最初のみ、ヘルスバーへの参照を取得する処理.
        if ( hpIncriment == 1 ) {

            healthBar = GameObject.Find("HealthBar").GetComponent<MonoHealthbar>();

        }

        // hpが10回復するまで処理を繰り返す.
        if ( hpIncriment <= recoveryVolume ) {

            // ヘルスバーに1ずつ加算.
            healthBar.Health += 1;

        }

        // 10加算したら、処理を終了して初期化.
        if ( hpIncriment == recoveryVolume ) {

            hpRecoveryBool = false;
            hpIncriment = 1;
            return;

        }

        hpIncriment += 1;
    }
예제 #5
0
    void hpDecrease()
    {
        // 一番最初のみ、ヘルスバーへの参照を取得する処理.
        if ( damageIncriment == 1 ) {

            healthBar = GameObject.Find("HealthBar").GetComponent<MonoHealthbar>();
            gameOverJudge();

        }

        // ダメージが10加わるまで処理を繰り返す.
        if ( damageIncriment <= damageVolume ) {

            // ヘルスバーから1ずつ減算.
            healthBar.Health -= 1;

        }

        // 10減算したら、addDamageTurnの数を1減らす.
        if ( damageIncriment == damageVolume ) {

            addDamageTurn -= 1;
            damageIncriment = 1;
            return;

        }

        damageIncriment += 1;
    }
예제 #6
0
    void energyRecovery()
    {
        if ( energyIncriment == 1 ) {

            EnergyBar = GameObject.Find("EnergyBar").GetComponent<MonoHealthbar>();

        }

        if ( energyIncriment % 4 == 0 ) {

            EnergyBar.Health += 1;

        }

        energyIncriment += 1;

        if ( energyIncriment == 400 ) {

            energyMaxBool = true;
            energyIncriment = 0;
            audioSource.clip = audioClip_5;
            audioSource.Play();

        }
    }
예제 #7
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        monoTexture.OutlineTexture = EditorGUILayout.ObjectField("Texture", monoTexture.OutlineTexture, typeof(Texture2D), true) as Texture2D;

        EditorGUILayout.Space();
        monoTexture.Width = EditorGUILayout.IntField(new GUIContent("Width", "Set the width of the texture."), monoTexture.Width);

        monoTexture.Height = EditorGUILayout.IntField(new GUIContent("Height", "Set the height of the texture."), monoTexture.Height);
        EditorGUILayout.Space();

        monoTexture.Zindex          = EditorGUILayout.IntField(new GUIContent("Z-Index", "Set which component is at top of others."), monoTexture.Zindex);
        monoTexture.KeepAspectRatio = EditorGUILayout.Toggle(new GUIContent("Keep Aspect Ratio", "Keep the aspect ratio-proportions of the texture."), monoTexture.KeepAspectRatio);

        EditorGUILayout.Space();
        Separator();
        EditorGUILayout.Space();

        GUILayout.Space(5);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Create New Prefab"))
        {
            if (prefabFolder == "")
            {
                prefabFolder = EditorUtility.OpenFolderPanel("Prefab Folder", "Assets", "Prefabs");
            }
            prefabFolder = EditorUtility.OpenFolderPanel("Prefab Folder", "Assets", "Prefabs");


            string tmp  = System.Text.RegularExpressions.Regex.Split(prefabFolder, "/Assets")[1];
            string path = "Assets" + tmp + "/" + newPrefabName + ".prefab";

            Object newPrefab = PrefabUtility.CreateEmptyPrefab(path);
            if (newPrefab == null)
            {
                Debug.LogError("Couldn't Create the Asset. Path: " + path);
                return;
            }

            PrefabUtility.ReplacePrefab(monoTexture.gameObject, newPrefab, ReplacePrefabOptions.ReplaceNameBased);
            MonoHealthbar temp = newPrefab as MonoHealthbar;
            if (temp == null)
            {
                Debug.Log("Null");
                return;
            }

            Debug.Log("Prefab Succefully Created. (" + path + ")");
        }

        GUIStyle style = new GUIStyle();

        style.fontStyle = FontStyle.Bold;
        style.alignment = TextAnchor.MiddleLeft;

        newPrefabName = EditorGUILayout.TextField(newPrefabName);

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
    }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        monoTexture.OutlineTexture = EditorGUILayout.ObjectField("Outline Texture", monoTexture.OutlineTexture, typeof(Texture2D), true) as Texture2D;
        monoTexture.FillTexture    = EditorGUILayout.ObjectField("Fill Texture", monoTexture.FillTexture, typeof(Texture2D), true) as Texture2D;

        EditorGUILayout.Space();
        monoTexture.Width  = EditorGUILayout.IntField(new GUIContent("Width", "Set the width of the texture."), monoTexture.Width);
        monoTexture.Height = EditorGUILayout.IntField(new GUIContent("Height", "Set the height of the texture."), monoTexture.Height);

        EditorGUILayout.Space();
        monoTexture.Zindex          = EditorGUILayout.IntField(new GUIContent("Z-Index", "Set which component is at top of others."), monoTexture.Zindex);
        monoTexture.KeepAspectRatio = EditorGUILayout.Toggle(new GUIContent("Keep Aspect Ratio", "Keep the aspect ratio-proportions of the texture."), monoTexture.KeepAspectRatio);
        monoTexture.Health          = EditorGUILayout.IntField(new GUIContent("Health", "Set the health-precent of the 'healthbar'."), monoTexture.Health);

        if (Event.current.type == EventType.ValidateCommand &&
            Event.current.commandName == "UndoRedoPerformed")
        {
            // Undo/redo was performed. Repaint.
            Repaint();
        }

        EditorGUILayout.Space();
        Separator();
        EditorGUILayout.Space();

        GUILayout.Space(5);


        GUILayout.BeginHorizontal();

        GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);

        buttonStyle.padding = new RectOffset(8, 8, 4, 5);
        if (GUILayout.Button("Create New Prefab", buttonStyle))
        {
            if (prefabFolder == "")
            {
                prefabFolder = EditorUtility.OpenFolderPanel("Prefab Folder", "Assets", "Prefabs");
            }
            prefabFolder = EditorUtility.OpenFolderPanel("Prefab Folder", "Assets", "Prefabs");


            string tmp  = System.Text.RegularExpressions.Regex.Split(prefabFolder, "/Assets")[1];
            string path = "Assets" + tmp + "/" + newPrefabName + ".prefab";

            Object newPrefab = PrefabUtility.CreateEmptyPrefab(path);
            if (newPrefab == null)
            {
                Debug.LogError("Couldn't Create the Asset. Path: " + path);
                return;
            }

            PrefabUtility.ReplacePrefab(monoTexture.gameObject, newPrefab, ReplacePrefabOptions.ReplaceNameBased);
            MonoHealthbar temp = newPrefab as MonoHealthbar;
            if (temp == null)
            {
                Debug.Log("Null");
                return;
            }

            Debug.Log("Prefab Succefully Created. (" + path + ")");
        }

        GUIStyle style = new GUIStyle(GUI.skin.textField);

        style.fontStyle   = FontStyle.Normal;
        style.alignment   = TextAnchor.MiddleLeft;
        style.padding     = new RectOffset(5, 3, 2, 3);
        style.fixedHeight = 22;

        newPrefabName = EditorGUILayout.TextField(newPrefabName, style);

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
    }
 void OnEnable()
 {
     monoTexture = (MonoHealthbar)target;
 }