コード例 #1
0
ファイル: playerchara.cs プロジェクト: bagisaewsome/Game
 // Update is called once per frame
 public void Hurt(int damage)
 {
     _health -= damage;
     Debug.Log(" health: " + _health);
     if (_health <= 0)
     {
         float timetakea = Time.realtimeSinceStartup;
         timetake = Mathf.Round(timetakea);
         GameObject    gun         = GameObject.Find("Main Camera");
         float         tiltAroundZ = Input.GetAxis("Horizontal") * 90;
         Quaternion    target      = Quaternion.Euler(0, 0, tiltAroundZ);
         gunfromcamera guun        = gun.GetComponent <gunfromcamera>();
         endtext.text = "YOU DIED!!! you last " + timetake + " seconds and killed " + kills + " ghosts.";
         soundSource.PlayOneShot(death);
         StartCoroutine(Die());
         _health = 0;
         playermove status    = GetComponent <playermove>();
         wanderAI   behavior  = GetComponent <wanderAI>();
         chargerAI  behaviora = GetComponent <chargerAI>();
         if (status != null)
         {
             status.SetAlivep(false);
         }
         if (behavior != null)
         {
             behavior.SetAlive(false);
         }
         if (behaviora != null)
         {
             behaviora.SetAlive(false);
         }
     }
 }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (health <= 0)
     {
         Destroy(this.gameObject);
         gunfromcamera stat = GetComponent <gunfromcamera>();
         stat.updated = false;
     }
 }
コード例 #3
0
 // public bool gotton = false;
 // Use this for initialization
 private void Start()
 {
     health = maxhealth;
     gunfromcamera stat = GetComponent <gunfromcamera>();
 }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     _health = 20;
     //   ammo = 50;
     gunfromcamera ammmo = GetComponent <gunfromcamera>();
 }