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 }
// Called when the node enters the scene tree for the first time. public void BodyEntered(Node node) { if (node.IsInGroup("Player")) { WinEvent wei = new WinEvent(); wei.FireEvent(); } }
public void BodyEntered(Node body) { if (body.IsInGroup("Player")) { //Fire the win event if the area was collided with WinEvent wei = new WinEvent(); wei.FireEvent(); } }
private void CellConverted(CellConvertEvent ccei) { for (int i = 0; i < cellsLeftToConvert.Count; i++) { if (cellsLeftToConvert[i].GetInstanceId() == ccei.CovertedCell.GetInstanceId()) { cellsLeftToConvert.RemoveAt(i); if (cellsLeftToConvert.Count == 0) { StopGame(); WinEvent wei = new WinEvent(); wei.FireEvent(); } } } }
// Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(float delta) { switch (state) { case ORB_STATE.IDLE: //Looks at the player LookAt(player.GlobalTransform.origin, Vector3.Up); //Start the win timer and after 2 min the player will win the game if he doesn't exit the room winTimer.Start(); if (winTimer.TimeLeft < 0.1) { //Send win message to winEvent WinEvent wei = new WinEvent(); wei.win = true; wei.FireEvent(); } break; case ORB_STATE.CHASE: //Stop the win timer, the game can never be won now winTimer.Stop(); //Looks at the player LookAt(player.GlobalTransform.origin, Vector3.Up); //Check if the distance from the player is more than 4 units if (Transform.origin.DistanceTo(player.Transform.origin) > 3f) { //velocity = (player.GlobalTransform.origin - GlobalTransform.origin).Normalized() * speed * delta; Transform = new Transform(Transform.basis, Transform.origin.LinearInterpolate(player.Transform.origin, speed * delta)); } //Check if the orb location is further than 20 units from the player if (Transform.origin.DistanceTo(player.Transform.origin) > 40f) { //Teleport the orb to the players location is it is further than 20 units, this stops the orb getting stuck problem //what can I say there is nothing like a good brute force solution to game jam games! Transform = new Transform(Transform.basis, player.Transform.origin + (Vector3.Up * 3)); } if (Transform.origin.DistanceTo(player.Transform.origin) < 5) { if (teleportTimer.IsStopped()) { teleportTimer.Start(); } if (teleportTimer.TimeLeft < 0.1) { player.Transform = new Transform(player.Transform.basis, teleportPoint.Transform.origin); } } else { teleportTimer.Stop(); } break; case ORB_STATE.SCAN: //just some eye candy I want to apply later if there is time, all I need is more time! break; case ORB_STATE.TELPORT: //We will just animate the orb shooting the player with a teleport lazer or something later break; } }