Ejemplo n.º 1
0
        private EquipmentUseResult PerformScannerUsage(ScannerEquipmentItem equipTemplate, ActiveEquipment activeEquipmentInstance, MappedBot owningBot)
        {
            ScanEquipmentUseResult result = new ScanEquipmentUseResult();

            if (!owningBot.ConsumeCharge(equipTemplate.ChargeConsumed))
            {
                result.State = UsageEndState.Fail_NoCharge;
                return(result);
            }

            Point mapOffset = owningBot.Position;

            foreach (var vSrc in equipTemplate.GetAllScanPoints())
            {
                Point v = new Point(vSrc.X + mapOffset.X, vSrc.Y + mapOffset.Y);

                ScanTileResult str = ScanTileResult.Unscanned;
                MapTile        mt  = MapTile.DefaultGround;

                if (activeWorld.IsValidSpace(v))
                {
                    var tileOccupant = GetTileOccupantByLocation(v);
                    if (tileOccupant != null)
                    {
                        if (tileOccupant.EngineId == owningBot.EngineId)
                        {
                            str = ScanTileResult.You;
                        }
                        else
                        {
                            int ctk = CreateTemporaryScanKey(owningBot.EngineId, tileOccupant.EngineId);
                            result.AddPointOfInterest(v, ctk);
                            str = tileOccupant.IsAlive() ? ScanTileResult.Bot : ScanTileResult.Wreckage;
                        }
                    }
                    else
                    {
                        mt = activeWorld.Map.GetTileAtPosition(v);
                    }
                }
                else
                {
                    mt = MapTile.BoundaryWall1;
                }

                if (str == ScanTileResult.Unscanned)
                {
                    // If there was not an active occupant, then look to the map.
                    switch (mt)
                    {
                    case MapTile.BoundaryWall1: str = ScanTileResult.SolidWall; break;

                    case MapTile.DefaultGround: str = ScanTileResult.Unoccupied; break;

                    default: throw new BdBaseException("DEFAULT - invalid tile mapping - " + mt.ToString());
                    }
                }

                result.SetDimensions(equipTemplate.MinimumXScanned, equipTemplate.MinimumYScanned, equipTemplate.TotalWidthScanned, equipTemplate.TotalHeightScanned);
                result.SetScanResultAtPosition(vSrc, str);
            }

            return(result);
        }
Ejemplo n.º 2
0
 public void SetScanResultAtPosition(Point pt, ScanTileResult res)
 {
     occupiedTiles.Add(pt, res);
 }