public static void OnDestroyHelper(GameObject objBeingDestroyed) { var toDestroy = new List<GameObject>(); foreach (var obj in objBeingDestroyed.engine.objects.Values) { if (obj.name.StartsWith(objBeingDestroyed.name)) toDestroy.Add(obj); } foreach (var obj in toDestroy) obj.Destroy(); }
public Bullet(GameObject owner, Vector2 direction) { this.owner = owner; Character ownerCharacter = owner as Character; if (owner != null) { this.startingSpeed = ownerCharacter.level.shotSpeed; this.range = ownerCharacter.level.shotRange; } this.speed = this.startingSpeed; this.direction = direction; this.rangeToGo = this.range; this.fill = true; this.order = 6; }
public void SpawnBlock(int bx, int by, GameObject spriteObj, string blockName) { Console.WriteLine ("bx: {0}, by: {1}, {2} {3}", bx, by, blocks.GetLength (0), blocks.Length); if (blocks [bx, by] == null) { blocks [bx, by] = spriteObj; blocks [bx, by].name = blockName; //blocks [x, y].currentSprite = (SpriteAsset) engine.GetAsset ("block"); blocks [bx, by].x = bx * blockW; blocks [bx, by].y = by * blockH; blocks [bx, by].order = this.order; if (blocksWithHitBox) blocks [bx, by].AddHitBox (blockName, 0, 0, blockW, blockH); Console.WriteLine ("Spawned block {0}.{1} at {2}.{3}", bx, by, blocks [bx, by].x, blocks [bx, by].y); engine.SpawnObject (blockName, blocks [bx, by]); } }
public Collision(string hitBoxName, GameObject other, string otherHitBoxName) { this.hitBox = hitBoxName; this.other = other; this.otherHitBox = otherHitBoxName; }
public void UpdatedObjectOrder(GameObject gameObject) { dirtyObjects[gameObject] = 2; }
/* * * GameObject's management * */ public void SpawnObject(string name, GameObject obj) { obj.Name = name; obj.Engine = this; obj.Enabled = true; obj.Id = totalObjCount++; Objects[name] = obj; dirtyObjects[obj] = 1; obj.Initialize(); }
public void SpawnObject(GameObject obj) { SpawnObject(obj.Name, obj); }
public void RemoveObject(GameObject obj) { if (debugCollisions && obj.HitBoxes != null) foreach (var hitBox in obj.HitBoxes.Values) if (debugCollisionsBoxes.ContainsKey(hitBox)) debugCollisionsBoxes.Remove(hitBox); Objects.Remove(obj.Name); dirtyObjects[obj] = 0; }
public TimerManager(GameObject owner) : this() { this.owner = owner; }
/* * * GameObject's management * */ public void SpawnObject(string name, GameObject obj) { obj.name = name; obj.engine = this; obj.enabled = true; this.objects [name] = obj; obj.Initialize (); // force the rendering list to be rebuilt this.dirtyObjects = true; }
public void RemoveObject(GameObject obj) { this.objects.Remove (obj.name); this.dirtyObjects = true; }