Init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Demo
|
||||
{
|
||||
[CommandPrefix("demo.gate.")]
|
||||
public class Gate : MonoBehaviour
|
||||
{
|
||||
[Command("opened")]
|
||||
private bool IsOpened
|
||||
{
|
||||
get { return GetComponent<Animator>().GetBool("opened"); }
|
||||
set { GetComponent<Animator>().SetBool("opened", value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06154700427c64e98af05ecbe66cac48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using QFSW.QC.Actions;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Demo
|
||||
{
|
||||
[CommandPrefix("demo.robot.")]
|
||||
public class Robot : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject deathFX = null;
|
||||
|
||||
[Command("speed")]
|
||||
private static float robotSpeed = 25f;
|
||||
|
||||
[Command("rotation-speed")]
|
||||
private static float robotRotationSpeed = 40f;
|
||||
|
||||
private Vector2 direction;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpriteRenderer rend = GetComponent<SpriteRenderer>();
|
||||
rend.color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1);
|
||||
|
||||
float size = Random.Range(0.8f, 1.2f);
|
||||
transform.localScale = new Vector3(size, size, size);
|
||||
|
||||
direction = Quaternion.Euler(0, 0, Random.Range(0, 306f)) * Vector3.up;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
GetComponent<Rigidbody2D>().AddForce(direction * robotSpeed * Time.fixedDeltaTime, ForceMode2D.Force);
|
||||
direction = Quaternion.Euler(0, 0, robotRotationSpeed * Time.fixedDeltaTime) * direction;
|
||||
}
|
||||
|
||||
[Command("kill-select")]
|
||||
private static IEnumerator<ICommandAction> KillAction()
|
||||
{
|
||||
Robot robot = default;
|
||||
IEnumerable<Robot> robots = InvocationTargetFactory.FindTargets<Robot>(MonoTargetType.All);
|
||||
|
||||
yield return new Value("Please select a robot");
|
||||
yield return new Choice<Robot>(robots, r => robot = r);
|
||||
|
||||
robot.Die();
|
||||
yield return new Typewriter($"{robot.name} has been killed");
|
||||
}
|
||||
|
||||
[Command("kill", MonoTargetType.Argument)]
|
||||
[Command("kill-multi", MonoTargetType.ArgumentMulti)]
|
||||
[Command("kill-all", MonoTargetType.All)]
|
||||
public void Die()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Destroy(Instantiate(deathFX, transform.position, Quaternion.identity), 3);
|
||||
}
|
||||
|
||||
[Command("position", MonoTargetType.All)]
|
||||
private Vector3 GetPosition()
|
||||
{
|
||||
return transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b1afda062bbc4058bf752265765c413
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using QFSW.QC.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Demo
|
||||
{
|
||||
public class RobotCollector : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI text = null;
|
||||
[SerializeField] private QuantumTheme theme = null;
|
||||
|
||||
public int RescueCount { [Command("demo.rescue-count")] get; set; }
|
||||
|
||||
private void Start() { UpdateText(); }
|
||||
private void UpdateText()
|
||||
{
|
||||
if (!theme) { text.text = $"{RescueCount} robots saved"; }
|
||||
else { text.text = $"{RescueCount.ToString().ColorText(theme.DefaultReturnValueColor)} robots saved"; }
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Player"))
|
||||
{
|
||||
Robot robot = collision.gameObject.GetComponent<Robot>();
|
||||
robot.Die();
|
||||
RescueCount++;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8089849882bad4d37821d7ee458144e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using QFSW.QC.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Demo
|
||||
{
|
||||
public class RobotSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Robot robotPrefab = null;
|
||||
[SerializeField] private TextMeshProUGUI text = null;
|
||||
[SerializeField] private QuantumTheme theme = null;
|
||||
|
||||
public int SpawnCount { [Command("demo.spawn-count")] get; private set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UpdateText();
|
||||
SpawnRobot(3);
|
||||
QuantumParser.AddNamespace("QFSW.QC.Demo");
|
||||
}
|
||||
|
||||
private void UpdateText()
|
||||
{
|
||||
if (!theme) { text.text = $"{SpawnCount} robots spawned"; }
|
||||
else { text.text = $"{SpawnCount.ToString().ColorText(theme.DefaultReturnValueColor)} robots spawned"; }
|
||||
}
|
||||
|
||||
[Command("demo.spawn-robot", MonoTargetType.Single)]
|
||||
private void SpawnRobot(int count = 1)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
SpawnCount++;
|
||||
Vector3 position = transform.position;
|
||||
position += new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
|
||||
Instantiate(robotPrefab, position, Quaternion.identity).name = $"Robot {SpawnCount}";
|
||||
}
|
||||
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5db368681e5f4c6eb1e484e8d786e27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user