Exemple #1
0
        private ComponentProperty[] ResolveLocations(ShipComponent component)
        {
            List <ComponentProperty> properties = new List <ComponentProperty>();
            Facing facing = grid.GetZone(component);

            properties.AddRange(ResolveLocations(facing, component.Type.properties));
            properties.AddRange(ResolveLocations(facing, component.Properties));
            return(properties.ToArray());
        }
Exemple #2
0
 public void ReportDamage(ShipComponent c)
 {
     if (c == null)
     {
         OnDamageAndShield();
     }
     else
     {
         OnComponentDestroyed(c);
     }
 }
Exemple #3
0
        public Facing GetZone(ShipComponent component)
        {
            IntPair p        = locations[component].location;
            int     mid      = (int)Math.Floor(width / 2f);
            bool    upOrLeft = (p.x >= mid ? p.x - 1 : p.x) + p.y < height;

            if ((p.x > mid ? p.x - 1 : p.x) > p.y)
            {
                return(upOrLeft ? Facing.UP : Facing.RIGHT);
            }
            else
            {
                return(upOrLeft ? Facing.LEFT : Facing.DOWN);
            }
        }
Exemple #4
0
        private ComponentAdjacencyBonus[] ResolveLocationAdjacencies(ShipComponent component)
        {
            Facing facing = grid.GetZone(component);
            List <ComponentAdjacencyBonus> adjacencyBonuses = new List <ComponentAdjacencyBonus>();

            foreach (ComponentAdjacencyBonus bonus in component.Type.adjacencyBonuses)
            {
                if (bonus.propertyIdentifier.EndsWith(zoneBasedStringMarker))
                {
                    adjacencyBonuses.Add(new ComponentAdjacencyBonus(
                                             bonus.componentIdentifier,
                                             bonus.propertyIdentifier.Replace(zoneBasedStringMarker, facing.GetPropertyString()),
                                             bonus.amount));
                }
                else
                {
                    adjacencyBonuses.Add(bonus);
                }
            }
            return(adjacencyBonuses.ToArray());
        }
Exemple #5
0
 private void Grid_OnComponentDestroyed(ShipComponent component)
 {
     newConfigAvailable(BuildShipConfiguration(), false);
 }
Exemple #6
0
 private void Grid_OnComponentMove(ShipComponent component, ShipGrid.LocationInformation location)
 {
     newConfigAvailable(BuildShipConfiguration(), false);
 }
Exemple #7
0
        public List <ShipComponent> GetAdjacentComponents(ShipComponent component)
        {
            List <IntPair> adjacentTiles = GetAdjacentTiles(component);

            return(components.Where(i => GetOccupiedTiles(i).Intersect(adjacentTiles).Any()).ToList());
        }
Exemple #8
0
 public void AddComponent(ShipComponent component, IntPair location)
 {
     locations.Add(component, new LocationInformation(location, Rotation.UP));
 }
Exemple #9
0
 private List <IntPair> GetAdjacentTiles(ShipComponent component)
 {
     return(GetAdjacentTiles(GetOccupiedTiles(component)));
 }
Exemple #10
0
        private List <IntPair> GetOccupiedTiles(ShipComponent component)
        {
            Rotation rotation = locations[component].rotation;

            return(component.Type.shape.Select(i => i.Rotate(rotation) + locations[component].location).ToList <IntPair>());
        }