Monster Core #21
@ -29,6 +29,7 @@ public class WaveObserver : Singleton<WaveObserver>
|
|||||||
_copyConstantSpawn = new List<int>();
|
_copyConstantSpawn = new List<int>();
|
||||||
_copyGroupSpawn = new List<List<int>>();
|
_copyGroupSpawn = new List<List<int>>();
|
||||||
_groupSpawnTimers = new List<float>();
|
_groupSpawnTimers = new List<float>();
|
||||||
|
_monsterCoreGroups = new List<bool>();
|
||||||
|
|
||||||
_spawnerTiming = 0;
|
_spawnerTiming = 0;
|
||||||
_currentGroupIndex = 0;
|
_currentGroupIndex = 0;
|
||||||
@ -252,6 +253,8 @@ public class WaveObserver : Singleton<WaveObserver>
|
|||||||
bool dropsCore = _monsterCoreGroups != null && _monsterCoreGroups.Count > _currentGroupIndex && _monsterCoreGroups[_currentGroupIndex];
|
bool dropsCore = _monsterCoreGroups != null && _monsterCoreGroups.Count > _currentGroupIndex && _monsterCoreGroups[_currentGroupIndex];
|
||||||
int totalToSpawn = _copyGroupSpawn[_currentGroupIndex][groupIndex];
|
int totalToSpawn = _copyGroupSpawn[_currentGroupIndex][groupIndex];
|
||||||
int monsterCoreTarget = -1;
|
int monsterCoreTarget = -1;
|
||||||
|
// TODO : Afficher input box quand bool "DropsMonsterCore" est checked
|
||||||
|
// TODO : Si spécifié, nbr fixe de core à drop
|
||||||
if (dropsCore && totalToSpawn > 0)
|
if (dropsCore && totalToSpawn > 0)
|
||||||
{
|
{
|
||||||
monsterCoreTarget = rand.Next(0, totalToSpawn);
|
monsterCoreTarget = rand.Next(0, totalToSpawn);
|
||||||
@ -264,35 +267,12 @@ public class WaveObserver : Singleton<WaveObserver>
|
|||||||
{
|
{
|
||||||
GameObject spawnedInstance = _subjects[currentRow].TriggerSpawn(currentGroup[groupIndex].GetEnemyObject());
|
GameObject spawnedInstance = _subjects[currentRow].TriggerSpawn(currentGroup[groupIndex].GetEnemyObject());
|
||||||
|
|
||||||
// Si ce spawn doit être le porteur du MonsterCore, on remplace/ajoute le comportement
|
// WHen Monster core time
|
||||||
if (monsterCoreTarget >= 0 && spawnCount == monsterCoreTarget)
|
if (monsterCoreTarget >= 0 && spawnCount == monsterCoreTarget)
|
||||||
{
|
{
|
||||||
if (spawnedInstance != null)
|
if (spawnedInstance != null)
|
||||||
{
|
{
|
||||||
// tentative de remplacer le composant Opponent par MonsterCoreDrop
|
spawnedInstance.AddComponent<MonsterCoreDrop>();
|
||||||
var existingOpponent = spawnedInstance.GetComponent<Opponent>();
|
|
||||||
if (existingOpponent != null)
|
|
||||||
{
|
|
||||||
// we remove the existing Opponent-derived behaviour to avoid duplicate logic
|
|
||||||
Object.Destroy(existingOpponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add MonsterCoreDrop component and configure son prefab (si disponible dans la Database)
|
|
||||||
MonsterCoreDrop mc = spawnedInstance.AddComponent<MonsterCoreDrop>();
|
|
||||||
mc.Init();
|
|
||||||
|
|
||||||
// essaye de récupérer le prefab "MonsterCore" dans la database (adapter le nom si nécessaire)
|
|
||||||
//GameObject corePrefab = null;
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
// corePrefab = Database.Instance.Prefabs["MonsterCore"];
|
|
||||||
//}
|
|
||||||
//catch { corePrefab = null; }
|
|
||||||
|
|
||||||
//if (corePrefab != null)
|
|
||||||
//{
|
|
||||||
// mc.SetCorePrefab(corePrefab);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,36 +2,39 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class MonsterCoreDrop : Opponent
|
public class MonsterCoreDrop : MonoBehaviour
|
||||||
{
|
{
|
||||||
private GameObject _monsterCorePrefab;
|
private GameObject _monsterCorePrefab;
|
||||||
|
|
||||||
public void Init()
|
public void Start()
|
||||||
{
|
{
|
||||||
base.Start();
|
Debug.Log("MONSTER CORING SSO HARD");
|
||||||
|
|
||||||
// Si le prefab n'est pas fixé via l'inspector, tenter de le charger depuis Resources/"Food"
|
// Si le prefab n'est pas fixé via l'inspector, tenter de le charger depuis Resources/"Food"
|
||||||
if (_monsterCorePrefab == null)
|
//if (_monsterCorePrefab == null)
|
||||||
{
|
//{
|
||||||
_monsterCorePrefab = Resources.Load<GameObject>("yieldFood");
|
// _monsterCorePrefab = Resources.Load<GameObject>("yieldFood");
|
||||||
if (_monsterCorePrefab == null)
|
// if (_monsterCorePrefab == null)
|
||||||
{
|
// {
|
||||||
Debug.LogWarning("MonsterCoreDrop: prefab 'yieldFood' introuvable dans le dossier Resources. Assignez-le dans l'inspector ou placez-le dans Resources/yieldFood.");
|
// Debug.LogWarning("MonsterCoreDrop: prefab 'yieldFood' introuvable dans le dossier Resources. Assignez-le dans l'inspector ou placez-le dans Resources/yieldFood.");
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCorePrefab(GameObject prefab)
|
public void Death()
|
||||||
{
|
{
|
||||||
_monsterCorePrefab = prefab;
|
//if (_monsterCorePrefab != null)
|
||||||
|
//{
|
||||||
|
// Instantiate(_monsterCorePrefab, transform.position, Quaternion.identity);
|
||||||
|
//}
|
||||||
|
Debug.Log("MONSTER CORE DROPPEDD");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Death()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
if (_monsterCorePrefab != null)
|
//if (_monsterCorePrefab != null)
|
||||||
{
|
//{
|
||||||
Instantiate(_monsterCorePrefab, transform.position, Quaternion.identity);
|
// Instantiate(_monsterCorePrefab, transform.position, Quaternion.identity);
|
||||||
}
|
//}
|
||||||
base.Death();
|
Debug.Log("MONSTER CORE DROPPEDD");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user