public override void _ExitTree() { MainEvent.UnregisterListener(UIEventFired); UnitDeathEvent.UnregisterListener(EndGame); WinEvent.UnregisterListener(WinTriggered); LoseEvent.UnregisterListener(LostTriggered); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { UnitDeathEvent.RegisterListener(UnitDeath); WinEvent.RegisterListener(WinTriggered); LoseEvent.RegisterListener(LoseTriggered); //Grab all the references for the scenes menuPanel = GetNode <Node2D>("Menu"); winPanel = GetNode <Node2D>("Win"); losePanel = GetNode <Node2D>("Lose"); creditsPanel = GetNode <Node2D>("Credits"); uiPanel = GetNode <Node2D>("UI"); background = GetNode <Sprite>("Background"); //Grab a refference to all the buttons that we have startBtn = GetNode <Button>("Start"); exitBtn = GetNode <Button>("Exit"); menuBtn = GetNode <Button>("Menubtn"); smallExitBtn = GetNode <Button>("SmallExit"); creditsBtn = GetNode <Button>("Creditsbtn"); //The buttons for the menu startBtn.Connect("pressed", this, nameof(ShowUI)); exitBtn.Connect("pressed", this, nameof(ExitGame)); menuBtn.Connect("pressed", this, nameof(ShowMenu)); smallExitBtn.Connect("pressed", this, nameof(ExitGame)); creditsBtn.Connect("pressed", this, nameof(ShowCredits)); //Hide all the scenes at start up HideAll(); ShowMenu(); }
private void UnitDeath(UnitDeathEvent ude) { if (ude.UnitNode.IsInGroup("Player")) { ShowLose(); } }
public void EnemyDies(UnitDeathEvent deathEvent) { //Check if the destroyd object was in the enemy group deathEvent.UnitNode.IsInGroup("Enemies"); { //Subtract from thte enemy list enemyCount--; } if (enemyCount == 0) { //Add to the wave level waveLevel++; //Start the new wave timer countdown waveTimer.Start(); } //Check if the wave level is done if (waveLevel == 11) { //Create a new win event ad populate it WinEvent win = new WinEvent(); win.won = true; win.FireEvent(); UIEvent uiEvent = new UIEvent(); uiEvent.winActive = true; uiEvent.FireEvent(); } //Go through the list of enemies and remove them from the list and then check if the list is empty if the list is //empty then the next wave function is called }
void OnDisable() { UnitDeathEvent.UnregisterListener(OnEnemyUnitDeath); EnemyAttackEvent.UnregisterListener(OnEnemyUnitAttack); LeftMouseSelectEvent.UnregisterListener(OnLeftMouseSelected); RightMouseSelectEvent.UnregisterListener(OnRightMouseClick); PlayerAttackEvent.UnregisterListener(OnAttacked); }
private void Die(GameObject gameObj, GameObject killer) { UnitDeathEvent unitDeath = new UnitDeathEvent(); unitDeath.expDropped = 50; unitDeath.UnitDied = gameObj; unitDeath.UnitKiller = killer; unitDeath.FireEvent(); Destroy(gameObj); }
void Die() { // I am dying for some reason. UnitDeathEvent udei = new UnitDeathEvent(); udei.Description = "Unit " + this.Name + " has died."; udei.UnitNode = (Node2D)GetParent(); udei.FireEvent(); //Remove the parent node forn the scene udei.UnitNode.QueueFree(); }
public void Die(GameObject gameObj) { //Die if (gameObject != null) { UnitDeathEvent unitDeathEvent = new UnitDeathEvent(); unitDeathEvent.UnitDied = gameObj; unitDeathEvent.expDropped = 50; unitDeathEvent.FireEvent(); Destroy(gameObj); Debug.Log(gameObj.name + " died"); } }
public void TakeDamage(int damage) { health -= damage; if (health <= 0) { // Unit is dead, so need to tell anything that cares about it before the object is destroyed UnitDeathEvent deathEvent = new UnitDeathEvent(); deathEvent.UnitGO = gameObject; deathEvent.FireEvent(); GameObject.Destroy(gameObject); } }
private void EndGame(UnitDeathEvent ude) { if (ude.UnitNode.IsInGroup("Player")) { enemySpawner.QueueFree(); crystal.QueueFree(); player.QueueFree(); map.QueueFree(); } if (ude.UnitNode.Name == "Crystal") { LoseEvent lei = new LoseEvent(); lei.lost = true; lei.FireEvent(); } }
private void OnEnemyUnitDeath(UnitDeathEvent unitDeath) { if (unitDeath.UnitKiller == gameObject) { stats.CurrentExp += unitDeath.expDropped; if (stats.CurrentExp >= stats.ExpToNextLevel) { LevelUp(); } } if (attackedObject == unitDeath.UnitDied) { //Debug.Log("stopAttacking = true"); stopAttacking = true; } }
// Called when the node enters the scene tree for the first time. public override void _Ready() { //Grabs the map scene from the Scene tree on the games start up mapScene = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene; playerScene = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene; crystalScene = ResourceLoader.Load("res://Scenes/Crystal.tscn") as PackedScene; enemySpawnerScene = ResourceLoader.Load("res://Scenes/EnemySpawner.tscn") as PackedScene; UIScene = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene; missilePickupScene = ResourceLoader.Load("res://Scenes/MissilePickup.tscn") as PackedScene; MainEvent.RegisterListener(UIEventFired); UnitDeathEvent.RegisterListener(EndGame); WinEvent.RegisterListener(WinTriggered); LoseEvent.RegisterListener(LostTriggered); ui = UIScene.Instance(); ui.Name = "UI"; AddChild(ui); }
public override void _Ready() { waveTimer = GetNode <Timer>("StartWaveTimer"); //Connect to the Start wave timers timout method waveTimer.Connect("timeout", this, nameof(Countdown)); //Start the new wave timer countdown waveTimer.Start(); //Regestir the Unit death event to listn for unit deaths UnitDeathEvent.RegisterListener(EnemyDies); //Get a refference to the map, used later map = GetNode <TileMap>("../Map/TileMap"); //Add the different enemies that cna be spawned enemyScenes.Add(ResourceLoader.Load("res://Scenes/SmallTank.tscn") as PackedScene); //enemyScenes.Add(ResourceLoader.Load("res://Scenes/LargeTank.tscn") as PackedScene); //Load the traps that are used later trapScene = ResourceLoader.Load("res://Scenes/Trap.tscn") as PackedScene; //Set up the traps as needed SetTraps(); }
void OnDestroy() { UnitDeathEvent.UnregisterListener(OnUnitDied); }
public override void _ExitTree() { UnitDeathEvent.UnregisterListener(UnitDeath); WinEvent.UnregisterListener(WinTriggered); LoseEvent.UnregisterListener(LoseTriggered); }
void OnEnable() { UnitDeathEvent.RegisterListener(OnUnitDeath); }
void OnUnitDeath(UnitDeathEvent unitDeathEvent) { enemyInfoUI.text = "Enemy Health: 0"; StartCoroutine("WaitAndUpdate"); }
// Use this for initialization void Start() { UnitDeathEvent.RegisterListener(OnUnitDied); }
void OnUnitDied(UnitDeathEvent unitDeath) { GD.Print("Alerted about unit death: " + unitDeath.UnitNode.Name); }
public override void _ExitTree() { UnitDeathEvent.UnregisterListener(EnemyDies); }