/// <summary> /// Code to run each tick /// </summary> private void Tick() { offsetVector = RotationHelper.Direction2DFromAngle(offsetAngle, owner.RotationAngle); offsetVector = offsetVector * offsetMagnitude; Position2D = owner.Position2D + offsetVector; RotationAngle = owner.RotationAngle; if (IsParent) { if (health < 0) { health = 0; } } //Burn damage if (isParent && isBurning && GM.eventM.Elapsed(tiBurnTick)) { health--; for (int i = 0; i < GM.r.FloatBetween(1, 2); i++) { FadingParticle smokeParticle = new FadingParticle(new Vector2(Centre2D.X + GM.r.FloatBetween(-2, 2), Centre2D.Y + GM.r.FloatBetween(-2, 2)), new Vector3(GM.r.FloatBetween(-4, 4), GM.r.FloatBetween(-4, 4), 0), GM.r.FloatBetween(0, 360), GM.r.FloatBetween(5, 10)); smokeParticle.Wash = Color.DarkSlateGray; } if (GM.r.FloatBetween(0, 1) > 0.90) { Ship ship = (Ship)owner; ship.CrewNum -= 1; } } }
/// <summary> /// Code to run each second /// </summary> internal void OneSecond() { //Repairing if (IsRepairing) { float repairAmount = crewNum; //Spread repair amount amongst each part HitBox[] repairArray = new HitBox[7]; int repairNum = 0; for (int i = 0; i <= 6; i++) { if (hitBoxArray[i].Health < 100 && ((hitBoxArray[i].DamageType == 0 && hullRepMats > 0) || (hitBoxArray[i].DamageType == 1 && sailRepMats > 0)) || hitBoxArray[i].IsBurning) { repairArray[repairNum] = hitBoxArray[i]; repairNum++; } } if (repairNum == 0) { if (!rightLoaded) { tiReloadRight.Paused = false; } if (!leftLoaded) { tiReloadLeft.Paused = false; } IsRepairing = false; } else { float repairPerPart = (repairAmount * 0.025f) / repairNum; for (int i = 0; i < repairNum; i++) { repairArray[i].Health += repairPerPart; if (repairArray[i].Health > 100) { repairArray[i].Health = 100; } if (repairArray[i].IsBurning && GM.r.FloatBetween(0, 1) > 0.9 * (0.9 - GameSetup.WeatherController.RainAmount)) { repairArray[i].IsBurning = false; } if (repairArray[i].DamageType == 0) { hullRepMats -= (repairPerPart * 0.5f); } else { sailRepMats -= (repairPerPart * (3 / 2)); } } } } //Calculations for sinking float hullHealthMissing = 0; for (int i = 0; i <= 3; i++) { hullHealthMissing += (100 - hitBoxArray[i].Health); } sinkAmount += (int)(hullHealthMissing * 0.15); if (GameSetup.WeatherController.RainAmount > 0.75f) { sinkAmount -= 4; } else { sinkAmount -= 6; } if (sinkAmount >= 1000) { //Splash for (int i = 0; i <= GM.r.FloatBetween(200, 400); i++) { float spawnRot = GM.r.FloatBetween(0, 360); Vector3 spawnVel = RotationHelper.Direction3DFromAngle(spawnRot, 0) * 200; FadingParticle splash = new FadingParticle(Position2D, spawnVel, spawnRot, 0.25f); splash.Wash = Color.Aqua; splash.SX = 1f; splash.SY = 5f; } Kill(); } //Calculations for sail damage speed multiplier sailDamageSpeedMul = 0; for (int i = 4; i <= 6; i++) { sailDamageSpeedMul += hitBoxArray[i].Health; } sailDamageSpeedMul *= 0.003f; //Boarding checks if (isBoarded && isCuttingRopes) { if (GM.r.FloatBetween(0, 1) > 0.75f) { isCuttingRopes = false; isBoarded = false; GameSetup.BoardingInProgress = false; if (isPlayer) { GameSetup.Opponent.isBoarding = false; } else { GameSetup.Player.isBoarding = false; } } } }