public void SetTankType(TankType tankType) { ObjectType objectType = ObjectType.Tank_Green; mTankAttack.Damage = 25f; switch (tankType) { case TankType.Blue: mTankAttack.Damage = 20f; objectType = ObjectType.Tank_Blue; break; case TankType.Red: mTankAttack.Damage = 10f; objectType = ObjectType.Tank_Red; break; } if (mTankModel != null) { mTankModel.Recycle(); } mTankModel = ObjectPool.Instance.GetRecyclableObject(objectType); mTankModel.Spawn(transform.position, transform.rotation, transform); mTankRigidbody.isKinematic = false; }
public static UIEventListenerContext Create(IUIEventListener listener) { UIEventListenerContext context = RecyclableObject.Create <UIEventListenerContext>(); context.m_listener = listener; return(context); }
/// <summary> /// 取出一个游戏对象 /// </summary> /// <returns> 取出的对象 </returns> public GameObject TakeOut() { Awake(); RecyclableObject recyclable = null; while (_storedObjects.Count > 0) { recyclable = _storedObjects.First.Value; _storedObjects.RemoveFirst(); if (recyclable) break; } if (!recyclable) { AddObjects(); recyclable = _storedObjects.First.Value; _storedObjects.RemoveFirst(); } _activeObjects.AddLast(recyclable.node); recyclable.transform.SetParent(null, false); recyclable.gameObject.SetActive(true); recyclable.activeTime = Time.time; return recyclable.gameObject; }
private void AttachRecyclableObjectScript(GameObject goToAttachTo, int idToUse) { if (goToAttachTo.GetComponentInChildren <RecyclableObject>() == null) { RecyclableObject rO = goToAttachTo.AddComponent <RecyclableObject>(); rO.recycleID = idToUse; } }
public static ISingleTween <T> AllocateSingleTween <T>(EnvironmentType env) where T : struct { if (env != EnvironmentType.Ev0) { TweenSingleton.Initialized(); } return(RecyclableObject.Allocate <SingleTween <T> >(env)); }
public void MultipleReleaseTest() { RecyclableObject obj = RecyclableObject.NewInstance(); obj.Release(); var exception = Assert.ThrowsAny <InvalidOperationException>(() => obj.Release()); Assert.True(exception != null); }
void LoadMore(RecyclableObject recyclableObject, int count) { for (int i = 0; i < count; ++i) { var ro = Instantiate(recyclableObject, transform); ro.Init(Recycle); m_PoolContents[recyclableObject.ObjectType].Enqueue(ro); } }
private static T Allocate <T>(EnvironmentType envType) where T : ActionNode { T t = RecyclableObject.Allocate <T>(envType); while (t.disposed) { t = RecyclableObject.Allocate <T>(envType); } return(t); }
public void ReleaseTest() { RecyclableObject obj = RecyclableObject.NewInstance(); obj.Release(); RecyclableObject obj2 = RecyclableObject.NewInstance(); Assert.Same(obj, obj2); obj2.Release(); }
private static T Allocate <T>(FrameworkEnvironment env) where T : ActionNode { T t = RecyclableObject.Allocate <T>(env); while (t.disposed) { t = RecyclableObject.Allocate <T>(env); } return(t); }
public void RecycleObject(RecyclableObject objectToRecycle) { if (this.recyclerDictionary.ContainsKey(objectToRecycle.recycleID)) { this.recyclerDictionary[objectToRecycle.recycleID].RecycleObject(objectToRecycle.gameObject); } else { Debug.Log("You are trying to free an object w/o a recycler. You are looking for id: " + objectToRecycle.recycleID); } }
public void RecycleAtDifferentThreadTest() { RecyclableObject obj = RecyclableObject.NewInstance(); RecyclableObject prevObject = obj; Task.Run(() => { obj.Release(); }).Wait(); obj = RecyclableObject.NewInstance(); Assert.True(obj == prevObject); obj.Release(); }
private bool IsRecycleable(GameObject objectToGet) { RecyclableObject ro = objectToGet.GetComponent <RecyclableObject>(); if (ro == null) { return(false); } else { return(true); } }
private int GetRecyclerID(GameObject goToGet) { if (this.recyclableObjectDictionary.ContainsKey(goToGet)) { return(this.recyclableObjectDictionary[goToGet]); } else { RecyclableObject ro = goToGet.GetComponent <RecyclableObject>(); return(ro.recycleID); } }
public void Recycle(RecyclableType recyclableType) { if (entry == null) { return; } if (entry.TypeRecyclable == recyclableType) { Debug.Log("Good Recycle"); switch (recyclableType) { case RecyclableType.plastic: plasticglasspaper[0].Play(); break; case RecyclableType.glass: plasticglasspaper[1].Play(); break; case RecyclableType.paper: plasticglasspaper[2].Play(); break; } Instantiate(goodRecycleParticlesPrefab, goodRecycleParticleSpawnPoint.transform.position, Quaternion.identity); entry.InteractionSuccess(); entry.DestroyInteractable(); } else { Debug.Log("Bad Recycle"); } CloseRecycler(); entry = null; }
public static void Recycle(UIEventListenerContext context) { RecyclableObject.Recycle(context); }
/// <summary> /// 跑一个线程任务 /// </summary> /// <param name="task"></param> /// <param name="callback"></param> public void RunTask(Action task, Action callback) { lock (CacheArgs) CacheArgs.Enqueue(RecyclableObject.Allocate <ThreadArgs>(this.container.env).Config(task, callback, this)); }
public void CloseRecycler() { entry = null; recyclerUI.SetActive(false); }
public void OpenRecycler(RecyclableObject _entry) { entry = _entry; recyclerUI.SetActive(true); }
void Recycle(RecyclableObject recyclableObject) { recyclableObject.transform.parent = transform; m_PoolContents[recyclableObject.ObjectType].Enqueue(recyclableObject); }
protected override void OnLoad() { this.message.Publish(this, 0, RecyclableObject.Allocate <OnPanelLoadArg>(APP.envType)); }