init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
60
Assets/Scripts/Boss.cs
Normal file
60
Assets/Scripts/Boss.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Boss : MonoBehaviour
|
||||
{
|
||||
public float Health, attackDelay;
|
||||
float f;
|
||||
public Transform Missile, Firepoint;
|
||||
public int attack;
|
||||
Animator anim;
|
||||
public GameObject wall;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
f += Time.deltaTime;
|
||||
if (f >= attackDelay && attack == 1)
|
||||
{
|
||||
f = 0;
|
||||
anim.SetTrigger("newAttack");
|
||||
attack = 0;
|
||||
shootMissiles();
|
||||
}
|
||||
if (attack == 0 && GameObject.FindGameObjectsWithTag("Missile").Length == 0)
|
||||
{
|
||||
anim.SetTrigger("newAttack");
|
||||
attack = 1;
|
||||
f = 0;
|
||||
}
|
||||
if (Health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Destroy(wall);
|
||||
}
|
||||
}
|
||||
public void shootMissiles()
|
||||
{
|
||||
Transform bullet = Instantiate(Missile, Firepoint.position, Firepoint.rotation);
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if(collision.gameObject.tag == "Bullet"){
|
||||
Health -= 1;
|
||||
}
|
||||
|
||||
if (collision.transform.tag == "Player")
|
||||
{
|
||||
collision.transform.GetComponent<PlayerStats>().Die();
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue