private void AddBalloon(Balloon balloon) { // existing balloons "move down" to compensate us moving up Vector3 pos; foreach(Balloon b in balloons) { pos = b.transform.localPosition; pos.y -= 1; b.transform.localPosition = pos; } // add the new balloon balloon.rigidbody2D.isKinematic = true; balloon.transform.parent = transform; balloon.transform.localPosition = new Vector3(0, -1, 0); balloons.Add(balloon.GetComponent<Balloon>()); balloon.Caught(); // we move up pos = transform.localPosition; pos.y += 1; transform.localPosition = pos; // if we're in the process of moving, adjust the targets if(moveStart != -1) { moveFrom.y += 1; moveTo.y += 1; } TryPop(); }
public void BalloonScored(Balloon balloon, int combo) { int amount = balloonScoreValue * combo; ScoreEffect effect = ((GameObject)Instantiate(scoreEffectPrefab)).GetComponent<ScoreEffect>(); effect.Amount = amount; effect.transform.position = balloon.transform.position; score += amount; }
private void Pop(Balloon balloon) { if(balloon.color != currentComboColor) { currentCombo = 0; currentComboColor = balloon.color; } currentCombo++; GameDriver.Instance.BalloonScored(balloon, currentCombo); balloons.Remove(balloon); balloon.PopGood(currentCombo); // move us downward moveFrom = transform.localPosition; moveTo = moveFrom; moveTo.y -= 1; moveStart = Time.time; }