private void Next() { if (navigableItems.Count > 1) { if (selected != navigableItems[navigableItems.Count - 1]) { selected.Deselect(); selected = navigableItems[navigableItems.IndexOf(selected) + 1]; selected.Select(); } else { selected.Deselect(); selected = navigableItems[0]; selected.Select(); } } }
void Start() { #if UNITY_IOS isMobile = true; #endif if (isMobile) { gameObject.SetActive(false); } else { List <GameObject> navigableGameObjects = new List <GameObject>(GameObject.FindGameObjectsWithTag("Navigable")); navigableGameObjects.Sort( delegate(GameObject i1, GameObject i2){ return(i1.name.CompareTo(i2.name)); } ); Navigable tmp; navigableItems = new List <Navigable>(); for (int i = 0; i < navigableGameObjects.Count; i++) { tmp = navigableGameObjects[i].GetComponent <Navigable>(); navigableItems.Add(tmp); } if (debug) { Debug.Log(navigableGameObjects.Count); Debug.Log(navigableItems.Count); } if (navigableItems.Count > 0) { selected = navigableItems[0]; selected.Init(); selected.Select(); } verticalToggle = false; enterToggle = true; } }
private IEnumerator spawnWave(Wave wave, float waveDelay) { yield return(new WaitForSeconds(waveDelay)); enemiesCompletedNavigation = 0; enemiesDestroyed = 0; for (int i = 0; i < wave.getNumEnemies(); i++) { Path path = wave.getPath(); var enemy = Instantiate(wave.getEnemy(), path.getWaypoints()[0].position, Quaternion.identity); Navigable navigable = enemy.GetComponent <Navigable>(); navigable.setPath(path); navigable.setMoveSpeed(wave.getMoveSpeed()); navigable.registerOnNavigationComplete(() => { Destroy(enemy); enemiesCompletedNavigation++; }); navigable.setIsLooping(wave.getIsLooping()); Damagable damagable = enemy.GetComponent <Damagable>(); damagable.registerOnKilled((shipInfo) => { enemiesDestroyed++; }); yield return(new WaitForSeconds(wave.getSpawnTime())); } }
void Start() { _nav = GetComponentInParent <Navigable>(); }