/// <summary> /// Release reticle for given spaceship, if it exists. /// </summary> /// <param name="t">Spaceship whose reticle to release.</param> void RemoveReticle(SSTeam t) { if (reticles.TryGetValue(t, out var r)) { r.gameObject.SetActive(false); reticles.Remove(t); } }
void Awake() { StartHealth = health; mySpawnPS = Instantiate(spawnPrefab).GetComponent <ParticleSystem>(); flight = GetComponent <SSFlight>(); engineSound = GetComponent <SSEngineSound>(); shield = GetComponent <SSShield>(); team = GetComponent <SSTeam>(); }
private void Start() { // get team-assigned mesh var mf = GetComponent <MeshFilter>(); if (!SSTeam.meshPairs.ContainsKey(mf.sharedMesh)) { SSTeam.CreateMeshPair(mf.sharedMesh); } if (team == 1) { mf.sharedMesh = SSTeam.meshPairs[mf.sharedMesh]; } }
/// <summary> /// Add reticle on given spaceship, if it doesn't exist already. /// </summary> /// <param name="t">Spaceship to add reticle on</param> /// <param name="mandatory">whether to add regardless of distance check</param> void AddReticle(SSTeam t, bool mandatory) { if (reticles.ContainsKey(t)) { return; } if (reticles.Count >= maxReticles) { // find furthest reticle var maxDistSqr = 0f; SSTeam maxDistT = null; foreach (var tt in reticles) { var dd = (tt.Key.transform.position - myTr.position).sqrMagnitude; if (dd > maxDistSqr) { maxDistSqr = dd; maxDistT = tt.Key; } } // remove that reticle if farther than this, or if mandatory specified if (mandatory || maxDistSqr > (t.transform.position - myTr.position).sqrMagnitude) { RemoveReticle(maxDistT); } else { return; } } // add reticle GameObject go = pool[maxReticles - 1]; for (int i = 0; i < maxReticles - 1; i++) { if (!reticles.ContainsValue(pool[i].transform)) { go = pool[i]; break; } } go.SetActive(true); reticles.Add(t, go.transform); }
void Awake() { team = GetComponent <SSTeam>(); controlPlayer = GetComponent <SSControlPlayer>(); particleSystems = new ParticleSystem[barrels.Length]; for (int i = 0; i < barrels.Length; i++) { particleSystems[i] = barrels[i].GetComponent <ParticleSystem>(); } var aupar = transform.Find("laserSound"); if (aupar) { auParent = aupar.gameObject; } au = auParent.GetComponents <AudioSource>(); soundRangeSqr = au[0].maxDistance * au[0].maxDistance; }
void Start() { flight = GetComponent <SSFlight>(); team = GetComponent <SSTeam>(); laser = GetComponent <SSLaser>(); }