public virtual void Commits() { if (IsClose()) { return; } int additionCount = pendingAdd.Count; if (additionCount > 0) { for (int i = 0; i < additionCount; i++) { SpriteBatchObject obj = pendingAdd[i]; objects.Add(obj); } pendingAdd.Clear(); } int removalCount = pendingRemove.Count; if (removalCount > 0) { for (int i = 0; i < removalCount; i++) { SpriteBatchObject obj = pendingRemove[i]; CollectionUtils.Remove(objects, obj); } pendingRemove.Clear(); } }
public void Commits() { bool changes = false; int additionCount = pendingAdd.Count; if (additionCount > 0) { object[] additionsArray = pendingAdd.ToArray(); for (int i = 0; i < additionCount; i++) { SpriteBatchObject o = (SpriteBatchObject)additionsArray[i]; objects.Add(o); } pendingAdd.Clear(); changes = true; } int removalCount = pendingRemove.Count; if (removalCount > 0) { object[] removalsArray = pendingRemove.ToArray(); for (int i_0 = 0; i_0 < removalCount; i_0++) { SpriteBatchObject object_1 = (SpriteBatchObject)removalsArray[i_0]; objects.Remove(object_1); } pendingRemove.Clear(); changes = true; } if (changes) { lazyObjects = objects.ToArray(); } }
public virtual SpriteBatchObject Remove(SpriteBatchObject obj0) { pendingRemove.Add(obj0); if (usePhysics) { UnbindPhysics(obj0); } return(obj0); }
public bool IsCollision(SpriteBatchObject o) { RectBox src = GetCollisionArea(); RectBox dst = o.GetCollisionArea(); if (src.Intersects(dst)) { return(true); } return(false); }
public PBody FindPhysics(SpriteBatchObject o) { if (usePhysics) { PBody body = (PBody)CollectionUtils.Get(_Bodys, o); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public void UnbindPhysics(SpriteBatchObject o) { if (usePhysics) { PBody body = (PBody)CollectionUtils.Remove(_Bodys, o); if (body != null) { body.SetTag(null); _manager.world.RemoveBody(body); } } }
public PBody BindPhysics(PBody body, SpriteBatchObject o) { if (usePhysics) { body.SetTag(o); _manager.AddBody(body); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindPhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddBox(fix, o.GetRectBox(), MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public virtual void RemoveTileObjects() { int count = objects.Count; SpriteBatchObject[] objectArray = objects.ToArray(); for (int i = 0; i < count; i++) { SpriteBatchObject o = (SpriteBatchObject)objectArray[i]; pendingRemove.Add(o); if (usePhysics) { UnbindPhysics(o); } } pendingAdd.Clear(); }
public PBody BindCirclePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { RectBox rect = o.GetRectBox(); float r = (rect.width + rect.height) / 4; PBody body = _manager.AddCircle(fix, o.X(), o.Y(), r, MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindTexturePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddShape(fix, o.GetAnimation() .GetSpriteImage(), MathUtils.ToRadians(o.GetRotation()), density); if (body.Size() > 0) { body.Inner_shapes()[0].SetPosition(o.X() / _manager.scale, o.Y() / _manager.scale); } body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody AddTexturePhysics(bool fix, SpriteBatchObject o) { return BindTexturePhysics(fix, Add(o), 1F); }
public virtual void RemoveTileObject(SpriteBatchObject o) { Remove(o); }
public virtual void AddTileObject(SpriteBatchObject o) { Add(o); }
public virtual SpriteBatchObject Remove(SpriteBatchObject obj0) { pendingRemove.Add(obj0); if (usePhysics) { UnbindPhysics(obj0); } return obj0; }
public PBody BindCirclePhysics(bool fix, SpriteBatchObject o) { return BindCirclePhysics(fix, Add(o), 1F); }
public PBody BindCirclePhysics(bool fix, SpriteBatchObject o) { return(BindCirclePhysics(fix, Add(o), 1F)); }
public PBody FindPhysics(SpriteBatchObject o) { if (usePhysics) { PBody body = (PBody)CollectionUtils.Get(_Bodys, o); return body; } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindPhysics(bool fix, SpriteBatchObject o) { return(BindPhysics(fix, o, 1F)); }
public PBody BindPhysics(PBody body, SpriteBatchObject o) { if (usePhysics) { body.SetTag(o); _manager.AddBody(body); CollectionUtils.Put(_Bodys, o, body); return body; } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindPhysics(bool fix, SpriteBatchObject o) { return BindPhysics(fix, o, 1F); }
public PBody BindTexturePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddShape(fix, o.GetAnimation() .GetSpriteImage(), MathUtils.ToRadians(o.GetRotation()), density); if (body.Size() > 0) { body.Inner_shapes()[0].SetPosition(o.X() / _manager.scale, o.Y() / _manager.scale); } body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return body; } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindCirclePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { RectBox rect = o.GetRectBox(); float r = (rect.width + rect.height) / 4; PBody body = _manager.AddCircle(fix, o.X(), o.Y(), r, MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys,o, body); return body; } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody AddTexturePhysics(bool fix, SpriteBatchObject o) { return(BindTexturePhysics(fix, Add(o), 1F)); }
public PBody AddCirclePhysics(bool fix, SpriteBatchObject o, float density) { return(BindCirclePhysics(fix, Add(o), density)); }
public PBody BindPhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddBox(fix, o.GetRectBox(), MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys,o, body); return body; } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody AddCirclePhysics(bool fix, SpriteBatchObject o, float density) { return BindCirclePhysics(fix, Add(o), density); }
public void Act(SpriteBatchObject sprite, long elapsedTime) { // 如果主角与地图上其它对象发生碰撞(以下分别验证) if (game.hero.IsCollision(sprite)) { // 与敌人 if (sprite is Enemy) { Enemy e = (Enemy)sprite; if (game.hero.Y() < e.Y()) { game.hero.SetForceJump(true); game.hero.Jump(); game.RemoveTileObject(e); } else { game.Damage(); } // 与金币 } else if (sprite is Coin) { Coin coin = (Coin)sprite; game.RemoveTileObject(coin); // 与加速道具 } else if (sprite is Accelerator) { game.RemoveTileObject(sprite); Accelerator accelerator = (Accelerator)sprite; accelerator.Use(game.hero); // 与二次弹跳道具 } else if (sprite is JumperTwo) { game.RemoveTileObject(sprite); JumperTwo jumperTwo = (JumperTwo)sprite; jumperTwo.Use(game.hero); } } }
public virtual void Remove(SpriteBatchObject obj0) { pendingRemove.Add(obj0); }
public virtual SpriteBatchObject Add(SpriteBatchObject obj0) { pendingAdd.Add(obj0); return(obj0); }
public virtual void Add(SpriteBatchObject obj0) { pendingAdd.Add(obj0); }
public bool IsCollision(SpriteBatchObject o) { RectBox src = GetCollisionArea(); RectBox dst = o.GetCollisionArea(); if (src.Intersects(dst)) { return true; } return false; }
public virtual SpriteBatchObject Add(SpriteBatchObject obj0) { pendingAdd.Add(obj0); return obj0; }