public GreenController newObject(Vector3 pos, Quaternion rot) { GreenController t = null; if (inactive.Count > 0) { Debug.Log("inactive.Count() " + inactive.Count + " > 0"); t = inactive[0]; inactive.RemoveAt(0); active.Add(t); } else if (createdObjects() < maxObjects) { Debug.Log("createdObjects() " + createdObjects() + " < maxObjects " + maxObjects); t = Instantiate <GreenController>(prefab, pos, rot); t.transform.parent = this.transform; active.Add(t); } if (t == null) { throw new System.Exception("Error! Spawned more than the max (" + maxObjects + ") number of bullets."); } t.gameObject.SetActive(true); t.transform.position = pos; t.transform.rotation = rot; return(t); }
/// <summary> /// Call this method to initialize this laser instance. /// </summary> /// <param name="caller">Caller instance</param> /// <param name="shooter">Shooter type</param> public void Init(GreenController caller, CharacterType shooter) { // Failed safe check if (caller.GetType() != typeof(GreenController)) { return; } _shooter = shooter; _isHit = false; }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(gameObject); if (instance == null) { instance = this; } else { if (instance != this) { Destroy(gameObject); } } }
private void RefreshShownColor() { GreenController.SetBrightness(Color.G / 255f * Brightness); RedController.SetBrightness(Color.R / 255f * Brightness); BlueController.SetBrightness(Color.B / 255f * Brightness); }
public void destroyObject(GreenController t) { t.gameObject.SetActive(false); inactive.Add(t); active.Remove(t); }