internal override void UpdateCamera() { base.UpdateCamera(); // additionally color the background and the planes according to the position of the center of the camera relative to the zones CCPoint camMid = CameraPosition + (CCPoint)CameraSize / 2; float radius = camMid.Length; var bgColor = RadiusToColor(radius, groundNotAir: true); var planeColor = RadiusToColor(radius, groundNotAir: false); // draw the bg lines DrawNode.Clear(); const float bgsize = 600000f; const int lineCount = 200; var bgLineColor = CCColor4B.Lerp(planeColor, CCColor4B.Black, 0.75f); for (int i = -lineCount; i < lineCount; i++) { DrawNode.DrawLine(new CCPoint(i * bgsize / lineCount, -bgsize), new CCPoint(i * bgsize / lineCount, bgsize), 20f, bgLineColor); DrawNode.DrawLine(new CCPoint(-bgsize, i * bgsize / lineCount), new CCPoint(bgsize, i * bgsize / lineCount), 20f, bgLineColor); } // draw the bg color DrawNodeBG.Clear(); DrawNodeBG.DrawRect(new CCRect(-999999999f, -999999999f, 999999999f * 2, 999999999f * 2), bgColor); // now the planes // only color the enemies foreach (var aircraft in ActiveAircrafts) { aircraft.ColorByPlayLayer(planeColor); } }
internal static CCColor4B RadiusToColor(float radius, bool groundNotAir) { int zone = RadiusToZoneNum(radius); // calculate the relative difference of the radius to the radius marking the center of the zone (in percent) float prevEndRad = zone != 0 ? ZoneEndRadii[zone - 1] : 0; float zoneSize = zone != ZoneEndRadii.Length ? ZoneEndRadii[zone] - prevEndRad : 18000f; float relDiff = (radius - prevEndRad) / zoneSize - 0.5f; const float lerpStart = 0.3f; if (relDiff < -lerpStart && zone != 0) { return(CCColor4B.Lerp(groundNotAir ? ZoneColorsGround[zone] : ZoneColorsAir[zone], groundNotAir ? ZoneColorsGround[zone - 1] : ZoneColorsAir[zone - 1], (-relDiff - lerpStart) / (0.5f - lerpStart) / 2)); } else if (relDiff > lerpStart && zone != ZoneEndRadii.Length) { return(CCColor4B.Lerp(groundNotAir ? ZoneColorsGround[zone] : ZoneColorsAir[zone], groundNotAir ? ZoneColorsGround[zone + 1] : ZoneColorsAir[zone + 1], (relDiff - lerpStart) / (0.5f - lerpStart) / 2)); } else { return(groundNotAir ? ZoneColorsGround[zone] : ZoneColorsAir[zone]); } }
public CCColor4B GetOuterHexagonColor(ResourceType resourceType) { var color = resourceType.GetColor(this); var blendColor = HexagonBlendColor; var blendIntensity = OuterHexagonBlendIntensity; var result = CCColor4B.Lerp(color, blendColor, blendIntensity); return(result); }
/// <summary> /// Damage clouds have a different color behaviour (fire for example) /// </summary> /// <param name="scale"></param> /// <param name="color"></param> public override void ScaleAndColor(out float scale, out CCColor4B color) { base.ScaleAndColor(out scale, out color); color = CLOUD_COLOR; // if you have a special FireColor (anything but gray) factor it in float lifePercentage = LifeTime / TotalLifeTime; if (!FireColor.Equals(CLOUD_COLOR)) { float factor = (float)Math.Cos(Math.PI / 2 * lifePercentage); color = CCColor4B.Lerp(CLOUD_COLOR, FireColor, factor); } }
internal void SetWreckPercentile(Aircraft aircraft, float percent) { if (aircraft == null || (aircraft.Layer != this && aircraft.Layer != GUILayer)) { return; } wreckPercentile[aircraft] = percent; // update colors CCColor4B darkColor = new CCColor4B(50, 50, 50); CCColor3B color = new CCColor3B(CCColor4B.Lerp(darkColor, CCColor4B.White, percent)); CCColor3B labelColor = new CCColor3B(CCColor4B.Lerp(darkColor, CCColor4B.White, percent + (1 - percent) * 0.40f)); aircraft.ChangeColor(color); // update the label foreach (var child in aircraft.Parent.Children) { if (child is CCLabel label) { label.Text = (percent * 100).ToString("n2") + "%"; label.Color = labelColor; break; } } }
internal static CCColor3B PlaneToDeathColor(CCColor4B planeColor) { return(new CCColor3B(CCColor4B.Lerp(planeColor, CCColor4B.Black, 0.5f))); }
internal void UpdateDrawNode(bool useMultiplGoal = false) { if (MyDrawNode == null) { return; } MyDrawNode.Clear(); if (LootboxCount != 0) { // visualize lootbar-progress const float GROWTH_FACTOR = 1.3f; const float BORDER_WIDTH = 4f; CCColor4B white = new CCColor4B(1f, 1f, 1f, DrawNodeAlpha); CCColor4B bright = new CCColor4B(1f, 1f, 1f, DrawNodeAlpha); CCRect progressRect = new CCRect(-(ContentSize.Width * GROWTH_FACTOR) / 2, -(ContentSize.Height * GROWTH_FACTOR) / 2, ContentSize.Width * GROWTH_FACTOR, ContentSize.Height * GROWTH_FACTOR); // draw the progress bar var progressPoly = new List <CCPoint> { CCPoint.Zero, new CCPoint(0, (ContentSize.Height * GROWTH_FACTOR) / 2) }; if (LootboxProgress >= 0.125f) { progressPoly.Add(progressRect.UpperRight); } else { progressPoly.Add(new CCPoint(LootboxProgress / 0.125f * progressRect.MaxX, progressRect.MaxY)); goto done; } if (LootboxProgress >= 0.375f) { progressPoly.Add(new CCPoint(progressRect.MaxX, progressRect.MinY)); } else { progressPoly.Add(new CCPoint(progressRect.MaxX, progressRect.MaxY - progressRect.Size.Height * ((LootboxProgress - 0.125f) * 4))); goto done; } if (LootboxProgress >= 0.625f) { progressPoly.Add(new CCPoint(progressRect.MinX, progressRect.MinY)); } else { progressPoly.Add(new CCPoint(progressRect.MaxX - progressRect.Size.Width * ((LootboxProgress - 0.375f) * 4), progressRect.MinY)); goto done; } if (LootboxProgress >= 0.875f) { progressPoly.Add(new CCPoint(progressRect.MinX, progressRect.MaxY)); } else { progressPoly.Add(new CCPoint(progressRect.MinX, progressRect.MinY + progressRect.Size.Height * ((LootboxProgress - 0.625f) * 4))); goto done; } if (LootboxProgress > 0.875f) { progressPoly.Add(new CCPoint(progressRect.MinX + progressRect.Size.Width * (LootboxProgress - 0.875f) * 2, progressRect.MaxY)); } done: var progressPolyPoints = progressPoly.ToArray(); MyDrawNode.DrawPolygon(progressPolyPoints, progressPolyPoints.Length, bright, 0f, CCColor4B.Transparent); // draw the progress bar border MyDrawNode.DrawRect(progressRect, CCColor4B.Transparent, BORDER_WIDTH, white); } // additionally color the button depending on the multiplier progress int multiplier = 1; float progress = 0; if (useMultiplGoal) { multiplier = (int)CurrentMathChallengeNode.MultiplGoal; progress = CurrentMathChallengeNode.MathChallenge.MultiplProgress; } else { multiplier = CurrentMathChallengeNode.Multiplier; progress = CurrentMathChallengeNode.MultiplProgressVisible; } var lastColor = MathChallengeNode.MultiplierBarColor(multiplier - 1); var nextColor = MathChallengeNode.MultiplierBarColor(multiplier); var currentColor = multiplier <= 5 ? CCColor4B.Lerp(lastColor, nextColor, progress) : lastColor; var darkenedColor = CCColor4B.Lerp(currentColor, CCColor4B.Black, 0.25f); darkenedColor.A = (byte)(DrawNodeAlpha * byte.MaxValue); MyDrawNode.DrawRect(new CCRect(-(ContentSize.Width) / 2, -(ContentSize.Height) / 2, ContentSize.Width, ContentSize.Height), darkenedColor); }