// 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 ShowOptions(PlayerKinematic player) { Index index = new Index((int)Position.x, (int)Position.y); int cost = 150; if (turretIndexes.ContainsKey(index)) { buildButton.Text = "Upgrade"; label.Text = turretIndexes[index].GetCost().ToString(); cost = turretIndexes[index].GetCost(); range.RectScale = new Vector2(turretIndexes[index].GetRange() * 0.005f, turretIndexes[index].GetRange() * 0.005f); } else { buildButton.Text = "Build Buy"; label.Text = "150"; range.RectScale = new Vector2(1, 1); } if (player.GetSpendingMoney() < cost) { buildButton.Disabled = true; } else { buildButton.Disabled = false; } Visible = true; }
public void ShowOptions(PlayerKinematic player) { this.player = player; int cost = player.GetWeaponDamage() * weaponUpgradeCostMultiplier; label.Text = cost.ToString(); if (player.GetSpendingMoney() < cost) { upgradeButton.Disabled = true; } else { upgradeButton.Disabled = false; } Visible = true; }
public void SetPlayer(PlayerKinematic player) { this.player = player; }