Import
temp
This commit is contained in:
parent
a87f0ed109
commit
a17810ffeb
114 changed files with 5184 additions and 5 deletions
93
Assets/otherTeam/OtherScripts/ManagerScipts/PastilleManager.cs
Executable file
93
Assets/otherTeam/OtherScripts/ManagerScipts/PastilleManager.cs
Executable file
|
@ -0,0 +1,93 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PastilleManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ArmyManager armyManagerScript;
|
||||
[SerializeField] SpawnDucks spawnManagerScript;
|
||||
[SerializeField] GameObject enemyPastillePrefab;
|
||||
[SerializeField] GameObject playerPastillePrefab;
|
||||
[SerializeField] GameObject selectedPastillePrefab;
|
||||
[SerializeField] GameManager gameManagerScript;
|
||||
|
||||
private bool removedPastilles = false;
|
||||
private bool addedInitialPastilles = false;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
if (!addedInitialPastilles && gameManagerScript.spawningPhase)
|
||||
{
|
||||
addedInitialPastilles = true;
|
||||
setEnemyPastilles();
|
||||
}
|
||||
|
||||
if (addedInitialPastilles && !removedPastilles && !gameManagerScript.spawningPhase)
|
||||
{
|
||||
removedPastilles = true;
|
||||
removeEnemyPastilles();
|
||||
removeTeamPastilles();
|
||||
};
|
||||
}
|
||||
|
||||
public void setEnemyPastilles()
|
||||
{
|
||||
foreach (GameObject enemyDuck in armyManagerScript.getArmy(true))
|
||||
{
|
||||
giveXPastilleToY(enemyPastillePrefab, enemyDuck);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTeamPastilles()
|
||||
{
|
||||
foreach (GameObject playerDuck in armyManagerScript.getArmy(false))
|
||||
{
|
||||
removeTroopsPastilles(playerDuck);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeEnemyPastilles()
|
||||
{
|
||||
foreach (GameObject enemyDuck in armyManagerScript.getArmy(true))
|
||||
{
|
||||
removeTroopsPastilles(enemyDuck);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setSelectedPastille(GameObject troop)
|
||||
{
|
||||
removeTroopsPastilles(troop);
|
||||
giveXPastilleToY(selectedPastillePrefab, troop);
|
||||
}
|
||||
|
||||
public void setPlayerPastille(GameObject troop)
|
||||
{
|
||||
removeTroopsPastilles(troop);
|
||||
giveXPastilleToY(playerPastillePrefab, troop);
|
||||
}
|
||||
|
||||
public void removeTroopsPastilles(GameObject troop)
|
||||
{
|
||||
Transform PastilleSpawner = troop.transform.Find("pastilleSpawner");
|
||||
foreach (Transform child in PastilleSpawner)
|
||||
{
|
||||
if (child.CompareTag("Pastille"))
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveXPastilleToY(GameObject pastille, GameObject troop)
|
||||
{
|
||||
Instantiate(pastille, troop.transform.Find("pastilleSpawner").transform);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue