Esempio n. 1
0
        public bool Check(Map map, ushort hexX, ushort hexY)
        {
            if (map.IsHexRaked (hexX, hexY))
                return true;

            var sceneries = new SceneryArray ();
            map.GetSceneries (hexX, hexY, sceneries);

            foreach (var scenery in sceneries) {
                ProtoItem proto = Global.GetProtoItem (scenery.ProtoId);
                if (proto == null)
                    continue;
                if ((proto.Flags & ItemFlag.ShootThru) == 0)
                    return false;
            }

            return true;
        }
Esempio n. 2
0
 public void MoveItem(Item item, uint count, Map to_map, ushort to_hx, ushort to_hy)
 {
     Global_MoveItemMap(item.ThisPtr, count, to_map.ThisPtr, to_hx, to_hy);
 }
Esempio n. 3
0
 public void MoveItems(ItemArray items, Map to_map, ushort to_hx, ushort to_hy)
 {
     Global_MoveItemsMap(items.ThisPtr, to_map.ThisPtr, to_hx, to_hy);
 }
Esempio n. 4
0
 // called by engine
 static void RaiseTurnBasedProcess(Map map, Critter cr, bool begin_turn)
 {
     if (TurnBasedProcess != null)
         TurnBasedProcess(null, new MapTurnBasedProcessEventArgs(map, cr, begin_turn));
 }
 public virtual void EventSmthTurnBasedProcess(Critter from_cr, Map map, bool begin_turn)
 {
     Crit_EventSmthTurnBasedProcess(thisptr, from_cr.ThisPtr, map.ThisPtr, begin_turn);
 }
Esempio n. 6
0
 public static Item SpawnContainer(Map map, int x, int y, int count = 1)
 {
     // we're gonna exploit the content of test.fopro - pid=type for first 13 entries
     return map.AddItem ((ushort)x, (ushort)y, (ushort)ItemType.Container, (uint)count);
 }
Esempio n. 7
0
 public MapInOutCritterEventArgs(Map map, Critter cr)
     : base(map)
 {
     this.Cr = cr;
 }
Esempio n. 8
0
 public MapEventArgs(Map map)
 {
     this.Map = map;
 }
Esempio n. 9
0
 // called by engine
 void RaiseTurnBasedProcess(Map map, bool begin_turn)
 {
     if (TurnBasedProcess != null)
         TurnBasedProcess(this, new CritterTurnBasedProcessEventArgs(this, map, begin_turn));
 }
Esempio n. 10
0
 // called by engine
 void RaiseSmthTurnBasedProcess(Critter from_cr, Map map, bool begin_turn)
 {
     if (SmthTurnBasedProcess != null)
         SmthTurnBasedProcess(this, new CritterSmthTurnBasedProcessEventArgs(this, from_cr, map, begin_turn));
 }
Esempio n. 11
0
 public CritterTurnBasedProcessEventArgs(Critter cr, Map map, bool begin_turn)
     : base(cr)
 {
     this.Map = map;
     this.BeginTurn = begin_turn;
 }
Esempio n. 12
0
 public CritterSmthTurnBasedProcessEventArgs(Critter cr, Critter from_cr, Map map, bool begin_turn)
     : base(cr, map, begin_turn)
 {
     this.From = from_cr;
 }
Esempio n. 13
0
 public virtual void ViewMap(Map map, uint look, ushort hx, ushort hy, Direction dir)
 {
     Crit_ViewMap(thisptr, map.ThisPtr, look, hx, hy, (byte)dir);
 }
Esempio n. 14
0
 public virtual void EventTurnBasedProcess(Map map, bool begin_turn)
 {
     Crit_EventTurnBasedProcess(thisptr, map.ThisPtr, begin_turn);
 }
Esempio n. 15
0
 public MapChainEventArgs(Map map)
 {
     this.Map = map;
 }
Esempio n. 16
0
 public MapCritterDeadEventArgs(Map map, Critter cr, Critter killer)
     : base(map)
 {
     this.Cr = cr;
     this.Killer = killer;
 }
Esempio n. 17
0
 // called by engine
 static void RaiseMapCritterOut(Map map, Critter cr)
 {
     if (MapCritterOut != null)
         MapCritterOut(null, new MapInOutCritterEventArgs(map, cr));
 }
Esempio n. 18
0
 public MapFinishEventArgs(Map map, bool to_delete)
     : base(map)
 {
     this.ToDelete = to_delete;
 }
Esempio n. 19
0
 // called by engine
 static void RaiseTurnBasedBegin(Map map)
 {
     if (TurnBasedBegin != null)
         TurnBasedBegin(null, new MapEventArgs(map));
 }
Esempio n. 20
0
 public MapTurnBasedProcessEventArgs(Map map, Critter cr, bool begin_turn)
     : base(map)
 {
     this.Cr = cr;
     this.BeginTurn = begin_turn;
 }
Esempio n. 21
0
 // called by engine
 static void RaiseTurnBasedEnd(Map map)
 {
     if (TurnBasedEnd != null)
         TurnBasedEnd(null, new MapEventArgs(map));
 }
Esempio n. 22
0
 public static Critter SpawnTestNpc(Map map, int x, int y, Direction dir = Direction.NorthEast)
 {
     return map.AddNpc (1, (ushort)x, (ushort)y, dir, null, null, null);
 }
Esempio n. 23
0
        public uint TraceDistance(Map map, ushort fromHexX, ushort fromHexY, ushort toHexX, ushort toHexY, uint maxDistance)
        {
            if (maxDistance == 0)
                maxDistance = Global.GetDistantion(fromHexX, fromHexX, toHexX, toHexY);
            float dir = GetDirectionF(fromHexX, fromHexY, toHexX, toHexY);
            Direction dir1, dir2;
            if ((30.0f <= dir) && (dir < 90.0f)) {
                dir1 = Direction.NorthWest;
                dir2 = Direction.NorthEast;
            } else if ((90.0f <= dir) && (dir < 150.0f)) {
                dir1 = Direction.West;
                dir2 = Direction.NorthWest;
            } else if ((150.0f <= dir) && (dir < 210.0f)) {
                dir1 = Direction.SouthWest;
                dir2 = Direction.West;
            } else if ((210.0f <= dir) && (dir < 270.0f)) {
                dir1 = Direction.SouthEast;
                dir2 = Direction.SouthWest;
            } else if ((270.0f <= dir) && (dir < 330.0f)) {
                dir1 = Direction.East;
                dir2 = Direction.SouthEast;
            } else {
                dir1 = Direction.NorthEast;
                dir2 = Direction.East;
            }

            ushort cx = fromHexX;
            ushort cy = fromHexY;
            ushort px = fromHexX;
            ushort py = fromHexY;

            ushort t1x, t1y, t2x, t2y;

            float x1 = 3 * (float)fromHexX + BIAS_FLOAT;
            float y1 = SQRT3T2_FLOAT * (float)fromHexY - ((float)(fromHexX % 2)) * SQRT3_FLOAT + BIAS_FLOAT;

            float x2 = 3 * (float)(toHexX) + BIAS_FLOAT;
            float y2 = SQRT3T2_FLOAT * (float)(toHexY) - ((float)(toHexX % 2)) * SQRT3_FLOAT + BIAS_FLOAT;

            float dx = x2 - x1;
            float dy = y2 - y1;

            float c1x, c1y, c2x, c2y; // test hex
            float dist1, dist2;

            for (uint i = 1; i <= maxDistance; i++) {
                t1x = cx;
                t2x = cx;
                t1y = cy;
                t2y = cy;
                map.MoveHexByDir(ref t1x, ref t1y, dir1, 1);
                map.MoveHexByDir(ref t2x, ref t2y, dir2, 1);
                c1x = 3 * (float)(t1x);
                c1y = SQRT3T2_FLOAT * (float)(t1y) - ((float)(t1x % 2)) * SQRT3_FLOAT;
                c2x = 3 * (float)(t2x);
                c2y = SQRT3T2_FLOAT * (float)(t2y) - ((float)(t2x % 2)) * SQRT3_FLOAT;
                dist1 = dx * (y1 - c1y) - dy * (x1 - c1x);
                dist2 = dx * (y1 - c2y) - dy * (x1 - c2x);
                dist1 = ((dist1 > 0) ? dist1 : -dist1);
                dist2 = ((dist2 > 0) ? dist2 : -dist2);
                if (dist1 <= dist2) {
                    cx = t1x;
                    cy = t1y;
                } else { // left hand biased
                    cx = t2x;
                    cy = t2y;
                }

                // if MoveHexByDir tried to leave the map and failed:
                if ((cx == px) && (cy == py))
                    return i - 1;
                else {
                    px = cx;
                    py = cy;
                }

                if (!context.Check(map, cx, cy))
                    return i;

            }
            return maxDistance;
        }