using UnityEngine; using System.Collections; using System.Collections.Generic; namespace DevelopEngine { /// /// Cheats. /// public class Cheats : MonoSingleton { /// /// The cheat delegate. /// public delegate string Exec (params string[] values); /// /// The cheats. /// private Dictionary mCheats = new Dictionary(); void Start () { gameObject.hideFlags = HideFlags.HideAndDontSave; } /// /// Regists the cheat. /// public static bool RegistCheat (string name, Exec cheat) { return Instance.AddCheat(name, cheat); } /// /// Adds the cheat. /// private bool AddCheat (string name, Exec cheat) { if (mCheats.ContainsKey(name)) return false; mCheats.Add(name, cheat); return true; } /// /// Executes the cheat. /// /// /// Name. /// /// /// Values. /// public static string ExecuteCheat (string name, params string[] values) { return Instance.ExecCheat(name, values); } /// /// Executes the cheat. /// /// /// Name. /// /// /// Values. /// private string ExecCheat (string name, params string[] values) { Exec cheat; if (mCheats.TryGetValue(name, out cheat)) { if (cheat != null) { return cheat(values); } } return "***unknown command***"; } } }