コード例 #1
0
 void OnCollisionEnter(Collision info)
 {
     if (info.collider.name.Equals("Player"))
     {
         print("touchie");
         Player.heal();
         Destroy(gameObject);
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (coolDown.canUse(Time.time))
        {
            if (Input.GetKeyDown(KeyCode.O) && playerHP.getMana() > 0 && !hasWand)
            {
                player.animator.SetBool("Spellcasting", true);
                player.SFX.PlayOneShot(player.fireball);
                // bul.SetActive(true);
                if (player.facingRight)
                {
                    pro.setSpeed(player.facingRight);
                    makeProjectile(2, 0.15f);
                    playerHP.useMana(1);
                }
                else
                {
                    pro.setSpeed(player.facingRight);
                    print(pro.projectileSpeed);
                    makeProjectile(-2, -0.15f);
                    playerHP.useMana(1);
                }
                coolDown.addTime(Time.time, timeforCoolDown);
            }
            else if (Input.GetKeyDown(KeyCode.O) && hasWand)
            {
                player.animator.SetBool("Spellcasting", true);
                player.SFX.PlayOneShot(player.fireball);
                // bul.SetActive(true);
                if (player.facingRight)
                {
                    pro.setSpeed(player.facingRight);
                    makeProjectile(2, 0.15f);
                }
                else
                {
                    pro.setSpeed(player.facingRight);
                    print(pro.projectileSpeed);
                    makeProjectile(-2, -0.15f);
                }
                coolDown.addTime(Time.time, timeforCoolDown);
            }
        }


        if (Input.GetKeyUp(KeyCode.O))
        {
            player.animator.SetBool("Spellcasting", false);
        }
        if (Input.GetKeyDown(KeyCode.Alpha4) && playerHP.getMana() > 0)         //&& (PlayerPrefs.GetString("hasFreeze") == "true"))
        {
            // bul.SetActive(true);
            if (player.facingRight)
            {
                ice.setSpeed(player.facingRight);
                makeFreeze(1, 1);
            }
            else
            {
                ice.setSpeed(player.facingRight);
                //print(ice.projectileSpeed);
                makeFreeze(-1, -1);
            }
            playerHP.useMana(1);
            freezeCool.addTime(Time.time, timeforCoolDown);
        }

        if (Input.GetKeyDown(KeyCode.Alpha3) && playerHP.getMana() > 0 && (PlayerPrefs.GetString("hasHeal") == "true"))
        {
            player.SFX.PlayOneShot(player.spellSFX);
            playerHP.useMana(1);
            playerHP.heal();
        }
    }