private void Start() { isOnGround = false; lastCollectibleType = CollectibleType.None; streak = 1; rb = GetComponent <Rigidbody>(); }
public Collectible(int x, int y, CollectibleType type, float speed) : base(x, y, Main.GetCollectibleSprite(type)) { this.Type = type; this.Speed.X = 0; this.Speed.Y = 1; this.Velocity = speed; }
string GetCollectibleName(CollectibleType t) { switch (t) { case CollectibleType.Anchor: return("anchor"); case CollectibleType.Coral: return("coral"); case CollectibleType.LifePreserver: return("life preserver"); case CollectibleType.OxygenTank: return("oxygen tank"); case CollectibleType.Plant: return("plant"); case CollectibleType.Rock: return("rock"); case CollectibleType.Treasure: return("treasure chest"); case CollectibleType.Vase: return("vase"); case CollectibleType.WoodPlank: return("wood plank"); default: return(null); } }
/*------------------------------------------------------------------*\ |* PRIVATE METHODES \*------------------------------------------------------------------*/ private void CreatePopup(float quantity, CollectibleType type) { var text = $"+ {quantity} {type.ToString()}"; var position = Helpers.SetY(entity.Position, Random.Range(2, 12)); DrawingTools.TextPopup(text, position, 4f, 2f, 34, Colors.Primary); }
private void Awake() { int RandomValue = Random.Range(0, 30); CollectibleType RandomType = (CollectibleType)Random.Range(0, 3); m_CollectibleLogic = new CollectibleLogic(new CollectibleData(RandomType, RandomValue)); }
public void AddIngredient(CollectibleType type) { if (type == CollectibleType.Flour && FloorNeed > 0) { FloorNeed -= 1; Hud.ChangeDoughNeed(type); StartCoroutine(playerController.Consume()); } if (type == CollectibleType.Water && WaterNeed > 0) { WaterNeed -= 1; Hud.ChangeDoughNeed(type); StartCoroutine(playerController.Consume()); } if (type == CollectibleType.Levain && LevainNeed > 0) { LevainNeed -= 1; Hud.ChangeDoughNeed(type); StartCoroutine(playerController.Consume()); } if (WaterNeed == 0 && FloorNeed == 0 && LevainNeed == 0) { Hud.ChangeDoughNeed(CollectibleType.Dough); } }
private void OnCollect(CollectibleType type) { if (isInNewRound && Game.ConsumedPelletsRatio > dotsConsumedRatioSpawn) { Spawn(); } }
int GetCollectiblePoints(CollectibleType t) { switch (t) { case CollectibleType.Anchor: return(800); case CollectibleType.Coral: return(20); case CollectibleType.LifePreserver: return(500); case CollectibleType.OxygenTank: return(0); case CollectibleType.Plant: return(20); case CollectibleType.Rock: return(10); case CollectibleType.Treasure: return(2000); case CollectibleType.Vase: return(800); case CollectibleType.WoodPlank: return(100); default: return(0); } }
// Keep the furthest collectible of one type from the player spawn public void KeepFurthestChest(CollectibleType collectibleType) { List <GameObject> collectibles = new List <GameObject>(); if (collectibleType == CollectibleType.WeaponChest) { collectibles = weaponChests; } else if (collectibleType == CollectibleType.AmmoChest) { collectibles = ammoChests; } float maxDistance = 0; int keepIndex = 0; for (int i = 0; i < collectibles.Count; i++) { float distance = Vector2.Distance(origin, collectibles[i].transform.position); if (distance >= maxDistance) { maxDistance = distance; keepIndex = i; } } for (int i = 0; i < collectibles.Count; i++) { if (i != keepIndex) { Destroy(collectibles[i]); } } }
private void OnTriggerEnter(Collider other) { grabbedObject = other.gameObject.GetComponent <CollectibleType>(); if (grabbedObject != null) { _localBlackboard._statusManager.UpdateAttackType(grabbedObject.RetrieveType()); Destroy(other.gameObject); //Debug.LogError("Grabbed a droplet"); } }
// ----------------------------------------------- // VirtualFunction: Use this for initialization // ----------------------------------------------- void Start() { // Get a random type of collectible mCurrType = (CollectibleType)Mathf.Floor(Random.Range(0, 3)); Collider coll = GetComponent <Collider>(); Renderer rend = GetComponent <Renderer>(); Light light = GetComponent <Light>(); PhysicMaterial physMat = new PhysicMaterial(); switch (mCurrType) { case CollectibleType.Bouncy: //physMat.bounciness = 1f; mCurrColor = Color.green; light.range = 5f; mPointVal = 5; break; case CollectibleType.ColorChanging: physMat.bounciness = 0.6f; coll.material = physMat; mCurrColor = Color.yellow; light.range = 8f; mPointVal = 3; break; case CollectibleType.Bomb: physMat.bounciness = 0.4f; coll.material = physMat; mCurrColor = Color.red; light.range = 12f; totalDuration--; mPointVal = 8; break; default: mPointVal = 5; break; } // Set parameters for the collectible //coll.material = physMat; rend.material.SetColor("_Color", mCurrColor); light.color = mCurrColor; mStartTime = Time.time; mBlinkColor = mCurrColor; mBlinkColor.a = 0f; BroadcastMessage("Initialize", mCurrType); //Destroy(physMat); }
//Collect items and store them foreach independant rituals public void CollectItem(CollectibleType ct, Collectible c) { if (_ritualCollectibles.ContainsKey(ct)) { _ritualCollectibles[ct].Add(c); } else { _ritualCollectibles.Add(ct, new List<Collectible> { c }); } }
public void StopPlaying(CollectibleType type) { foreach (var source in sources) { if (source.type == type) { source.source.DOFade(0, fadeDuration); source.playing = false; } } if (NoSourcePlaying()) { wind.DOFade(1, fadeDuration); } }
private void RemovePickupConditions(CollectibleType collectibleType) { if (collectibleConditions.Contains(collectibleType)) { collectibleConditions.Remove(collectibleType); } collectibleSpawner.onCollectibleAdded.RemoveListener(OnCollectibleAdded); var collectibles = collectibleSpawner.collectiblePool.FindAll(x => x.collectibleData.collectibleType == collectibleType); foreach (var item in collectibles) { item.onCollected.RemoveListener(OnCollected); } }
public void pickUp(CollectibleType collectible) { switch (collectible) { case CollectibleType.Coin: _score++; _scoreLabel.text = "Score : " + _score; break; case CollectibleType.Key: _door.open(); break; } }
public IEnumerator Consume() { isPourring = true; animator.SetBool(TransitionParameter.Pouring.ToString(), true); GameObject.FindObjectOfType <AudioManager>().PlaySound(currentCollectibeType); currentCollectibeType = CollectibleType.None; Destroy(Holding); yield return(new WaitForSeconds(1.5f)); Hud.ClosePanels(); LetGo(); }
public void PlaySound(CollectibleType type, string name = "") { Sound s; if (type != CollectibleType.None) { s = Array.Find(sounds, sound => sound.type == type); } else { s = Array.Find(sounds, sound => sound.name == name); } s.source.Play(); }
public static Collectible CreateCollectible(CollectibleType collectibleType, Vector2 position, Tile currentTile) { Collectible newCollectible = null; switch (collectibleType) { case CollectibleType.POWERUP: int randomType = RandomManager.GetRandomInt(0, 1); switch (randomType) { case 0: newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.SPEEDBOOST), position, currentTile, Powerup.PowerupType.SPEEDBOOST); break; case 1: if (RandomManager.GetRandomTrueFalse(75)) { newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.TOY_PISTOL), position, currentTile, Powerup.PowerupType.TOY_PISTOL); } else { newCollectible = new Powerup(DespicableGame.GetTexture(DespicableGame.GameTextures.PLAYERTRAP_COLLECTIBLE), position, currentTile, Powerup.PowerupType.PLAYERTRAP); } break; } break; case CollectibleType.GOAL: newCollectible = new Goal(DespicableGame.GetTexture(DespicableGame.GameTextures.GOAL), position, currentTile); break; case CollectibleType.TRAP: newCollectible = new Trap(DespicableGame.GetTexture(DespicableGame.GameTextures.TRAP), position, currentTile); break; case CollectibleType.SHIP: newCollectible = new Ship(DespicableGame.GetTexture(DespicableGame.GameTextures.LEVEL_EXIT), position, currentTile); break; case CollectibleType.BANANA: newCollectible = new Banana(DespicableGame.GetTexture(DespicableGame.GameTextures.BANANA), position, currentTile); break; } return newCollectible; }
public void AddToScore(CollectibleType collectibleType, int scoreToAdd, GameObject collectibleObject) { if (collectibleType == CollectibleType.Simple) { simplesCount += 1; score += scoreToAdd; simpleCollectibles.Add(collectibleObject); } else { preciousCount += 1; preciousCountTemp += 1; preciousScoreTemp += scoreToAdd; preciousCollectiblesTemp.Add(collectibleObject); } }
private void LetGo() { //Let Go Holding = null; currentCollectibeType = CollectibleType.None; holdPos.obj.SetActive(false); isHolding = false; isPourring = false; animator.SetBool(TransitionParameter.Holding.ToString(), false); animator.SetBool(TransitionParameter.Pouring.ToString(), false); //Put back player speed; moveSpeed = normalSpeed; }
IEnumerator PickupListener(CollectibleType collectibleType) { Debug.Log("Pickup listener started @" + Time.frameCount); switch (collectibleType) { case CollectibleType.Blueprint: int previousBlueprints = blueprintsCollected; while (blueprintsCollected <= previousBlueprints) { //Debug.Log ("Blueprint loop running @"+Time.frameCount); yield return(0); } break; case CollectibleType.BigScrap: //int previousScrap = PlayerResources.Instance.Scraps; //while (PlayerResources.Instance.Scraps <= previousScrap) //{ // yield return 0; //} break; case CollectibleType.Xeno: print("Pick up Xeno!"); int previousXenos = gameProfile.xenos; while (gameProfile.xenos <= previousXenos) { yield return(0); } //yield return new WaitForSeconds(1); break; default: Debug.LogError("Unhandled collectible type: " + collectibleType); break; } // int previousItemsCollected = LevelManager.Instance.itemsCollected; // while (previousItemsCollected == LevelManager.Instance.itemsCollected) { // yield return 0; // } Debug.Log("Ending prompt @" + Time.frameCount); //StartCoroutine(EndPrompt()); yield break; }
private void OnTriggerEnter(Collider collision) { CollectibleController temp = collision.gameObject.GetComponent <CollectibleController>(); if (temp != null) { if (temp.GetCollectibleType.Equals(lastCollectibleType)) { streak++; EventManager.Instance.StreakEvent(streak); } else { lastCollectibleType = temp.GetCollectibleType; streak = 1; EventManager.Instance.StreakEvent(streak); } } }
// -------------------------- // // Sound Events // -------------------------- // private void OnCollectItem(CollectibleType type) { switch (type) { case CollectibleType.Pellet: audioMap?.GetEvent(AudioEvent.AudioEventType.Munch)?.Play(audioSrc); break; case CollectibleType.PowerPellet: audioMap?.GetEvent(AudioEvent.AudioEventType.PowerPellet)?.Play(audioSrc); break; case CollectibleType.Fruit: audioMap?.GetEvent(AudioEvent.AudioEventType.Fruit)?.Play(audioSrc); break; default: break; } }
public void Collect(CollectibleType collectibleType) { collectedCollectibles.Add(collectibleType); //The below is not the best way to do things //It would be better to publically broadcast a message //And have other scripts listen for the type of collectible //Health Powerup if (collectibleType == CollectibleType.HealthPowerup) { Destructible destructible = GetComponent <Destructible>(); if (destructible != null) { destructible.HealDamage(1); } } else if (collectibleType == CollectibleType.Token) { Debug.Log("Picked up a coin!"); } }
public void Feeding(CollectibleType type) { if (type == CollectibleType.Flour && FloorNeed > 0) { FloorNeed -= 1; if (currentLifePoint < maxLifePoint) { float newlifeAmount = currentLifePoint + healingPoint; if (newlifeAmount > maxLifePoint) { currentLifePoint = maxLifePoint; } else { currentLifePoint = newlifeAmount; } } Hud.ChangeFloorNeed(FloorNeed); StartCoroutine(playerController.Consume()); } if (type == CollectibleType.Water && WaterNeed > 0) { WaterNeed -= 1; if (currentLifePoint < maxLifePoint) { float newlifeAmount = currentLifePoint + healingPoint; if (newlifeAmount > maxLifePoint) { currentLifePoint = maxLifePoint; } else { currentLifePoint = newlifeAmount; } } Hud.ChangeWaterNeed(WaterNeed); StartCoroutine(playerController.Consume()); } }
void SetupCollectible(GameObject prefab, CollectibleType type, bool yIsUp) { var extents = prefab.GetComponentInChildren <MeshRenderer>() .bounds.extents; var maxExtent = Mathf.Sqrt( Mathf.Pow(extents.x, 2) + Mathf.Pow(extents.z, 2)); var maxRadius = waterSurface.localScale.x - maxExtent; var position2d = Random.insideUnitCircle * maxRadius; var position = new Vector3(position2d.x, 0, position2d.y); position.y = seabedTerrain.SampleHeight(position) + seabedTerrainYPosition; var instance = Instantiate(prefab, position, prefab.transform.rotation); if (yIsUp) { instance.transform.Rotate(Random.Range(-25f, 25f), Random.Range(-180f, 180f), 0); } else { instance.transform.Rotate(Random.Range(-25f, 25f), 0, Random.Range(-180f, 180f)); } var interactableObject = instance.AddComponent <VRTK_InteractableObject>(); interactableObject.touchHighlightColor = highlightColor; interactableObject.allowedTouchControllers = VRTK_InteractableObject.AllowedController.RightOnly; var haptics = instance.AddComponent <VRTK_InteractHaptics>(); haptics.strengthOnTouch = 0.5f; haptics.durationOnTouch = 0.2f; var collectible = instance.AddComponent <Collectible>(); collectible.type = type; }
public void ChangeDoughNeed(CollectibleType type) { if (type == CollectibleType.Levain) { LevainNeed.GetComponent <Image>().sprite = NeedOK; LevainNeed.GetComponentInChildren <TextMeshProUGUI>().text = ""; } if (type == CollectibleType.Flour) { FlourNeed.GetComponent <Image>().sprite = NeedOK; FlourNeed.GetComponentInChildren <TextMeshProUGUI>().text = ""; } if (type == CollectibleType.Water) { WaterNeed.GetComponent <Image>().sprite = NeedOK; WaterNeed.GetComponentInChildren <TextMeshProUGUI>().text = ""; } if (type == CollectibleType.Dough) { DoughNeed.GetComponent <Image>().sprite = NeedOK; DoughNeed.GetComponentInChildren <TextMeshProUGUI>().text = ""; } }
public CollectionType CreateInstance() { using (_reader) { // General collectible stuff, position, synced anim... var x = _reader.ReadInt32(); var y = _reader.ReadInt32(); var musicStartCode = reader.ReadInt32(); var musicBpm = reader.ReadInt32(); // ... // Tricky part: sub-type specific information follows CollectibleType collectableType = (CollectibleType)reader.ReadByte(); if (collectableType is Coin) { return(new Coin { X = x, Y = y, MusicStartCode = musicStartCode // etc.. }); } if (collectableType is ItemBox) { return(new ItemBox { X = x, Y = y, MusicStartCode = musicStartCode // etc.. }); } return(null); } }
// Spawn a collectible public void SpawnCollectible(Vector2 position, CollectibleType collectibleType) { int posX = (int)position.x; int posY = (int)position.y; Tile tile = tiles[posX][posY].GetComponent <Tile>(); if (tile.tileType == TileType.Wall) { return; } tile.CollectibleType = collectibleType; GameObject collectibleToSpawn = null; List <GameObject> listToAddObject = new List <GameObject>(); if (collectibleType == CollectibleType.WeaponChest) { collectibleToSpawn = weaponChestPrefab; listToAddObject = weaponChests; } else if (collectibleType == CollectibleType.AmmoChest) { collectibleToSpawn = ammoChestPrefab; listToAddObject = ammoChests; } GameObject g = Instantiate(collectibleToSpawn, new Vector2(posX * mapScale, posY * mapScale), Quaternion.identity, collectiblesContainers); Bounds bounds = g.GetComponent <SpriteRenderer>().sprite.bounds; var xSize = bounds.size.x; g.transform.localScale = new Vector3(0.5f / xSize * mapScale, 0.5f / bounds.size.y * mapScale, 1); listToAddObject.Add(g); }
private void OnCollect(CollectibleType type) { if (state == BGMState.PowerPellet || state == BGMState.Retreating) { return; } if (type == CollectibleType.Pellet) { int bestIndex = 0; for (int i = 0; i < bgmSiren.Length; i++) { if (Game.ConsumedPelletsRatio > sirenStart[i]) { bestIndex = i; } } if (bestIndex != currSirenIndex) { currSirenIndex = bestIndex; PlaySiren(); } } }
private void PickUp() { if (Input.GetKeyDown(KeyCode.E) && Pickable != null) { Holding = Pickable; currentCollectibeType = Pickable.GetComponent <Collectible>().type; Pickable.SetActive(false); HoldingPos[] holdingObjects = HoldingPos.GetComponent <HoldingType>().holdingObjects; holdPos = Array.Find(holdingObjects, hold => hold.type == currentCollectibeType); holdPos.obj.SetActive(true); isHolding = true; animator.SetBool(TransitionParameter.Holding.ToString(), true); //Remove pickable Pickable = null; canPickUp = false; Hud.ClosePanels(); //Slow Down player moveSpeed = slowSpeed; } }
private void Awake() { if (PlayerPrefs.GetInt("FmodOn") > 0) { fmodOn = true; } if (GetComponent <PatrolCollectible>() != null) { _type = GetComponent <PatrolCollectible>().Type; } else { _type = GetComponent <BaseCollectible>().Type; } if (GetComponent <StudioEventEmitter>() == null) { _emitter = gameObject.AddComponent(typeof(StudioEventEmitter)) as StudioEventEmitter; } else { _emitter = GetComponent <StudioEventEmitter>(); } if (fmodOn) { string idleSoundPath = "event:/SFX/" + _type.ToString() + "_idle"; if (FMOD_Debug.CheckFmodEvent(idleSoundPath)) { _emitter.Event = idleSoundPath; _emitter.Play(); } } }
/// <summary> /// Creates a new weapon and adds it to the game. (No other components created) /// </summary> /// <param name="type">The type of weapon to create.</param> public uint CreateCollectible(CollectibleType type, Position position) { uint eid = Entity.NextEntity(); Collectible collectible; Sprite sprite; Collideable collideable; /* Locations for the sprites: gold = 136,46,32,32 silver = 170, 46, 32, 32 bronze = 204, 46, 32, 32 heart = 156, 360, 24, 24 */ switch (type) { case CollectibleType.health1: collectible.CollectibleType = Components.CollectibleType.health; collectible.CollectibleValue = 1; sprite = new Sprite() { EntityID = eid, SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/TestMiscIcons1"), SpriteBounds = new Rectangle(156, 360, 24, 24), }; break; case CollectibleType.money1: collectible.CollectibleType = Components.CollectibleType.money; collectible.CollectibleValue = 1; sprite = new Sprite() { EntityID = eid, SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/MiscIcons1"), SpriteBounds = new Rectangle(204, 46, 32, 32), }; break; case CollectibleType.money5: collectible.CollectibleType = Components.CollectibleType.money; collectible.CollectibleValue = 5; sprite = new Sprite() { EntityID = eid, SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/TestMiscIcons1"), SpriteBounds = new Rectangle(170, 46, 32, 32), }; break; case CollectibleType.money10: collectible.CollectibleType = Components.CollectibleType.money; collectible.CollectibleValue = 10; sprite = new Sprite() { EntityID = eid, SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/TestMiscIcons1"), SpriteBounds = new Rectangle(136, 46, 32, 32), }; break; case CollectibleType.pog: collectible.CollectibleType = Components.CollectibleType.pog; collectible.CollectibleValue = 0; //use random generator here, or more complex if you want sprite = new Sprite(); /*sprite = new Sprite() { EntityID = eid, SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/TestMiscIcons1"), SpriteBounds = new Rectangle(136, 46, 32, 32), };*/ break; default: throw new Exception("Unknown CollectibleType"); } collectible.EntityID = eid; position.EntityID = eid; collideable = new Collideable() { EntityID = eid, RoomID = position.RoomID, Bounds = new CircleBounds(position.Center, position.Radius) }; _game.CollisionComponent[eid] = collideable; _game.CollectibleComponent.Add(eid, collectible); //_game.MovementComponent.Add(eid, movement); //Eventually do a sin wave y emulation to do the wave effect _game.PositionComponent.Add(eid, position); _game.SpriteComponent.Add(eid, sprite); return eid; }
private static string ParseXesamCollectible (XPathNavigator nav, CollectibleType col) { // Got XPathNavigator: // iterate over selections (equals, fullText, etc.) // recurse over collections (and, or) // // FIXME: Assuming only 1 field and 1 data element string q = String.Empty, field; while (true) { if (nav.GetAttribute ("negate", String.Empty) == "true") q += "-"; switch (nav.Name) { case "and": nav.MoveToFirstChild (); q += "( "; q += ParseXesamCollectible (nav, CollectibleType.And); q += " )"; nav.MoveToParent (); break; case "or": nav.MoveToFirstChild (); q += "( "; q += ParseXesamCollectible (nav, CollectibleType.Or); q += " )"; nav.MoveToParent (); break; case "fullText": nav.MoveToFirstChild (); q += "("; q += ParseXesamData (nav, ComparisonType.None); q += ")"; nav.MoveToParent (); break; case "inSet": nav.MoveToFirstChild (); field = ParseXesamField (nav); bool first = false; q += "( "; while (nav.MoveToNext ()) { if (!first) first = true; else q += " or "; q += field + GetFieldDelimiter(field) + ParseXesamData (nav, ComparisonType.Equals); } q += " )"; nav.MoveToParent (); break; case "contains": goto case "equals"; case "startsWith": goto case "equals"; case "equals": nav.MoveToFirstChild (); field = ParseXesamField (nav); q += field; q += GetFieldDelimiter (field); nav.MoveToNext (); q += ParseXesamData (nav, ComparisonType.Equals); nav.MoveToParent (); break; case "greaterThanEquals": goto case "greaterThan"; case "greaterThan": nav.MoveToFirstChild (); field = ParseXesamField (nav); q += field; q += GetFieldDelimiter (field); nav.MoveToNext (); q += ParseXesamData (nav, ComparisonType.Greater); nav.MoveToParent (); break; case "lessThanEquals": goto case "greaterThan"; case "lessThan": nav.MoveToFirstChild (); field = ParseXesamField (nav); q += field; q += GetFieldDelimiter (field); nav.MoveToNext (); q += ParseXesamData (nav, ComparisonType.Greater); nav.MoveToParent (); break; default: Console.Error.WriteLine ("TBD: {0}", nav.Name); break; } if (nav.MoveToNext () && col != CollectibleType.None) { q += (col == CollectibleType.And ? " AND " : " OR "); } else { break; } } return q; }