65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Castle : Building
|
|
{
|
|
public float PopulationGiven => GlobalConfig.Instance.Current.populationGivenPerHouse;
|
|
|
|
[SerializeField]
|
|
private Root _root;
|
|
|
|
public override void Start()
|
|
{
|
|
base.Start();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
base.Update();
|
|
if (IsEnemyDetected)
|
|
{
|
|
AttackEnemy();
|
|
}
|
|
|
|
}
|
|
|
|
public override void LevelStart()
|
|
{
|
|
ResourceManager.Instance.MaximumPopulation += PopulationGiven * 2;
|
|
base.LevelStart();
|
|
}
|
|
public override void LevelDestroy()
|
|
{
|
|
ResourceManager.Instance.MaximumPopulation -= PopulationGiven * 2;
|
|
base.LevelDestroy();
|
|
}
|
|
|
|
void AttackEnemy()
|
|
{
|
|
//Attack Cooldown
|
|
if (AttackInterval < AttackSpeedWait)
|
|
{
|
|
//TODO: Probleme avec l'envoie de projectile sur un angle.
|
|
//Sur la meme fonctionne, mais doit corriger le projectile
|
|
//pour qu'il puisse etre envoye dans les lignes du bas et haut.
|
|
for(int i = 0; i < 5 && IsEnemyDetected; i++)
|
|
{
|
|
Invoke("ShootInterval", 0.1f);
|
|
if(Enemy.Hp <= 0) IsEnemyDetected = false;
|
|
}
|
|
|
|
AttackSpeedWait = 0f;
|
|
|
|
}
|
|
|
|
AttackSpeedWait += Time.deltaTime;
|
|
|
|
}
|
|
|
|
void ShootInterval()
|
|
{
|
|
_root.ShotProjectile();
|
|
}
|
|
}
|