public GrowthLayout(GrowthOption[] growthOptions, Rectangle bounds) { this.Bounds = bounds; int actionCount = growthOptions.Sum(op => op.GrowthActions.Length); GrowthOptions = growthOptions; optionRects = new Dictionary <GrowthOption, RectangleF>(); Actions = new GrowthActionFactory[actionCount]; actionRects = new Dictionary <GrowthActionFactory, RectangleF>(); float actionWidth = 1.0f / actionCount; float actionHeight = 1.5f / actionCount; float x = 0f; int actionIndex = 0; foreach (var g in growthOptions) { float gx = x; foreach (var a in g.GrowthActions) { Actions[actionIndex++] = a; actionRects.Add(a, RectangleF.Inflate(new RectangleF(x, 0, actionWidth, actionHeight), -.1f * actionWidth, -.1f * actionHeight)); x += actionWidth; } optionRects.Add(g, new RectangleF(gx, 0, x - gx, actionHeight)); } size = new SizeF(1f, actionHeight); // Fit to Bounds ScaleToFit(bounds.Width, bounds.Height); Translate(bounds.X, bounds.Y); }
void DrawAction(GrowthActionFactory action, RectangleF rect) { if (action is JaggedEarth.RepeatableActionFactory repeatableActionFactory && repeatableActionFactory.Inner is not JaggedEarth.GainTime ) { action = repeatableActionFactory.Inner; } if (action is GainEnergy ge) { GainEnergy(rect, ge.Delta); return; } if (action is ReclaimAll) { DrawIconInCenter(rect, Img.ReclaimAll); return; } if (action is ReclaimN) { DrawIconInCenter(rect, Img.Reclaim1); return; } if (action is ReclaimHalf) { DrawIconInCenter(rect, Img.ReclaimHalf); return; } if (action is DrawPowerCard) { DrawIconInCenter(rect, Img.GainCard); return; } if (action is PlacePresence pp) { PlacePresence(rect, pp.Range, pp.FilterEnum); return; } if (action is MovePresence mp) { MovePresence(rect, mp.Range); return; } switch (action.Name) { case "PlayExtraCardThisTurn(2)": AdditionalPlay(rect, 2); break; case "PlayExtraCardThisTurn(1)": AdditionalPlay(rect, 1); break; // Ocean case "PlaceInOcean": PlacePresence(rect, null, Target.Ocean); break; case "GatherPresenceIntoOcean": DrawIconInCenter(rect, Img.GatherToOcean); break; case "PushPresenceFromOcean": DrawIconInCenter(rect, Img.Pushfromocean); break; // Heart of the WildFire case "EnergyForFire": DrawIconInCenter(rect, Img.Oneenergyfire); break; // Lure of the Deep Wilderness case "GainElement(Moon,Air,Plant)": GainElement(rect, Element.Moon, Element.Air, Element.Plant); break; // Fractured Dates case "GainElement(Air)": GainElement(rect, Element.Air); break; case "GainElement(Moon)": GainElement(rect, Element.Moon); break; case "GainElement(Sun)": GainElement(rect, Element.Sun); break; case "GainTime(2)": GainTime(rect); break; case "GainTime(1)x2": Gain1TimeOr2CardPlaysX2(rect); break; case "GainTime(1)x3": Gain1TimeOr2EnergyX3(rect); break; case "DrawPowerCardFromDaysThatNeverWere": DrawImage(rect, Img.FracturedDays_DrawDtnw); break; // Starlight Seeks Its Form case "MakePowerFast": DrawIconInCenter(rect, Img.Icon_Fast); break; // Grinning Trickster case "GainEnergyEqualToCardPlays": DrawIconInCenter(rect, Img.GainEnergyEqualToCardPlays); break; // Stones Unyielding Defiance case "GainElements(Earth,Earth)": iconDrawer.DrawTheIcon(new IconDescriptor { ContentImg = Img.Token_Earth, ContentImg2 = Img.Token_Earth, }, rect ); break; // !!! this is drawn as an OR, layer them and make them an AND // Many Minds case "Gather1Beast": DrawIconInCenter(rect, Img.Land_Gather_Beasts); break; case "PlacePresenceAndBeast": PlacePresence(rect, 3, Target.Any); DrawIconInCenter(rect.InflateBy(-rect.Width * .2f), Img.Icon_Beast); break; case "ApplyDamage": DrawIconInCenter(rect, Img.Damage_2); break; default: graphics.FillRectangle(Brushes.Goldenrod, Rectangle.Inflate(rect.ToInts(), -5, -5)); break; } }
public GrowthActionFactory Bind(GrowthActionFactory inner) => new RepeatableActionFactory(inner, this);
public void Register(GrowthActionFactory factory) { factories.Add(factory); }
internal RepeatableActionFactory(GrowthActionFactory inner, ActionRepeater repeater) { this.Inner = inner; this.repeater = repeater; repeater.Register(this); }