//实现回调接口,将用过的飞碟和飞的动作加入到free列表中 public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Competeted, int intParam = 0, string strParam = null, UnityEngine.Object objectParam = null) { if (source is CCFlyAction) { DiskNumber--; DiskFactory df = Singleton <DiskFactory> .Instance; df.FreeDisk(source.gameobject); FreeSSAction(source); } }
SSAction GetSSAction() { SSAction action = null; if (free.Count > 0) { action = free[0]; free.Remove(free[0]); } else { action = ScriptableObject.Instantiate <CCFlyAction>(Fly[0]); } used.Add(action); return(action); }
public void FreeSSAction(SSAction action) { SSAction tmp = null; foreach (SSAction i in used) { if (action.GetInstanceID() == i.GetInstanceID()) { tmp = i; } } if (tmp != null) { tmp.reset(); free.Add(tmp); used.Remove(tmp); } }