示例#1
0
 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++;
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
                }
            //}
        }
示例#6
0
文件: Room.cs 项目: kjchiu/zomgame-2
 public Room(Coord aTopLeft, int aHeight, int aWidth, Direction aDirection)
 {
     iTopLeft = aTopLeft;
     iHeight = aHeight;
     iWidth = aWidth;
     iDoorLocation = aDirection;
 }
示例#7
0
        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;
        }
示例#8
0
 protected Pieces(string name, Couleur couleur, Coord coord)
 {
     Name = name;
     Couleur = couleur;
     Coord = coord;
     Depart = true;
     Captured = false;
 }
示例#9
0
 public FlamingLongSword(string name = "Flaming Long Sword", Coord position = new Coord())
     : base(name,
            position: position,
            specialAttack: Weapon.WeaponSpecialAttacks.Flaming,
            specialAttackDescription: Weapon.WeaponSpecialAttacks.Flaming.WeaponDescription())
 {
     
 }
示例#10
0
        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)
        {

        }
示例#11
0
 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);
 }
示例#12
0
 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;
 }
示例#13
0
        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;
        }
示例#14
0
        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);
        }
示例#15
0
        public Wall(Coord position)
            : base("Wall", 
                   "█", 
                   Color.LightGray, 
                   false, 
                   true,
                   "A rock wall",
                   position)
        {

        }
示例#16
0
        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);
        }
示例#17
0
        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);
                }
            }
        }
示例#18
0
        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)
        {

        }
示例#19
0
 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;
 }
示例#20
0
        //  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;
        }
示例#21
0
 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;
 }
示例#23
0
        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)

        {

        }
示例#24
0
        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());
        }
示例#26
0
 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;
 }
示例#27
0
        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)
        {

        }
示例#28
0
        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;
                }
            }
        }
示例#29
0
        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;
     }
 }
示例#31
0
 extern static bool SetConsoleCursorPosition(IntPtr handle, Coord coord);
示例#32
0
 extern static bool ReadConsoleOutput(IntPtr handle, void *buffer, Coord bsize, Coord bpos, ref SmallRect region);
示例#33
0
 extern static bool WriteConsoleOutput(IntPtr handle, CharInfo [] buffer, Coord bsize, Coord bpos, ref SmallRect region);
示例#34
0
 extern static bool FillConsoleOutputAttribute(IntPtr handle, short c, int size, Coord coord, out int written);
示例#35
0
 extern static bool FillConsoleOutputCharacter(IntPtr handle, char c, int size, Coord coord, out int written);
示例#36
0
        public void SetCursorPosition(int left, int top)
        {
            Coord coord = new Coord(left, top);

            SetConsoleCursorPosition(outputHandle, coord);
        }
示例#37
0
 extern static bool SetConsoleScreenBufferSize(IntPtr handle, Coord newSize);