using System; using System.Collections; using UnityEngine; namespace UltimateNPCWeapons.Scripts { public class RingaboltsOathProjectile : MonoBehaviour { public float speed = 30; public float deathTimer = 1; private float projRange; private Transform t; private Renderer r; private GameObject atalanta; private int damage; private int anim = 0; private float tick = 0; private bool bursting; private bool reborn; private bool dying; private Vector3 dir; private void Awake() { t = transform; r = t.GetChild(0).GetComponent(); atalanta = t.GetChild(1).gameObject; } private void Set(Package2 d) { damage = (int)d.damage; dir = new Vector3(d.dir.x, 0f, 0f); dir.Normalize(); projRange = d.projRange; StartCoroutine(Die()); } private IEnumerator Burst(Vector3 targ) { bursting = true; yield return new WaitForSeconds(0.1f); dir = targ - t.position; dir = new Vector3(dir.x, 0f, 0f); dir.Normalize(); bursting = false; yield return new WaitForSeconds(0.4f); yield break; } private void Exile() { Network.RemoveRPCs(GetComponent().viewID); Network.Destroy(gameObject); } [RPC] private void hide() { t.position = new Vector3(-500f, -500f, -500f); } private IEnumerator Die() { if (!dying) { dying = true; yield return new WaitForSeconds(deathTimer + projRange * 0.05f); if (!reborn) { hide(); yield return new WaitForSeconds(5f); UnityEngine.Object.Destroy(gameObject); } else { reborn = false; dying = false; StartCoroutine(Die()); } } yield break; } private IEnumerator DieNetwork(float w) { if (!dying) { dying = true; yield return new WaitForSeconds(deathTimer); hide(); gameObject.GetComponent().RPC("hide", RPCMode.All, new object[0]); yield return new WaitForSeconds(w); Exile(); } yield break; } [RPC] private void DieN() { Network.RemoveRPCs(base.GetComponent().viewID); Network.Destroy(base.gameObject); } private void Update() { tick += speed * Time.deltaTime; if (tick > 1.8f) { tick = 0; anim = (anim + 1) % 4; r.material.mainTextureOffset = new Vector2(0.25f * anim, 0f); } } private void Eye(int a) { if (!reborn) { damage += a; reborn = true; speed *= 1.2f; atalanta.SetActive(true); } } private void OnTriggerEnter(Collider c) { if (c.gameObject.layer == 9 || c.gameObject.layer == 28) { float[] array = new float[] { damage, t.position.x }; if (Network.isServer) c.gameObject.SendMessage("TD", array); } } } }