public GameObject GetNewEnemyFromType(Enumerations.EnemyType enemyType) { if (InactiveObjects.Exists(x => x.GetComponent(enemyType.ToString()))) { var poolObject = InactiveObjects.Find(x => x.GetComponent(enemyType.ToString())); var anim = GetComponentInChildren <Animator> (); anim.SetBool("isDead", false); ActiveObjects.Add(poolObject); InactiveObjects.Remove(poolObject); poolObject.transform.parent = transform; // Initialize happens later Enemy pooledEnemy = poolObject.GetComponent <Enemy>(); pooledEnemy.Repool(); poolObject.SetActive(true); return(poolObject); } //Debug.LogWarning(enemyType); var GO = PrefabPool.Find(x => x.GetComponent(enemyType.ToString()) != null); if (GO == null) { var msg = string.Format("No object found with type '{0}'.", enemyType); Debug.LogError(msg, gameObject); } var resultGO = GameObject.Instantiate(GO) as GameObject; ActiveObjects.Add(resultGO.gameObject); resultGO.transform.parent = transform; return(resultGO); }
public void PoolEnemyObject(GameObject enemyGameObject) { //Debug.LogError("Pooling " + enemyGameObject.GetInstanceID() + enemyGameObject.GetComponent("Enemy").GetType()); enemyGameObject.SetActive(false); ActiveObjects.Remove(enemyGameObject); InactiveObjects.Add(enemyGameObject); }
/// <summary> /// Add to the list of actives /// </summary> /// <param name="objsToAdd">Objects to add</param> public void AddActives(params GameObject[] objsToAdd) { List <GameObject> actives = ActiveObjects.ToList(); actives.AddRange(objsToAdd); SetActive(actives.Distinct().ToArray()); }
public GameObject GetObject() { GameObject obj; if (AvailableObjects.Count > 0) { obj = AvailableObjects[0]; AvailableObjects.RemoveAt(0); try { obj.SetActive(true); } catch (MissingReferenceException e) { Debug.LogError("MRE from " + gameObject.name); throw e; } } else { //None available, so create a new one obj = Instantiate(prefab); } //Prep the object for the game world before returning obj.transform.parent = null; obj.transform.position = Vector3.zero; obj.transform.rotation = Quaternion.identity; obj.transform.localScale = Vector3.one; ActiveObjects.Add(obj); return(obj); }
/// <summary> /// Удалить активный объект с карты /// </summary> /// <param name="Id">Идентификатор объекта</param> public void RemoveActiveObject(Guid Id) { MapActiveObjectState ActiveObject = GetActiveObjectById(Id); DeAttachActiveObject(ActiveObject); ActiveObjects.Remove(Id); }
public GameObject GetNewProjectileFromType(Enumerations.ProjectileTypes bulletType, Vector3 startPos, Quaternion startRot) { //Debug.Log(string.Format("Fetching object with type '{0}'.", bulletType)); if (InactiveObjects.Exists(x => x.GetComponent(bulletType.ToString()))) { Debug.Log(string.Format("Object found in pool.")); var poolObject = InactiveObjects.Find(x => x.GetComponent(bulletType.ToString())); ActiveObjects.Add(poolObject); InactiveObjects.Remove(poolObject); poolObject.transform.parent = transform; poolObject.transform.rotation = startRot; poolObject.SetActive(true); return(poolObject); } var GO = PrefabPool.Find(x => x.GetComponent(bulletType.ToString()) != null); if (GO == null) { var msg = string.Format("No object found with type '{0}'.", bulletType); Debug.LogError(msg, gameObject); } var resultGO = GameObject.Instantiate(GO, startPos, startRot) as GameObject; ActiveObjects.Add(resultGO.gameObject); resultGO.transform.parent = transform; return(resultGO); }
public bool Register(GameObject _object) { if (_object == null || !Enabled) { return(false); } bool _added = false; if (!IsRegistered(_object)) { ActiveObjects.Add(_object); _added = true; ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>(); // if the object is an ICE entity we have to adapt the parent according to it's hierarchy settings if (_entity != null && _entity.UseHierarchyManagement) { _object.transform.SetParent(UpdateGroupParent(), true); } if (_entity != null) { OnGroupMessage += _entity.Message.ReceiveGroupMessage; } } return(_added); }
static void SqlDataUtility_SqlCommandExecuted(ActiveObjects.SqlServer.SqlCommandType type, string command, Dictionary<string, object> parameters) { int queries = totalQueries++; HttpContext context = HttpContext.Current; string url = context != null && context.Request != null ? context.Request.RawUrl : null; if (context != null && context.Items != null) { int queryCount = 0; if (context.Items.Contains("SqlServerQueryCount")) { int.TryParse(context.Items["SqlServerQueryCount"].ToString(), out queryCount); context.Items.Remove("SqlServerQueryCount"); } queryCount++; context.Items.Add("SqlServerQueryCount", queryCount); } if (log.IsDebugEnabled) { log.DebugFormat( "SQL|{4}|{0}|{1}|{2}|{3}", command, type, Mubble.Models.Tools.GetParametersString(parameters), totalQueries++, url ); } }
public bool Deregister(GameObject _object) { if (_object == null || !Enabled) { return(false); } ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>(); if (_entity != null) { OnGroupMessage -= _entity.Message.ReceiveGroupMessage; } if (SuspendedObjects.Count > 0) { SuspendedObjects.Remove(_object); } if (ActiveObjects.Count > 0) { return(ActiveObjects.Remove(_object)); } else { return(false); } }
/// <summary> /// Add all the objects in ObjectsToAdd to ActiveObjects, then update ActiveObjects before deleting objects in ObjectsToRemove /// </summary> /// <param name="elapsedGameTime">The seconds that have elapsed since the last update loop</param> public override void Update(float elapsedGameTime) { // Always call the super class' function - it will deal with whether it should run it itself base.Update(elapsedGameTime); // Add the objects and then clear the list - it is only a temporary holder ActiveObjects.AddRange(ObjectsToAdd); ObjectsToAdd.Clear(); // Loop through the active object foreach (T obj in ActiveObjects) { if (obj.ShouldUpdate) { // Update the object obj.Update(elapsedGameTime); } } // Remove all the objects that are no longer alive ActiveObjects.RemoveAll(x => x.IsAlive == false); // Remove all the objects we have marked to remove foreach (T obj in ObjectsToRemove) { ActiveObjects.Remove(obj); } ObjectsToRemove.Clear(); // Clear the list - it is only a temporary holder }
public void Initialize() { ActiveObjects.Add(new Player(PlayerStart)); ActiveObjects.AddRange(StaticObjects); ActiveObjects.AddRange(EnemyDots); ActiveObjects.AddRange(Coins); ActiveObjects.Add(Goal); }
/// <summary> /// Returns the most recent child we added which is castable to the inputted type. /// Shouldn't really be called unless we have children /// </summary> /// <returns>The most recent child we added</returns> public K LastChild <K>() where K : T { K lastChildOfType = ActiveObjects.FindLast(x => x is K) as K; DebugUtils.AssertNotNull(lastChildOfType); return(lastChildOfType); }
/// <summary> /// Returns the most recent child we added which is castable to the inputted type and satisfies the inputted condition. /// Shouldn't really be called unless we have children /// </summary> /// <returns>The most recent child we added</returns> public K LastChild <K>(Predicate <K> condition) where K : T { K lastChildOfType = ActiveObjects.FindLast(x => x is K && condition(x as K)) as K; DebugUtils.AssertNotNull(lastChildOfType); return(lastChildOfType); }
private void _Despawn(GameObject toDespawn) { toDespawn.SetActive(false); toDespawn.transform.parent = Holder.transform; ActiveObjects.Remove(toDespawn); InactiveObjects.Add(toDespawn); }
private void MarkPassedObjects() { // Call OnObjectLeft on all passed objects // Also handle addition/removal of active objects for (int i = 0; i < objectsInView.Count;) { double startingPosition = GetObjectGroupStartingPosition(objectsInView[i]); double endingPosition = GetObjectGroupEndingPosition(objectsInView[i]); if (endingPosition < position) { if (ActiveObjects.Contains(objectsInView[i])) { objectsToDeactivate.Add(objectsInView[i]); } else { // This should be single hit object objectsToActivate.Add(objectsInView[i]); objectsToDeactivate.Add(objectsInView[i]); } OnObjectLeft(objectsInView[i]); objectsInView.RemoveAt(i); } else { // Use actual starting postion startingPosition = objectsInView[i].AbsolutePosition; // Handle new active objects if (startingPosition < position) { if (!activeObjects.Contains(objectsInView[i])) { objectsToActivate.Add(objectsInView[i]); } } i++; } } // Call OnMeasureLeft on all passed measures for (int i = 0; i < measuresInView.Count;) { var measureEnd = measuresInView[i].AbsolutePosition + measuresInView[i].TimingPoint.MeasureDuration; if (measureEnd < position || measuresInView[i].AbsolutePosition > endPosition) { OnMeasureLeft(measuresInView[i]); measuresInView.RemoveAt(i); } else { i++; } } }
/// <summary> /// Adds the given GameObject to this pool. If despawn is true, also despawns the object. /// </summary> private void Bind(GameObject gameObject, bool despawn) { ActiveObjects.Add(gameObject); if (despawn) { Despawn(gameObject); } }
public ReplayGameObject SpawnObject(GameObject go) { int newObjectId = NextIdentifier; var result = new ReplayGameObject(newObjectId, go); ActiveObjects.Add(result); return(result); }
/// <summary> /// Получить активный объект по идентификатору /// </summary> /// <param name="Id">Идентификатор</param> /// <returns>Объект</returns> public MapActiveObjectState GetActiveObjectById(Guid Id) { if (Id == null) { throw new ArgumentNullException("Id", "Id cannot be null"); } if (!ActiveObjects.ContainsKey(Id)) { throw new ArgumentException("ActiveObject", "This ActiveObject not found"); } return(ActiveObjects[Id]); }
public bool DestroyObject(GameObject go) { var resObj = ActiveObjects.FirstOrDefault(x => x.SourceObject == go); if (resObj != null) { ActiveObjects.Remove(resObj); return(true); } return(false); }
void UpdatePossiblePosition(GameObject obj, Vector2 newPos, bool recycle) { bool isStatic = IsStaticObject(obj.tag); //Check the has-object-pos dictionary if (recycle) // reuse { //In the possible position, add the current pos stored in the object dict and remove the new pos if (isStatic) { //Debug.Log("Add " + staticObjectDicts[obj] + " Remove " + newPos + " Obj name:" + obj.name); possiblePositions.Add(staticObjectDicts[obj]); staticObjectDicts[obj] = newPos; RemovePossiblePosition(possiblePositions, newPos); } else { //Debug.Log("Add " + dynamicObjectDicts[obj] + " Remove " + newPos + " Obj name:" + obj.name); possiblePositions.Add(dynamicObjectDicts[obj]); dynamicObjectDicts[obj] = newPos; RemovePossiblePosition(possiblePositions, newPos); } } else //Instantiate new object { //In the possible positions list, just remove the current pos if (isStatic) { if (IsExists(newPos, staticObjectDicts)) { return; } staticObjectDicts.Add(obj, newPos); RemovePossiblePosition(possiblePositions, newPos); //Debug.Log("remove: " + newPos); } else { if (IsExists(newPos, dynamicObjectDicts)) { return; } dynamicObjectDicts.Add(obj, newPos); RemovePossiblePosition(possiblePositions, newPos); ActiveObjects.Add(obj); } //Debug.Log("Remove " + newPos + "Obj name: " + obj.name + "status: " + status); } }
public void Reset() { (Globals.ActiveScene.ActiveObjects.First(x => x is Player) as Player).Reset(PlayerStart); AquiredCoins = 0; ActiveObjects.ForEach(x => { if (!(x is Coin)) return; ActiveObjects.Remove(x); }); ActiveObjects.AddRange(GetCoins()); }
public void Insert(GameObject gameObject) { gameObject.transform.DOKill(); if (gameObject.activeInHierarchy) { gameObject.SetActive(false); } PooledObject obj = poolObjectLookup[gameObject]; ActiveObjects.Remove(obj); Push(obj); }
public virtual IEnumerable<ActiveObjects.IActiveObject> FilterData(ActiveObjects.IActiveCollection data) { IEnumerable<IActiveObject> e = data as IEnumerable<IActiveObject>; if (e == null) { List<IActiveObject> list = new List<IActiveObject>(data.Count); foreach (IActiveObject obj in data) { list.Add(obj); } e = list; } return e; }
/// <summary> /// Идентификатор размещения активного объекта /// </summary> /// <param name="ActiveObject">Активный объект</param> /// <returns>Идентифкатор размещения</returns> public Guid GetIdOfActiveObject(MapActiveObjectState ActiveObject) { if (ActiveObject == null) { throw new ArgumentNullException("ActiveObject", "ActiveObject cannot be null"); } if (!ActiveObjects.ContainsValue(ActiveObject)) { throw new ArgumentException("ActiveObject", "This ActiveObject not found"); } Guid id = ActiveObjects.Where(ao => ao.Value == ActiveObject).FirstOrDefault().Key; return(id); }
/// <summary> /// Finds an object of the inputted name and casts to the inputted type K. /// First searches the ActiveObjects and then the ObjectsToAdd /// </summary> /// <typeparam name="K">The type we wish to return the found object as</typeparam> /// <param name="predicate">The predicate we will use to apply a condition for which we wish to find the object</param> /// <returns>Returns the object casted to K or null</returns> public K FindChild <K>(Predicate <T> predicate) where K : T { K obj = null; obj = ActiveObjects.Find(predicate) as K; if (obj != null) { return(obj); } obj = ObjectsToAdd.Find(predicate) as K; return(obj); }
public void DestroyItem(GameObject _object) { if (_object == null && EntityGameObject != _object) { return; } SuspendedObjects.Remove(_object); ActiveObjects.Remove(_object); if (!CompareByID(_object.GetInstanceID())) { CreatureRegister.Destroy(_object); } }
/// <summary> /// 对象关闭时登记 /// </summary> public static void OnObjectClose(IService obj) { Logger.Information("[服务关闭] {0}", obj.ServiceName); bool can; lock (ActiveObjects) { ActiveObjects.Remove(obj); } can = ActiveObjects.Count == 0; if (can) { ActiveSemaphore.Release(); //发出完成信号 } }
/// <summary> /// 对象活动时登记 /// </summary> public static void OnObjectActive(IService obj) { bool can; Logger.Information("[OnObjectActive] {0}", obj.ServiceName); lock (ActiveObjects) { ActiveObjects.Add(obj); } can = ActiveObjects.Count + FailedObjects.Count == FlowServices.Length; if (can) { ActiveSemaphore.Release(); //发出完成信号 } }
/// <summary> /// Because we add objects in the update loop, the current objects we need to load are in ObjectsToAdd. /// Iterate through them, call Initialise on each of them and add to our ActiveObjects /// </summary> public override void Initialise() { // Check to see whether we have already called Initialise CheckShouldInitialise(); foreach (T obj in ObjectsToAdd.FindAll(x => x.ShouldInitialise)) { // Call initialise on all objects which have not already been initialised obj.Initialise(); } ActiveObjects.AddRange(ObjectsToAdd); ObjectsToAdd.Clear(); base.Initialise(); }
/// <summary> /// Iterate through all the objects in ActiveObjects and call Begin /// </summary> public override void Begin() { base.Begin(); // Do not need to check whether begun has already been called - this is guaranteed // Do another pass on our ObjectsToAdd to add any stragglers ActiveObjects.AddRange(ObjectsToAdd); ObjectsToAdd.Clear(); foreach (T obj in ActiveObjects.FindAll(x => !x.IsBegun)) { // Call begin on any object which has not already begun obj.Begin(); } }
public GameObject GetNewEnemyFromType(Enumerations.EnemyType enemyType) { Debug.Log(string.Format("Fetching object with type '{0}'.", enemyType), gameObject); var GO = PrefabPool.Find(x => x.GetComponent(Enumerations.PowerupType.DamagePowerup.ToString()) != null); if (GO == null) { var msg = string.Format("No object found with type '{0}'.", enemyType); Debug.LogError(msg, gameObject); } var resultGO = GameObject.Instantiate(GO) as GameObject; ActiveObjects.Add(resultGO.gameObject); resultGO.transform.parent = transform; return(resultGO); }
public static void VUIObjectsUpdate(bool StartObject) { ActiveObjects.Clear(); foreach (var O in VUIObjects) { if (O.Value["Active"] == "true") { ActiveObjects.Add(O.Key); } } Count = ActiveObjects.Count - 1; if (StartObject == true) { Section = 0; } }
public UrlFriendlyFilterAttribute(string field, ActiveObjects.FilterType type) : base(field, type) { }
public NormalizeStringFilterAttribute(string field, ActiveObjects.FilterType type) : base(field, type) { }