// Update is called once per frame void Update() { //Otherwise we check if the tick has advanced then release the lock if (!currentTickTime.Equals(Metronome.Instance.currentTime)) { lockedThisTick = false; currentTickTime = new NotationTime((Metronome.Instance.currentTime)); } if (firing && AudioSettings.dspTime >= timeUntilCanFireAgain) { firing = false; } //If an object hasn't been locked on this tick do raycasting //Cannot rely on list count anymore, will have to keep track in method if (numberOfLocks < maxLock && !lockedThisTick) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.SphereCastAll(ray.origin, 1, ray.direction, 1000.0f); for (int i = 0; i < hits.Length; i++) { GameObject obj = hits[i].transform.gameObject; if (obj.CompareTag("Thumper")) { CubeThumper thump = obj.GetComponent <CubeThumper>(); if (thump.Lockable() && !lockedThisTick) { thump.HitCube(); if (!targetedCubes.Contains(thump)) { targetedCubes.Add(thump); } lockedThisTick = true; numberOfLocks++; } } if (!obj.CompareTag("Cleanup") && obj.CompareTag("Player") && !firing) { Fire(); } } } }
internal void AddCube(CubeThumper cubeThumper) { cubes.Add(cubeThumper); }