init
This commit is contained in:
commit
3b4c6e0ec6
506 changed files with 434142 additions and 0 deletions
38
Assets/Scripts/BombSpawner.cs
Normal file
38
Assets/Scripts/BombSpawner.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BombSpawner : MonoBehaviour{
|
||||
|
||||
[SerializeField, Range(1, 10)] float spawnRate = 5f;
|
||||
float currentTime;
|
||||
|
||||
[SerializeField] GameObject bomb = default;
|
||||
|
||||
SphereCollider col;
|
||||
PlayerController player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
col = GetComponent<SphereCollider>();
|
||||
player = FindObjectOfType<PlayerController>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
currentTime -= Time.deltaTime;
|
||||
if(currentTime <= 0){
|
||||
col.enabled = true;
|
||||
bomb.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider col){
|
||||
if(col.CompareTag("Player")){
|
||||
currentTime = spawnRate;
|
||||
this.col.enabled = false;
|
||||
bomb.SetActive(false);
|
||||
player.numberOfBombs++;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue