/* Doesn't work * public List<IEnumerable<T>> getTypes<T>() where T : SpaceObject * { * if (typeof(T) == typeof(SpaceObject)) * { * return (List<IEnumerable<T>>)getTypes(true, true, true, true); * } * else if (typeof(T) == typeof(NonInteractiveObject)) * { * return (List<IEnumerable<T>>)getTypes(false, false, false, true); * } * else if (typeof(T) == typeof(InteractiveObject)) * { * return (List<IEnumerable<T>>)getTypes(true, true, true, false); * } * else if (typeof(T) == typeof(DestructableObject)) * { * return (List<IEnumerable<T>>)getTypes(true, true, false, false); * } * else if (typeof(T) == typeof(IndestructableObject)) * { * return (List<IEnumerable<T>>)getTypes(false, false, true, false); * } * else if (typeof(T) == typeof(Player)) * { * return (List<IEnumerable<T>>)getTypes(true, false, false, false); * } * else if (typeof(T).IsSubclassOf(typeof(NonInteractiveObject)) * { * List<IEnumerable<T>> items = new List<IEnumerable<T>>(); * foreach (T item in theNonInteractives) * { * if (item.GetType().IsSubclassOf(typeof(T)) || item.GetType() == typeof(T)) * { * items[0].Add(item); * } * } * return items; * } * } */ //The following methods remove or add the given DestructableObject to the correct list. public void RemoveFromGame(DestructableObject remove) { if (remove.GetType() == typeof(Player)) { remove.DestroyThis(); } else { removeDestructables.Add(remove); } }
protected override void DestructableObjectCollision(DestructableObject other, Collision2D collision) { if (other.team != this.team) { other.DamageThis(scale.x * damageMultiplier * difficultyModifier); } else if (other.GetType() == typeof(Blob)) { if (mergeTimer == 0 && ((Blob)(other)).mergeTimer == 0 && scale.x + other.scale.x < maxSize) { MergeWith((Blob)other); } } }