using System; using UnityEngine; public class Fish : MonoBehaviour { public void Init(Vector3[] paths, float minTime, float maxTime, float lookTime) { this.itweenPath = paths; this.minTime = minTime; this.maxTime = maxTime; this.lookTime = lookTime; } public void MovePath() { if (!this.isInit) { this.go = new GameObject("LookTarget"); this.go.transform.parent = base.gameObject.transform.parent; this.go.layer = base.gameObject.layer; this.go.transform.position = this.itweenPath[1]; this.isInit = true; } this.pathNo++; if (this.pathNo > this.itweenPath.Length - 1) { this.pathNo = 1; } int num = (this.pathNo + 1 <= this.itweenPath.Length - 1) ? (this.pathNo + 1) : 1; iTween.MoveTo(this.go, iTween.Hash(new object[] { "position", this.itweenPath[num], "time", UnityEngine.Random.Range(this.minTime, this.maxTime), "easeType", "linear", "isLocal", true })); iTween.MoveTo(base.gameObject, iTween.Hash(new object[] { "position", this.itweenPath[this.pathNo], "time", UnityEngine.Random.Range(this.minTime, this.maxTime), "easeType", "linear", "oncomplete", "MovePath", "isLocal", true })); } private void Update() { base.transform.LookAt(this.go.transform); } private int pathNo; private Vector3[] itweenPath; private float minTime; private float maxTime; private float lookTime; private bool isInit; private GameObject go; }