// Event for updating the collected amount of fish to be displayed in gameOver public void CollectFish(ICollectible collectible) { if (collectible.ID == 0) { collectedFish++; } }
public static void ItemCollected(ICollectible collectible) { if (OnItemCollected != null) { OnItemCollected(collectible); } }
private void InGameEvents_OnItemCollected(ICollectible collectible) { if (collectible.ID == 11) { starsCollected++; } }
public void CollectCoins(ICollectible collectible) { if (collectible is Coin) { collectedCoins.text = "Coins: " + GameManager.Instance.collectedCoins; } }
void ItemCollected(ICollectible collectible) { if (collectible.ID == this.CollectibleID) { CurrentAmount++; Evaluate(); } }
public void Insert(ICollectible c, int index) { if (index < 0) index = 0; if (index >= _items.Count) index = _items.Count; _items.Insert(index, c); _actions++; }
public static void PlayItemSound(ICollectible item) { SoundEffect sound; if (item is Coin) { sound = game.Content.Load<SoundEffect>(Utility.COIN_SOUND); } else { sound = game.Content.Load<SoundEffect>(Utility.SPAWN_SOUND); } sound.Play(); }
private void OnTriggerEnter2D(Collider2D collision) { ICollectible collectible = collision.GetComponent <ICollectible>(); // pickes up collided ICollectible if (collectible != null && collectible is PowerUp) { collectible.PickUp(gameObject); } }
private void OnTriggerEnter(Collider other) { // If we collide with a collectible item, collect it ICollectible collectible = other.gameObject.GetComponent <ICollectible>(); if (collectible != null) { Collect(collectible); } }
public static void PlayCollectSound(ICollectible item) { if (item is Mushroom || item is Flower) { SoundEffect sound = game.Content.Load<SoundEffect>(Utility.POWERUP_SOUND); sound.Play(); } else if (item is LifeMushroom) { SoundEffect sound = game.Content.Load<SoundEffect>(Utility.ONEUP_SOUND); sound.Play(); } }
void OnTriggerEnter2D(Collider2D otherCollider) { ICollectible collectible = otherCollider.GetComponent <ICollectible>(); if (collectible != null) { collectible.Collect(); killCountText.text += "I"; } }
public void Collect(ICollectible collectible) { if (collectible is null) { throw new ArgumentNullException(nameof(collectible)); } collectible.GetCollectedBy(this); _collectibles.Add(collectible); Collected?.Invoke(this, collectible); }
public void CollectItem(ICollectible collectible) { Item item = (Item)collectible; if (item != null) { item.PickUp(this); itemsInInventory.Add(item); Notify(item); } }
private void CheckForCollectables(RaycastHit2D[] hits) { foreach (RaycastHit2D hit in hits) { ICollectible collectable = hit.collider.GetComponent <ICollectible>(); if (collectable != null) { collectable.Collect(); continue; } } }
public override bool ActivateBlock(Vector2 direction, ICollidable ob) { if (!(ob is Player.IMario)) return false; if (!(direction.Y > Utility.ZERO)) return false; if (item is Mushroom && SprintFourGame.GetInstance().Mario.IsBig()) item = new Flower(item.Position); SoundManager.PlayItemSound(item); item.Spawn(Block.Position); Block.ChangeState(new UsedBlockState()); Block.BlockState.ActivateBlock(direction, ob); return true; }
// when interacting with a trigger (collectibles) private void OnTriggerEnter(Collider c) { // Is collectible? ICollectible collectible = c.gameObject.GetComponent <ICollectible>(); if (collectible != null) { // collect and increase score var score = (GameObject)GameObject.FindWithTag("Score"); score.GetComponent <Score>().Increase(collectible.Collect()); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Collectible") { ICollectible collectible = other.GetComponent <ICollectible>(); if (collect(collectible)) { Destroy(other.gameObject); } } }
/* * User Functions */ // Note: Will collect a resource if any bit of that resource can fit in the container public bool collect(ICollectible collectible) { IContainer container = cargoHold.getContainer(collectible.getType()); if (container.isFull()) { return(false); } container.add(collectible.getAmount()); return(true); }
private void OnTriggerEnter(Collider other) { if (SessionManager.Instance.IsGamePaused || !SessionManager.Instance.IsGameStarted) { return; } ICollectible collectible = other.GetComponent <ICollectible>(); if (collectible != null && collectible.GetType() == Diamond.DiamondType) { SessionManager.Instance.IncreaseDiamondAmount(collectible.GetValue()); ParticlesManager.Instance.IntantiateDiamondBlimp(transform.position, collectible.GetValue()); Destroy(other.gameObject); } }
public void Add(ICollectible c, bool dropped=false) { if (dropped) { MoveItemMessage mim = (MoveItemMessage)_owner.Map.ProtocolHelper.NewMessage(MessageTypes.MoveItem); mim.Slot = -1; mim.Quantity = 1; mim.id = c.GetID(); mim.To = MoveTarget.Inventory; mim.Encode(); if (_owner.Map != null) _owner.Map.SendMessage(mim, true); } _items.Add(c); _actions++; }
private void Awake() { Debug.Log($"Loading Level {LevelIndex}"); // Get the power ups remaining from the GameManager // If the list is null then we haven't loaded this level yet var powerUpsRemaining = GameManager.Instance.GetLevelPowerUpsRemaining(LevelIndex); if (powerUpsRemaining == null) { Debug.Log($"Loading All Powerups for Level {LevelIndex}"); foreach (var powerUp in levelPowerUps) { var loc = powerUp.spawnLocation; var pu = Instantiate(powerUp.powerUpPrefab, new Vector3(loc.x, loc.y, 0.0f), Quaternion.identity); spawnedPowerUps.Add(pu); ICollectible collectible = pu.GetComponent <ICollectible>(); if (collectible != null) { collectible.OnCollected += OnPowerUpCollected; } } GameManager.Instance.SetPowerUpsRemaining(LevelIndex, spawnedPowerUps); } else if (powerUpsRemaining.Count <= 0) { // All power ups have been collected Debug.Log("All power ups for level {LevelIndex} have been collected"); } else { Debug.Log($"Loading Remaining Powerups for Level {LevelIndex}"); foreach (var powerUp in powerUpsRemaining) { if (powerUp != null) { powerUp.SetActive(true); } } } }
public bool Contains(ICollectible c) { return _items.Contains(c); }
public static void ItemBlockCollision(ICollectible item, Block block) { if (block.BlockState is KillBlockState) { item.Remove(); return; } if (item.Spawning) return; Vector2 direction = GetCollisionDirection(item.Bounds, block.Bounds); int penetration = GetPenetration(item.Bounds, block.Bounds, direction); item.Position += direction * penetration; var star = item as Star; if (star != null) star.Bounce(direction); if (!(Math.Abs(direction.X) > Utility.DOUBLE_TOLERANCE)) return; var mushroom = item as Mushroom; if (mushroom != null) { mushroom.MoveRight = !mushroom.MoveRight; } var lifeMushroom = item as LifeMushroom; if (lifeMushroom != null) { lifeMushroom.MoveRight = !lifeMushroom.MoveRight; } }
public void AddItemToInventory(ICollectible item) { this.inventory.Add(item); }
public QuestionBlockState(ICollectible collectible) { item = collectible; }
public static void PlayerItemCollision(IMario player, ICollectible item) { if (player.CurrentState is DeadMarioState) return; SoundManager.PlayCollectSound(item); item.Collect(player); }
public HiddenBlockState(ICollectible collectible) { item = collectible; }
public void Insert(ICollectible c, int index, bool dropped) { if (index < 0) index = 0; if (index >= _items.Count) index = _items.Count; if (dropped) { MoveItemMessage mim = (MoveItemMessage)_owner.Map.ProtocolHelper.NewMessage(MessageTypes.MoveItem); mim.Slot = index; mim.Quantity = 1; mim.id = c.GetID(); mim.To = MoveTarget.Inventory; mim.Encode(); if (_owner.Map != null) _owner.Map.SendMessage(mim, true); } _items.Insert(index, c); _actions++; }
public void Remove(ICollectible c) { _items.Remove(c); _actions++; }
private void Collect(ICollectible collectible) { collectible.Collect(_playerInventory); }
public void Add(ICollectible c) { _items.Add(c); _actions++; }