IEnumerator MoveToPosition(List <string> list) { GameObject aimGameObject = GameObject.Find(list[0]); Quaternion qua1 = transform.rotation; transform.LookAt(aimGameObject.transform); Quaternion qua2 = transform.rotation; transform.rotation = qua1; StartCoroutine(SlerpToQua(qua2)); MapManagerScript.ShowBuilding(localPosition); localPosition = list[0]; MapManagerScript.HidBuilding(localPosition); while (transform.localPosition != aimGameObject.transform.position) { transform.localPosition = Vector3.MoveTowards(transform.localPosition, aimGameObject.transform.position, 3 * Time.deltaTime); yield return(0); } if (list.Count > 1) { list.RemoveAt(0); StartCoroutine(MoveToPosition(list)); } else { characterAnimator.SetBool("IsRun", false); StartCoroutine(SlerpToQua(Quaternion.Euler(new Vector3(0, 180, 0)))); StaticScript.lockMouse = false; } }
// Start is called before the first frame update void Start() { _map = GameObject.FindGameObjectWithTag(Constants.TAG_MAP_MANAGER).GetComponent <MapManagerScript>(); _state = GameObject.FindGameObjectWithTag(Constants.TAG_STATE_MANAGER).GetComponent <StateManagerScript>(); _builder = GameObject.FindGameObjectWithTag(Constants.TAG_CHUNK_BUILDER).GetComponent <ChunkBuilderScript>(); _camera = GameObject.FindGameObjectWithTag(Constants.TAG_MAIN_CAMERA).GetComponent <CameraMoverScript>(); }
void Start() { // Check spawn points exist if (spawnPoints.Length == 0) { Debug.LogError("No spawn points referenced."); } // Get map manager GameObject managerObject = GameObject.Find("Manager"); if (managerObject != null) { mapManager = managerObject.GetComponent <MapManagerScript>(); scaler = managerObject.GetComponent <GameController>(); } if (managerObject == null) { Debug.Log("Cannot find 'Manager' script"); } setPlayer(scaler.getNumOfPLayers()); waveCountdown = timeBetweenWaves; wavesCompleted = false; }
// Start is called before the first frame update void Start() { _cBuilder = GameObject.FindGameObjectWithTag(Constants.TAG_CHUNK_BUILDER).GetComponent <ChunkBuilderScript>(); _tBuilder = GameObject.FindGameObjectWithTag(Constants.TAG_TILE_BUILDER).GetComponent <TileBuilderScript>(); _camera = GameObject.FindGameObjectWithTag(Constants.TAG_MAIN_CAMERA).GetComponent <CameraMoverScript>(); _map = GameObject.FindGameObjectWithTag(Constants.TAG_MAP_MANAGER).GetComponent <MapManagerScript>(); UpdateWaveInfoText(); }
// Start is called before the first frame update void Start() { _map = GameObject.FindGameObjectWithTag(Constants.TAG_MAP_MANAGER).GetComponent <MapManagerScript>(); _state = GameObject.FindGameObjectWithTag(Constants.TAG_STATE_MANAGER).GetComponent <StateManagerScript>(); _animation = GameObject.FindGameObjectWithTag(Constants.TAG_CHUNK_BUILDER).GetComponent <ChunkBuilderMouseAnimation>(); _camera = GetComponent <Camera>(); INITIALSIZE = (_map._chunkHeightAndWidth / 2f) + 1; Debug.Log(INITIALSIZE); targetZoom = INITIALSIZE; SetInitialPosition(); }
void Awake() { //Check if instance already exists, if not, set instance to this if (instance == null) { instance = this; } //If instance already exists and it's not this, destroy this, enforcing the singleton pattern else if (instance != this) { Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); InitGame(); }
// Use this for initialization void Start() { keyScript = gameObject.AddComponent <KeyScript>(); tileManagerScript = gameObject.AddComponent <TileManagerScript>(); mapManagerScript = gameObject.AddComponent <MapManagerScript>(); controllScript = gameObject.AddComponent <ControllScript>(); controllScript.enabled = false; keyScript.LoadKey(); if (!mapManagerScript.IsDataFile("/mapki.dat")) { SaveMapsScript s = gameObject.AddComponent <SaveMapsScript>(); mapManagerScript.LoadMaps(s.PrepareData()); } else { mapManagerScript.LoadMaps("/mapki.dat"); } buttonAction action = SetUpGame; gameMenuScript.SetUpLevelButtons(action); gameMenuScript.UpdateLevelButtons(keyScript.GetKeyValue()); }
// Start is called before the first frame update void Start() { _map = GameObject.FindGameObjectWithTag(Constants.TAG_MAP_MANAGER).GetComponent <MapManagerScript>(); _cam = GameObject.FindGameObjectWithTag(Constants.TAG_MAIN_CAMERA).GetComponent <Camera>(); }
public void carFinished() { List <int> path; int startId; int endId; startId = UnityEngine.Random.Range(0, verticesPositions.Count); do { endId = UnityEngine.Random.Range(0, verticesPositions.Count); } while (startId.Equals(endId)); path = g.shortest_path(startId, endId); if (path == null) { Debug.Log("Path is null?"); } else { //Debug.Log("Points: " + startId + " -> " + endId); //Debug.Log("Path: "); path.Add(startId); path.Reverse(); } List <Vector3> pathForCar = new List <Vector3>(); Vector3[] help; //pathForCar.Add(verticesPositions[path[0]]); help = MapManagerScript.getCrossingAtIndex(path[0]).getPathForCrossing(path[1], path[1]); foreach (Vector3 v in help) { pathForCar.Add(v); } pathForCar.RemoveAt(pathForCar.Count - 1); for (int i = 1; i < path.Count - 1; i++) { //pathForCar.Add(verticesPositions[path[i]]); help = MapManagerScript.getCrossingAtIndex(path[i]).getPathForCrossing(path[i - 1], path[i + 1]); foreach (Vector3 v in help) { pathForCar.Add(v); } pathForCar.RemoveAt(pathForCar.Count - 1); } if (pathForCar.Count > 5) { for (int h = 0; h < 5; h++) { pathForCar.RemoveAt(pathForCar.Count - 1); } /*for (int j = 0; j < pathForCar.Count; j++) * { * Instantiate(Vertex, pathForCar[j], Quaternion.identity); * }*/ //Debug.Log (pathForCar.Count); GameObject instance = (Instantiate(car, pathForCar[0], Quaternion.identity) as GameObject).GetComponent <CarScript>().SetUp(pathForCar, this); } else { carFinished(); } }
// Start is called before the first frame update void Start() { _map = GameObject.FindGameObjectWithTag(Constants.TAG_MAP_MANAGER).GetComponent <MapManagerScript>(); _stateManager = GameObject.FindGameObjectWithTag(Constants.TAG_STATE_MANAGER).GetComponent <StateManagerScript>(); }