update: deploy buttons
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class DeployButton : MonoBehaviour
|
||||
{
|
||||
public TMP_Text textField;
|
||||
public SceneAsset level;
|
||||
|
||||
DeployController dc;
|
||||
|
||||
void Start() {
|
||||
dc = FindFirstObjectByType<DeployController>();
|
||||
}
|
||||
|
||||
public void DeployFromButton() {
|
||||
dc.Deploy(level.name);
|
||||
}
|
||||
|
||||
public void SetLevelInfoText() {
|
||||
LevelInfo levelInfo = GameController.i.GetLevel(level.name);
|
||||
string s = $"HP: {levelInfo.hp}/{levelInfo.maxHp}\nEnemies: {levelInfo.enemies.Values.Sum(x => x)}\nBullet type: {GameController.GetBulletTypeString(levelInfo.factory)}";
|
||||
textField.text = s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91892d4e2104434449afa34292a91d79
|
||||
@@ -1,3 +1,6 @@
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -11,4 +14,9 @@ public class DeployController : MonoBehaviour
|
||||
LevelInfo level = GameController.i.GetLevel(sceneName);
|
||||
SceneManager.LoadScene(level.scene.name);
|
||||
}
|
||||
|
||||
public void SetLevelInfoText(TMP_Text textField, SceneAsset level) {
|
||||
LevelInfo levelInfo = GameController.i.GetLevel(level.name);
|
||||
string s = $"HP: {levelInfo.hp}/{levelInfo.maxHp}\nEnemies: {levelInfo.enemies.Values.Sum(x => x)}\nBullet type: {GameController.GetBulletTypeString(levelInfo.factory)}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,16 @@ public class GameController : MonoBehaviour
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetBulletTypeString(BulletType bulletType) {
|
||||
return bulletType switch {
|
||||
BulletType.Rifle => "Rifle",
|
||||
BulletType.Minigun => "Minigun",
|
||||
BulletType.Rocket => "Rocket",
|
||||
BulletType.Railgun => "Railgun",
|
||||
_ => "None",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
Reference in New Issue
Block a user