public CelestialBodyExplosion() { Handler = new IntegerHandler(CheckEnemiesHit); Output = new Dictionary<int, Enemy>(); CelestialBodyRectangle = new PhysicalRectangle(); CelestiablBodyRange = new Circle(Vector3.Zero, 0); }
public BulletsDeflected() { Output = new List<KeyValuePair<Enemy, Bullet>>(); Handler = new IntegerHandler(CheckBulletIsDeflected); CurrentBullet = null; CurrentBulletRectangle = new PhysicalRectangle(); CurrentBulletDeflectRange = new Circle(Vector3.Zero, 0); }
public static void Main(string[] args) { var integerHandler = new IntegerHandler(); var stringHandler = new StringHandler(); ValidateHandler(integerHandler); ValidateHandler(stringHandler); }
public BoostedTurrets() { Output = new List<KeyValuePair<Turret, Turret>>(); Handler = new IntegerHandler(CheckTurretIsBoosted); CurrentTurret = null; CurrentTurretRectangle = new PhysicalRectangle(); CurrentTurretRange = new Circle(Vector3.Zero, 0); }
public EnemyInRange() { Output = new List<KeyValuePair<Turret, Enemy>>(); Handler = new IntegerHandler(CheckEnemyIsInRange); CurrentTurret = null; CurrentTurretRectangle = new PhysicalRectangle(); CurrentTurretRange = new Circle(Vector3.Zero, 0); }
public ObjectsCollisions() { Output = new List<KeyValuePair<ICollidable, ICollidable>>(); HandlerBulletEnemy = new IntegerHandler(CheckBulletEnemy); HandlerBulletExplosion = new IntegerHandler(CheckBulletExplosion); HandlerShootingStars = new IntegerHandler(CheckShootingStars); HandlerShootingStarExplosion = new IntegerHandler(CheckShootingStarExplosion); TmpObjects = new Dictionary<int, int>(); Rectangle = new PhysicalRectangle(); Circle = new Circle(Vector3.Zero, 0); }
//Ланцюжок відповідальностей - Chaino Of Responsibility public Run ChainoOfResponsibility() { Console.WriteLine("Chaino Of Responsibility:"); Chain chain = new StringHandler(); chain += new IntegerBypassHandler(); chain += new IntegerHandler(); chain += new IntegerHandler(); // ніколи не дойде сюди chain += new NullHandler(); chain.Message("1st string value"); chain.Message(100); chain.Message("2nd string value"); chain.Message(4.7f); // не обробляється chain.Message(null); return(this); }
public void GetItems(Line line, IntegerHandler callback) { Vector2 start = line.DebutV2; Vector2 direction = line.FinV2 - start; Vector2 multipliedDirection; float length = line.Longueur; direction.Normalize(); bool wantsNext = true; for (int i = 0; i < length; i += CellSize / 2) { Vector2.Multiply(ref direction, i, out multipliedDirection); Vector2 position; Vector2.Add(ref start, ref multipliedDirection, out position); Vector2.Subtract(ref position, ref SpaceUpperLeft, out position); Vector2.Divide(ref position, CellSize, out position); int x_1 = (int) position.X; int y_1 = (int) position.Y; if (x_1 >= 0 && x_1 < NbColumns && y_1 >= 0 && y_1 < NbRows) for (int k = 0; k < Grid[y_1][x_1].Count; k++) { if (!wantsNext) return; wantsNext = callback(Grid[y_1][x_1][k]); } } }
public void GetItems(Rectangle rectangle, IntegerHandler callback) { Vector2 upperLeft = new Vector2(rectangle.Left, rectangle.Top); Vector2.Subtract(ref upperLeft, ref SpaceUpperLeft, out upperLeft); Vector2.Divide(ref upperLeft, CellSize, out upperLeft); int lowerXIndex = (int) upperLeft.X; int lowerYIndex = (int) upperLeft.Y; int upperXIndex = lowerXIndex + rectangle.Width / CellSize; int upperYIndex = lowerYIndex + rectangle.Width / CellSize; bool wantsNext = true; for (int i = lowerXIndex; i <= upperXIndex; i++) for (int j = lowerYIndex; j <= upperYIndex; j++) if (i >= 0 && i < NbColumns && j >= 0 && j < NbRows) for (int k = 0; k < Grid[j][i].Count; k++) { if (!wantsNext) return; wantsNext = callback(Grid[j][i][k]); } }
public HiddenEnemies() { Output = new Dictionary<Enemy, CelestialBody>(); Handler = new IntegerHandler(CheckEnemyIsHidden); CurrentCelestialBody = null; }