| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
-
- 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<NetworkEnemyBasic>();
- 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<Animation>().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;
- }
- }
- }
|