init
This commit is contained in:
commit
bd5b1556ff
269 changed files with 6249829 additions and 0 deletions
31
Assets/Scripts/Fireball.cs
Normal file
31
Assets/Scripts/Fireball.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Fireball : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
public float attackSpeed;
|
||||
public GameObject explosion;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
StartCoroutine(Attack());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
transform.Translate(Vector3.right * speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
IEnumerator Attack(){
|
||||
yield return new WaitForSeconds(2f);
|
||||
transform.position = new Vector2(GameObject.FindGameObjectWithTag("Player").transform.position.x, transform.position.y);
|
||||
speed = -attackSpeed;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
Instantiate(explosion, transform.position, Quaternion.identity);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue