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); }
// removes the old room sprite and the temp new room sprite // resets camera back to origin and moves player as well private void ResetRoomDrawn() { // make transition the current and redraw Dungeon_Container.RemoveChild(_dungeon.CurrentRoom); _dungeon.ChangeTransitionToCurrentRoom(); Dungeon_Container.RemoveChild(_dungeon.TransitionRoom); Dungeon_Container.AddChildAtIndex(_dungeon.CurrentRoom, 0); // redraw minimap _dungeon.minimap.UpdateMinimap(_dungeon); // readjust player int x = 0; int y = 0; if (Dungeon_Container.x != 0) { x = (Dungeon_Container.x > 0) ? _dungeon.RoomWidth : -_dungeon.RoomWidth; } if (Dungeon_Container.y != DUNGEON_CONTAINER_OFFSET) { y = (Dungeon_Container.y > 0) ? _dungeon.RoomHeight : -_dungeon.RoomHeight; } player.Move(x, y); Dungeon_Container.x = 0; Dungeon_Container.y = 0 + DUNGEON_CONTAINER_OFFSET; }
virtual public void HandleAddedToContainer(FContainer container) { if (_container != container) { if (_container != null) //remove from the old container first if there is one { _container.RemoveChild(this); } _container = container; } }
public void HandleGotBacteria(BacteriaBubble bacteria) { bacteriaContainer_.RemoveChild(bacteria); bacterias_.Remove(bacteria); dyingBacteriaHolder_.AddChild(bacteria); dyingBacterias_.Add(bacteria); bacteria.play("pop"); FSoundManager.PlaySound("bacteria_pop"); }
public override void Update() { if (stomach_bubbles_.Count < StomachLevel.MAX_STOMACH_BUBBLES) { Debug.Log("less stomach bubbles than max amount"); float new_bubble_chance = Random.value; if (new_bubble_chance > .5f) { Debug.Log("Creating a new bubble"); StomachBubble new_bubble = new StomachBubble(); stomach_bubbles_.Add(new_bubble); float x_pos = Random.value; float y_pos = Random.value; new_bubble.SetPosition(x_pos * bubble_container_size_.width + bubble_container_size_.xMin, y_pos * bubble_container_size_.height + bubble_container_size_.yMin); bubbles_container_.AddChild(new_bubble); } } for (int b = stomach_bubbles_.Count - 1; b >= 0; b--) { StomachBubble bubble = stomach_bubbles_[b]; if (bubble.Finished) { bubbles_container_.RemoveChild(bubble); stomach_bubbles_.Remove(bubble); } } }
public void clearMap() { enemyList.Clear(); spawnPoints.Clear(); warpPoints.Clear(); if (tilemap != null) { tilemap.RemoveFromContainer(); tilemap.RemoveAllChildren(); } foreach (FTilemap f in otherTilemaps) { if (f != null) { f.RemoveFromContainer(); } } if (tilemapCollision != null) { tilemapCollision.RemoveFromContainer(); } if (objectGroup != null) { objectGroup.RemoveFromContainer(); } for (int x = 0; x < playerLayer.GetChildCount(); x++) { playerLayer.RemoveChild(playerLayer.GetChildAt(x)); x--; } }
private IEnumerator LiveOutAndDie() { if (parent != null) { parent.AddChild(this); } else if (targetScreen != null) { targetScreen.AddChild(this); } while (lifespan-- > 0) { if (beam) { this.alpha = (float)lifespan / (float)fullLife; this.scaleX *= 1.01f; } this.x += velocity.x; this.y += velocity.y; yield return(null); } if (parent != null) { parent.RemoveChild(this); } else { targetScreen.RemoveChild(this); } }
private void checkForPlayerBubbleOffScreen() { for (int b = bubbles_.Count - 1; b >= 0; b--) { PlayerBubble bubble = bubbles_[b]; // remove a bubble if it falls off screen if (bubble.y < -Futile.screen.halfHeight - 50 || bubble.y > Futile.screen.halfHeight + 50) { if (bubble.x < -Futile.screen.halfWidth - 50 || bubble.x > Futile.screen.halfWidth + 50) { bubbles_.Remove(bubble); bubbleContainer_.RemoveChild(bubble); } } } }
public void RemoveElement(InterfaceObject element) { int index = _elements.IndexOf(element); if (index < 0) { return; } if (visible) { element.OnDeactivate(); } element._parent = null; _elements.RemoveAt(index); _container.RemoveChild(element.container); }
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(); }
void checkForDeadBacteria() { for (int b = dyingBacterias_.Count - 1; b >= 0; b--) { BacteriaBubble bacteria = dyingBacterias_[b]; if (bacteria.FinishedCount >= 1) { dyingBacterias_.Remove(bacteria); dyingBacteriaHolder_.RemoveChild(bacteria); } } }
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 Update() { hudStuff.text = "Energy: " + jugador.getEnergy() + "\n Score: " + jugador.getScore(); hudShadow.text = hudStuff.text; if (jugador.getEnergy() <= 0) { hudStuff.text = "Game Over, \n press return to continue..."; hudShadow.text = hudStuff.text; gameArea.alpha--; projectileContainer.alpha--; entityContainer.alpha--; particleContainer.alpha--; if (Input.GetKeyDown(KeyCode.Return)) { Game.instance.GoToPage(PageType.MainMenuPage); } return; } for (int x = enemies.Count - 1; x >= 0; x--) { enemies[x].Update(); if (enemies[x].getEnergy() < 0) { entityContainer.RemoveChild(enemies[x]); enemies.RemoveAt(x); } } for (int x = projectiles.Count - 1; x >= 0; x--) { projectiles[x].Update(); for (int w = enemies.Count - 1; w >= 0; w--) { if (projectiles[x].sprite.localRect.CloneAndOffset(projectiles[x].x, projectiles[x].y).CheckIntersect(enemies[w].sprite.localRect.CloneAndOffset(enemies[w].x, enemies[w].y))) { enemies[w].setEnergy(enemies[w].getEnergy() - projectiles[x].getEnergy()); jugador.AddScore(enemies[w].scoreValue); projectiles[x].ttl = -2f; ScreenShake(2, 3); FSoundManager.PlaySound("explosion"); } } if (projectiles[x].ttl < 0) { projectiles[x].DestroyEffect(); projectileContainer.RemoveChild(projectiles[x]); projectiles.RemoveAt(x); } } for (int x = Enemyprojectiles.Count - 1; x >= 0; x--) { Enemyprojectiles[x].Update(); if (Enemyprojectiles[x].sprite.localRect.CloneAndOffset(Enemyprojectiles[x].x, Enemyprojectiles[x].y).CheckIntersect(jugador.sprite.localRect.CloneAndOffset(jugador.Position.x, jugador.Position.y))) { jugador.setEnergy(jugador.getEnergy() - Enemyprojectiles[x].getEnergy()); ScreenShake(3, 10); Enemyprojectiles[x].ttl = -1; FSoundManager.PlaySound("explosion"); } if (Enemyprojectiles[x].ttl < 0) { Enemyprojectiles[x].DestroyEffect(); projectileContainer.RemoveChild(Enemyprojectiles[x]); Enemyprojectiles.RemoveAt(x); } } jugador.Update(); if (enemies.Count < minimalEnemies) { GenerateFoe(); } if (jugador.getScore() > 0) { if ((jugador.getScore() % 300) == 0) { Shielded shiel = new Shielded(new Vector2(jugador.GetPosition().x + UnityEngine.Random.Range(-Futile.screen.width * 2, Futile.screen.width * 2), Futile.screen.halfHeight - 20)); enemies.Add(shiel); jugador.AddScore(jugador.getScore() + 10); } if ((jugador.getScore() % 500) == 0) { minimalEnemies++; } } }