public void placeHydrant()
 {
     if (HydrantCount > 0 && currentHydrant == null)
     {
         FireHydrant currentHydrant = Instantiate(hydrantPrefab, this.gameObject.transform);
         currentHydrant.player = this;
         HydrantCount--;
         currentHydrant.placeHydrant();
         activeHydrants.Add(currentHydrant);
     }
     else if (currentHydrant != null)
     {
         currentHydrant.placeHydrant();
         currentHydrant = null;
     }
 }
Ejemplo n.º 2
0
    void OnTriggerStay(Collider collider)
    {
        Debug.Log("hit tree: " + canSwing + canHit);
        Tree        hitTree = collider.gameObject.GetComponent <Tree>();
        FireHydrant hydrant = collider.gameObject.GetComponent <FireHydrant>();

        if (canHit && hitTree != null && !hitTree.isHouse && hitTree.FireState != 2)
        {
            hitTree.KillTree();
            //canHit = false;
            axeChopAudioSource.Play();
        }
        else if (canHit && hydrant != null)
        {
            hydrant.ExplodeHydrant();
            // canHit = false;
        }
    }
    void Update()
    {
        //Debug.Log("rotate axis: "); Debug.Log(Input.GetAxis("Rotate"));
        //transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed, 0);
        //transform.Translate(0, 0, Input.GetAxis("Vertical") * Time.deltaTime * movementSpeed);

        /*else if (currentTool.gameObject.name == "Axe")
         * {
         *  Hose.SetActive(false);
         *  Axe.SetActive(true);
         *  axeEquipped = true;
         *  hoseEquipped = hydrantEquipped = false;
         *  if (currentHydrant != null)
         *  {
         *      currentHydrant.gameObject.SetActive(false);
         *  }
         * }
         * else if (currentTool.gameObject.name == "Hydrant")
         * {
         *  Hose.SetActive(false);
         *  Axe.SetActive(false);
         *  hydrantEquipped = true;
         *  hoseEquipped = axeEquipped = false;
         *  if (currentHydrant != null)
         *  {
         *      currentHydrant.gameObject.SetActive(true);
         *
         *  }
         *  else if (HydrantCount > 0)
         *  {
         *      currentHydrant = Instantiate(hydrantPrefab, this.gameObject.transform);
         *      currentHydrant.player = this;
         *      HydrantCount--;
         *  }
         * }*/
        if (OnFire && !dodging)
        {
            DecreaseHealth();
        }

        moveDirection = Vector3.Normalize(Input.GetAxis("Horizontal") * transform.right + Input.GetAxis("Vertical") * transform.forward);

        if (Input.GetButtonDown("Fire1") && (CurrentWater > 0))
        {
            waterStream.Play();
            sprayingWater = true;
            waterAudioSource.Play();
        }
        else if (Input.GetButtonUp("Fire1") || CurrentWater <= 0)
        {
            waterStream.Stop();
            sprayingWater = false;
            waterAudioSource.Pause();
        }

        if (Input.GetButtonDown("Select"))
        {
            bool hydrantPickedUp = false;
            for (int i = 0; i < activeHydrants.Count; i++)
            {
                if (activeHydrants[i].isPlayerInRangeOfHydrant())
                {
                    activeHydrants[i].pickUpHydrant();
                    hydrantPickedUp = true;
                    currentHydrant  = activeHydrants[i];
                    break;
                }
            }
            if (!hydrantPickedUp)
            {
                placeHydrant();
            }
        }



        if (Input.GetButtonDown("Fire2"))
        {
            Axe.gameObject.SetActive(true);
            Hose.gameObject.SetActive(false);
            Debug.Log("winding up axe");
            Axe.GetComponent <Axe>().windupAxe();
        }
        else if (Input.GetButton("Fire2"))
        {
            Debug.Log("charging axe");
            Axe.GetComponent <Axe>().chargeAxe();
        }
        else if (Input.GetButtonUp("Fire2"))
        {
            Debug.Log("swinging axe");
            Axe.GetComponent <Axe>().swingAxe();
        }

        if (Input.GetButtonDown("Sprint") && CurrentStamina >= 50.0f)
        {
            CurrentStamina -= 50.0f;
            StartCoroutine("PlayerDodge");
        }
        else if (CurrentStamina < 100 && !dodging)
        {
            CurrentStamina += StaminaTickRate;
            movementSpeed   = walkSpeed;
        }
        StaminaImage.fillAmount = CurrentStamina / 100;

        if (sprayingWater)
        {
            CurrentWater         -= WaterTickRate;
            WaterImage.fillAmount = CurrentWater / 100;
        }

        //Gravity
        //moveDirection.y -= 10f * Time.deltaTime;
        characterController.Move(moveDirection * movementSpeed * Time.deltaTime);
        OnFire = false;
    }
Ejemplo n.º 4
0
 public void pickUpHydrant(FireHydrant hydrant)
 {
     currentHydrant           = hydrant;
     myToolbelt.toolBeltIndex = 3;
     myToolbelt.updateBelt();
 }
Ejemplo n.º 5
0
 public void nullifyHydrant()
 {
     currentHydrant           = null;
     myToolbelt.toolBeltIndex = 1;
     myToolbelt.updateBelt();
 }
Ejemplo n.º 6
0
    void Update()
    {
        //Debug.Log("rotate axis: "); Debug.Log(Input.GetAxis("Rotate"));
        //transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed, 0);
        //transform.Translate(0, 0, Input.GetAxis("Vertical") * Time.deltaTime * movementSpeed);
        currentTool = myToolbelt.currentTool;
        if (currentTool.gameObject.name == "Hose")
        {
            Hose.SetActive(true);
            Axe.SetActive(false);
            hoseEquipped = true;
            axeEquipped  = hydrantEquipped = false;
            if (currentHydrant != null)
            {
                currentHydrant.gameObject.SetActive(false);
            }
        }
        else if (currentTool.gameObject.name == "Axe")
        {
            Hose.SetActive(false);
            Axe.SetActive(true);
            axeEquipped  = true;
            hoseEquipped = hydrantEquipped = false;
            if (currentHydrant != null)
            {
                currentHydrant.gameObject.SetActive(false);
            }
        }
        else if (currentTool.gameObject.name == "Hydrant")
        {
            Hose.SetActive(false);
            Axe.SetActive(false);
            hydrantEquipped = true;
            hoseEquipped    = axeEquipped = false;
            if (currentHydrant != null)
            {
                currentHydrant.gameObject.SetActive(true);
            }
            else if (HydrantCount > 0)
            {
                currentHydrant = Instantiate(hydrantPrefab, this.gameObject.transform);
                // currentHydrant.player = this;
                HydrantCount--;
            }
        }
        if (OnFire && !dodging)
        {
            DecreaseHealth();
        }

        moveDirection = Vector3.Normalize(Input.GetAxis("Horizontal") * transform.right + Input.GetAxis("Vertical") * transform.forward);

        if (Input.GetButtonDown("Fire1") && (CurrentWater > 0) && hoseEquipped)
        {
            waterStream.Play();
            sprayingWater = true;
        }
        else if (Input.GetButtonDown("Fire1") && axeEquipped)
        {
            Debug.Log("winding up axe");
            Axe.GetComponent <Axe>().windupAxe();
        }
        else if (Input.GetButton("Fire1") && axeEquipped)
        {
            Debug.Log("charging axe");
            Axe.GetComponent <Axe>().chargeAxe();
        }
        else if (Input.GetButtonUp("Fire1") && axeEquipped)
        {
            Debug.Log("swinging axe");
            Axe.GetComponent <Axe>().swingAxe();
        }
        else if (Input.GetButtonUp("Fire1") || CurrentWater <= 0)
        {
            waterAudioSource.Play();
        }
        else if (Input.GetButtonUp("Fire1") || !hoseEquipped)
        {
            waterStream.Stop();
            sprayingWater = false;
            waterAudioSource.Pause();
        }

        if (Input.GetButtonDown("Sprint") && CurrentStamina >= 50.0f)
        {
            CurrentStamina -= 50.0f;
            StartCoroutine("PlayerDodge");
        }
        else if (CurrentStamina < 100 && !dodging)
        {
            CurrentStamina += StaminaTickRate;
            movementSpeed   = walkSpeed;
        }
        StaminaImage.fillAmount = CurrentStamina / 100;

        if (sprayingWater)
        {
            CurrentWater         -= WaterTickRate;
            WaterImage.fillAmount = CurrentWater / 100;
        }

        //Gravity
        //moveDirection.y -= 10f * Time.deltaTime;
        characterController.Move(moveDirection * movementSpeed * Time.deltaTime);
        OnFire = false;
    }