// 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 HandleAttack() * { * while(attackedObject != null) * { * if (rdyToAttack && attack) * { * //Debug.Log("Time since last attack: " + (Time.time - timeSinceAttack)); * if (Time.time - timeSinceAttack > stats.AttackCooldown) * { * timeSinceAttack = Time.time; * Vector3 lookAtVec = new Vector3(attackedObject.transform.position.x, transform.position.y, attackedObject.transform.position.z); * transform.LookAt(lookAtVec); * * if (animatorController != null) * animatorController.Attack(); * * if (attackedObject != null) * { * //AttackEvent(hit.transform.gameObject, damage); * PlayerAttackEvent unitAttackEvent = new PlayerAttackEvent(); * unitAttackEvent.Description = "Unit " + gameObject.name + " has attacked."; * unitAttackEvent.UnitAttacked = attackedObject; * unitAttackEvent.UnitAttacker = gameObject; * unitAttackEvent.UnitStats = stats; * unitAttackEvent.FireEvent(); * * } * } * } * } * }*/ void OnEnable() { UnitDeathEvent.RegisterListener(OnEnemyUnitDeath); EnemyAttackEvent.RegisterListener(OnEnemyUnitAttack); LeftMouseSelectEvent.RegisterListener(OnLeftMouseSelected); RightMouseSelectEvent.RegisterListener(OnRightMouseClick); PlayerAttackEvent.RegisterListener(OnAttacked); }
// 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(); }
// Use this for initialization void Start() { UnitDeathEvent.RegisterListener(OnUnitDied); }
void OnEnable() { UnitDeathEvent.RegisterListener(OnUnitDeath); }