// Called when the node enters the scene tree for the first time. public override void _Ready() { var levelInitVariable = (LevelInitVariable)GetNode("/root/LevelInitVariable"); this.playerKinematic = GetNode <PlayerKinematic>("PlayerKinematic"); this.betweenRoundTimer = GetNode <Timer>("BetweenRoundTimer"); this.spawnTimer = GetNode <Timer>("SpawnTimer"); this.roundStartSound = GetNode <AudioStreamPlayer2D>("RoundStartSound"); this.highScoreSaveData = GetNode <HighScoreSaveData>("HighScoreSaveData"); this.turretCreatorNode = (TurretCreator)TurretCreatorScene.Instance(); this.turretCreatorNode.init(this); this.turretCreatorNode.Visible = false; this.weaponUpgrader = (WeaponUpgrader)WeaponUpgraderScene.Instance(); this.weaponUpgrader.Visible = false; AddChild(turretCreatorNode); AddChild(weaponUpgrader); playerKinematic.AddTurret(turretCreatorNode); playerKinematic.AddWeaponUpgrader(weaponUpgrader); this.playerKinematic.SetRoundState(RoundState.TOWER_DEFENCE); enemies = new Enemy[maxEnemies]; playerKinematic.SetRound(round); saved = false; this.levelIndex = levelInitVariable.levelIndex; Init(levelIndex); }
public void AddTurret(TurretCreator turretCreatorNode) { this.turretCreatorNode = turretCreatorNode; turretCreatorNode.SetPlayer(this); }