IEnumerator NecromancerSequence() { if (!canSequence) { yield break; } if (firstTimeShoot) { StartCoroutine(WaitToShoot(randShootingOffset)); } else { StartCoroutine(CanSequence()); EncounterGenerator eg = GameObject.Find("EncounterGenerator").GetComponent <EncounterGenerator>(); int rand = Random.Range(0, 2); if (rand == 0) { eg.PlaceEnemyInFreeSpot("Skeleton", 0.3f, 0.5f, 3.5f, Vector2.zero, 0, false, null); } else { eg.PlaceEnemyInFreeSpot("SkeletonWithSword", 0.3f, 0.5f, 3.5f, Vector2.zero, 0, false, null); } SFX.PlayOneShot(necromancerSkeletonsSFX); yield return(new WaitForSeconds(3)); Shoot(); } }
/// <summary> /// Iterates through all possible encounters until a sufficient match is found /// </summary> /// <remarks> /// The iterator lazily finds matching encounters, then verifies secondary checks to weed out any non-exact matches. /// </remarks> /// <param name="pk">Source data to find a match for</param> /// <param name="info">Object to store matched encounter info</param> /// <returns> /// Information containing the matched encounter and any parsed checks. /// If no clean match is found, the last checked match is returned. /// If no match is found, an invalid encounter object is returned. /// </returns> public static void FindVerifiedEncounter(PKM pk, LegalInfo info) { var encounters = EncounterGenerator.GetEncounters(pk, info); using var encounter = new PeekEnumerator <IEncounterable>(encounters); if (!encounter.PeekIsNext()) { VerifyWithoutEncounter(pk, info); return; } var first = encounter.Current; var EncounterValidator = EncounterVerifier.GetEncounterVerifierMethod(first.Generation); while (encounter.MoveNext()) { var enc = encounter.Current; // Check for basic compatibility. var e = EncounterValidator(pk, enc); if (!e.Valid && encounter.PeekIsNext()) { continue; } // Looks like we might have a good enough match. Check if this is really a good match. info.EncounterMatch = enc; info.Parse.Add(e); if (!VerifySecondaryChecks(pk, info, encounter)) { continue; } // Sanity Check -- Some secondary checks might not be as thorough as the partial-match leak-through checks done by the encounter. if (enc is not IEncounterMatch mx) { break; } var match = mx.GetMatchRating(pk); if (match != EncounterMatchRating.PartialMatch) { break; } // Reaching here implies the encounter wasn't valid. Try stepping to the next encounter. if (encounter.PeekIsNext()) { continue; } // We ran out of possible encounters without finding a suitable match; add a message indicating that the encounter is not a complete match. info.Parse.Add(new CheckResult(Severity.Invalid, LEncInvalid, CheckIdentifier.Encounter)); break; } if (!info.FrameMatches && info.EncounterMatch is EncounterSlot { Version : not GameVersion.CXD }) // if false, all valid RNG frame matches have already been consumed
private void Awake() { if (SceneManager.GetActiveScene().name == "EncounterPlace") { GameObject encounterGeneratorObj = GameObject.Find("EncounterGenerator"); encounterGenerator = encounterGeneratorObj.GetComponent <EncounterGenerator>(); encounterGenerator.EncounterNpcs.Add(gameObject); encounterGenerator.EncounterNpcArray[0] = gameObject; } }
// Get the right references... void Start() { GameObject gameManagerObj = GameObject.Find("GameManager"); gameManager = gameManagerObj.GetComponent <GameManager>(); seed = gameManager.seed; rigid = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); render = GetComponent <SpriteRenderer>(); //In the tagsDemo scene, we want to do something when we make a choice... rpgTalk.OnMadeChoice += OnMadeChoice; if (SceneManager.GetActiveScene().name == "EncounterPlace") { GameObject encounterGeneratorObj = GameObject.Find("EncounterGenerator"); encounterGenerator = encounterGeneratorObj.GetComponent <EncounterGenerator>(); } }
public void changeHealth(int amount) { if (amount < 0 && DeathSFX) { StartCoroutine(flashWhite()); } health += amount; if (health <= 0) { health = 0; if (spawnPoof) { SFX.PlayOneShot(DeathSFX); GameObject spawn = Instantiate(spawnPoof, transform.position, Quaternion.identity); Destroy(spawn, 0.3f); if (gameObject.name == "Necromancer") { EncounterGenerator eg = GameObject.Find("EncounterGenerator").GetComponent <EncounterGenerator>(); StartCoroutine(eg.Despawn()); } Destroy(gameObject.transform.parent.gameObject, 0.2f); } } else if (health >= 0) { if (SFX) { SFX.PlayOneShot(HitSFX); } int t = Mathf.FloorToInt((health * 1f) / (maxHealth * 1f) * 10f); if (t == 0) { t = 1; } healthBar.GetComponent <SpriteRenderer>().sprite = healthbarSprites[t]; } }
private void Awake() { instance = this; }