// Start is called before the first frame update void Start() { player = GameObject.Find("Player"); potionController = player.GetComponentInChildren <PotionController>(); previousPos = transform.position; previospreviousPos = transform.position; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "HealthPotion" && currentHealth < maxHealth) { PotionController potion = collision.GetComponent <PotionController>(); GainHealth(potion.HealthPoints); Destroy(potion.gameObject); } }
protected override void Interact(Character actor) { Interaction.text = string.Format("{0} Found", ItemUtil.ItemToString(_item)); PotionController.Add(_item); WeaponController.Add(_item); StartCoroutine(ClearInteractionWait()); HasBeenInteractedWith = true; }
// TODO: Add Character and Armor Controllers public static void ConfigureControllers(DataContext context, Mapper mapper, out PotionController potionController, out WeaponController weaponController, out ArmorController armorController, out CharacterController characterController) { PotionRepository potionRepository = new PotionRepository(context); WeaponRepository weaponRepository = new WeaponRepository(context); ArmorRepository armorRepository = new ArmorRepository(context); CharacterRepository characterRepository = new CharacterRepository(context); potionController = new PotionController(potionRepository, mapper); weaponController = new WeaponController(weaponRepository, mapper); armorController = new ArmorController(armorRepository, mapper); characterController = new CharacterController(characterRepository, mapper); }
// Start is called before the first frame update void Start() { uiScript = uiObject.GetComponent <UIController>(); gridMapScript = GameObject.Find("codeHandler").GetComponent <GridMap>(); ChangePotionCount(startingPotionCount); SetLaserCharge(laserChargeMax); if (uiScript == null) { print("failed to load script"); } Cursor.visible = false; playerHealth = playerHeathMax; oldCameraRotation = cameraTransform.rotation; potionControllerScript = GameObject.Find("codeHandler").GetComponent <PotionController>(); }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.GetComponent <PotionController>()) { PotionController pCon = collision.gameObject.GetComponent <PotionController>(); bool alreadyCured = false; for (int i = 0; i < npcLine.Count; i++) { if (npcLine[i] != null & alreadyCured == false) { int correct = 0; for (int x = 0; x < npcLine[i].GetComponent <NPC>().ailments.Length; x++) { if (npcLine[i] != null) { if ((bool)pCon.GetType().GetField(npcLine[i].GetComponent <NPC>().ailments[x].ToLower()).GetValue(pCon)) { correct++; print(correct); } } if (correct >= 3) { Destroy(collision.gameObject); StartCoroutine(moveToBack(npcLine[i])); npcLine[i].GetComponent <SpriteRenderer>().sprite = npcHappy; npcLine[i].GetComponent <NPC>().enabled = false; Destroy(npcLine[i].GetComponent <NPC>().display.gameObject); npcLine[i] = null; alreadyCured = true; } } } } } }
private void Awake() { instance = this; }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.GetComponent <IngredientType>()) { if (collision.gameObject.GetComponent <IngredientType>().hasBeenThrown) { if (item1 == null & collision.gameObject.GetComponent <IngredientType>().hasBeenThrown) { item1 = collision.gameObject.GetComponent <IngredientType>().ingredient; render.sprite = full; Item1Display.sprite = item1.image; Destroy(collision.gameObject); foreach (ParticleSystem p in gameObject.GetComponentsInChildren <ParticleSystem>()) { if (p.gameObject.name != "LightFlashes") { p.Play(); } else { p.Stop(); } } } else if (item2 == null & collision.gameObject.GetComponent <IngredientType>()) { item2 = collision.gameObject.GetComponent <IngredientType>().ingredient; foreach (ParticleSystem p in gameObject.GetComponentsInChildren <ParticleSystem>()) { if (p.gameObject.name == "LightFlashes") { p.Emit(30); } } render.sprite = empty; foreach (ParticleSystem p in gameObject.GetComponentsInChildren <ParticleSystem>()) { p.Stop(); } GameObject newPotion = Instantiate(potionBase); newPotion.transform.position = gameObject.transform.position + new Vector3(0, 1.2f, 0); newPotion.transform.parent = null; bool hot = false; bool cold = false; bool magic = false; bool warding = false; bool holy = false; bool evil = false; bool soothing = false; bool frightening = false; bool soft = false; bool hard = false; if (item1.cold | item2.cold) { cold = true; } if (item1.hot | item2.hot) { hot = true; } if (item1.magic | item2.magic) { magic = true; } if (item1.warding | item2.warding) { warding = true; } if (item1.holy | item2.holy) { holy = true; } if (item1.evil | item2.evil) { evil = true; } if (item1.soothing | item2.soothing) { soothing = true; } if (item1.frightening | item2.frightening) { frightening = true; } if (item1.soft | item2.soft) { soft = true; } if (item1.hard | item2.hard) { hard = true; } PotionController pCon = newPotion.GetComponent <PotionController>(); pCon.cold = cold; pCon.hot = hot; pCon.magic = magic; pCon.warding = warding; pCon.holy = holy; pCon.evil = evil; pCon.soothing = soothing; pCon.frightening = frightening; pCon.soft = soft; pCon.hard = hard; Destroy(collision.gameObject); item1 = null; item2 = null; Item1Display.sprite = null; } } } }