public Shard(Coord ul, Coord ur, Coord ll, Coord lr) { _ul = ul; _ur = ur; _ll = ll; _lr = lr; }
private static void InitialiseInhab(Inhabitant thing,Room room,AMaterialStats stats) { int trytimes = 0; bool done = false; Coord size = new Coord(3, 3); while (!done && trytimes < 20) { //Random distribution HACK! u can make more distribution types int tryx = MyRandom.Random.Next(0, room.RoomOccupiedGrid.GetLength(0) - size.X); int tryy = MyRandom.Random.Next(0, room.RoomOccupiedGrid.GetLength(1) - size.Y); if (CheckClear(new Coord(tryx, tryy), size,room.RoomOccupiedGrid)) { MakeNotCLear(new Coord(tryx, tryy), size, room.RoomOccupiedGrid); thing.Initialise(size - new Coord(1, 1) , room.Position + (new Vector2(tryx+1.5f, tryy+1.5f)*Globals.SmallGridSize) , room.RoomAmbient.RoomColour, room.RoomAmbient.GlowColour, stats , room.RoomAmbient.RoomTileset); done = true; } trytimes++; } }
private static void Main() { var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var n = input[0]; var coord0 = new Coord(input[1], input[2]); var rgcoord = new HashSet<Coord>(); for (var i = 0; i < n; i++) { input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); rgcoord.Add(new Coord(input[0], input[1])); } var d = 0; while (rgcoord.Any()) { d++; var coord = rgcoord.First(); var vX = coord.x - coord0.x; var vY = coord.y - coord0.y; foreach (var coordT in rgcoord.ToList()) { if (vY*(coordT.x - coord0.x) == vX*(coordT.y - coord0.y)) rgcoord.Remove(coordT); } } Console.WriteLine(d); }
private static void DrawTargetMark(Unit currentUnit, Coord target, bool toShow) { if (toShow) { ZBuffer.ReadBuffer("targetBuffer", target.X, target.Y, 3, 3); var buffer = ZBuffer.BackupBuffer("defaultBuffer"); ZIOX.OutputType = ZIOX.OutputTypeEnum.Buffer; ZIOX.BufferName = "defaultBuffer"; var targetColor = IsTargetOnSoldier(currentUnit, target) ? Color.Yellow : Color.Cyan; ZIOX.Print(target.X-1, target.Y-1, (char)Tools.Get_Ascii_Byte('┌'), targetColor); ZIOX.Print(target.X+1, target.Y-1, (char)Tools.Get_Ascii_Byte('┐'), targetColor); ZIOX.Print(target.X-1, target.Y+1, (char)Tools.Get_Ascii_Byte('└'), targetColor); ZIOX.Print(target.X+1, target.Y+1, (char)Tools.Get_Ascii_Byte('┘'), targetColor); MapRender.DrawVisibleUnits(currentUnit); ZIOX.OutputType = ZIOX.OutputTypeEnum.Direct; ZBuffer.WriteBuffer("defaultBuffer", UIConfig.GameAreaRect.Left, UIConfig.GameAreaRect.Top); ZBuffer.SaveBuffer("defaultBuffer", buffer); } else { ZBuffer.WriteBuffer("targetBuffer", target.X, target.Y); } }
private static void DFS(Coord coord, Coord target, long sum, int[,] lab) { //if (!visited.Contains(coord)) //{ visited.Add(coord); if (coord.Equals(target)) { results.Add(sum); return; } if (lab[coord.X, coord.Y] == 1) { sum += 1; } if (coord.X + 1 < lab.GetLength(0)) { DFS(new Coord(coord.X + 1, coord.Y), target, sum, lab); } if (coord.Y + 1 < lab.GetLength(1)) { DFS(new Coord(coord.X, coord.Y + 1), target, sum, lab); } //} }
public Room(Coord aTopLeft, int aHeight, int aWidth, Direction aDirection) { iTopLeft = aTopLeft; iHeight = aHeight; iWidth = aWidth; iDoorLocation = aDirection; }
public static Coord DoTargetAction(Unit unit) { var exitFlag = false; var target = new Coord(unit.Position.X, unit.Position.Y); DrawTargetMark(unit, target, true); while (!exitFlag) { var key = ZInput.ReadKey(); var oldTarget = new Coord(target.X, target.Y); switch (key) { case ConsoleKey.LeftArrow : MoveTarget(target, -1, 0); break; case ConsoleKey.RightArrow : MoveTarget(target, +1, 0); break; case ConsoleKey.UpArrow : MoveTarget(target, 0, -1); break; case ConsoleKey.DownArrow : MoveTarget(target, 0, +1); break; case ConsoleKey.Enter : return target; break; case ConsoleKey.Escape : exitFlag = true; break; } if (!oldTarget.Equals(target)) { DrawTargetMark(unit, oldTarget, false); DrawTargetMark(unit, target, true); } } return null; }
protected Pieces(string name, Couleur couleur, Coord coord) { Name = name; Couleur = couleur; Coord = coord; Depart = true; Captured = false; }
public FlamingLongSword(string name = "Flaming Long Sword", Coord position = new Coord()) : base(name, position: position, specialAttack: Weapon.WeaponSpecialAttacks.Flaming, specialAttackDescription: Weapon.WeaponSpecialAttacks.Flaming.WeaponDescription()) { }
public StackItemTest( Color color = new Color(), string description = "Stackable Item", Coord position = new Coord(), int uses = _UnlimitedUses) :base("Stack Item", "s", color: color, cost: 1, description: description, position: position, uses: uses) { }
public ShardSet(Coord ul, Coord lr, int n) { var ur = new Coord(ul.X, lr.Y); var ll = new Coord(lr.X, ul.Y); _set = Split(new Shard(ul, ur, ll, lr), n); Console.WriteLine("n: " + n); Console.WriteLine("#shards: " + _set.Count); }
public static bool IsTargetOnSoldier(Unit currentUnit, Coord target) { foreach (var team in MainGame.Teams) foreach (var unit in team.Units.Where(a => a.Name != currentUnit.Name)) if (target.Equals(unit.Position)) return true; return false; }
public static Item GenerateByBuilderType( Type type, Pg.Level level = Pg.Level.Novice, Coord position = new Coord()) { return Generators.ContainsKey(type) ? Generators[type].GenerateRandom(level, position) : null; }
public byte[] Render(Coord coord, string format, int tileWidth, int tileHeight) { ProxyProvider proxy; if (!this._proxyDictionary.TryGetValue(format.ToString(), out proxy)) throw new InvalidTileFormatException( string.Format("Invalid tile FORMAT {0}", format) ); return proxy.Render(coord, format, tileWidth, tileHeight); }
public Wall(Coord position) : base("Wall", "█", Color.LightGray, false, true, "A rock wall", position) { }
public void Reprair() { Coord[] natural = new Coord[10]; Coord[] stretchability = new Coord[10]; Coord[] shrinkability = new Coord[10]; int[] breaks = new int[10]; // Подготовить массивы с характеристиками компонентов // ... // Определить, где должны быть точки разрыва int breakCount = _compositor.Compose(natural, stretchability, shrinkability, _componentCount, _lineWidth, breaks); }
private void GetAdjacentCoords(List<Coord> AdjacentCoords, PixelData Canvas, Coord coord, System.Drawing.Color SeekColor) { if (coord.X >= 0 && coord.X < Canvas.Width && coord.Y >= 0 && coord.Y < Canvas.Height && Canvas[coord.X, coord.Y] == SeekColor) { if (!AdjacentCoords.Contains(coord)) { AdjacentCoords.Add(coord); GetAdjacentCoords(AdjacentCoords, Canvas, new Coord(coord.X - 1, coord.Y), SeekColor); GetAdjacentCoords(AdjacentCoords, Canvas, new Coord(coord.X + 1, coord.Y), SeekColor); GetAdjacentCoords(AdjacentCoords, Canvas, new Coord(coord.X, coord.Y - 1), SeekColor); GetAdjacentCoords(AdjacentCoords, Canvas, new Coord(coord.X, coord.Y + 1), SeekColor); } } }
public WoodenShield(string name = "Wooden Shield", Coord position = new Coord()) : base( name, Shield.DefaultSymbol, Color.Brown, 1, 0, description: "A wooden small shield", cost: 1, weight: 2, position: position) { }
static int play(int[,] game, Coord c) { if (1 == game[c.x, c.y]) { return 1; } else if (0 == game[c.x, c.y]) { game[c.x, c.y] = -1; return 0; } else return -1; }
// Octant data // // \ 1 | 2 / // 8 \ | / 3 // -----+----- // 7 / | \ 4 // / 6 | 5 \ // // 1 = NNW, 2 =NNE, 3=ENE, 4=ESE, 5=SSE, 6=SSW, 7=WSW, 8 = WNW /// <summary> /// Start here: go through all the octants which surround the player to determine which open cells are visible /// </summary> public static List<Coord> GetVisibleCells(Level level, Coord playerPosition, ObjectHeight playerHeight) { MapSize = level.Size; Map = level.Map; PlayerPos = playerPosition; PlayerHeight = playerHeight; VisiblePoints = new List<Coord>{ PlayerPos }; foreach (var octant in VisibleOctants) ScanOctant(1, octant, 1.0, 0.0); return VisiblePoints; }
public ArrowTrap(Coord position = new Coord()) : base( name: "Arrow Trap", charge: 1, bonus: 1, damage: new DamageCalculator( new Dictionary<DamageType, DamageCalculator.DamageCalculatorMethod>() { { DamageType.Physical, (mod) => Dice.Throws(8, mod: mod) } }), description: "A hidden crossbow that fires a bolt", position: position) { }
private static bool CheckClear(Coord pos,Coord size, bool[,] grid) { for (int x = pos.X; x < pos.X + size.X; x++) { for (int y = pos.Y; y < pos.Y + size.Y; y++) { if (grid[x, y]) { return false; } } } return true; }
public Leather(string name = "Leather", Coord position = new Coord()) : base(name, Armor.DefaultSymbol, Color.SaddleBrown, new Damage( new Dictionary<DamageType, int>() { { DamageType.Physical, 1 } }), _ArmorType.Light_Armor, description: "An armor built in boiled leather", cost: 2, weight: 5, position: position) { }
public List<Coord> GetPath(Coord target) { var rep = new List<Coord>(); if (this is Cavalier) return rep; var x = GetX() + Math.Sign(target.X - GetX()); var y = GetY() + Math.Sign(target.Y - GetY()); while (!(x == target.X && y == target.Y)) { x += Math.Sign(target.X - x); y += Math.Sign(target.Y - y); rep.Add(new Coord(x, y)); } return rep; }
private static void Main(string[] args) { var dimensions = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var rows = dimensions[0]; var cols = dimensions[1]; var lab = new int[rows, cols]; var coinsCount = int.Parse(Console.ReadLine()); for (int i = 0; i < coinsCount; i++) { var coords = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); lab[coords[0], coords[1]] = 1; } var coord = new Coord(0, 0); var target = new Coord(rows - 1, cols - 1); DFS(coord, target, 0, lab); Console.WriteLine(results.Max()); }
public Trap(string name, int charge, int bonus, DamageCalculator damage, string description = "Basic Trap", Coord position = new Coord()) : base(name, "^", System.Drawing.Color.Blue, true, false, description, position, true) { Charge = charge; Bonus = bonus; Damage = damage; IsCurrentlyTriggerable = true; }
public LongSword( string name = "Long Sword", Coord position = new Coord(), _SpecialAttack specialAttack = null, string specialAttackDescription = null) : base(name, DefaultSymbol, Color.DarkGray, new DamageCalculator( new Dictionary<DamageType, DamageCalculator.DamageCalculatorMethod>() { { DamageType.Physical, (mod) => Dice.Throws(8, mod: mod) } }), description: "A long sword", specialAttack: specialAttack, specialAttackDescription: specialAttackDescription, cost: 10, weight: 2, position: position) { }
private void pictureBox1_Click(object sender, EventArgs e) { if (e.GetType() == typeof(MouseEventArgs)) { string coordinates; MouseEventArgs me = e as MouseEventArgs; //textOutput.Text += me.Location.ToString(); coordinates = me.Location.ToString(); Coord mouse = new Coord(coordinates); List<Coord> mice = new List<Coord>(); mice.Add(mouse); foreach (Coord m in mice) { textOutput.Text += m.mouseCo; } } }
public override void LayoutSymbol(SymbolLayout Sym) { Coord w = new Coord(0, 0); Sym.AddTerminal(Terminal, w); Coord dw = new Coord(1, 1); Coord pw = new Coord(dw.y, -dw.x); w += dw * 10; Sym.AddWire(Terminal, w); Sym.AddLine(color, w - pw * 4, w + pw * 4); Sym.AddLoop(color, w + pw * 2, w + pw * 2 + dw * 10, w + dw * 12, w - pw * 2 + dw * 10, w - pw * 2); if (ConnectedTo != null) Sym.DrawText(() => V.ToString(), new Point(0, 6), Alignment.Far, Alignment.Near); }
public char? ReadCharacterAt(int x, int y) { IntPtr consoleHandle = GetStdHandle(-11); if (consoleHandle == IntPtr.Zero) { return null; } var position = new Coord { X = (short)x, Y = (short)y }; var result = new StringBuilder(1); uint read = 0; if (ReadConsoleOutputCharacter(consoleHandle, result, 1, position, out read)) { return result[0]; } else { return null; } }
extern static bool SetConsoleCursorPosition(IntPtr handle, Coord coord);
extern static bool ReadConsoleOutput(IntPtr handle, void *buffer, Coord bsize, Coord bpos, ref SmallRect region);
extern static bool WriteConsoleOutput(IntPtr handle, CharInfo [] buffer, Coord bsize, Coord bpos, ref SmallRect region);
extern static bool FillConsoleOutputAttribute(IntPtr handle, short c, int size, Coord coord, out int written);
extern static bool FillConsoleOutputCharacter(IntPtr handle, char c, int size, Coord coord, out int written);
public void SetCursorPosition(int left, int top) { Coord coord = new Coord(left, top); SetConsoleCursorPosition(outputHandle, coord); }
extern static bool SetConsoleScreenBufferSize(IntPtr handle, Coord newSize);