Example #1
0
    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Traveller" && other.gameObject == targetTraveller)
        {
            //currentTarget = null;
            travellerHealth tScript = other.gameObject.GetComponent <travellerHealth>();
            tScript.stopHealingEffect();
            interactionPopUp3.SetActive(false);
            travHealingBar.SetActive(false);
            targetTraveller = null;
            healingSFX.Stop();

            //interactionText.text  = "";
            return;
        }
        if (other.tag == "LampLight" && other.gameObject == currentTarget)
        {
            if (lScript != null)
            {
                if (lScript.getCurrentLightType() == 0)
                {
                    //lScript.setMiniMapPathColor(0);

                    lScript.turnOffPaths();
                    //Debug.Log("turning off)");
                }
                lScript.turnOffWorldPaths();
                lScript.switcherScript.setDefault();
            }

            interactionPopUp.SetActive(false);

            currentTarget = null;
            lScript       = null;

            return;
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 0f || inTutorial)
        {
            if (isHealing)
            {
                heldDuration = 0f;
                isHealing    = false;
                if (targetTraveller != null)
                {
                    travellerHealth tScript = targetTraveller.GetComponent <travellerHealth>();
                    if (tScript.isHealingEffectOn())
                    {
                        tScript.stopHealingEffect();
                        healingSFX.Stop();
                    }
                }
                if (travHealingBar.activeInHierarchy)
                {
                    travHealingBar.SetActive(false);
                }
                // moved outside of off claue above (if you move away from trav it'll loop infintely)
                anim.SetBool("isHealing", false);
            }
            return;
        }

        if (Input.GetButtonDown("Circle") || Input.GetKeyDown(KeyCode.Space))
        {
            isHealing = true;
            if (targetTraveller != null && targetTraveller.tag == "Traveller")
            {
                travellerHealth tScript = targetTraveller.GetComponent <travellerHealth>();
                if (tScript.currentHealth != tScript.startingHealth)
                {
                    tScript.startHealEffect();
                    healingSFX.Play();
                }
            }
        }
        if (Input.GetButton("Circle") || Input.GetKey(KeyCode.Space))
        {
            heldDuration += Time.deltaTime;
            if (heldDuration > 0.5f)               //&& !setHealing) {
            //start healing
            //setHealing = true;

            {
                if (targetTraveller != null && targetTraveller.tag == "Traveller")
                {
                    travellerHealth tScript = targetTraveller.GetComponent <travellerHealth>();
                    currentHealTime += Time.deltaTime;
                    if (canHeal)
                    {
                        if (pController.getResource() > 0 && currentHealTime >= timeToHeal)
                        {
                            anim.SetBool("isHealing", true);
                            //tScript.increaseCape();
                            tScript.GetHeal(1);

                            pController.addResource(-1f);

                            currentHealTime = 0f;
                        }

                        return;
                    }

                    //stop healing if we cannot heal
                    else
                    {
                        if (tScript.isHealingEffectOn())
                        {
                            tScript.stopHealingEffect();
                            healingSFX.Stop();
                        }
                        //Debug.Log("stopping effect");
                        //Debug.Log(tScript.currentHealth);
                        //Debug.Log(tScript.startingHealth);
                    }
                }
            }
        }

        if (Input.GetButtonUp("Circle") || Input.GetKeyUp(KeyCode.Space))
        {
            heldDuration = 0f;
            isHealing    = false;
            if (targetTraveller != null)
            {
                travellerHealth tScript = targetTraveller.GetComponent <travellerHealth>();
                if (tScript.isHealingEffectOn())
                {
                    tScript.stopHealingEffect();
                    healingSFX.Stop();
                }
            }
            if (travHealingBar.activeInHierarchy)
            {
                travHealingBar.SetActive(false);
            }
            // moved outside of off claue above (if you move away from trav it'll loop infintely)
            anim.SetBool("isHealing", false);
        }

        if ((Input.GetMouseButtonUp(1) || Input.GetButtonUp("Square")) && stunUnlocked)
        {
            if (pController.getResource() >= 20 && monstersInRange.Count >= 1)
            {
                setStun();
                return;
            }
        }


        if (Input.GetButtonDown("X") || Input.GetMouseButtonDown(0))
        {
            //call stun enemy function
            if (currentTarget != null && currentTarget.tag == "LampLight")
            {
                if (lScript.getCurrentLightType() == 0 && pController.getResource() >= pController.getCurrentResourceNeeded())
                {
                    pController.setTargetLight(currentTarget);
                    //set color
                    lScript.setMiniMapPathColor(pController.equippedLight);
                    lScript.turnOnPaths();


                    //Debug.Log("truning on light");
                    return;
                }
                else if (lScript.getCurrentLightType() > 0)
                {
                    //Debug.Log("turning off light");
                    if (!restrictRecover)
                    {
                        pController.setTargetLight(currentTarget);
                        lScript.setMiniMapPathColor(0);
                        lScript.turnOffPaths();
                    }
                }
            }
        }


        if (currentTarget && (lScript != null))
        {
            //interactionText.text = "Light";
            //popUpText.fontSize = 100;

            if (lScript.getCurrentLightType() != 0)
            {
                //popUpText.fontSize = 110;
                popUpText.text      = "Recover";
                popUpTextCount.text = "(+" + (int)lScript.harvestAmount() + ")";
                // " + (int) lScript.harvestAmount()
            }
            else if (pController.getResource() < pController.getCurrentResourceNeeded())
            {
                //popUpText.fontSize = 70;
                popUpText.text = "Not Enough!";
                if (pController.equippedLight == 1)
                {
                    popUpTextCount.text = "(-10)";
                }
                else if (pController.equippedLight == 2)
                {
                    popUpTextCount.text = "(-15)";
                }
                else if (pController.equippedLight == 3)
                {
                    popUpTextCount.text = "(-15)";
                }
            }
            else
            {
                //popUpText.fontSize = 120;
                popUpText.text = "Ignite";

                if (pController.equippedLight == 1)
                {
                    popUpTextCount.text = "(-10)";
                }
                else if (pController.equippedLight == 2)
                {
                    popUpTextCount.text = "(-15)";
                }
                else if (pController.equippedLight == 3)
                {
                    popUpTextCount.text = "(-15)";
                }

                //(int) pController.getCurrentResourceNeeded() + ")"
                //Debug.Log("Setting to ignite");
            }
            //popUpText.text = "hello";
            //Debug.Log("Could not set text");
            return;
        }


        else
        {
            interactionText.text = "";
            return;
        }
    }