/// <summary> /// Создает стандартный ресетер /// </summary> /// <param name="target"> Целевой объект для сброса </param> /// <param name="requireResetAttributeInfo"> Информация о параметрах сброса </param> public StandardResetHandler(IResetable target, RequireResetAttribute requireResetAttributeInfo = null) { _target = target; _info = requireResetAttributeInfo ?? _target.GetType().GetCustomAttributes(typeof(RequireResetAttribute), true).OfType <RequireResetAttribute>(). FirstOrDefault() ?? new RequireResetAttribute(); }
/// <summary> /// Queues an object for resetting at the beginning of the next frame. /// </summary> /// <param name="o">The entity to be reset.</param> internal void QueueReset(IResetable o) { if (!_pendingReset.Contains(o)) { _pendingReset.Enqueue(o); } }
public void Sleep(int miliseconds, WarriorState state, IResetable resetable) { Thread.Sleep(miliseconds); if (state.State != State.Interrupted) { resetable.Reset(); } }
public void Reset() { IResetable channelModule = (IResetable)ChannelModule; channelModule.Reset(); VolumeModule.Reset(); InvokeEventStatusChanged(String.Format("{0}:\t \"{1}\" has reseted.", this.GetType(), name)); }
public static void Unregister(IResetable resetable, params string[] keys) { foreach (string key in keys) { if (resetables.TryGetValue(key, out List <IResetable> result)) { result.RemoveAll(x => Equals(x, resetable)); } } }
/// <summary> /// Adds a GameObject to the list of things to be reset at gameover /// </summary> /// <param name="go">Component to reset at gameover.</param> public void AddResetableObject(IResetable component, ResetableType type) { if (type == ResetableType.GameOver) { _resetablesGameOver.Add(component); } else if (type == ResetableType.BallOver) { _resetablesBallOver.Add(component); } }
public static void RemoveResetableItemFromList(IResetable item) { if (itemToBeRemoved == null) { itemToBeRemoved = new List <IResetable>(); } itemToBeRemoved.Add(item); if (isResetting == false) { RemoveResetableItems(); } }
public static void Register(IResetable resetable, params string[] keys) { foreach (string key in keys) { if (!resetables.TryGetValue(key, out List <IResetable> result)) { result = new List <IResetable>(); resetables.Add(key, result); } result.Add(resetable); } }
public void UnRegister(IResetable t, string identifier) { if (this.Resetables.ContainsKey(identifier)) { #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Environment {this.name} unregistered resetable {identifier}"); } #endif this.Resetables.Remove(identifier); } }
// 使用 void UseObject(GameObject go, Vector3 pos, Quaternion rotate) { go.transform.position = pos; go.transform.rotation = rotate; go.SetActive(true); // 对于 实现了 重置接口的 对象 重置一下 IResetable reset = go.GetComponent <IResetable> (); if (reset != null) { reset.OnReset(); } }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="resetable"></param> /// <param name="identifier"></param> public void Register(IResetable resetable, string identifier) { if (!this.Resetables.ContainsKey(identifier)) { #if NEODROID_DEBUG if (this.Debugging) { Debug.Log($"Environment {this.name} has registered resetable {identifier}"); } #endif this.Resetables.Add(identifier, resetable); } else { #if NEODROID_DEBUG if (this.Debugging) { Debug.Log( $"WARNING! Please check for duplicates, Environment {this.name} already has resetable {identifier} registered"); } #endif } }
public void OnRestart() { foreach (GameObject item in ItemsToReset) { item.SetActive(true); IResetable resetable = item.GetComponentInChildren <IResetable>(); if (resetable != null) { resetable.Reset(); } } ScoreManager.Instance.SetScore(this); TimeManager.Instance.Continue(); player.transform.parent = null; player.transform.position = new Vector3(m_RebirthPos.x, m_RebirthPos.y, 0); //回归初始位置 player.transform.rotation = new Quaternion(0, 0, 0, 0); //初始旋转角 player.GetComponent <Rigidbody2D>().velocity = Vector3.zero; //质心速度清零 player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll; //角速度清零 player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None; player.GetComponent <Rigidbody2D>().isKinematic = false; m_deathing = false; }
public void AddResetable(IResetable resetable) => resetables.Add(resetable);
/// <summary> /// Register a resetable on this level. /// </summary> public void RegisterResetable(IResetable _resetable) => resetables.Add(_resetable);
private void GoTwoWordsCommands() { if (CheckDeviseType(command[0])) { if ("create" == command[1].ToLower()) { CreateNewDevice(); } else { command = null; throw new ArgumentException("Command is wrong"); } } else if ("delete" == command[1].ToLower()) { if (deviceList.ContainsKey(command[0])) { deviceList.Remove(command[0]); Console.WriteLine("Device {0} has been removed", command[0]); } else { throw new ArgumentException("Wrong device name"); } } else if ("on" == command[1].ToLower()) { IEnablable device = deviceList[command[0]]; device.On(); } else if ("off" == command[1].ToLower()) { IEnablable device = deviceList[command[0]]; device.Off(); } else if ("defrost" == command[1].ToLower()) { if (deviceList[command[0]] is IDefrostable) { IDefrostable device = (IDefrostable)deviceList[command[0]]; device.Defrost(); } else { throw new ArgumentException("Wrong device"); } } else if ("reset" == command[1].ToLower()) { if (deviceList[command[0]] is IResetable) { IResetable device = (IResetable)deviceList[command[0]]; device.Reset(); } else { throw new ArgumentException("Wrong device"); } } else if ("write" == command[1].ToLower()) { if (deviceList[command[0]] is IGetChannelList) { IGetChannelList device = (IGetChannelList)deviceList[command[0]]; List <string> channelList = device.GetChannelList(); Console.WriteLine("Channel list of {0}", command[0]); foreach (string item in channelList) { Console.WriteLine(item); } Console.ReadLine(); } else { throw new ArgumentException("Wrong device"); } } else { throw new ArgumentException("Wrong command"); } }
public override void Init(PetParameter _petParameter) { resetable = _petParameter.Resetable; resetable?.AddCooldownRef(this); }
public void Sleep(int miliseconds, WarriorState state, IResetable resetable) { }
public void Reset(IResetable resetable) { }
/// <summary> /// </summary> /// <param name="resetable"></param> public void UnRegister(IResetable resetable) { this.UnRegister(resetable, resetable.Identifier); }