/// <summary> /// Get the color of the currently active node. If the active node is null /// then it gets the color of the current color palette selection. /// </summary> /// <returns></returns> public static Vector4 GetCurrentColor() { int colorIndex = InGame.inGame.shared.curObjectColor; Classification.Colors color = ColorPalette.GetColorFromIndex(colorIndex); return(Classification.ColorVector4(color)); } // end of WayPoint GetActiveColor()
// c'tor public ColorPalette() { // Create elements for the color buttons. // Start with a blob of common parameters. UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob(); blob.width = 1.0f; blob.height = 1.0f; blob.edgeSize = 0.5f; blob.selectedColor = Color.White; blob.unselectedColor = Color.White; blob.normalMapName = @"QuarterRound4NormalMap"; int numColors = (int)Classification.Colors.SIZEOF - 1; buttonHitBoxes = new AABB2D[numColors]; for (int i = 0; i < numEntries; i++) { buttonHitBoxes[i] = new AABB2D(); } for (int i = 0; i < numEntries; i++) { buttons[i] = new UIGrid2DTextureElement(blob, null); buttons[i].NoZ = false; // Set initial size. textureSize[i] = inactiveSize; buttons[i].BaseColor = Classification.ColorVector4(GetColorFromIndex(i)); } camera = new UiCamera(); }
public override void SetColor(Classification.Colors color) { base.SetColor(color); // Apply a twitch to transition the RGBA color to match. // colorRGBA = ColorVector4(color); TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { tail.Color = val; }; TwitchManager.CreateTwitch(tail.Color, Classification.ColorVector4(color), set, 0.1f, TwitchCurve.Shape.EaseInOut); }
public override void Render(Camera camera) { modelAnim.Update(); modelAnim.SetupIdle(sro); sro.RenderColor = Classification.ColorVector4(Color); Matrix matrixRender = this.matrixSro * world; sro.Render(camera, ref matrixRender, null); }
private static void RenderEffect(ScoreEffect scoreEffect, Camera camera, Vector3 forward) { if (scoreEffect.crts == null) { return; } GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Vector3 diff = scoreEffect.curr - camera.ActualFrom; float dist = diff.Length(); Parameter(EffectParams.ScoreAlpha).SetValue(scoreEffect.alpha); Parameter(EffectParams.ScoreColor).SetValue(Classification.ColorVector4(scoreEffect.color)); Parameter(EffectParams.ScoreColorDarken).SetValue(kScoreColorDarken); device.SetVertexBuffer(vertexBuf); device.Indices = UI2D.Shared.QuadIndexBuff; Matrix translation = new Matrix(); Matrix world = Matrix.CreateBillboard( scoreEffect.curr, camera.ActualFrom, camera.ViewUp, forward); float distanceScalar = kEffectScalar * dist; float offset = 0; for (int i = 0; i < scoreEffect.crts.Length; ++i) { CharRenderTarget crt = scoreEffect.crts[i]; if (i > 0) { offset += crt.charWidth / 2; } translation = Matrix.CreateTranslation(world.Left * offset * distanceScalar); Matrix worldViewProj = world * translation * camera.ViewMatrix * camera.ProjectionMatrix; Vector2 scoreSize = new Vector2(crt.surface.Width, crt.surface.Height) * distanceScalar; Parameter(EffectParams.WorldViewProj).SetValue(worldViewProj); Parameter(EffectParams.ScoreSize).SetValue(scoreSize); Parameter(EffectParams.ScoreTexture).SetValue(crt.surface); Effect.CurrentTechnique.Passes[0].Apply(); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2); offset += crt.charWidth / 2; } }
/// <summary> /// Fire a missile from the given shooter's position at the target position. /// </summary> /// <param name="shooter"></param> /// <param name="targetPos"></param> /// <param name="color"></param> /// <param name="verbPayload"></param> /// <returns></returns> public bool Fire(GameActor shooter, Vector3 targetPos, Classification.Colors color, GameThing.Verbs verbPayload, int damage) { if (numActiveBleeps < kMaxBleeps) { float speed = shooter.BlipSpeed; float time2Live = shooter.BlipRange / speed; Bleep bleep = new Bleep(); bleep.Position = shooter.WorldGlowPosition; bleep.StartHeight = bleep.Position.Z; bleep.Position.Z = shooter.WorldCollisionCenter.Z; bleep.Velocity = Vector3.Normalize(targetPos - bleep.Position) * speed; float vdotv = Vector3.Dot(bleep.Velocity, shooter.Movement.Velocity); if (vdotv > 0) { /// If the bullet is moving the same direction as the shooter, /// add in the shooter's speed in the bullet's direction. /// This will only speed up the bullet, not change it's firing /// direction. vdotv /= bleep.Velocity.LengthSquared(); bleep.Velocity += bleep.Velocity * vdotv; } bleep.Life = bleep.TTL = time2Live; bleep.VerbPayload = verbPayload; bleep.Damage = damage; Vector4 color4 = Classification.ColorVector4(color); /// Brighten up the color a bit. color4.X = MyMath.SmoothStep(0.0f, 1.0f, color4.X); color4.Y = MyMath.SmoothStep(0.0f, 1.0f, color4.Y); color4.Z = MyMath.SmoothStep(0.0f, 1.0f, color4.Z); bleep.Color = new Color(color4); bleep.TTTerraHit = CheckTerrainHit(bleep, speed); if (shooter.ActiveBleeps.Bleeps.Count == 0) { Shooters.Add(shooter); } shooter.ActiveBleeps.Bleeps.Add(bleep); // Increment the number of active bleeps. Without this, on the // current frame we can end up shooting enough new bleeps to // exceed the max. ++numActiveBleeps; return(true); } return(false); }
// c'tor public Path(Classification.Colors color) { this.color = color; rgbColor = Classification.ColorVector4(color); Paths.Add(this); Road = new Road(this); ///This might not be the best place for this. Node.PrevNode.Reset(); } // end of Path c'tor
} // end of CruiseMissile InitSmokeEmitter() public override void SetColor(Classification.Colors color) { // Set the body color. base.SetColor(color); // Also change the smoke color. if (smokeEnabled) { OffsetEmitter oe = attachments[0] as OffsetEmitter; SharedSmokeSource sss = oe.Emitter as SharedSmokeSource; sss.Color = Classification.ColorVector4(color); } } // end of SetColor()
/// <summary> /// Fire a missile from the given shooter's position at the target position. /// </summary> /// <param name="shooter"></param> /// <param name="targetPos"></param> /// <param name="color"></param> /// <param name="verbPayload"></param> /// <returns></returns> public bool Fire(GameActor shooter, GameActor target, Vector3 targetPos, Classification.Colors color) { if (numActiveBeams < kMaxBeams) { float speed = shooter.BeamSpeed; float time2Live = shooter.BeamDist / speed; Beam Beam = new Beam(); Beam.Position = shooter.WorldCollisionCenter; Beam.StartHeight = shooter.WorldCollisionCenter.Z; Beam.Position.Z = shooter.WorldCollisionCenter.Z; // Save out the actor Beam.TargetActor = target; // Raise the height of the target pos slightly to avoid terrain hits targetPos.Z += heightOffSet; Beam.Velocity = Vector3.Normalize(targetPos - Beam.Position) * speed; float vdotv = Vector3.Dot(Beam.Velocity, shooter.Movement.Velocity); if (vdotv > 0) { /// If the bullet is moving the same direction as the shooter, /// add in the shooter's speed in the bullet's direction. /// This will only speed up the bullet, not change it's firing /// direction. vdotv /= Beam.Velocity.LengthSquared(); Beam.Velocity += Beam.Velocity * vdotv; } Beam.Life = Beam.TTL = time2Live; Vector4 color4 = Classification.ColorVector4(color); /// Brighten up the color a bit. color4.X = MyMath.SmoothStep(0.0f, 1.0f, color4.X); color4.Y = MyMath.SmoothStep(0.0f, 1.0f, color4.Y); color4.Z = MyMath.SmoothStep(0.0f, 1.0f, color4.Z); Beam.Color = new Color(color4); Beam.TTTerraHit = CheckTerrainHit(Beam, speed); if (shooter.ActiveBeams.Beams.Count == 0) { Shooters.Add(shooter); } shooter.ActiveBeams.Beams.Add(Beam); return(true); } return(false); }
private void Setup(Vector3 position, // Starting position. GameActor launcher, // Actor that launched this missile. float initialRotation, GameThing.Verbs verbPayload, int damage, MissileChassis.BehaviorFlags behavior, Classification.Colors color, float desiredSpeed, bool wantSmoke) { smokeEnabled = wantSmoke; // Or, we could change the sound to something other than the rumble. if (!smokeEnabled) { XmlActorParams.IdleSoundName = null; } MissileChassis missileChassis = Chassis as MissileChassis; missileChassis.Missile = this; missileChassis.Launcher = launcher; missileChassis.VerbPayload = verbPayload; missileChassis.Damage = damage; missileChassis.Behavior = behavior; missileChassis.Rotation = initialRotation; missileChassis.DesiredSpeed = desiredSpeed; Mass = 10.0f; Movement.Position = position; // Calculate initial missile speed. float initialSpeed = desiredSpeed; Vector3 gunVel = launcher.Movement.Velocity; Vector3 shotVel = new Vector3((float)Math.Cos(initialRotation), (float)Math.Sin(initialRotation), 0f) * initialSpeed; if (gunVel.X != 0 || gunVel.Y != 0) { // Add in some of the launcher's velocity. Missile will // gradually adjust its speed to its desired velocity. Vector3 gunVelNorm = Vector3.Normalize(gunVel); Vector3 shotVelNorm = Vector3.Normalize(shotVel); float dot = Vector3.Dot(gunVelNorm, shotVelNorm); Vector3 proj = gunVel * dot; initialSpeed = proj.Length() * MyMath.Direction(dot); } // Don't allow initial speed to be negative because it looks odd. missileChassis.Speed = Math.Max(desiredSpeed, initialSpeed); classification.Color = color; InitSmokeEmitter(Classification.ColorVector4(classification.Color)); InitMuzzleFlash(Classification.ColorVector4(classification.Color), 2.0f, 8.0f); missileChassis.IgnoreGlassWalls = true; missileChassis.Feelers.Clear(); // Don't want missiles to hit glass walls. // Register for collisions. //InGame.inGame.RegisterCollide(this); } // end of Setup()
/// <summary> /// Do a smooth transitioned color change. /// </summary> /// <param name="color"></param> public override void SetColor(Classification.Colors color) { base.SetColor(color); SetColor(Classification.ColorVector4(color)); }