using System.
Collections;
using [Link];
using UnityEngine;
public class Spawner : MonoBehaviour
{
public Enemy enemyPrefab;
public Transform topBorder;
public Transform bottomBorder;
public float spawnIntervalMax = 3.5f;
public float spawnIntervalMin = 1f;
public float spawnTimer = 0f;
public int spawnCounter = 10;
public int spawnAddPerLevel = 5;
void Update()
{
if (spawnTimer > 0)
{
spawnTimer -= [Link];
}
else if (spawnCounter > 0)
{
Spawn();
}
}
public void Spawn()
{
spawnCounter--;
spawnTimer = [Link](spawnIntervalMin, spawnIntervalMax);
Vector2 randomPosition = new Vector2([Link].x,
[Link]([Link].y, [Link].y));
Instantiate(enemyPrefab, randomPosition, [Link]);
}
}
using [Link];
using [Link];
using UnityEngine;
public class LevelController : MonoBehaviour
{
public Spawner spawner;
public static bool finished = false;
public static int level = 1;
private void Start()
{
finished = false;
}
private void Update()
{
if(finished == false)
{
Check();
}
}
public void Check()
{
if ([Link] <= 0)
{
Enemy[] enemies = FindObjectsOfType<Enemy>();
if ([Link] <= 0)
{
Victory();
}
}
if([Link] <= 0)
{
Defeat();
}
public void Victory()
{
print("Victory!");
finished = true;
level += 1;
}
public void Defeat()
{
print("Defeat!");
finished = true;
level = 1;
}
}
using [Link];
using [Link];
using UnityEngine;
public class Corn : MonoBehaviour
{
public static Corn singleton;
public int health;
private void Awake()
{
singleton = this;
}
public void TakeDamage()
{
if (health > 0)
{
health -= 1;
}
}
}
using [Link];
using [Link];
using UnityEngine;
public class Enemy : MonoBehaviour
{
public int health;
public float speed = 1f;
float borderPosX;
public Animator animator;
public float shootInterval = 1f;
public float shootTimer = 0f;
public float speedPerLevel = 0.2f;
private void Start()
{
speed += speedPerLevel * [Link];
borderPosX = [Link].x;
}
private void Update()
{
if (shootTimer > 0)
{
shootTimer -= [Link];
}
float enemyPosX = [Link].x;
if (enemyPosX > borderPosX)
{
[Link]("isMoving", true);
[Link] += -[Link] * speed * [Link];
}
else
{
[Link]("isMoving", false);
if (shootTimer <= 0)
{
Attack();
shootTimer = shootInterval;
}
}
}
public void TakeDamage()
{
health -= 1;
if (health <= 0)
Destroy(gameObject);
}
public void Attack()
{
[Link]();
}
}