예제 #1
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.tag != "Player")
        {
            return;
        }

        if (healPercentage > 0.0f)
        {
            if (PlayerHealth.health >= PlayerHealth.maxHealth)
            {
                return;
            }

            var heal = PlayerHealth.Heal(healPercentage);

            var go       = Instantiate(healTextPrefab) as GameObject;
            var healText = go.GetComponent <HealText>();
            healText.heal = heal;
        }

        if (maxHealthUp > 0)
        {
            var up = Mathf.RoundToInt(Random.Range(0.6f, 1.4f) * maxHealthUp);

            PlayerHealth.AddMaxHealth(up);

            var go       = Instantiate(healTextPrefab) as GameObject;
            var healText = go.GetComponent <HealText>();
            healText.heal = Mathf.RoundToInt(up);
        }

        var audio = GetComponent <AudioSource>();

        if (audio != null)
        {
            audio.Play();
            enabled = false;
            GetComponent <SphereCollider>().enabled = false;
            GetComponent <SphereCollider>().radius  = 0;
            StartCoroutine(AsyncDestroy());
        }
        else
        {
            Destroy(gameObject);
        }
    }
예제 #2
0
    void RareGacha()
    {
        var backupColor = GUI.color;

        GUI.color = Color.yellow;

        var topleft = Camera.main.ViewportToScreenPoint(
            new Vector3(0.3f, 0.1f, 0.0f));

        var size = Camera.main.ViewportToScreenPoint(
            new Vector3(0.4f, 0.35f, 0.0f));

        var area = new Rect(
            topleft.x, topleft.y,
            size.x, size.y);

        GUILayout.BeginArea(area);

        GUILayout.FlexibleSpace();

        var guiStyle = new GUIStyle(GUI.skin.GetStyle("label"));

        guiStyle.alignment = TextAnchor.MiddleCenter;
        guiStyle.fontSize  = 30;

        GUILayout.Label(
            "☆☆☆レアガチャ☆☆☆",
            guiStyle,
            GUILayout.MinHeight(60));

        //GUILayout.FlexibleSpace();

//		GUI.color = Color.red;
//		guiStyle.fontSize = 20;
//
//		GUILayout.Label(
//			"11連でSR1枚確定キャンペーン中!!!",
//			guiStyle);

        GUI.color = Color.yellow;

        //GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal();

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("レア1回\n(最大HP 10)", GUILayout.MinWidth(120), GUILayout.MinHeight(60)))
        {
            if (PlayerHealth.maxHealth >= 10)
            {
                PlayerHealth.AddMaxHealth(-10);
                rareGacha.Draw(1);
                gacha    = rareGacha;
                guiState = StateGacha;
            }
            else
            {
                guiState = StateLack;
            }
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("レア11連\n(最大HP 100)", GUILayout.MinWidth(120), GUILayout.MinHeight(60)))
        {
            if (PlayerHealth.maxHealth >= 100)
            {
                PlayerHealth.AddMaxHealth(-100);
                rareGacha.Draw(11);
                gacha    = rareGacha;
                guiState = StateGacha11;
            }
            else
            {
                guiState = StateLack;
            }
        }

        GUILayout.FlexibleSpace();

        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        GUILayout.EndArea();

        GUI.color = backupColor;
    }