public void HandleGotBanana(BBanana banana) { CreateBananaExplodeEffect(banana); _bananaContainer.RemoveChild (banana); _bananas.Remove(banana); BMain.instance.score++; if(BMain.instance.score == 1) { _scoreLabel.text = "1 Banana"; } else { _scoreLabel.text = BMain.instance.score+" Bananas"; } FUnityParticleSystemNode particleNode = new FUnityParticleSystemNode(_particlePrefab, true); AddChild (particleNode); particleNode.x = banana.x; particleNode.y = banana.y; FSoundManager.PlaySound("BananaSound", 1.0f); }
public void HandleGotBanana(BBanana banana) { CreateBananaExplodeEffect(banana); _bananaContainer.RemoveChild(banana); _bananas.Remove(banana); BMain.instance.score++; if (BMain.instance.score == 1) { _scoreLabel.text = "1 Banana"; } else { _scoreLabel.text = BMain.instance.score + " Bananas"; } FUnityParticleSystemNode particleNode = new FUnityParticleSystemNode(_particlePrefab, true); AddChild(particleNode); particleNode.x = banana.x; particleNode.y = banana.y; FSoundManager.PlaySound("BananaSound", 1.0f); }
public void CreateBanana() { BBanana banana = new BBanana(); _bananaContainer.AddChild(banana); banana.x = RXRandom.Range(-Futile.screen.width/2 + 50, Futile.screen.width/2 - 50); //padded inside the screen width banana.y = Futile.screen.height/2 + 60; //above the screen _bananas.Add(banana); _totalBananasCreated++; }
public void CreateBanana() { BBanana banana = new BBanana(); _bananaContainer.AddChild(banana); banana.x = RXRandom.Range(-Futile.screen.width / 2 + 50, Futile.screen.width / 2 - 50); //padded inside the screen width banana.y = Futile.screen.height / 2 + 60; //above the screen _bananas.Add(banana); _totalBananasCreated++; }
private void CreateBananaExplodeEffect(BBanana banana) { //we can't just get its x and y, because they might be transformed somehow Vector2 bananaPos = _effectHolder.OtherToLocal(banana, Vector2.zero); FSprite explodeSprite = new FSprite("Banana"); _effectHolder.AddChild(explodeSprite); explodeSprite.shader = FShader.Additive; explodeSprite.x = bananaPos.x; explodeSprite.y = bananaPos.y; explodeSprite.rotation = banana.rotation; // Go.to (explodeSprite, 0.3f, new TweenConfig().floatProp("scale",1.3f).floatProp("alpha",0.0f).onComplete(HandleExplodeSpriteComplete)); }
protected void HandleUpdate() { _secondsLeft -= Time.deltaTime; if (_secondsLeft <= 0) { FSoundManager.PlayMusic("VictoryMusic", 0.5f); BMain.instance.GoToPage(BPageType.ScorePage); return; } _timeLabel.text = ((int)_secondsLeft) + " Seconds Left"; if (_secondsLeft < 10) //make the timer red with 10 seconds left { _timeLabel.color = new Color(1.0f, 0.2f, 0.0f); } _framesTillNextBanana--; if (_framesTillNextBanana <= 0) { if (_totalBananasCreated % 4 == 0) //every 4 bananas, make the bananas come a little bit sooner { _maxFramesTillNextBanana--; } _framesTillNextBanana = _maxFramesTillNextBanana; CreateBanana(); } //loop backwards so that if we remove a banana from _bananas it won't cause problems for (int b = _bananas.Count - 1; b >= 0; b--) { BBanana banana = _bananas[b]; //remove a banana if it falls off screen if (banana.y < -Futile.screen.halfHeight - 50) { _bananas.Remove(banana); _bananaContainer.RemoveChild(banana); } } _frameCount++; }
public void HandleGotBanana(BBanana banana) { CreateBananaExplodeEffect(banana); _bananaContainer.RemoveChild (banana); _bananas.Remove(banana); BMain.instance.score++; if(BMain.instance.score == 1) { _scoreLabel.text = "1 Banana"; } else { _scoreLabel.text = BMain.instance.score+" Bananas"; } BSoundPlayer.PlayBananaSound(); }
public void HandleGotBanana(BBanana banana) { CreateBananaExplodeEffect(banana); _bananaContainer.RemoveChild(banana); _bananas.Remove(banana); BMain.instance.score++; if (BMain.instance.score == 1) { _scoreLabel.text = "1 Banana"; } else { _scoreLabel.text = BMain.instance.score + " Bananas"; } BSoundPlayer.PlayBananaSound(); }
public void HandleMultiTouch(FTouch[] touches) { foreach (FTouch touch in touches) { if (touch.phase == TouchPhase.Began) { //we go reverse order so that if we remove a banana it doesn't matter //and also so that that we check from front to back for (int b = _bananas.Count - 1; b >= 0; b--) { BBanana banana = _bananas[b]; Vector2 touchPos = banana.GlobalToLocal(touch.position); if (banana.textureRect.Contains(touchPos)) { //HandleGotBanana(banana); break; //break so that a touch can only hit one banana at a time } } } } }
private void CreateBananaExplodeEffect(BBanana banana) { //we can't just get its x and y, because they might be transformed somehow Vector2 bananaPos = _effectHolder.LocalToLocal(banana,Vector2.zero); FSprite explodeSprite = new FSprite("Banana.png"); _effectHolder.AddChild(explodeSprite); explodeSprite.shader = FShader.Additive; explodeSprite.x = bananaPos.x; explodeSprite.y = bananaPos.y; explodeSprite.rotation = banana.rotation; Go.to (explodeSprite, 0.3f, new TweenConfig().floatProp("scale",1.3f).floatProp("alpha",0.0f).onComplete(HandleExplodeSpriteComplete)); }