using System; using System.Collections; using UnityEngine; namespace Subworlds.Scripts { class AttackDroidScript : EnemyScript { private Vector3 dir; private bool attacking; private void Awake() { base.trig[0] = gameObject.transform.GetChild(1).gameObject; base.trig[1] = gameObject.transform.GetChild(2).gameObject; base.Initialize(100, 5, 70, new int[] { 3, 3, 57 }, 60); var network = gameObject.GetComponent(); network.isPirate = true; } private void Update() { if (Network.isServer) { if (!this.attacking) { this.r.velocity = new Vector3(0f, 0f, 0f); if (this.target) { if (Mathf.Abs(this.target.transform.position.x - this.t.position.x) < 45f) { this.attacking = true; base.StartCoroutine(this.Attack()); } else { this.target = null; this.r.velocity = new Vector3(0f, 0f, 0f); } } } } } private IEnumerator Attack() { gameObject.transform.GetChild(0).gameObject.GetComponent().Play(); yield return new WaitForSeconds(0.55f); this.dir = this.target.transform.position - this.t.position; this.dir.Normalize(); yield return new WaitForSeconds(0.05f); this.r.velocity = this.dir * (30f); yield return new WaitForSeconds(1.1f); this.r.velocity = new Vector3(0f, 0f, 0f); this.attacking = false; yield break; } } }