| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System.Collections;
- using UnityEngine;
- namespace Subworlds.Scripts
- {
- class BrokenLaserScript : MonoBehaviour
- {
- private Renderer r;
- private GameObject hazard;
- public int anim;
- public bool active;
- private bool animating;
- private bool running;
- private void Awake()
- {
- this.r = base.GetComponent<Renderer>();
- this.hazard = base.transform.GetChild(0).gameObject;
- OnEnable();
- }
- private void OnEnable()
- {
- if (!animating)
- base.StartCoroutine(this.Anim());
- if (Network.isServer)
- {
- if (!running && this.gameObject.activeSelf)
- base.StartCoroutine(this.Run());
- }
- }
- private void OnDisable()
- {
- this.r.material.mainTextureOffset = new Vector2(0f, 0f);
- this.animating = false;
- this.running = false;
- }
- [RPC]
- private void ChageState(bool state)
- {
- active = state;
- StartCoroutine(SetActiveDelay(state));
- }
- private IEnumerator SetActiveDelay(bool state)
- {
- yield return new WaitForSeconds(0.15f);
- hazard.SetActive(state);
- }
- private IEnumerator Run()
- {
- running = true;
- while (true)
- {
- yield return new WaitForSeconds(1f);
- base.GetComponent<NetworkView>().RPC("ChageState", RPCMode.All, new object[] { true });
- yield return new WaitForSeconds(2f);
- base.GetComponent<NetworkView>().RPC("ChageState", RPCMode.All, new object[] { false });
- }
- }
- // Token: 0x0600009B RID: 155 RVA: 0x0000E4C8 File Offset: 0x0000C8C8
- private IEnumerator Anim()
- {
- this.animating = true;
- while (true)
- {
- anim = (anim + 1) % 4;
- if (active)
- {
- this.r.material.mainTextureScale = new Vector2(0.2f, 1f);
- this.r.material.mainTextureOffset = new Vector2(0.2f * (anim + 1), 0f);
- }
- else
- {
- this.r.material.mainTextureScale = new Vector2(0.2f, 1f);
- this.r.material.mainTextureOffset = new Vector2(0f, 0f);
- }
- yield return new WaitForSeconds(0.1f);
- }
- }
- }
- }
|