public void OnDestroy() { Destroy(Instantiate(HP_Prefabs.bulletFadePrefab, gameObject.transform.position, gameObject.transform.localRotation), 0.03f); //bullet fade out sprite if (specialAttrib.Contains("Explosion") && PlayerData.instance.equippedCharm_17) { HP_Prefabs.prefabDictionary.TryGetValue("Knight Spore Cloud", out GameObject sporeCloud); GameObject sporeCloudGO = Instantiate(sporeCloud, gameObject.transform.position + new Vector3(0, 0, -.001f), Quaternion.identity); sporeCloudGO.SetActive(true); } if (specialAttrib.Contains("DungExplosion")) { HP_Prefabs.prefabDictionary.TryGetValue("Dung Explosion", out GameObject dungExplosion); GameObject dungExplosionGO = Instantiate(dungExplosion, gameObject.transform.position + new Vector3(0, 0, -.001f), Quaternion.identity); dungExplosionGO.SetActive(true); dungExplosionGO.name += " KnightMadeDungExplosion"; if (specialAttrib.Contains("Small")) { dungExplosionGO.transform.localScale = new Vector3(0.75f, 0.75f, 0); } } //If its from a grenade launch or a offensive fire support projectile, make it explode else if (gameObject.GetComponent <HP_BulletBehaviour>().specialAttrib.Contains("Explosion") || isFireSupportBullet) { GameObject explosionClone = HP_Prefabs.SpawnObjectFromDictionary("Gas Explosion Recycle M", gameObject.transform.position + new Vector3(0, 0, -.001f), Quaternion.identity); explosionClone.name += " KnightMadeExplosion"; //Shrinks the explosion when its not a fire support bullet or its not an upgraded vengeful, as a nerf/downgrade if (isFireSupportBullet) { HP_SpellControl.PlayAudio("mortarexplosion", true); } else if (PlayerData.instance.fireballLevel > 1) { explosionClone.transform.localScale = new Vector3(1.3f, 1.3f, 0); } else { explosionClone.transform.localScale = new Vector3(0.7f, 0.7f, 0); } } }
/* ======================================================FIRE SUPPORT OFFENSIVE TARGET=========================== * NOTE: * Heres the thing with this method * * Turns out if the game object that gets deleted, whatever coroutine they do also gets deleted * Which is why the coroutine only fires 1 round before destroying itself * This method just ensures that theres a long enough lifespan on the bullet once it hits that it'll be able to * deplete all the rounds */ public void OffensiveFireSupport_Target(GameObject fireSupportGO, GameObject enemyGO, bool trackTarget) { Vector3 pos = gameObject.transform.position; Modding.Logger.Log("CALL AN AIR STRIKE AT THIS POSITION " + pos); fireSupportGO.GetComponent <BoxCollider2D>().enabled = false; //If i dont disable the collider, itll keep colliding and keep calling fire support on wtv it collides on fireSupportGO.GetComponent <SpriteRenderer>().enabled = false; //Just to make sure it stops showing up visually fireSupportGO.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); //Stop the bullet movement, so the line renderer wont show up int totalShells = (PlayerData.instance.screamLevel > 1) ? 10 : 6; //Modding.Logger.Log(enemyGO.transform == null); if (trackTarget && enemyGO != null) { StartCoroutine(HP_SpellControl.StartSteelRain(enemyGO, totalShells)); } else { StartCoroutine(HP_SpellControl.StartSteelRainNoTrack(pos, totalShells)); } Destroy(fireSupportGO, 25f); }