public float GetDistance(eWayType _type) { List <Point> _list; float _distance = 0; switch (_type) { case eWayType.Up: if (distanceUp == 0) { _list = listUp; for (int i = 0, imax = _list.Count - 1; i < imax; i++) { distanceUp += Vector3.Distance(_list[i].position, _list[i + 1].position); } } _distance = distanceUp; break; case eWayType.Down: if (distanceDown == 0) { _list = listDown; for (int i = 0, imax = _list.Count - 1; i < imax; i++) { distanceDown += Vector3.Distance(_list[i].position, _list[i + 1].position); } } _distance = distanceDown; break; } return(_distance); }
public Point(Vector3 _pos, string _tag) { position = _pos; type = (eWayType)System.Enum.Parse(typeof(eWayType), _tag, true); //switch (_tag) //{ // case "Up": type = eWayType.Up; break; // case "Down": type = eWayType.Down; break; // default: type = eWayType.Common; break; //} }
public Enemy GetHealth(eWayType _type) { Enemy _enemy = null; Point _point; for (int i = 0, imax = listHealth.Count; i < imax; i++) { _point = listHealth[i].point; if (_point.type == _type || _point.type == eWayType.Common) { _enemy = listHealth[i]; break; } } return(_enemy); }
//private void Start() //{ // InitData(); //} public void SetData(float _health, eWayType _wayType) { health = _health; wayType = _wayType; gameObject.SetActive(true); if (wayType == eWayType.Up) { wayPoints = WayPoints.ins.listUp; } else { wayPoints = WayPoints.ins.listDown; } index = 0; point = wayPoints[index]; distance = WayPoints.ins.GetDistance(wayType); trans = transform; trans.position = point.position; textMesh.text = string.Format("{0}", health); }
// Update is called once per frame void Update() { if (Time.time > nextTime) // && count < 10) { nextTime = Time.time + NEXTF_TIME; eWayType _type = (count++ % 2 == 0) ? eWayType.Down : eWayType.Up; Enemy _enemy = Instantiate(enemyPrefab, transform.position, Quaternion.identity) as Enemy; _enemy.SetData(100 + count * 10, _type); _enemy.name += count.ToString() + _type.ToString(); _enemy.transform.SetParent(transform); list.Add(_enemy); listDistance.Add(_enemy); listHealth.Add(_enemy); bSort = true; } if (Time.time > sortTime && list.Count > 0) { sortTime = Time.time + 1f / 20f; SortList(); } }