using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
publicclass atari : MonoBehaviour
{
SpriteRenderer MainSpriteRenderer;
public GameObject player;
public GameObject wifi;
public Text point_text;
public Sprite genki;
public Sprite turai;
public AudioSource wifion;
public AudioSource wifinasi;
float point = 0.0f;
// Start is called before the first frame updatevoid Start()
{
MainSpriteRenderer = player.GetComponent<SpriteRenderer>();
}
// Update is called once per framevoid Update()
{
Vector3 Apos = player.transform.position;
Vector3 Bpos = wifi.transform.position;
float dis = Vector3.Distance(Apos, Bpos);
if (dis < 2.0f)
{
Debug.Log("近づいた");
wifion.Pause();
wifinasi.UnPause();
point =point+(8-dis)*Time.deltaTime;
int poi = (int)point;
point_text.text= "元気"+point.ToString("f0") +"%";
MainSpriteRenderer.sprite =genki;
}
else
{
wifion.UnPause();
wifinasi.Pause();
MainSpriteRenderer.sprite = turai;
}
if (point > 100)
{
Debug.Log("クリア");
SceneManager.LoadScene("ED");
}
}
}