public void GainExperience(int damageDealt) { if (damageDealt == 0) { return; } experienceSpriteFont.AddValue(damageDealt); for (int i = 0; i < Parameter.ThorExperienceTable.Count(); i++) { if (experienceSpriteFont.FinalValue > Parameter.ThorExperienceTable[i] && i + 1 != Parameter.ThorExperienceTable.Count()) { continue; } if (experienceSpriteFont.FinalValue >= Parameter.ThorExperienceTable.Last()) { levelSpriteFont.UpdateValue(i + 2); } else { levelSpriteFont.UpdateValue(i + 1); } int extraColor = i + 1; if (extraColor == Parameter.ThorExperienceTable.Count()) { extraColor = i; } //Interpolating color values float ciV1 = experienceSpriteFont.FinalValue - damageDealt; float ciV2 = Parameter.ThorExperienceTable[i]; if (i != 0) { ciV1 = Math.Max(0, ciV1 - Parameter.ThorExperienceTable[i - 1]); ciV2 -= Parameter.ThorExperienceTable[i - 1]; } beamColor = Color.Lerp( Parameter.ColorGradient[i], Parameter.ColorGradient[extraColor], ciV1 / ciV2); break; } }
public void CancelChangesAction(object sender) { for (int i = 0; i < attributeNumericSpriteFontList.Count; i++) { NumericSpriteFont nsf = attributeNumericSpriteFontList[i]; nsf.UpdateValue(attributes[i]); } remainingPoints = GameInformation.Instance.PlayerInformation.GetCurrentAttributePoints() - attributes.ToList().Sum(); cancel.Disable(); accept.Disable(); UpdateAttributeButtons(); }
public void Update(GameTime GameTime) { #if DEBUG //DEBUG debugCrosshair1.Update(CannonPosition); debugCrosshair2.Update(CrosshairPointer.Position); #endif //Calculating Cannon Position, Cannon Frame (Sprite) Position & Angle int newPosX = (int)(crosshairPreset.CannonOffsetDistance * Math.Cos(mobile.MobileFlipbook.Rotation + crosshairPreset.CannonOffsetRotation)); int newPosY = (int)(crosshairPreset.CannonOffsetDistance * Math.Sin(mobile.MobileFlipbook.Rotation + crosshairPreset.CannonOffsetRotation)); crosshairFrame.Position = CannonPosition = mobile.MobileFlipbook.Position + new Vector2(newPosX, newPosY); crosshairFrame.Rotation = mobile.MobileFlipbook.Rotation; //Update the shooting angle based on how much time up/down key has been pressed if (mobile.IsPlayable) { UpdateShootingAngle(GameTime); } else { AutomaticUpdateShootingAngle(GameTime); } // Force shooting angle to keep between the selected min and max ShootingAngle = MathHelper.Clamp(ShootingAngle, aimPreset.AimFalseRotationMin, aimPreset.AimFalseRotationMax); // Update the crosshair angle if (mobile.IsPlayable) { if (!IsTrueAngle) { selectedCrosshairAngle = crosshairAngleList[0]; } else { selectedCrosshairAngle = crosshairAngleList[1]; } } // Calculate new crosshair pointer depending on wich side the tank is facing if (mobile.Facing == Facing.Left) { CrosshairPointer.Rotation = crosshairFrame.Rotation + MathHelper.ToRadians(270 + ShootingAngle); newPosX = (int)(crosshairPreset.CrosshairPointerOffset * Math.Cos(crosshairDesiredRotation + MathHelper.ToRadians(ShootingAngle))); newPosY = (int)(crosshairPreset.CrosshairPointerOffset * Math.Sin(crosshairDesiredRotation + MathHelper.ToRadians(ShootingAngle))); //And calculate the Delay numeric field position if (mobile.IsPlayable) { selectedCrosshairAngle.Position = crosshairFrame.Position + 30 * new Vector2( (float)Math.Cos(crosshairFrame.Rotation + MathHelper.ToRadians(150)), (float)Math.Sin(crosshairFrame.Rotation + MathHelper.ToRadians(150))); } } else { CrosshairPointer.Rotation = crosshairFrame.Rotation + MathHelper.ToRadians(90 - ShootingAngle); newPosX = (int)(crosshairPreset.CrosshairPointerOffset * Math.Cos(crosshairDesiredRotation - MathHelper.ToRadians(ShootingAngle))); newPosY = (int)(crosshairPreset.CrosshairPointerOffset * Math.Sin(crosshairDesiredRotation - MathHelper.ToRadians(ShootingAngle))); //And calculate the Delay numeric field position if (mobile.IsPlayable) { selectedCrosshairAngle.Position = crosshairFrame.Position - 30 * new Vector2( (float)Math.Cos(crosshairFrame.Rotation - MathHelper.ToRadians(150)), (float)Math.Sin(crosshairFrame.Rotation - MathHelper.ToRadians(150))); } } CalculateHUDAngle(); // Update the HUD angle text after defining its position selectedCrosshairAngle?.UpdateValue(HUDSelectedAngle); selectedCrosshairAngle?.Update(); // Update the crosshair pointer location CrosshairPointer.Position = CannonPosition - new Vector2(newPosX, newPosY); // Update crosshair aim range indicators crosshairRangeIndicatorList.ForEach( (x) => { x.Position = crosshairFrame.Position; x.Rotation = crosshairFrame.Rotation; }); //Update Animations animationEventHandler?.Invoke(GameTime, null); }