void controlLureImage() { //check if light is in traveller radius GameObject trav = GameObject.FindGameObjectWithTag("Traveller"); if (trav == null) { Debug.Log("Could not find the traveller"); } travellerScript tScript = trav.GetComponent <travellerScript>(); if (tScript == null) { Debug.Log("could not find tScript"); } //get the current lamp that the traveller is at // get its adjacent lamps from light controller // check against our current target //if it is //lureImage.sprite = travellerLureIcon; //go through all monster tagged objects //for each grab script and get the current lamp foreach (GameObject g in GameObject.FindGameObjectsWithTag("Monster")) { EnemyMovement eMovement = g.GetComponent <EnemyMovement>(); if (eMovement == null) { Debug.Log("Could not find monster movement script"); } GameObject lamp = eMovement.findCurrentLamp(); if (lamp != null) { lightSourceController lController = lamp.GetComponent <lightSourceController>(); if (lController == null) { Debug.Log("Could not find light source controller"); } //if (lController.getAdjacentSources().) if (checkAdjacent(lController.getAdjacentSources())) { //check if monster is in monster radius //lureImage.enabled = true; //lureImage.sprite = monsterLureIcon; } } } }
void Awake() { equippedLight = 0; restrictMovement = false; tScript = traveller.GetComponent <travellerScript>(); if (tScript == null) { Debug.Log("Could not find tscript"); } }
void OnTriggerStay(Collider other) { if (other.tag == "Traveller" && setHealing) { //call healing function in traveller's script travellerScript tScript = other.GetComponent <travellerScript>(); if (pController.getResource() > 0) { tScript.increaseCape(); pController.addResource(-0.1f); } } }
// Update is called once per frame void Update() { // Heal when held in vicinity of monster // impulse stun when tapped //Debug.Log(currentTarget); if (Input.GetMouseButton(0) || Input.GetButton("X")) { heldDuration += Time.deltaTime; if (heldDuration > 0.5f) //&& !setHealing) { //start healing //setHealing = true; { if (targetTraveller != null && targetTraveller.tag == "Traveller") { travellerScript tScript = targetTraveller.GetComponent <travellerScript>(); if (pController.getResource() > 0) { tScript.increaseCape(); pController.addResource(-0.1f); } return; } } } if (Input.GetMouseButtonUp(0) || Input.GetButtonUp("X")) { //Debug.Log(heldDuration); //0.2f is general approximation of a tap if (heldDuration <= 0.5f) { //start impulse //call stun enemy function if (currentTarget != null && currentTarget.tag == "LampLight") { pController.setTargetLight(currentTarget); } if (targetMonster != null && targetMonster.tag == "Monster") { setStun(); return; } } heldDuration = 0f; //if (setHealing) // setHealing = false; } if (currentTarget) { //interactionText.text = "Light"; popUpText.fontSize = 150; popUpText.text = "Light"; return; } if (targetMonster && currentTarget) { interactionText.text = "Press X to stun Monster \n Hold X to transfer light to Traveller"; return; } if (targetMonster) { //interactionText.text = "Stun"; popUpText.fontSize = 150; popUpText.text = "Stun"; return; } if (targetTraveller) { //interactionText.text = "(Hold) Heal"; popUpText.fontSize = 90; popUpText.text = "Hold to Heal"; return; } else { interactionText.text = ""; return; } }