You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

2 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fireball : MonoBehaviour
{
DragonMovement.AttackType _attackType = DragonMovement.AttackType.FIREBALL;
float _lifeSpan = 0f;
public DragonMovement.AttackType AttackType { get => _attackType; set => _attackType = value; }
2 years ago
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
_lifeSpan += Time.deltaTime;
float speed = 1000f; //fireball
if (_attackType == DragonMovement.AttackType.CONE)
{
speed = 600f;
float growth = 8f * Time.deltaTime;
transform.localScale = transform.localScale + new Vector3(growth, growth, 0f);
if (transform.localPosition.x > 250f)
{
GameObject.Destroy(this.gameObject);
}
}
transform.position = new Vector3(transform.position.x + speed * Time.deltaTime, transform.position.y, transform.position.z);
2 years ago
if (_lifeSpan >= 0.8f)
2 years ago
{
GameObject.Destroy(this.gameObject);
}
}
}