Exemplo n.º 1
0
    private void Update()
    {
        if (Input.GetButtonDown("Fire2"))
        {
            playerMovement.enabled = false;
            isReparing             = true;
            GetReparablesInRange();
            StartCoroutine(RepairRoutine());
        }


        if (Input.GetButtonUp("Fire2"))
        {
            if (reparablesInRange != null)
            {
                reparablesInRange.Clear();
            }

            playerMovement.enabled = true;
            isReparing             = false;
            if (currenReparable != null && currenReparable.currentState == ReparableState.Repairing)
            {
                currenReparable.currentState = ReparableState.Broken;
            }
            currenReparable = null;
        }
    }
Exemplo n.º 2
0
    //Gets reparables in range of the action sphere
    private void GetReparablesInRange()
    {
        reparablesInRange = new List <Reparable>();
        collidersInRange  = Physics.OverlapSphere(transform.position + transform.forward * .5f + transform.up * 0.5f, m_RepairRadius);

        for (int i = 0; i < collidersInRange.Length; i++)
        {
            if (collidersInRange[i].GetComponent <Reparable>() != null)
            {
                reparablesInRange.Add(collidersInRange[i].GetComponent <Reparable>());
            }
        }
        if (reparablesInRange.Count > 0)
        {
            currenReparable = reparablesInRange[0];
        }
    }
Exemplo n.º 3
0
 private void Awake()
 {
     reparable = GetComponent <Reparable>();
     meshRenderer.material.color = brokenColor;
 }