private static void HandleLayoutOverflow(GrowDirection direction, float minSize, float wPos, float wSize, out float pos, out float size) { var overflow = minSize - wSize; if (overflow <= 0 || direction == GrowDirection.Constrain) { pos = wPos; size = wSize; return; } switch (direction) { case GrowDirection.End: pos = wPos; break; case GrowDirection.Begin: pos = wPos - overflow; break; case GrowDirection.Both: pos = wPos - overflow / 2; break; default: throw new ArgumentOutOfRangeException(); } size = minSize; }
MadSprite.FillType ToFillType(GrowDirection growDirection) { switch (growDirection) { case GrowDirection.LeftToRight: return MadSprite.FillType.LeftToRight; case GrowDirection.RightToLeft: return MadSprite.FillType.RightToLeft; case GrowDirection.TopToBottom: return MadSprite.FillType.TopToBottom; case GrowDirection.BottomToTop: return MadSprite.FillType.BottomToTop; case GrowDirection.ExpandHorizontal: return MadSprite.FillType.ExpandHorizontal; case GrowDirection.ExpandVertical: return MadSprite.FillType.ExpandVertical; case GrowDirection.RadialCW: return MadSprite.FillType.RadialCW; case GrowDirection.RadialCCW: return MadSprite.FillType.RadialCCW; case GrowDirection.ColorChange: return MadSprite.FillType.None; default: MadDebug.Assert(false, "Unkwnown grow direction: " + growDirection); return MadSprite.FillType.None; } }
public bool GrowDirectionSupportedByFollowEffect(GrowDirection growDirection) { switch (growDirection) { case EnergyBarBase.GrowDirection.LeftToRight: case EnergyBarBase.GrowDirection.RightToLeft: case EnergyBarBase.GrowDirection.TopToBottom: case EnergyBarBase.GrowDirection.BottomToTop: return true; default: return false; } }
public bool GrowDirectionSupportedByFollowEffect(GrowDirection growDirection) { switch (growDirection) { case GrowDirection.LeftToRight: case GrowDirection.RightToLeft: case GrowDirection.TopToBottom: case GrowDirection.BottomToTop: return(true); default: return(false); } }
void WindSetup() { switch (direction) { case 0: growDirection = GrowDirection.LeftToRight; break; case 1: growDirection = GrowDirection.LeftToRight; break; case 2: growDirection = GrowDirection.RightToLeft; break; } textureBar = windBar; }
public override void Initialize() { base.Initialize(); XPolicy = SizePolicy.EXPAND; YPolicy = SizePolicy.EXPAND; MoveState = MoveOption.DYNAMIC; _direction = GrowDirection.DOWN; Container.Initialize(); _buttonSelection.Initialize(); Container.Active = false; Active = true; }
public SensitivePlantGenerator SetGrowDirection(GrowDirection direction) { _direction = direction; return(this); }
public static void SetGrowHorizontal(Control control, GrowDirection value) { control.SetValue(GrowHorizontalProperty, value); }
/// <summary> /// /// </summary> /// <param name="leafPercent">树叶比例</param> /// <param name="flowerPercent">开花比例</param> /// <param name="direct">生长方向</param> public void DrawTree( Point begin, double angle, double length, short width, double leafPercent = 0.5, double flowerPercent = 0.05, GrowDirection direct = GrowDirection.Right) { if (length < MinLength) { if (length < MinLength * leafPercent) { tree.Leaves.Add(new CozyLeaf() { begin = begin, end = new Point(begin.X + 2 * Math.Cos(angle), begin.Y + 2 * Math.Cos(angle)), }); return; } else if (length < MinLength * (leafPercent + flowerPercent)) { tree.Flowers.Add(new CozyFlower() { pos = begin, size = 3, }); } return; } int x = (int)(begin.X + length * Math.Cos(angle)); int y = (int)(begin.Y - length * Math.Sin(angle)); var end = new Point(x, y); tree.Branchs.Add(new CozyBranch() { begin = begin, end = end, width = width, }); width -= (short)rand.Next(5, 8); if (width < 1) { width = 1; } var sub = rand.Next(2, 4); for (var i = 0; i < sub; ++i) { var len = rand.NextDouble(); if (len < 0.1) { len += 1.4; } if (len > 0.9) { len -= 0.4; } var nextAngle = angle + (rand.NextDouble() - 0.5) * PI; switch (direct) { case GrowDirection.TallAndStraight: nextAngle = angle + (rand.NextDouble() - 0.5) * PI / 3; break; case GrowDirection.Left: nextAngle = angle + (rand.NextDouble() - 0.1) * PI / 2; break; case GrowDirection.Right: nextAngle = angle + (rand.NextDouble() - 0.7) * PI / 2; break; } if (canAcceptAngle(nextAngle)) { DrawTree(end, nextAngle, len * length, width); } } }
public SampleTree SetDirection(GrowDirection direct) { direction = direct; return(this); }
void WindSetup() { switch(direction){ case 0:growDirection=GrowDirection.LeftToRight; break; case 1:growDirection=GrowDirection.LeftToRight; break; case 2:growDirection=GrowDirection.RightToLeft; break; } textureBar=windBar; }