// Start is called before the first frame update void Start() { GetFuel(); naveManager = objetoCombustibles.GetComponent <NaveManager>(); colorObject.color = combustible.color; anim = GetComponent <Animator>(); }
private void Awake() { winner = null; onRaceFinished = new UnityEvent(); onRaceFinished.AddListener(FinishRace); navesList = new List <NaveManager>(); List <GameObject> naves = new List <GameObject>(); for (int i = 0; i < Global.numPlayers; i++) { if (i == 0) { naves.Add(Instantiate(navePrefab, spawns[i].position, Quaternion.identity)); naves[i].GetComponentInChildren <NaveController>().modelTransform.rotation = Quaternion.Euler(0, spawns[i].eulerAngles.y, 0); } else { naves.Add(Instantiate(naveEnemigaPrefab, spawns[i].position, Quaternion.identity)); naves[i].GetComponentInChildren <NaveController>().modelTransform.rotation = Quaternion.Euler(0, spawns[i].eulerAngles.y, 0); } } if (Global.numPlayers > 1) { Camera cam1 = naves[0].GetComponentInChildren <Camera>(); Camera cam2 = naves[1].GetComponentInChildren <Camera>(); naves[1].GetComponentInChildren <AudioListener>().enabled = false; List <CanvasScaler> scalers = new List <CanvasScaler>(); for (int i = 0; i < Global.numPlayers; i++) { scalers.Add(naves[i].GetComponentInChildren <CanvasScaler>()); } if (screenDivision == ScreenDivision.Horizontal) { cam1.rect = new Rect(new Vector2(0, 0.5f), new Vector2(1, 0.5f)); cam2.rect = new Rect(new Vector2(0, 0), new Vector2(1, 0.5f)); foreach (CanvasScaler scaler in scalers) { scaler.referenceResolution = new Vector2(1920, 540); } } else if (screenDivision == ScreenDivision.Vertical) { cam1.rect = new Rect(new Vector2(0, 0), new Vector2(0.5f, 1)); cam2.rect = new Rect(new Vector2(0.5f, 0), new Vector2(0.5f, 1)); foreach (CanvasScaler scaler in scalers) { scaler.referenceResolution = new Vector2(960, 1080); } } } }
private bool CheckShips(NaveManager naveManager) { foreach (NaveManager nm in passedShips) { if (nm == naveManager) { return(false); } } passedShips.Add(naveManager); return(true); }
private void OnTriggerEnter(Collider other) { if (other.tag == "NaveCentre") { NaveManager naveManager = other.gameObject.GetComponentInParent <NaveManager>(); if (CheckShips(naveManager)) { RechargeFuel(naveManager); } if (CheckpointManager.newest == this) { if (isFinal) { GameManager.winner = naveManager; GameManager.onRaceFinished.Invoke(); } else { GetComponentInChildren <RadarTarget>().radarImage = notNewestIcon; CheckpointManager.OnCheckpointUnlocked.Invoke(); } } } }
private void Awake() { myNaveManager = GetComponentInParent <NaveManager>(); }
// Start is called before the first frame update void Start() { naveController = GetComponent <NaveController>(); inputManager = GetComponent <InputManager>(); naveManager = GetComponent <NaveManager>(); }
private void RechargeFuel(NaveManager naveManager) { naveManager.combustible.currentAmmount += fuelRechargeAmmount; naveManager.combustible.currentAmmount = Mathf.Clamp(naveManager.combustible.currentAmmount, 0, naveManager.combustible.deposit); }