Esempio n. 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());
        }
Esempio n. 2
0
 public void ReportDamage(ShipComponent c)
 {
     if (c == null)
     {
         OnDamageAndShield();
     }
     else
     {
         OnComponentDestroyed(c);
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 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());
        }
Esempio n. 5
0
 private void Grid_OnComponentDestroyed(ShipComponent component)
 {
     newConfigAvailable(BuildShipConfiguration(), false);
 }
Esempio n. 6
0
 private void Grid_OnComponentMove(ShipComponent component, ShipGrid.LocationInformation location)
 {
     newConfigAvailable(BuildShipConfiguration(), false);
 }
Esempio n. 7
0
        public List <ShipComponent> GetAdjacentComponents(ShipComponent component)
        {
            List <IntPair> adjacentTiles = GetAdjacentTiles(component);

            return(components.Where(i => GetOccupiedTiles(i).Intersect(adjacentTiles).Any()).ToList());
        }
Esempio n. 8
0
 public void AddComponent(ShipComponent component, IntPair location)
 {
     locations.Add(component, new LocationInformation(location, Rotation.UP));
 }
Esempio n. 9
0
 private List <IntPair> GetAdjacentTiles(ShipComponent component)
 {
     return(GetAdjacentTiles(GetOccupiedTiles(component)));
 }
Esempio n. 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>());
        }