static void PhaseManager(Phase p) { switch (p) { case (Phase.ORDERS): { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(StrategicClock.strategicClock, Turn()); break; } case (Phase.GO): { break; } case (Phase.REVIEW): { break; } case (Phase.INTERRUPT): { break; } } }
//im so sorry u exist //Sets up our dictionaries static Character() { StrategicClock.PhaseChange.AddListener(PhaseManager); JobTitlesDictLong.Add(OfficerRoles.Navy, NavalRankNames); JobTitlesDictLong.Add(OfficerRoles.Army, ArmyRankNames); JobTitlesDictLong.Add(OfficerRoles.Research, ResearchRankNames); JobTitlesDictLong.Add(OfficerRoles.Government, GovRankNames); JobTitlesDictShort.Add(OfficerRoles.Navy, NavalRankNamesS); JobTitlesDictShort.Add(OfficerRoles.Army, ArmyRankNamesS); JobTitlesDictShort.Add(OfficerRoles.Research, ResearchRankNamesS); JobTitlesDictShort.Add(OfficerRoles.Government, GovRankNamesS); RolesAbbrev.Add(OfficerRoles.Navy, "OF"); RolesAbbrev.Add(OfficerRoles.Army, "MN"); RolesAbbrev.Add(OfficerRoles.Government, "GV"); RolesAbbrev.Add(OfficerRoles.Research, "RD"); NobleRanks.Add(Sex.Female, NobleRanksF); NobleRanks.Add(Sex.Male, NobleRanksM); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(StrategicClock.strategicClock, LoadTitles()); }
// Use this for initialization void Start() { if (render == null) { render = GetComponent <Renderer> (); } ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, LightControl()); }
public void OpenShipMenu() { ShipUI.active = !ShipUI.activeSelf; if (ShipUI) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, BuildArmorString()); } }
/* * public void TakeComponentDamage(int amount){ * if (DesignTemplate == null) { * return; * } * int attempts = 0; * ShipComponents target; * while (amount > 0) { * target = RollDAC (); * while (target.isDamaged ()) { * target = RollDAC (); * attempts++; * if (attempts > MaxAttempts) { * Debug.Log ("Ship destroyed from excessive damage"); * ship.SpawnDebris (ship.transform.position); * break; * } * } * if (amount >= target.GetHTK ()) { * target.Damage (); * DamagedComponents.Add (target); * amount -= target.GetHTK (); * crew -= (int)(Random.Range (.75f, 1.2f) * target.CrewRequired); * } else if (amount < target.GetHTK ()) { * float chance = amount / target.GetHTK (); * if (Random.Range (0f, 1f) < chance) { * target.Damage (); * crew -= (int)(Random.Range (.25f, .95f) * target.CrewRequired); * DamagedComponents.Add (target); * } else { * crew -= (int)(Random.Range (.15f, .35f) * target.CrewRequired); * } * * amount = 0; * } * if (crew < 0) { * crew = 0; * ship.SpawnDebris (transform.position); //TODO make it just go neutral instead of exploding * } * } * CalculateIntegrity (); * ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this,ChangeStats()); * OutputReport (); * } */ public IEnumerator TakeComponentDamage(float amount) { Debug.Log("Component Damage"); int attempts = 0; ShipComponents target; while (amount > 0) { target = RollDAC(); while (target.isDestroyed()) { target = RollDAC(); attempts++; if (attempts > MaxAttempts) { Debug.Log("Ship destroyed from excessive damage"); yield return(Ninja.JumpToUnity); ship.SpawnDebris(ship.transform.position); break; } } if (amount >= target.GetHTK()) { target.Damage(); DamagedComponents.Add(target); amount -= target.GetHTK(); crew -= (int)(random.Next(80, 110) / 100 * target.CrewRequired); } else if (amount < target.GetHTK()) { float chance = amount / target.GetHTK(); if (random.Next(0, 100) / 100 < chance) { target.Damage(); crew -= (int)(random.Next(35, 95) / 100 * target.CrewRequired); DamagedComponents.Add(target); } else { crew -= (int)(random.Next(5, 25) / 100 * target.CrewRequired); } amount = 0; } if (crew < 0) { crew = 0; // ship.SpawnDebris (transform.position); //TODO make it just go neutral instead of exploding } } yield return(Ninja.JumpToUnity); CalculateIntegrity(); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, ChangeStats()); // OutputReport (); }
public static void GenerateCharacters(Empire e, Dictionary <OfficerRoles, KeyValuePair <int, List <float> > > Input) { foreach (OfficerRoles role in Enum.GetValues(typeof(OfficerRoles))) { if (Input.ContainsKey(role)) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(StrategicClock.strategicClock, GenerateCharactersCoroutine(e, role, Input[role].Value, Input[role].Key)); } } }
void CalculateFleetSpeed() { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, FleetSpeedIterator()); if (Speed > MaxSpeed) { Speed = MaxSpeed; } if (Mode == MoveMode.DOCKED) { Speed = 0f; } }
void OnChange() { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, CheckCrewRequirements()); CalculateArmorWidth(); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, CalculateMass()); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, CheckRequirements()); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, CalcMaxSpeed()); ArmorText.text = ArmorLength.ToString() + " x " + ArmorThickness.ToString(); SetupMaint(); InstalledText.text = GenerateInstalledText(); BuildDescription(); }
public void SetupArmor(int c, int r, float armorStrength) { Armor = new float[c, r]; for (int x = 0; x < Armor.GetLength(0); x += 1) { for (int y = 0; y < Armor.GetLength(1); y += 1) { Armor [x, y] = armorStrength; } } ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, BuildArmorString()); MaxArmor = armorStrength; }
public void PhysicsDamage(float dam, Shield s, Vector3 source, Vector3 force, Transform en, List <Int2> pattern) { GameObject g = GameObject.Instantiate(ShieldPrefab); LineRenderer l = g.GetComponent <LineRenderer> (); g.transform.position = parent.transform.position; g.transform.position = Vector3.MoveTowards(g.transform.position, source, .2f); parent.ScreenProxyDelete(g); if (!ShieldsWillHold(dam, source, en)) { parent.ship.rb.AddForce(force); } if (s.strength > 0f) { float applyDam = dam; dam -= s.strength; s.strength -= applyDam; if (s.strength < 0f) { s.strength = 0f; } } if (dam > 0f) { if (WallShield.strength > 0f) { float applyDam = dam; dam -= WallShield.strength; WallShield.strength -= applyDam; if (WallShield.strength < 0f) { WallShield.strength = 0f; } } if (dam > 0f) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(parent, parent.ship.DamageArmor(pattern, (int)dam)); //parent.integrity -= Random.Range (10f, 25f) * dam; if (abs.integrity <= 0f && !dead) { parent.ship.Die(); parent.ship.SpawnDebris(source); dead = true; } } } }
void Start() { SystemSize = OutlineCircleStarMarker.SYSRADIUS; numPlanets = Random.Range(0, 3); for (int i = 0; i < numPlanets; i++) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, GeneratePlanet((i + 1) * (SystemSize / numPlanets))); //GeneratePlanet ((i+1) * (SystemSize / numPlanets)); } if (asteroidBelt) { GenerateAsteroidRing(50f); } }
void Awake() { Species s = new Species("Poof"); StreamingPath = Application.streamingAssetsPath; Debug.LogError("Streaming path loaded into string. Proceed."); if (Manager != null) { Debug.Log("Error, multiple ThemeManagers present"); } Trait.Load(); Manager = this; GenerateThemes(); if (!DebugSuppressPortraitLoading) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, ImportPortraits()); } }
// Use this for initialization void Awake() { star = Resources.Load <GameObject> ("StarMarker") as GameObject; ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, Generate()); }
IEnumerator DamageArmor(List <Int2> pattern, float dam) { if (dam >= Mass / 1000) { if (random.NextDouble() < dam / (Mass / (2 + 15 * (1 - Sturdiness)))) { Debug.Log("Shock Damage"); TakeComponentDamage(dam * random.NextFloat(.35f, .6f)); } } float counter = dam; //Counter is how much damage will be passed on to components. Set to max in case the ship isnt armored. if (Armored) { int startX = random.Next(0, Armor.GetLength(0) - 1); int startY = 0; for (startY = Armor.GetLength(1) - 1; startY >= 0; startY--) { if (Armor[startX, startY] > 0f) { break; } } int HullBound = 0; counter = 0; //reset counter to 0, we'll calculate it using the armor since this ship has armor. //adjust penetration profile by damage for (int i = 0; dam > 0; i++) { // if (i >= pattern.Count) { i = 0; } Int2 v = pattern[i]; if (startY + v.y < HullBound) { if (dam >= 1f) { counter++; dam -= 1; } else { counter += dam; dam = 0f; } } if (startX + v.x < 0) { v.x += Armor.GetLength(0) - 1; } if (startX + v.x > Armor.GetLength(0) - 1) { v.x -= Armor.GetLength(0) - 1; } if (startX + v.x >= 0 && startX + v.x < Armor.GetLength(0) && startY + v.y >= 0 && startY + v.y < Armor.GetLength(1)) { try { if (dam > Armor[startX + v.x, startY + v.y]) { dam -= Armor[startX + v.x, startY + v.y]; Armor[startX + v.x, startY + v.y] = 0f; } else { Armor[startX + v.x, startY + v.y] -= dam; dam = 0f; } } catch { Debug.Log("Invalid armor coords"); } } } } yield return(Ninja.JumpToUnity); Debug.Log("Penetrating hits: " + counter); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(StrategicClock.strategicClock, TakeComponentDamage(counter)); }
void UpdateTextVoid() { StopAllCoroutines(); ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, UpdateText()); }
//lowest layer to hull is always 0, negatives have penetrated armor entirely. public IEnumerator DamageArmor(List <Int2> pattern, float dam) { if (shipClass.usingTemplate) { if (dam >= shipClass.Mass / 1000) { if (rnd.NextDouble() < dam / (shipClass.Mass / (2 + 15 * (1 - shipClass.DesignTemplate.Sturdiness)))) { Debug.Log("Shock Damage"); shipClass.TakeComponentDamage(dam * rnd.NextFloat(.45f, .7f)); } } } int startX = rnd.Next(0, Armor.GetLength(0) - 1); int startY = 0; for (startY = Armor.GetLength(1) - 1; startY >= 0; startY--) { if (Armor [startX, startY] > 0f) { break; } } int HullBound = 0; float counter = 0; //adjust penetration profile by damage for (int i = 0; dam > 0; i++) //TODO REFACTOR PLS PLS PLS ITS SO BAD { if (i >= pattern.Count) { i = 0; } Int2 v = pattern[i]; if (startY + v.y < HullBound) { if (dam >= 1f) { counter++; dam -= 1; } else { counter += dam; dam = 0f; } } if (startX + v.x < 0) { v.x += Armor.GetLength(0) - 1; } if (startX + v.x > Armor.GetLength(0) - 1) { v.x -= Armor.GetLength(0) - 1; } if (startX + v.x >= 0 && startX + v.x < Armor.GetLength(0) && startY + v.y >= 0 && startY + v.y < Armor.GetLength(1)) { try { if (dam > Armor [startX + v.x, startY + v.y]) { dam -= Armor [startX + v.x, startY + v.y]; Armor [startX + v.x, startY + v.y] = 0f; } else { Armor [startX + v.x, startY + v.y] -= dam; dam = 0f; } } catch { Debug.Log("Invalid armor coords"); } } } yield return(Ninja.JumpToUnity); Debug.Log("Penetrating hits: " + counter); if (shipClass.usingTemplate) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, shipClass.TakeComponentDamage(counter)); } else { integrity -= rnd.NextFloat(2f, 5f) * counter; } if (ShipUI) { ThreadNinjaMonoBehaviourExtensions.StartCoroutineAsync(this, BuildArmorString()); } }