private void InitializeSingleChest(ChestModel chestModel, GameObject view, ControllersStorage controllers) { var chest = new ChestController(chestModel, view); controllers.Add(chest); }
void HandleChestOpening(ChestController chest) { if (_chestsClosing != null || !GameIsRunning) //If currently other chests are on delay to close or game ended { chest.Close(); //Immediately return; } if (_firstChest == null) { _firstChest = chest; } else/*if(_firstChest != null)*/ { if (_firstChest.ItemIndex == chest.ItemIndex) { _firstChest = null; PlayerMovedSuccessfully?.Invoke(true); } else { _chestsClosing = StartCoroutine(CloseChestsAfterDelay(chest)); PlayerMovedSuccessfully?.Invoke(false); } } }
void CheckChest(RaycastHit2D rayLeft, RaycastHit2D rayRight) { bool hitChest = false; GameObject chestObject = null; ChestController cc = null; if (rayLeft.distance <= 0.3f && rayLeft.collider.tag.Contains("Chest")) { hitChest = true; chestObject = rayLeft.collider.gameObject; cc = chestObject.GetComponent <ChestController>(); } else if (rayRight.distance <= 0.3f && rayRight.collider.tag.Contains("Chest")) { hitChest = true; chestObject = rayRight.collider.gameObject; cc = chestObject.GetComponent <ChestController>(); } else { return; } if (!hitChest) { return; } else if (!cc.isClosed) { return; } else { cc.Open(); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Ground")) { isGrounded = true; } if (other.gameObject.CompareTag("Chest")) { ChestController c = other.gameObject.GetComponent <ChestController>(); if (!c.IsOpen) { c.IsOpen = true; countStones += 3; } } if (other.gameObject.CompareTag("Item")) { if (countStones < 3) { other.gameObject.SetActive(false); countStones = countStones + 1; } } }
public void CollisionDetected(string tagName, GameObject collidedGameObject) { Debug.Log(tagName); if (tagName == "Key") { this.playerKeyCount++; } if (tagName == "Chest") { ChestController cc = collidedGameObject.GetComponent <ChestController>(); if (this.playerKeyCount >= KEY_COUNT_PER_CHEST && !cc.isUnlocked) { cc.Unlock(); this.playerKeyCount -= KEY_COUNT_PER_CHEST; } } if (tagName == "Diamond") { DiamondController dc = collidedGameObject.GetComponent <DiamondController>(); this.playerDiamondCount += dc.value; if (this.playerDiamondCount > 999) { this.playerDiamondCount = 999; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Ladder") { canClimb = true; } if (collision.CompareTag("Chest")) { ChestController chest = collision.gameObject.GetComponent <ChestController>(); if (!chest.isOpen) { chest.isOpen = true; if (!skillController.hasSkill(chest.skill)) { skillController.obtainSkill(chest.skill); } } } if (collision.CompareTag("Checkpoint")) { checkpoint = collision.gameObject.transform.position; } }
void OnTriggerEnter2D(Collider2D col) { PlayerController pc = col.GetComponent <PlayerController>(); EnemyController ec = col.GetComponent <EnemyController>(); ChestController cc = col.GetComponent <ChestController>(); if (pc != null) { pc.OnHit(); } if (ec != null) { ec.OnHit(); } if (cc != null) { cc.OnHit(); } //collectable no hit if (col.tag == "Collectable") { return; } OnHit(); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(ItemTag.Player)) { hasExplosive = ChestController.DoesHaveItem(ItemTag.Tnt); if (hasExplosive && !explosionOccured) { //Explode(); explosivePlanted = true; explosionOccured = true; messageBroadcasted = true; instantiatedTNT = (GameObject)Instantiate(TNT, new Vector3(transform.position.x + 1.5f, transform.position.y, transform.position.z), transform.rotation); instantiatedTNT.tag = "Untagged"; //showPopUp("Explosion in " + explosionTimer.ToString() + " seconds..."); ChestController.RemoveItem(ItemTag.Tnt); } else if (!messageBroadcasted && !(GameState.gameState.HazardWasDestroyed(ItemTag.Rock1) || GameState.gameState.HazardWasDestroyed(ItemTag.Rock2))) { string message = "You need a TNT to destroy this rock!"; messageBroadcasted = true; ShowPopUp(message); } } }
public void Start() { chestController = GameObject.FindGameObjectWithTag("ChestController").GetComponent <ChestController>(); ChestUI = chestController.NewChest(); _Index = Index; Index++; }
public static void showMap() { if (ChestController.DoesHaveItem(ItemTag.Map)) { isAppearing = true; } }
public void Setup() { _lootTableMock = new Mock <ILootTable>(); _lootTableMock.Setup(m => m.Roll(It.IsAny <int>())) .Returns(new LootItem("1", "Special Hat")); _loggerMock = new Mock <ILogger>(); _sut = new ChestController(_lootTableMock.Object, _loggerMock.Object); }
private void CalulateScore() { int coins = ChestController.ItemCount(ItemTag.Coin); int diamonds = ChestController.ItemCount(ItemTag.Diamond); int percentOfPickedPickUps = (int)((coins + diamonds) * 100 / pickUpsCount); score = (int)(breathingGasAmount + health) + percentOfPickedPickUps; }
public override void Compare(UnityEngine.Object obj) { ChestController chest = (ChestController)obj; if (chest.gameObject.name.Contains(chestName)) { value++; } }
IEnumerator CloseChestsAfterDelay(ChestController secondChest) { yield return(_closeDelay); _firstChest.Close(); secondChest.Close(); _firstChest = null; _chestsClosing = null; }
void Start() { audioSource = GetComponent <AudioSource>(); spriteRenderer = GetComponent <SpriteRenderer>(); chestControllerScript = chestController.GetComponent <ChestController>(); fruitAInside = false; fruitBInside = false; chestIsOpen = false; }
void Awake() { chestAScript = chestA.GetComponentInChildren <ChestController>(); chestBScript = chestB.GetComponentInChildren <ChestController>(); spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.enabled = false; myScore = 0; globalScore = 0; }
void OnTriggerEnter2D(Collider2D collider2d) { if (collider2d.tag == "Player" && !chest.IsOpen) { if (chestController == null) { chestController = collider2d.gameObject.GetComponent <ChestController>(); } InteractionManager.Instance.RegisterTrigger(this, Interaction.Type.Inspect); } }
// Use this for initialization void Start() { gameOverText.text = ""; restartText.text = ""; gameOver = false; restart = false; chestController = null; moveRigth = true; energy = 0; rgb2d = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); ShieldAudioSource = GetComponent <AudioSource>(); }
void attackOverlappingObject() { if (overlappingAttackableObject == null) { return; } if (overlappingAttackableObject.tag.Equals("chest")) { ChestController chestController = overlappingAttackableObject.GetComponent <ChestController>(); chestController.openChest(); } }
void Start() { inventory = Inventory.instance; chestController = ChestController.instance; chest = FindObjectOfType <Chest>(); inventoryUI.SetActive(false); equipmentUI.SetActive(false); chestUI.SetActive(false); // Важно е този скрипт(UIController) да се извърши след Inventory, EquipmentController и ChestController, // защото иначе при отваряне на инвентара или chest-a, ще дава Index out of range, // понеже масивите items[], currentEquipment[] и chestItems[] няма да са инициализирани. // Приоритетът на изпълнение на скриптовете може да се настройва ръчно от меню Script Execution Order. onUpdateUICallback += UpdateChestUI; }
private void OnCollisionEnter2D(Collision2D collision) { // so using tilemaps, we can make new tilemaps and assign different tags to them, for ex: water and ground. //Debug.Log("player has collided with " + collision.collider.name + " with tag: " + collision.gameObject.tag); if (collision.gameObject.tag == "groundable") { GroundPlayer(); } if (collision.gameObject.tag == "hangable" && !Player.instance.isGrounded) { Hang(); } if (collision.gameObject.tag == "breakable" && !Player.instance.isGrounded) { Hang(); } if (collision.gameObject.tag.Contains("Enemy")) { EnemyController enemy = collision.gameObject.GetComponent <EnemyController>(); if (collision.gameObject.tag.Contains("Slime")) { } if (!enemy.attributes.isDead) { Player.instance.TakeDamage(enemy.attributes.damage); if (Player.instance.health <= 0) { GameManager.instance.KillPlayer(); } } } if (collision.gameObject.tag.Contains("Chest")) { //print("collided with chest"); ChestController cc = collision.gameObject.GetComponent <ChestController>(); if (cc.isClosed) { cc.Open(); } } }
void Update() { if (gameOver) { gameOverText.text = "GAME OVER! :C"; restartText.text = "Press R to try"; animator.SetTrigger("Dead"); restart = true; Analytics.CustomEvent("gameOver", new Dictionary <string, object> { { "energy", energy } }); } if (!gameOver) { if (Input.GetButton("Fire1") && newShield == null) { ShieldAudioSource.PlayOneShot(shieldClip); Vector3 positionShield = new Vector3(transform.position.x + 2, transform.position.y + 1, transform.position.z); newShield = Instantiate(shield, positionShield, transform.rotation) as GameObject; } slider.value = energy; energyText.text = energy.ToString(); if (chestController != null) { energy += 10; } chestController = null; } if (restart) { if (Input.GetKeyDown(KeyCode.R)) { //Application.LoadLevel (Application.LoadLevel); UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex); } } }
public void InitializeExperiment( uint playerAFruits, uint playerBFruits, uint speedA, uint speedB, bool commonCounter ) { cursorAScript.speed = (int)speedA; cursorBScript.speed = (int)speedB; boardManagerA.SetUpExperiment(10, 10, playerAFruits); boardManagerB.SetUpExperiment(10, 10, playerBFruits); chestAScript = chestA.GetComponentInChildren <ChestController>(); chestBScript = chestB.GetComponentInChildren <ChestController>(); chestCommonScript = chestCommon.GetComponentInChildren <CommonChestController>(); chestCommonScript.actAsCounter = commonCounter; chestAScript.SetToCapture(false); chestBScript.SetToCapture(false); running = true; }
/// <inheritdoc /> /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { Instance = this; Config = helper.ReadConfig <Config>(); var textures = LoadAssets(helper); _compatibilityInfo = GetCompatibilityInfo(helper); ChestController = new ChestController(textures, _compatibilityInfo, Config); FridgeController = new FridgeController(ChestController); SaveManager = new SaveManager(ChestController, Config); Helper.Events.Display.MenuChanged += OnMenuChanged; Helper.Events.Display.RenderingActiveMenu += OnRenderingActiveMenu; Helper.Events.Input.ButtonPressed += OnButtonPressed; Helper.Events.GameLoop.SaveLoaded += SaveManager.SaveLoaded; Helper.Events.GameLoop.Saving += SaveManager.Saving; Helper.Events.GameLoop.GameLaunched += OnLaunch; Helper.Events.GameLoop.UpdateTicked += OnUpdateTicked; }
public void OnSwitchButton() { Inventory inventory = GetComponentInParent <Inventory>(); ChestController chest = GetComponentInParent <ChestController>(); if (inventory != null) { Inventory.instance.PutInChest(item); Inventory.instance.RemoveItem(item); ClearSlot(); } else if (chest != null) { ChestController.instance.ReturnToInventory(item); } else { Debug.Log("The item is not in the inventory, nor in the chest."); } }
void OnTriggerEnter2D(Collider2D col) { PlayerController pc = col.GetComponent <PlayerController>(); EnemyController ec = col.GetComponent <EnemyController>(); ChestController cc = col.GetComponent <ChestController>(); ProjectileHandler prc = col.GetComponent <ProjectileHandler>(); if (pc != null) { pc.OnHit(999f); } if (ec != null) { ec.OnHit(); } if (cc != null) { cc.OnHit(); } if (cc != null) { prc.OnHit(); } }
public void OverrideProprety() { if (!overrideProperty) { return; } _chestController = GetComponent <ChestController>(); _chestController.RequiredLevel = requiredLevel; switch (typeOfChests) { case MyEnum.exp: _chestController.SetupChestsFromOtherScript(1); break; case MyEnum.destroy: _chestController.SetupChestsFromOtherScript(2); break; case MyEnum.damage: _chestController.SetupChestsFromOtherScript(3); break; } }
void OnTriggerEnter2D(Collider2D c) { if (c.gameObject.tag == "Shop") { ShopController.instance.nearShop = true; } if (c.gameObject.tag == "Portal") { // Display do you want to enter // or // Just transition SceneController.instance.ChangeScene(); } if (c.gameObject.tag == "Chest") { chest = c.gameObject.GetComponent <ChestController>(); if (chest.active) { MenuController.instance.chestPrompt.gameObject.SetActive(true); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Player")) { //if (hasKey) if (ChestController.DoesHaveItem("Key")) { //gate.GetComponent<Rigidbody2D>().constraints = Rigidbody2DConstraints.None; //gate.transform.position += new Vector3(0, 0, -2); //gate.transform.localScale -= new Vector3(0.5F, 0, 0); //gate.transform.Rotate(0, 0, 90); //gate.SetActive(false); ChestController.RemoveItem("Key"); gateAmimation.SetBool("Open", true); AudioManager.audioManager.PlaySound(ItemTag.Gate); gateCollider.enabled = false; } else { string message = "You need a key to open the gate!"; showPopUp(message); } } }
public SaveManager(ChestController chestController, Config config) { _chestController = chestController; _config = config; }