override public void Collect(Collectable collectable) { if (collectable is Mushroom2DTK && simplehealth is HealthAndPower2DTK) { ((HealthAndPower2DTK)simplehealth).PowerUp(); } }
public void SetUseWith(int id) { UseWithObject = (Collectable)GlobalVars.database.GetObject(id); UseWithObjectId = id; if(UseWithObject != null) UseWith = true; }
public void Load(Collectable collectable) { if (SavedCollectables.ContainsKey(collectable.PersistenceKey)) { collectable.LoadPersistedObject(SavedCollectables[collectable.PersistenceKey]); } }
private void AddCollectedValue(Collectable collectable) { int bonus = 0; if (collectable == null) { ++bonus; } else if (collectable.type == Collectable.Type.Score) { bonus += (int)Math.Round(collectable.value); } else if (collectable.type == Collectable.Type.Objective) { objectives += (int)Math.Round(collectable.value); } else if (collectable.type == Collectable.Type.Speed) { movement.AccelerateForward(collectable.value); } scores += bonus; LevelSettings.SetScoresCount(scores); LevelSettings.SetObjectivesCount(objectives); CheckSpeed(); }
/// Author: JT /// Date: 2/16/2021 /// <summary> /// Refreshes the inventory UI to display our current items. /// </summary> /// Edit: Chase O'Connor /// Function was restructred to work with our current system rather than the /// system that was made following the tutorial. private void RefreshInventoryItems() { foreach (GameObject image in itemSlots) { image.transform.GetChild(imageIndex).GetComponent <Image>().sprite = null; image.transform.GetChild(imageIndex).GetComponent <Image>().enabled = false; image.transform.GetChild(amountIndex).GetComponent <Text>().text = ""; } foreach (Image potionImage in potionSlots) { potionImage.sprite = null; } //int x = 0; //creates new inventory UI elements for the different items in the item list ///Updates the inventory UI for (int i = 0; i < inventory.ItemList.Count; i++) { Collectable item = inventory.ItemList[i]; itemSlots[i].transform.GetChild(imageIndex).GetComponent <Image>().sprite = item.UISprite; itemSlots[i].transform.GetChild(imageIndex).GetComponent <Image>().enabled = true; //increases the amount for the stackable items and displays the proper number in the UI if (item is PotionIngredient ingredient && ingredient.amountInInv > 1) { itemSlots[i].transform.GetChild(amountIndex).GetComponent <Text>().text = ingredient.amountInInv.ToString(); }
public void Start() { ModeCurrent = gMode.GM_WORLD; UseWith = false; UseWithObject = null; }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Finish") { SceneManager.LoadScene(sceneName: "endgame"); } if (collision.gameObject.tag == "collectable") { Collectable collectable = collision.gameObject.GetComponent <Collectable>(); score += collectable.score; Destroy(collectable.gameObject); } if (collision.gameObject.tag == "jumpscare") { Scream.Play(); JumpCam.SetActive(true); //ThePlayer.SetActive(false); //FlashIng.SetActive(true); StartCoroutine(EndJump()); } if (collision.gameObject.tag == "CrawlerTrigger") { Crawler.SetActive(true); //ThePlayer.SetActive(false); StartCoroutine(DeactivateEnemy()); } }
public void SpawnCollectable() { Vector3 spawnPos = new Vector3(UnityEngine.Random.Range(3, 7), Random.Range(mainCamera.transform.position.y + 10, mainCamera.transform.position.y + 15)); GameObject c = Instantiate(collectGo, spawnPos, Quaternion.Euler(new Vector3(0, 90, 0))); int collectType = Random.Range(0, 3); Collectable coll = c.GetComponentInChildren <Collectable>(); if (collectType == 1) { coll.wing1.material.mainTexture = orangeButterfly; coll.wing2.material.mainTexture = orangeButterfly; coll.type = 1; } else if (collectType == 2) { coll.wing1.material.mainTexture = blueButterfly; coll.wing2.material.mainTexture = blueButterfly; coll.type = 2; } else { coll.wing1.material.mainTexture = rainbowButterfly; coll.wing2.material.mainTexture = rainbowButterfly; coll.type = 3; } }
public void RemoveFromCollection(Collectable listObj) { for (int i = 0; i < collectables.Count; i++) { collectables.Remove(listObj); } }
public override void Draw(GameTime gameTime) { Vector2 PlayerPosition = new Vector2(_sprites[0].CollisionRectangle.X + (_sprites[0].CollisionRectangle.Width / 2) - 400, 0); var _viewMatrix = _camera.GetViewMatrix(PlayerPosition); Globals.SpriteBatch.Begin(transformMatrix: _viewMatrix); foreach (var sprite in _sprites) { if (sprite is Collectable) { Collectable _collectable = sprite as Collectable; if (!_collectable.IsCollected) { _collectable.Draw(); } } else if (sprite is Enemy) { Enemy _enemy = sprite as Enemy; if (!_enemy.HasDied) { _enemy.Draw(); } } else { sprite.Draw(); } } Globals.SpriteBatch.End(); }
// Use this for initialization void Start() { for (int j = 0; j < collectablePrefabs.Length; ++j) { List <Item> m_newType = new List <Item>(); for (int i = 0; i < m_poolAmount; ++i) { if (collectablePrefabs[j] != null) { Item newItem = new Item(); newItem.m_object = GameObject.Instantiate(collectablePrefabs[j]); Collectable script = newItem.m_object.GetComponent <Collectable>(); if (script != null) { newItem.m_script = script; } newItem.m_object.transform.SetParent(this.transform); newItem.m_object.SetActive(false); m_newType.Add(newItem); } } m_pool.Add(m_newType); } }
protected void OnTriggerEnter(Collider collider) { GameObject go = collider.gameObject; EnemyMovement em = go.GetComponent <EnemyMovement>(); if (em) { if (isBlocking) { PerformStun(em); } else { TakeDamage(); } return; } Collectable collectable = go.GetComponent <Collectable>(); if (collectable) { // TODO this is a hack collidingCollectable = go; return; } }
public void OnHookCameBack() { nextHookPosition = hookPositionBeforeShooting; hookState = HookState.rotating; GetComponent <Aiming>().enabled = true; // enable aiming if (HookedCollectable) { if (HookedCollectable.gameObject.GetComponent <ManaCollectable>() != null) // collectable is mana type { GetComponentInParent <Tower>().OnCollectableCatch(HookedCollectable.gameObject); HookedCollectable = null; FindObjectOfType <AudioManager>().Play("Hook Tower"); } else // collectable is shield type { if (isHoldingShield) { // this shield collectable already came back to base Destroy(HookedCollectable.gameObject); FindObjectOfType <AudioManager>().Play("Hook Tower"); HookedCollectable = null; isHoldingShield = false; } else { isHoldingShield = true; HookedCollectable.gameObject.GetComponent <ShieldCollectable>().switchToShield(); } } } else // no collectable hooked { isHoldingShield = false; } }
private void CheckForEstimatedGatherRotation() { if (!gatherRotation.CanBeOverriden || DisableRotationOverride) { return; } CollectableItem = Items.OfType <Collectable>().FirstOrDefault(); if (CollectableItem != null) { Logger.Info(Localization.Localization.ExGather_Rotationbaseoff, CollectableItem); } else { Logger.Info(Localization.Localization.ExGather_RotationbaseoffGatherIncrease, GatherIncrease); } var rotation = GetOverrideRotation(); if (rotation == null) { Logger.Info(Localization.Localization.ExGather_RotationNotChange); return; } Logger.Info(Localization.Localization.ExGather_RotationEstimate, gatherRotation.Attributes.Name, rotation.Attributes.Name); gatherRotation = rotation; }
public void StartCollect(GameObject target) { if (!GameManager.Instance.isRunning) { return; } CancelInteraction(); var collectable = target.GetComponent <Collectable>(); if (collectable == null) { Debug.LogWarning("Cannot collect this game object!", target); return; } if (!ownedRectangle.Contains(collectable.transform.position) && !GameManager.Instance.allowCheats) { Debug.LogWarning("Player tried to collect outside of owned rectangle!"); return; } collectable.StartCollecting(this); activeCollectable = collectable; timerStart = Time.time; EffectsManager.Instance.RpcShowInteraction(gameObject, collectable.transform.position); SoundManager.Instance.RpcPlaySoundPlayer(SoundEffect.CollectableCollecting, playerId); }
public void CancelInteraction() { EffectsManager.Instance.RpcHideInteraction(); if (activeCollectable) { activeCollectable.StopCollecting(); activeCollectable = null; SoundManager.Instance.RpcStopSoundPlayer(SoundEffect.CollectableCollecting, playerId); } if (activeType != TowerType.None) { NetworkServer.Destroy(activeBuildTower); activeBuildTower = null; activeType = TowerType.None; SoundManager.Instance.RpcStopSoundPlayer(SoundEffect.TowerBuilding, playerId); statistics.towersBuilt -= 1; } if (activeDestroyingTower != null) { EffectsManager.Instance.RpcStopTowerDestroyEffect(activeDestroyingTower); activeDestroyingTower = null; SoundManager.Instance.RpcStopSoundPlayer(SoundEffect.TowerDestroying, playerId); } }
public static void InstantiateItemInWorld(this string itemName, Vector3 spawnPosition, int amnt = 1) { Collectable collect = GameDataManager.InstantiateItem(spawnPosition).GetComponent <Collectable>(); collect.SetItemName(itemName); collect.amount = amnt; }
void Start() { if (GameController.instance != null) { GameController.instance.SetMinigame(this); } for (int i = 0; i < Random.Range(7, 12); i++) { GameObject collectableObj = Instantiate(collectablePrefab, collectableParent.transform); collectableObj.transform.position = worldDimensions * new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Collectable collectable = collectableObj.GetComponent <Collectable>(); collectable.goodObject = Random.Range(0f, 1f) < 0.6f; if (collectable.goodObject) { totalGoodObjects++; } collectables.Add(collectable); } numGoodObjectsGotten = 0; numBadObjectsGotten = 0; }
public void Collect(GameObject collectable, bool isPlayer1) { Collectable collectableScript = collectable.GetComponent <Collectable>(); string collectableType = collectableScript.collectableType; Color collectableColor = collectables.GetCollectableColor(); this.gameObject.GetComponent <PowerUpController>().ActivatePowerUp(isPlayer1, collectableType); if (collectableType != "death") { this.gameObject.GetComponent <PowerUpCooldown>().StartCooldown(isPlayer1, collectableColor); if (isPlayer1) { SoundController.instance.PlayRandomizedSound(witchPowerUp); } else { SoundController.instance.PlayRandomizedSound(devilPowerUp); } } else { SoundController.instance.PlayRandomizedSound(deathPowerUp); } Destroy(collectable); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Collectable") { if (collision.GetComponent <Collectable>().myType == Collectable.CollectableType.Key) { onPlayer = collision.GetComponent <Collectable>(); onPlayer.collected = true; } else if (collision.GetComponent <Collectable>().myType == Collectable.CollectableType.Photo) { onPlayer = collision.GetComponent <Collectable>(); onPlayer.collected = true; } } else if (collision.tag == "Portal" && onPlayer.myType == Collectable.CollectableType.Photo) { collectedPhotos[onPlayer.collectableID] = onPlayer; collectablePanel.SetActive(true); for (int i = 0; i < photosInPanel.Length; i++) { photosInPanel[i].gameObject.SetActive(false); } photosInPanel[onPlayer.collectableID].gameObject.SetActive(true); onPlayer.isUsed = true; onPlayer = null; } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.GetType() == typeof(CircleCollider2D) && !sprite.CompareTag("Powerup")) { anim.Play(); hitsound.Play(); if (!IsUsed) { StartCoroutine(CoinOut()); // play hit animation and if not used play coin animation and collect coin Collectable.Play(); OnCoinCollect(); gameObject.GetComponent <SpriteRenderer>().sprite = Used; this.IsUsed = true; } } if (collision.collider.GetType() == typeof(CircleCollider2D) && sprite.CompareTag("Powerup")) { anim.Play(); hitsound.Play(); if (!IsUsed) { StartCoroutine(PowerupsOut()); // call powerupsout() Collectable.Play(); gameObject.GetComponent <SpriteRenderer>().sprite = Used; // play hit animation and if not used collect the powerup depend upon the tag set this.IsUsed = true; } } }
public override string ToString() { string output = String.Join("|", new string[] { Macro1.ToString(), // 0 Macro1Time.ToString(), // 1 Macro2.ToString(), // 2 Macro2Time.ToString(), // 3 Macro2Check.ToString(), // 4 Macro3.ToString(), // 5 Macro3Time.ToString(), // 6 Macro3Check.ToString(), // 7 Food.ToString(), // 8 FoodCheck.ToString(), // 9 Syrup.ToString(), // 10 SyrupCheck.ToString(), // 11 Select.ToString(), // 12 Cancel.ToString(), // 13 Collectable.ToString(), // 14 FoodDuration.ToString() // 15 }); return(output); }
private bool SetGatherItem(ICollection <GatheringItem> windowItems) { foreach (var item in Items) { var items = windowItems.Where(i => i.IsFilled && !i.IsUnknown).ToArray(); if (item.Id > 0) { GatherItem = items.FirstOrDefault(i => i.ItemData.Id == item.Id && (!i.ItemData.Unique || i.ItemData.ItemCount() == 0)); } GatherItem = GatherItem ?? items.FirstOrDefault( i => string.Equals(item.LocalName, i.ItemData.CurrentLocaleName, StringComparison.InvariantCultureIgnoreCase) && (!i.ItemData.Unique || i.ItemData.ItemCount() == 0)) ?? items.FirstOrDefault( i => string.Equals(item.Name, i.ItemData.EngName, StringComparison.InvariantCultureIgnoreCase) && (!i.ItemData.Unique || i.ItemData.ItemCount() == 0)); if (GatherItem != null) { // We don't need to check null...since it will be null anyway. CollectableItem = item as Collectable; return(true); } } return(false); }
private void PickUp() { Collider[] colliders; colliders = Physics.OverlapSphere(castStartPosition.position, castDistance); foreach (var item in colliders) { Collectable collectable = item.transform.gameObject.GetComponent <Collectable>(); if (collectable == null) { continue; } if (collectable.PickupType == PickupType.Collectable) { //if (pickupState == PickupState.HasWeapon) return; GameObject pickedUp = Instantiate(item.transform.gameObject, hand.transform.position, hand.transform.rotation, hand.transform); pickedUp.GetComponent <Collider>().enabled = false; if (currentWeapon != null) { Destroy(currentWeapon.gameObject); } currentWeapon = pickedUp; if (OnPickup != null) { OnPickup(pickedUp); } pickupState = PickupState.HasWeapon; Destroy(item.transform.gameObject); } } }
public void OnTriggerEnter(Collider other) { GoalTrigger _goalTrigger = other.GetComponent <GoalTrigger>(); if (_goalTrigger != null) { _goalTrigger.DOTrigger(); return; } Trigger _trigger = other.GetComponent <Trigger>(); if (_trigger != null) { trigger = _trigger; return; } Collectable _collectable = other.GetComponent <Collectable>(); if (_collectable != null) { uI.SetListItem(_collectable.ID); gameManager.AddWinItems(); _collectable.thisGameObject.SetActive(false); _collectable.soundEffect.Play(); } }
private void OnTriggerEnter2D(Collider2D collision) { //This is checking the collision for a gameObject that has the //Script 'EnemyHealth' Attached to it GameObject checkCollision = collision.gameObject; EnemyHealth attacked = checkCollision.GetComponent <EnemyHealth>(); Collectable pickUp = checkCollision.GetComponent <Collectable>(); if (attacked != null) { print("Attacked Enemy"); Destroy(collision.gameObject); addScore(); } if (pickUp != null) { AudioSource source = pickUp.gameObject.GetComponent <AudioSource>(); if (!source.isPlaying) { source.Play(); } print("Coin Grabbed"); Destroy(collision.gameObject); addScore(); } }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody>(); gunBodyBaseRotation = gunBody.transform.localRotation; _previousTag = this.gameObject.tag; _collectable = GetComponent <Collectable>(); }
private void OnTriggerEnter2D(Collider2D collision) { newCollectable = collision.GetComponent <Collectable>(); if (newCollectable != null) { if (currentPickedupCollectable != null) { return; } else { currentTouchedCollectable = newCollectable; } } if (collision.transform.tag == "Hell") { inHell = true; Camera.main.GetComponent <PostPManager>().gotoHell(); SoundManager.instance.PlayLoop(hell); Debug.Log("In hell"); } }
public Collectable GetCollectable(CollectableType _type) { Collectable collectable = null; switch (_type) { case CollectableType.Gold: collectable = goldCoins.GetPooledCollectable(); break; case CollectableType.Stamina: collectable = staminaBars.GetPooledCollectable(); break; case CollectableType.Charge: collectable = charges.GetPooledCollectable(); break; case CollectableType.Shield: collectable = shields.GetPooledCollectable(); break; case CollectableType.MegaCoin: collectable = megaCoins.GetPooledCollectable(); break; default: Debug.LogError("Invalid Request to Collectable Pooler"); break; } return(collectable); }
private void OnTriggerEnter2D(Collider2D collision) { collectable = collision.GetComponent <Collectable>(); if (collectable) { collectable.Collect(); OnCollected?.Invoke(collectable.value); } switch (collision.tag) { case "Danger": TakeDamage(25, collision); break; case "Respawn": respawnPoint = transform.position; break; case "JumpPad": GetComponent <Movement>().JumpUp(jumpPadJumpMultiplier); break; case "enemy": TakeDamage(20, collision); break; default: break; } }
public void DestroyCollectableAtPosition(Coord collectablePosition) { Collectable theCollectable = this.allActiveCollectables.FirstOrDefault(c => c.position == collectablePosition); this.allActiveCollectables.Remove(theCollectable); Destroy(theCollectable.gameObject); }
private IEnumerator AnimateReveal() { float time = 3f; CreateSphereCollider(); var randomItem = Items[Random.Range(0, Items.Length)]; var itemGO = (GameObject) GameObject.Instantiate(randomItem, transform.position + new Vector3(0f, 1.6f, 0f), Quaternion.LookRotation(Vector3.right)); _attachedItem = itemGO.GetComponent<Collectable>(); itemGO.transform.parent = gameObject.transform; //Move up TweenParms revealTween = new TweenParms().Prop( "position", transform.position + Vector3.up * buryDepth).Ease( EaseType.Linear).Delay(0f); HOTween.To(gameObject.transform, time, revealTween); //Scale power var targetScale = itemGO.transform.localScale; itemGO.transform.localScale = new Vector3(0f, 0f, 0f); TweenParms scaleTween = new TweenParms().Prop( "localScale", targetScale).Ease( EaseType.EaseInOutElastic).Delay(2.5f); HOTween.To(itemGO.transform, 1f, scaleTween); yield return new WaitForSeconds(time); _active = true; }
void Start() { collectable = transform.GetComponent <Collectable>(); collectable.onClick += amount => { }; }
// Attempts to collect an object public bool Collect( Collectable other ) { if ( maxCollectionSize <= collection.Count ) { return false; } if ( false == collection.Contains ( other ) ) { other.audio.Play (); if ( other.itemType == Collectable.ItemType.GhostKey) { AppManager.Instance.humanWinScreen.SetActive(true); AppManager.Instance.BeginGameOver(); } else { AppManager.Instance.DisplayMessage("This is just a " + other.name + ". I'll Keep Looking."); } collection.Add ( other ); other.Collected (); if ( makeAttachPointParent ) { other.gameObject.transform.parent = attachPoint; other.transform.position = Vector3.zero; other.transform.localPosition = Vector3.zero; } else { other.transform.position = attachPoint.position; other.transform.localPosition = Vector3.zero; } } return true; }
// when passing by an item, spoons will try to grab it if he is ready public void handleCollection(Collectable item) { if(p_spoon.isActive()) { item.setCollected(); Destroy(item.gameObject); } }
public void OnCollect(Collectable collectable) { if (collectable.GetComponent<Cloud>()) steam += collectable.GetComponent<Cloud>().steamAmount; if (collectable.GetComponent<Valuable>()) GameObject.FindObjectOfType<LevelController>().UpdateValuables(collectable.GetComponent<Valuable>()); }
public CollectState(Collectable data) { this.data = data; //Show item get pop-up }
public void AddToHold(Collectable col) { collected.Play(); if((hold.Count + col.size) <=holdlimit){ hold.Add(col.name); holdguys[hold.Count-1].GetComponent<MeshRenderer>().enabled = true; } }
void OnTriggerEnter(Collider other) { var coll = other.gameObject.GetComponent<Collectable> (); if (coll != null) { collectable = coll; } else { collectable = null; } }
void onTriggerExit(Collider other) { var coll = other.gameObject.GetComponent<Collectable> (); if (coll == null) { collectable = null; } else { // is this okay? collectable = null; } }
void CreateCollectableInSpot() { int indexPowerUp = m_rnd.Next(0, collectables.Length); // creates a number between 0 and powerups.Length // Instantiate the prefab of the power up with the values in the inspector GameObject pu = (GameObject)Instantiate(collectables[indexPowerUp].gameObject, transform.position, Quaternion.identity); pu.name = "Collectable"; m_currentCollectable = pu.GetComponent<Collectable>(); pu.transform.SetParent(transform); m_acumTime = 0; }
// Returns a ref to the object if found, else returns null public Collectable holdsCollectableType(Collectable.ItemType itemType ) { foreach ( Collectable item in collection ) { if ( item.itemType == itemType ) { return item; } } return null; }
public void SetCollectable(Collectable powerUp) { if (m_currentCollectable != null) m_currentCollectable.FinishCollectable (); m_currentCollectable = powerUp; // Set the player as the parent of the power up m_currentCollectable.transform.parent = transform; m_currentCollectable.StartCollectable(this); m_currentCollectable.SetFeedback (m_feedback); }
public void Grow(Collectable col) { eaten += 1; aquisition.Play(); transform.localScale +=new Vector3(col.size/100.0f,col.size/100.0f,0); if (eaten == 5) { music.pitch +=0.01f; totalVines++; Vines v = disabledVines[0]; v.enabled = true; disabledVines.Remove(v); eaten = 0; } }
void PickUpItem() { gameManager.GetComponent<ItemManager> ().setItem (collectable); hasItem = true; images = canvas.GetComponentsInChildren<Image> (); Image imageToPut = images [0]; Image imageToPut2 = images [1]; imageToPut.sprite = imageToPut2.sprite = getCorrectSprite(collectable.itemType); //Renderer rend = collectable.GetComponent<Renderer> (); //Collider col = collectable.GetComponent<Collider> (); // rend.enabled = false; //col.enabled = false; //GameObject.DestroyObject (collectable); collectable = null; }
private void Loot(Collector collector) { if (animator) { animator.SetTrigger("Looted"); } if (loot) { collector.Collect(Instantiate(loot)); loot = null; } interactable.action = null; looted = true; if (destroyOnLoot) { Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { // If this spot is empty, we decrease the runes collected. if (!isFull && (other.gameObject.layer == LayerMask.NameToLayer("Force"))){ InventaryRune ir = other.gameObject.transform.parent.GetComponentInChildren<InventaryRune> (); if (ir) { ir.DropRune (); } } // Check for PowerUpOwner component CollectableOwner owner = other.transform.parent.GetComponentInChildren<CollectableOwner>(); if (owner == null || m_currentCollectable == null) return; owner.SetCollectable(m_currentCollectable); m_currentCollectable = null; }
/// <summary> /// Chooses the goal room. /// </summary> private void CreateGoal(bool showTip) { var possibleGoals = GetPossibleGoals () .OrderByDescending (o => o.GameObject.transform.position.magnitude) .Take (3); GoalRoom = possibleGoals.ElementAt (MazeRandom.Next (0, possibleGoals.Count ())); GoalPos = Convert.WorldToUnit(GoalRoom.GameObject.transform.position); var goal = new Collectable (CollectableConstants.GoalId, Instantiate (GoalPrefab) as GameObject); if(showTip) { InitHelpTipForCollectable(CollectableConstants.GoalId); } GoalRoom.AddCollectable (goal); }
void OnTriggerEnter(Collider other) { // If this spot is empty, we decrease the runes collected. if (!isFull && (other.gameObject.layer == LayerMask.NameToLayer("Player"))){ //Debug.Log ("OnTriggerEnter.other: " + other); other.gameObject.GetComponent<InventaryRune> ().DropRune(); } // Check for PowerUpOwner component CollectableOwner owner = other.GetComponent<CollectableOwner>(); if (owner == null || m_currentCollectable == null) return; owner.SetCollectable(m_currentCollectable); m_currentCollectable = null; m_acumTime = 0; spotStatus = status.IDLE; }
public virtual void Collect (Collectable collectable) { }
// Lets go of an object, does NOT reposition anywhere. public void Release( Collectable other ) { if ( collection.Contains ( other ) ) { collection.Remove ( other ); other.Released (); if ( makeAttachPointParent ) { other.transform.parent = null; } } }
public void setItem(Collectable colItem) { item = colItem; }
public void Collect(Collectable collectable) { collectable.SendMessage("OnCollect", this, SendMessageOptions.RequireReceiver); }
void OnTriggerEnter(Collider other) { // If this spot is empty, we decrease the runes collected. if (!isFull && (other.gameObject.layer == LayerMask.NameToLayer("Force"))){ //Debug.Log ("OnTriggerEnter.other: " + other); InventaryRune ir = other.gameObject.transform.parent.GetComponentInChildren<InventaryRune> (); if (ir != null) ir.DropRune(); } // Check for PowerUpOwner component CollectableOwner owner = other.transform.parent.GetComponentInChildren<CollectableOwner>(); if (owner == null || m_currentCollectable == null) return; //owner.SetCollectable(m_currentCollectable); //Do not set collectable because we do not need to destroy/finish the collectable m_currentCollectable.StartCollectable(owner); m_currentCollectable = null; m_acumTime = 0; spotStatus = status.IDLE; }
void LoadObjects(string fileName) { List<Base_Object> data = new List<Base_Object>(); try { string line; StreamReader file = new StreamReader(fileName, Encoding.Default); ObjectData objectTemp = new ObjectData(); using (file) { do { line = file.ReadLine(); if (line != null) { if(line[0] == '{') { objectTemp.Reset(); bool done = false; //string[] elements; do { line = file.ReadLine(); if(line == null) done = true; else if(line[0] == '}') done = true; else { string[] elements = line.Split('='); if(elements.Length < 2) done = true; else { elements[0] = elements[0].Trim(); // gets rid of leading whitespace switch(elements[0]) { case "name": objectTemp.Name = elements[1]; break; case "desc": objectTemp.Desc = elements[1]; break; case "collectable": string t = elements[1].ToLower(); if(t.CompareTo("true") == 0 || t.CompareTo("1") == 0) objectTemp.isCollectable = true; break; case "icon": objectTemp.IconFileName = elements[1]; break; case "combinable": string s = elements[1].ToLower(); if(s.CompareTo("true") == 0 || s.CompareTo("1") == 0) objectTemp.isCombinable = true; break; case "combines_with": objectTemp.CombinesWith = int.Parse(elements[1]); break; } } } } while (!done); Base_Object b; if(objectTemp.isCollectable) { Texture2D texture = null; //Resources.Load(objectTemp.IconFileName) b = new Collectable(objectTemp.Name, objectTemp.Desc, texture); if(objectTemp.isCombinable) { ((Collectable)b).combinable = true; ((Collectable)b).combines_with = objectTemp.CombinesWith; } } else { b = new Base_Object(objectTemp.Name, objectTemp.Desc); } data.Add(b); } } } while (line != null); file.Close(); // PRINT TEST string msg = ""; foreach(Base_Object obj in data) { msg = obj.name + "; " + obj.desc; if(obj.type == Object_Type.OBJ_COLLECT) { msg += " [COLLECTABLE]"; if(((Collectable)obj).combinable) msg += " [COMBINABLE]"; } print(msg); } } } catch (System.Exception e) { print( e.Message); } }
public void OnCollected(Collectable collectable) { this.Score++; }
private void CreateCollectables(int count, int type, GameObject prefab) { for (var i = 0; i < count; ++i) { var pos = MazeRandom.Next (MaxPoint); while(pos == GoalPos) { pos = MazeRandom.Next (MaxPoint); } var collectable = new Collectable(type, Instantiate (prefab) as GameObject); GetRoom (pos).AddCollectable(collectable); } }
// DO NOT USE public void AddObject(string name, string desc, Texture2D tex) { Collectable o = new Collectable(name, desc, tex); objects.Add(o); }
void LoadObjects(string fileName) { string line; StreamReader file = new StreamReader(fileName, Encoding.Default); if(file != null) { WorldObjectData objectTemp = new WorldObjectData(); do { line = file.ReadLine(); if (line != null) { if(line[0] == '{') { objectTemp.Reset(); bool done = false; //string[] elements; do { line = file.ReadLine(); if(line == null) done = true; else if(line[0] == '}') done = true; else { string[] elements = line.Split('='); if(elements.Length < 2) done = true; else ProcessObjectFileLine(elements, ref objectTemp); } } while (!done); Base_Object b; if(objectTemp.isCollectable) { Texture2D texture = (Texture2D)Resources.Load("textures/items/" + objectTemp.IconFileName); b = new Collectable(objectTemp.Name, objectTemp.Desc, texture); } else { b = new Base_Object(objectTemp.Name, objectTemp.Desc); } db.AddObject(b); } } } while (line != null); file.Close(); } }
/// <summary> /// Called when the master volume is changed: used to modify the LFE value for this player /// </summary> void MasterVolume_Changed(object sender, Collectable<Device>.ItemEventArgs e) { _lfeVolume = ((MasterVolume)e.Item).LFEVolume; if (_currentStream != 0) SetMatrix(_currentStream); }