コード例 #1
0
 /* Handle the repair behavior */
 void Update()
 {
     if (Input.GetMouseButtonDown(1) &&
         Physics.Raycast(
             m_LookTransform.position,
             m_LookTransform.forward,
             out m_Hit,
             m_InteractDistance,
             1 << 9))
     {
         // Start repairing
         m_RepairableSystem = m_Hit.transform.GetComponent <Repairable>();
         m_Repairing        = (m_RepairableSystem != null);
         animator.SetBool("Repairing", m_Repairing);
         effects.PlayBlowtorch();
     }
     else if (Input.GetMouseButton(1) && m_Repairing)
     {
         // continue repairing
         m_RepairableSystem.Repair(m_RepairSpeed * Time.deltaTime);
     }
     else if (Input.GetMouseButtonUp(1) && m_Repairing)
     {
         m_RepairableSystem = null;
         m_Repairing        = false;
         animator.SetBool("Repairing", false);
         effects.Stop();
     }
 }
コード例 #2
0
 public void OnPressed()
 {
     if (repairable != null)
     {
         repairable.Repair();
     }
 }
コード例 #3
0
ファイル: RepairManager.cs プロジェクト: AkhilMenon007/GCFG
        public void Repair()
        {
            if (currentRepairable == null)
            {
                return;
            }
            var inventoryDict = new Dictionary <Item, int>();

            foreach (var item in repairItems)
            {
                if (item.Value.weight > 0f && item.Value.repairAmount > 0)
                {
                    inventoryDict.Add(item.Key, item.Value.repairAmount);
                }
            }
            if (localInventory.TryRemoveItems(inventoryDict))
            {
                currentRepairable.Repair(inventoryDict);
                localInventory.RemoveItems(inventoryDict);
            }
        }
コード例 #4
0
    /**************************
     *******   REPAIR   *******
     *************************/

    private IEnumerator DoRepair(Repairable _repairable)
    {
        UIManager.I?.ActiveRepair(IsPlayerOne, new Vector2(transform.position.x, transform.position.y + 1.5f));
        UIManager.I?.SetReppairPercent(IsPlayerOne, 0);
        IsPlayable = false;

        audioSource.time = 0;
        audioSource.Play();

        bool _doRepair = true;

        OnRepairSomething += (Repairable _r) =>
        {
            if (_r == _repairable)
            {
                UIManager.I?.SetReppairPercent(IsPlayerOne, 1);
                _doRepair = false;
            }
        };

        while (_doRepair)
        {
            yield return(null);

            if (Input.GetKeyDown(IsPlayerOne ? KeyCode.Joystick1Button2 : KeyCode.Joystick2Button2) || Input.GetKeyDown(IsPlayerOne ? KeyCode.Joystick1Button1 : KeyCode.Joystick2Button1) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.Joystick1Button3 : KeyCode.Joystick2Button3) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.E : KeyCode.RightShift) || Input.GetKeyDown(playerInputs.IsPlayerOne ? KeyCode.F : KeyCode.Return))
            {
                if (_repairable.Repair(this))
                {
                    break;
                }
            }
        }

        OnRepairSomething?.Invoke(_repairable);
        audioSource.Stop();

        IsPlayable      = true;
        repairCoroutine = null;
    }
コード例 #5
0
ファイル: PlayerAction.cs プロジェクト: Brenstem/GGJ2020
    private void Update()
    {
        bool pressedAction = Input.GetButton(GetComponent <PlayerMovement>().playerPortOne ? InputStatics.PLACE_1 : InputStatics.PLACE_2);
        var  anim          = GetComponent <PlayerMovement>().animator;

        isRepairing = false;
        if (pressedAction)
        {
            PickupType holdingItem = _playerPickUpScript.CurrentlyHolding();

            switch (holdingItem)
            {
            case PickupType.WRENCH:
                _audio.clip = wrenchSound;
                break;

            case PickupType.ANTI_FLAMETHROWER:
                _audio.clip = fireExtinguisherSound;
                break;

            case PickupType.MOP:
                _audio.clip = mopSound;
                break;

            case PickupType.METAL:
                _audio.clip = wrenchSound;
                break;

            case PickupType.WIRE:
                _audio.clip = wrenchSound;
                break;

            case PickupType.SCREW:
                _audio.clip = wrenchSound;
                break;

            case PickupType.CHIP:
                _audio.clip = wrenchSound;
                break;

            case PickupType.TAPE:
                _audio.clip = tapeSound;
                break;

            case PickupType.GLUE:
                _audio.clip = glueSound;
                break;

            case PickupType.NOTHING:
                break;

            default:
                break;
            }

            if (_repairableInView != null && _repairableInView.CanRepair() && _repairableInView.HaveCurrentTool(holdingItem))
            {
                _audio.Play();
                _playerPickUpScript.RemoveItemIfNotTool();

                _repairableInView.Repair(Time.deltaTime);

                isRepairing = true;
                anim.SetBool("isRepairing", isRepairing);
                var t = GetComponent <PlayerPickUp>()._toolHolder.transform;
                defaultTransform = t;
                string animation = "anim_char_fix_generic";
                switch (holdingItem)
                {
                case PickupType.ANTI_FLAMETHROWER:
                    animation = "anim_char_antiFlame";
                    break;

                case PickupType.MOP:
                    //t.position = new Vector3(0.00107f, 0.00005f, -0.00635f);
                    //t.rotation = Quaternion.Euler(0.0f, 81.17f, 95.2f);
                    animation = "anim_char_mopping";
                    break;

                default:
                    break;
                }
                anim.Play(animation);
            }
        }

        /*
         * if (!isRepairing) {
         *  GameObject.Find("ToolHolder").transform.position = defaultTransform.position;
         *  GameObject.Find("ToolHolder").transform.rotation = defaultTransform.rotation;
         * }
         */
        anim.SetBool("isRepairing", isRepairing);
    }