public EGFiretruck GetClosestIdleTruck(Vector3 pos) { EGFiretruck closest = null; float shortestDist = -1; for (int i = 0; i < _idleTrucks.Count; i++) { EGFiretruck truck = _idleTrucks[i]; float dist = Vector3.Distance(truck.transform.position, pos); if (closest == null) { closest = truck; shortestDist = dist; } else if (dist < shortestDist) { closest = truck; shortestDist = dist; } } if (closest != null) { _idleTrucks.Remove(closest); } return(closest); }
void Start() { truck = transform.root.gameObject.GetComponent <EGFiretruck> (); //set the tile size of the texture (in UV units), based on the rows and columns Vector2 size = new Vector2(1f / UnifiedAnimator.FLAME_COLUMNS, 1f / NUM_STATES); GetComponent <Renderer>().sharedMaterial.SetTextureScale("_MainTex", size); }
public void RemoveTruck(EGFiretruck truck) { if (_idleTrucks.Contains(truck)) { _idleTrucks.Remove(truck); } else if (_activeTrucks.Contains(truck)) { _activeTrucks.Remove(truck); } }
public EGFiretruck GetActiveTruckAtIndex(int index) { EGFiretruck truck = null; if (index >= 0 && index < _activeTrucks.Count) { truck = _activeTrucks[index]; } return(truck); }
void HandleTouchTruckStart(RaycastHit hitInfo) { if (hitInfo.transform.gameObject.tag.Equals("Truck")) { EGFiretruck truck = hitInfo.transform.root.gameObject.GetComponent <EGFiretruck> (); if (truck != null) { _dispatcher.SetSelectedTruck(truck); } } }
public EGFiretruck PopIdleTruck() { EGFiretruck poppedTruck = null; if (_idleTrucks.Count > 0) { poppedTruck = _idleTrucks[0]; _idleTrucks.Remove(poppedTruck); } return(poppedTruck); }
void HandleTouchTruckEnded(RaycastHit hitInfo) { singleTouchDown = false; dragging = false; if (hitInfo.transform.gameObject.tag.Equals("Truck")) { EGFiretruck truck = hitInfo.transform.root.gameObject.GetComponent <EGFiretruck> (); if (truck != null) { _dispatcher.SetSelectedTruck(truck); } } }
public void RemoveActiveTruck(EGFiretruck truck) { _activeTrucks.Remove(truck); }
public void RemoveIdleTruck(EGFiretruck truck) { _idleTrucks.Remove(truck); }
public void AddActiveTruck(EGFiretruck truck) { _activeTrucks.Add(truck); }
public void AddIdleTruck(EGFiretruck truck) { _idleTrucks.Add(truck); }