private void CreateActiveObject(GameObject gObj, BallObject data) { ActiveBall newBall = new ActiveBall(); newBall.data = data; newBall.gameObject = gObj; activeQueue[data.exercise].Add(newBall); }
public void RemoveFromActive(BallObject data) { List <ActiveBall> q = activeQueue[data.exercise]; ActiveBall target = q.Single(t => t.data.id == data.id); q.Remove(target); CheckLevelEnd(); }
public void DestroyActiveObject(string exercise) { List <ActiveBall> q = activeQueue[exercise]; if (q.Count > 0) { // Animate explosion, destroy object, and play audio ActiveBall target = q[0]; Rigidbody2D ball = target.gameObject.transform.GetChild(1).gameObject.GetComponent <Rigidbody2D>(); Instantiate(explosion, new Vector2(ball.transform.position.x, ball.transform.position.y), Quaternion.identity); Destroy(target.gameObject); AudioSource.PlayClipAtPoint(boom, Camera.main.transform.position, 0.7f); // Remove from queue, update level data q.RemoveAt(0); levelData.successRate[0]++; levelData.successfulActivityRecord[exercise]++; // Spawn new ball if no active ball (to not keep player waiting) timeout = CheckActiveQueue() ? timeout : 0f; CheckLevelEnd(); } }
public void UpdateActiveObject(GameObject newObj, BallObject d) { ActiveBall target = activeQueue[d.exercise].First(x => x.data.id == d.id); target.gameObject = newObj; }