working
This commit is contained in:
parent
4e91f448c9
commit
1b2611e5a9
90 changed files with 7029 additions and 2762 deletions
|
@ -2,106 +2,25 @@ using UnityEngine;
|
|||
using System.Collections.Generic;
|
||||
|
||||
|
||||
public class ArmyManager : MonoBehaviour
|
||||
public static class ArmyManager
|
||||
{
|
||||
private List<GameObject> enemyArmy = new List<GameObject>();
|
||||
private List<GameObject> playerArmy = new List<GameObject>();
|
||||
private GameObject enemyCrownDuck = null;
|
||||
private GameObject playerCrownDuck = null;
|
||||
[SerializeField] private GameManager gameManagerScript;
|
||||
private static List<GameObject> enemyArmy = new List<GameObject>();
|
||||
private static List<GameObject> playerArmy = new List<GameObject>();
|
||||
private static GameObject enemyCrownDuck = null;
|
||||
private static GameObject playerCrownDuck = null;
|
||||
|
||||
|
||||
public static List<AbstractUnit> getArmy(bool isEnemy)
|
||||
{
|
||||
List<AbstractUnit> units = (isEnemy ? GlobalsVariable.AliveUnitsTeamB : GlobalsVariable.AliveUnitsTeamA);
|
||||
return units;
|
||||
}
|
||||
|
||||
|
||||
public static GameObject getCrownDuck(bool isEnemy)
|
||||
{
|
||||
return(isEnemy ? GlobalsVariable.QueenB.gameObject : GlobalsVariable.QueenA.gameObject);
|
||||
}
|
||||
|
||||
|
||||
// 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()
|
||||
{
|
||||
//Debug.Log("Enemy Count : " + enemyArmy.Count);
|
||||
//Debug.Log("Player Count : " + playerArmy.Count);
|
||||
//Debug.Log(playerCrownDuck);
|
||||
}
|
||||
|
||||
public List<GameObject> getArmy(bool isEnemy){
|
||||
return(isEnemy ? enemyArmy : playerArmy);
|
||||
}
|
||||
|
||||
public void addTroopToArmy(bool isEnemy, GameObject Duck){
|
||||
(isEnemy ? enemyArmy : playerArmy).Add(Duck);
|
||||
}
|
||||
|
||||
public void removeTroopFromArmy(bool isEnemy, GameObject Duck)
|
||||
{
|
||||
(isEnemy ? enemyArmy : playerArmy).Remove(Duck);
|
||||
}
|
||||
|
||||
public void setCrownDuck(bool isEnemy, GameObject CrownDuck)
|
||||
{
|
||||
if (isEnemy) {
|
||||
enemyCrownDuck = CrownDuck;
|
||||
} else {
|
||||
playerCrownDuck = CrownDuck;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCrownDuck(bool isEnemy)
|
||||
{
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getCrownDuck(bool isEnemy)
|
||||
{
|
||||
return(isEnemy ? enemyCrownDuck : playerCrownDuck);
|
||||
}
|
||||
|
||||
public void kill(bool isEnemy, GameObject Duck, bool hasCrown)
|
||||
{
|
||||
removeTroopFromArmy(isEnemy, Duck);
|
||||
if (hasCrown)
|
||||
{
|
||||
gameManagerScript.endOfLevel(isEnemy);
|
||||
}
|
||||
removeTroopFromArmy(isEnemy, gameObject);
|
||||
}
|
||||
|
||||
public void giveCrownDuckTo(bool isEnemy, GameObject duckToCrown)
|
||||
{
|
||||
if ((isEnemy ? enemyCrownDuck : playerCrownDuck) != null)
|
||||
{
|
||||
(isEnemy ? enemyCrownDuck : playerCrownDuck).GetComponent<BaseDuckScript>().loseMyCrown();
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
|
||||
//becomeCrownDuck will call army manager later and set it locally
|
||||
duckToCrown.GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
|
||||
public void removeCrownDuckFrom(bool isEnemy, GameObject duckToRemoveCrown)
|
||||
{
|
||||
(isEnemy ? enemyCrownDuck : playerCrownDuck).GetComponent<BaseDuckScript>().loseMyCrown();
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,211 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public bool difficultySelectionPhase = true;
|
||||
public bool spawningPhase = false;
|
||||
|
||||
public bool combatPhase = false;
|
||||
public bool endOfGamePhase = false;
|
||||
|
||||
public bool foundWinner = false;
|
||||
|
||||
public bool playerWon;
|
||||
[SerializeField] public int currentLevel;
|
||||
[SerializeField] public int difficulty;
|
||||
[SerializeField] public ArmyManager armyManager;
|
||||
[SerializeField] public UnlockedLevelsManager unlockedLevelsManager;
|
||||
[SerializeField] public int baseCoins;
|
||||
[SerializeField] public int currentCoins;
|
||||
[SerializeField] private GameObject coinDisplay;
|
||||
private TextMeshProUGUI coinDisplayMesh;
|
||||
[SerializeField] public GameObject healthCanvas;
|
||||
[SerializeField] public GameObject wonCanvas;
|
||||
[SerializeField] public GameObject lostCanvas;
|
||||
[SerializeField] private GameObject coinDisplayCanvas;
|
||||
[SerializeField] private GameObject difficultySelectionCanvas;
|
||||
[SerializeField] private GameObject troopSelectionCanvas;
|
||||
[SerializeField] private RawImage highScoreImage;
|
||||
[SerializeField] private RawImage winHighScoreImage;
|
||||
[SerializeField] private RawImage loseHighScoreImage;
|
||||
[SerializeField] private Texture bronzeSprite;
|
||||
[SerializeField] private Texture silverSprite;
|
||||
[SerializeField] private Texture goldSprite;
|
||||
[SerializeField] private Texture notBeatenSprite;
|
||||
[SerializeField] public List<string> levels;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
wonCanvas.SetActive(false);
|
||||
lostCanvas.SetActive(false);
|
||||
coinDisplayCanvas.SetActive(false);
|
||||
troopSelectionCanvas.SetActive(false);
|
||||
coinDisplayMesh = coinDisplay.GetComponent<TextMeshProUGUI>();
|
||||
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
highScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
highScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
highScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
highScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
highScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
coinDisplayMesh.text = currentCoins.ToString();
|
||||
/*
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
if (spawningPhase)
|
||||
{
|
||||
startFight();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void startFight()
|
||||
{
|
||||
troopSelectionCanvas.SetActive(false);
|
||||
spawningPhase = false;
|
||||
combatPhase = true;
|
||||
if (armyManager.getArmy(true).Count == 0)
|
||||
{
|
||||
foundWinner = true;
|
||||
playerWon = true;
|
||||
} else if (armyManager.getArmy(false).Count == 0)
|
||||
{
|
||||
foundWinner = true;
|
||||
playerWon = false;
|
||||
} else {
|
||||
if (!armyManager.getCrownDuck(true))
|
||||
{
|
||||
armyManager.getArmy(true)[0].GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
if (!armyManager.getCrownDuck(false))
|
||||
{
|
||||
armyManager.getArmy(false)[0].GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void endOfLevel(bool thePlayerWon)
|
||||
{
|
||||
combatPhase = false;
|
||||
endOfGamePhase = true;
|
||||
foundWinner = true;
|
||||
playerWon = thePlayerWon;
|
||||
coinDisplayCanvas.SetActive(false);
|
||||
healthCanvas.SetActive(false);
|
||||
if (playerWon)
|
||||
{
|
||||
unlockedLevelsManager.beatCurrentLevel(currentLevel, difficulty);
|
||||
wonCanvas.SetActive(true);
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
winHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
winHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
winHighScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
winHighScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
winHighScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lostCanvas.SetActive(true);
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
loseHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
loseHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
loseHighScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
loseHighScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
loseHighScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool spendCoins(int amount)
|
||||
{
|
||||
if (currentCoins >= amount)
|
||||
{
|
||||
currentCoins -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void refundCoins(int amount)
|
||||
{
|
||||
currentCoins += amount;
|
||||
}
|
||||
|
||||
public void SelectDifficulty(int selectedDifficulty)
|
||||
{
|
||||
difficultySelectionPhase = false;
|
||||
spawningPhase = true;
|
||||
difficulty = selectedDifficulty;
|
||||
coinDisplayCanvas.SetActive(true);
|
||||
troopSelectionCanvas.SetActive(true);
|
||||
difficultySelectionCanvas.SetActive(false);
|
||||
currentCoins = (int)(baseCoins * (difficulty == 1 ? 1.2f : (difficulty == 3 ? 0.8f : 1f)));
|
||||
}
|
||||
|
||||
public void backToMainMenu()
|
||||
{
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
|
||||
public void goToNextLevel()
|
||||
{
|
||||
SceneManager.LoadScene(levels[currentLevel]);
|
||||
}
|
||||
|
||||
public void replayLevel()
|
||||
{
|
||||
SceneManager.LoadScene(levels[currentLevel-1]);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b44c52b4de179af282b4cf5f073b748
|
|
@ -1,95 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MenuManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public GameObject mainPanel;
|
||||
[SerializeField] public GameObject settingsPanel;
|
||||
[SerializeField] public GameObject levelsPanel;
|
||||
[SerializeField] public UnlockedLevelsManager unlockedLevelsManager;
|
||||
[SerializeField] public List<GameObject> levelButtons;
|
||||
[SerializeField] public GameObject lockPrefab;
|
||||
[SerializeField] public GameObject bronzeStarPrefab;
|
||||
[SerializeField] public GameObject silverStarPrefab;
|
||||
[SerializeField] public GameObject goldStarPrefab;
|
||||
[SerializeField] public List<string> levels;
|
||||
|
||||
void Start()
|
||||
{
|
||||
mainPanel.SetActive(true);
|
||||
settingsPanel.SetActive(false);
|
||||
levelsPanel.SetActive(false);
|
||||
|
||||
for (int i = 0; i < levelButtons.Count; i++)
|
||||
{
|
||||
bool didSpawn = false;
|
||||
GameObject spawnedUI = null;
|
||||
switch (unlockedLevelsManager.getLevelStatus(i+1))
|
||||
{
|
||||
case 0:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(lockPrefab);
|
||||
break;
|
||||
case 2:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(bronzeStarPrefab);
|
||||
break;
|
||||
case 3:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(silverStarPrefab);
|
||||
break;
|
||||
case 4:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(goldStarPrefab);
|
||||
break;
|
||||
}
|
||||
|
||||
if (didSpawn)
|
||||
{
|
||||
spawnedUI.transform.SetParent(levelButtons[i].transform, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
mainPanel.SetActive(false);
|
||||
levelsPanel.SetActive(true);
|
||||
//SceneManager.LoadScene("GameScene"); // Replace "GameScene" with your scene name
|
||||
}
|
||||
|
||||
public void OpenSettings()
|
||||
{
|
||||
mainPanel.SetActive(false);
|
||||
settingsPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Debug.Log("Quit Game"); // This won't quit the editor but will work in a built application
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void backToMenu()
|
||||
{
|
||||
mainPanel.SetActive(true);
|
||||
settingsPanel.SetActive(false);
|
||||
levelsPanel.SetActive(false);
|
||||
Debug.Log("Back To Menu"); // This won't quit the editor but will work in a built application
|
||||
}
|
||||
|
||||
public void goToLevel(int level)
|
||||
{
|
||||
//Debug.Log(unlockedLevelsManager.getLevelStatus(level));
|
||||
if (unlockedLevelsManager.getLevelStatus(level) != 0)
|
||||
{
|
||||
SceneManager.LoadScene(levels[level - 1]);
|
||||
Debug.Log("Go To Level " + level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2f8d5c10ecc0fc1984f4b0913b0db37
|
|
@ -1,93 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 91334ba5025ad505fb2c78f519e24dec
|
|
@ -1,198 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class SpawnDucks : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject armyManagerEntity;
|
||||
[SerializeField] GameObject gameManagerEntity;
|
||||
private GameManager gameManagerScript;
|
||||
private ArmyManager armyManagerScript;
|
||||
[SerializeField] private List<GameObject> duckPrefabs;
|
||||
[SerializeField] GameObject theCamera;
|
||||
[SerializeField] GameObject healthCanvas;
|
||||
[SerializeField] GameObject troopSelectionCanvas;
|
||||
//[SerializeField] private List<Sprite> duckImages;
|
||||
[SerializeField] private List<GameObject> troopIcons;
|
||||
[SerializeField] private Sprite chosenCadre;
|
||||
[SerializeField] private Sprite unchosenCadre;
|
||||
private LayerMask groundLayerMask;
|
||||
private LayerMask duckLayerMask;
|
||||
private LayerMask noSpawnLayerMask;
|
||||
private bool didHitGround;
|
||||
|
||||
private RaycastHit hitGround;
|
||||
private RaycastHit hitDuck;
|
||||
private RaycastHit hitNoSpawn;
|
||||
|
||||
private Vector3 directionToMouse;
|
||||
private int whichTroopToSpawn = 0;
|
||||
private GameObject currentlySpawningTroop;
|
||||
private GameObject selectedTroop;
|
||||
[SerializeField] public GameObject troopEditPanel;
|
||||
[SerializeField] private Button crownButton;
|
||||
[SerializeField] private Sprite hasCrownButton;
|
||||
[SerializeField] private Sprite noCrownButton;
|
||||
|
||||
[SerializeField] private Button offenseModeButton;
|
||||
[SerializeField] private Button randomModeButton;
|
||||
[SerializeField] private Button defenseModeButton;
|
||||
|
||||
[SerializeField] private Sprite offenseModeOff;
|
||||
[SerializeField] private Sprite offenseModeOn;
|
||||
[SerializeField] private Sprite randomModeOff;
|
||||
[SerializeField] private Sprite randomModeOn;
|
||||
[SerializeField] private Sprite defenseModeOff;
|
||||
[SerializeField] private Sprite defenseModeOn;
|
||||
private BaseDuckScript selectedTroopScript;
|
||||
[SerializeField] private PastilleManager pastilleManager;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI priceTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI healthTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI movSpeedTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI armorTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI damageTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI attackSpeedTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI descriptionTagMesh;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
troopEditPanel.SetActive(false);
|
||||
groundLayerMask = LayerMask.GetMask("Dirt") | LayerMask.GetMask("Sand");
|
||||
duckLayerMask = LayerMask.GetMask("Duck");
|
||||
noSpawnLayerMask = LayerMask.GetMask("Water") | LayerMask.GetMask("Wall");
|
||||
currentlySpawningTroop = duckPrefabs[0];
|
||||
ActivateDuckCadre(0);
|
||||
updateTroopStats();
|
||||
gameManagerScript = gameManagerEntity.GetComponent<GameManager>();
|
||||
armyManagerScript = armyManagerEntity.GetComponent<ArmyManager>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
choseIfShowTroopEditPanel();
|
||||
if (Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
deactivateDuckCadre(whichTroopToSpawn);
|
||||
whichTroopToSpawn++;
|
||||
whichTroopToSpawn = whichTroopToSpawn % troopIcons.Count;
|
||||
ActivateDuckCadre(whichTroopToSpawn);
|
||||
currentlySpawningTroop = duckPrefabs[whichTroopToSpawn];
|
||||
updateTroopStats();
|
||||
}
|
||||
|
||||
if (gameManagerScript.spawningPhase && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
didHitGround = Physics.Raycast(ray, out hitGround, Mathf.Infinity, groundLayerMask);
|
||||
bool didHitNoSpawn = Physics.Raycast(ray, out hitNoSpawn, Mathf.Infinity, noSpawnLayerMask);
|
||||
bool didHitDuck = Physics.Raycast(ray, out hitDuck, Mathf.Infinity, duckLayerMask);
|
||||
if (didHitDuck && (!didHitNoSpawn || hitDuck.distance < hitNoSpawn.distance) && (!didHitGround || hitDuck.distance <= hitGround.distance))
|
||||
{
|
||||
if (!hitDuck.transform.gameObject.GetComponent<BaseDuckScript>().getTeam())
|
||||
{
|
||||
setSelectedTroop(hitDuck.transform.gameObject);
|
||||
}
|
||||
} else if(didHitGround && (!didHitNoSpawn || hitGround.distance < hitNoSpawn.distance) && (!didHitDuck || hitGround.distance < hitDuck.distance)){
|
||||
if (currentlySpawningTroop.GetComponent<BaseDuckScript>().cost <= gameManagerScript.currentCoins)
|
||||
{
|
||||
GameObject newDuck = Instantiate(currentlySpawningTroop, (hitGround.point + new Vector3(0f, currentlySpawningTroop.transform.Find("TigeUI").GetComponent<Renderer>().bounds.size.y * 0.8f,0f)), Quaternion.identity);
|
||||
BaseDuckScript duckScript = newDuck.GetComponent<BaseDuckScript>();
|
||||
duckScript.setTeam(false);
|
||||
duckScript.setArmyManager(armyManagerEntity);
|
||||
duckScript.setGameManager(gameManagerEntity);
|
||||
duckScript.setHealthCanvas(healthCanvas);
|
||||
gameManagerScript.spendCoins(duckScript.cost);
|
||||
setSelectedTroop(newDuck);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTroopStats()
|
||||
{
|
||||
List<string> troopStats = currentlySpawningTroop.GetComponent<BaseDuckScript>().troopStats;
|
||||
priceTagMesh.text = "Prix : " + troopStats[0];
|
||||
healthTagMesh.text = "PV : " + troopStats[1];
|
||||
movSpeedTagMesh.text = "Vitesse (Déplacement) : " + troopStats[2];
|
||||
armorTagMesh.text = "Armure : " + troopStats[3];
|
||||
damageTagMesh.text = "Dégats : " + troopStats[4];
|
||||
attackSpeedTagMesh.text = "Vitesse (Attaque) : " + troopStats[5];
|
||||
descriptionTagMesh.text = "Description : " + troopStats[6];
|
||||
}
|
||||
|
||||
public void choseIfShowTroopEditPanel()
|
||||
{
|
||||
if (selectedTroop != null)
|
||||
{
|
||||
troopEditPanel.SetActive(true);
|
||||
crownButton.image.sprite = (selectedTroopScript.hasCrown) ? hasCrownButton : noCrownButton;
|
||||
offenseModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 1) ? offenseModeOn : offenseModeOff);
|
||||
randomModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 2) ? randomModeOn : randomModeOff);
|
||||
defenseModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 3) ? defenseModeOn : defenseModeOff);
|
||||
}
|
||||
else
|
||||
{
|
||||
troopEditPanel.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
public void despawnSelectedDuck()
|
||||
{
|
||||
selectedTroopScript.despawn();
|
||||
selectedTroop = null;
|
||||
}
|
||||
|
||||
public void ActivateDuckCadre(int duck)
|
||||
{
|
||||
troopIcons[duck].gameObject.transform.GetChild(1).GetComponent<Image>().sprite = chosenCadre;
|
||||
}
|
||||
|
||||
public void deactivateDuckCadre(int duck)
|
||||
{
|
||||
troopIcons[duck].gameObject.transform.GetChild(1).GetComponent<Image>().sprite = unchosenCadre;
|
||||
}
|
||||
|
||||
public void giveCrownToSelected()
|
||||
{
|
||||
armyManagerScript.giveCrownDuckTo(false, selectedTroop);
|
||||
}
|
||||
|
||||
public void removeCrownFromSelected()
|
||||
{
|
||||
armyManagerScript.removeCrownDuckFrom(false, selectedTroop);
|
||||
}
|
||||
|
||||
public void toggleCrownFromSelected()
|
||||
{
|
||||
if (selectedTroopScript.hasCrown)
|
||||
{
|
||||
removeCrownFromSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
giveCrownToSelected();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedDuckMode(int mode)
|
||||
{
|
||||
selectedTroopScript.setAttackMode(mode);
|
||||
}
|
||||
|
||||
public void setSelectedTroop(GameObject troop)
|
||||
{
|
||||
if (selectedTroop != null)
|
||||
{
|
||||
pastilleManager.setPlayerPastille(selectedTroop);
|
||||
}
|
||||
selectedTroop = troop;
|
||||
selectedTroopScript = selectedTroop.GetComponent<BaseDuckScript>();
|
||||
pastilleManager.setSelectedPastille(troop);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ed16af9570d167a2b8823760227756a
|
|
@ -1,68 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
public class UnlockedLevelsManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool mainMenuLevel;
|
||||
static public List<int> unlockedLevels = null; //0 = locked, 1 = unlocked not beaten, 2 = beaten easy, 3 = beaten medium, 4 = beaten hard
|
||||
private int howManyLevels = 5;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
if (mainMenuLevel)
|
||||
{
|
||||
if (unlockedLevels == null){
|
||||
unlockedLevels = new List<int>();
|
||||
for (int i = 0; i < howManyLevels; i++)
|
||||
{
|
||||
unlockedLevels.Add(0);
|
||||
}
|
||||
|
||||
unlockedLevels[0] = 4;
|
||||
unlockedLevels[1] = 3;
|
||||
unlockedLevels[2] = 2;
|
||||
unlockedLevels[3] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void beatCurrentLevel(int currentLevel, int difficulty) //difficulty = 1,2,3
|
||||
{
|
||||
if (unlockedLevels != null){
|
||||
if (!mainMenuLevel)
|
||||
{
|
||||
if (currentLevel != howManyLevels - 1)
|
||||
{
|
||||
if (unlockedLevels[currentLevel] == 0)
|
||||
{
|
||||
unlockedLevels[currentLevel] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlockedLevels[currentLevel - 1] < difficulty + 1)
|
||||
{
|
||||
unlockedLevels[currentLevel - 1] = difficulty + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLevelStatus(int level)
|
||||
{
|
||||
if (unlockedLevels != null)
|
||||
{
|
||||
return unlockedLevels[level - 1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<int> getAllStatuses()
|
||||
{
|
||||
return unlockedLevels;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f665727602dd2411b714a7aae91bf0d
|
Loading…
Add table
Add a link
Reference in a new issue