Пример #1
0
    protected override void SetAction()
    {
        if (!usable)
        {
            return;
        }


        SetActionTextUpgrade(IsInRange() && CanUpgrade());

        if (!Input.GetKey(KeyCode.E))
        {
            ResetAction();
            return;
        }

        Debug.DrawRay(cameraPosition, transform.forward * interactionRange, Color.magenta);
        if (IsInRange())
        {
            if (CanUpgrade())
            {
                _aimedBuildingStats = hit.collider.transform.GetComponent <BuildingStats>();
                _upgradeTime        = _aimedBuildingStats.GetTimeUpgradeOfCurrentLevel();
                StartAction();
            }

            if (_currentUpgradeTime == _upgradeTime)
            {
                FinishAction();
            }
        }
        else if (_isUpgrading)
        {
            ResetAction();
        }
    }