예제 #1
0
    public void CheckInput(ControlObject controlObject)
    {
        // Move
        if (snapping)
        {
            moveDirection = (controlObject.rightLeft * transform.right + controlObject.forwardBack * transform.forward).normalized;
        }
        else
        {
            moveDirection = (controlObject.rightLeft * transform.right + controlObject.forwardBack * transform.forward + controlObject.upDown * transform.up).normalized;
        }

        // Look/Rotate
        lookRotation += new Vector3(-controlObject.verticalLook, controlObject.horizontalLook, controlObject.roll);

        // Jump
        if (controlObject.jump && grounded)
        {
            Jump();
        }

        // Interact
        if (controlObject.interact)
        {
            RaycastHit?hit = GetComponentInChildren <PlayerCamera>().GetUsableTarget(useRange);
            if (hit != null && PlayerCamera.instance.checkForUsable)
            {
                hit.Value.collider.GetComponent <IUsable>().Use();
            }
        }

        // Shield Cells
        if (controlObject.chargeShieldCell && fuelSlot.connectedModule)
        {
            fuelSlot.connectedModule.GetComponent <FuelPack>().ChargeShields();
        }

        // Weapons
        if (controlObject.fire && weaponSlot.currentWeapon != null)
        {
            weaponSlot.currentWeapon.Fire();
        }
        if (controlObject.aim && weaponSlot.GetCurrentWeaponType() == GameTypes.PlayerWeaponType.MatterManipulator)
        {
            weaponSlot.GetComponentInChildren <MatterManipulator>().EquipFuelPack(fuelSlot);
        }
        if (controlObject.matterManipilator)
        {
            if ((weaponSlot.GetCurrentWeaponType() == GameTypes.PlayerWeaponType.MatterManipulator && !GetComponentInChildren <MatterManipulator>().IsHoldingObject()) ||
                weaponSlot.GetCurrentWeaponType() != GameTypes.PlayerWeaponType.MatterManipulator &&
                canEquip)
            {
                weaponSlot.SwitchWeapons();
            }
        }

        // TODO: REMOVE
        if (Input.GetKeyDown(KeyCode.L) && fuelSlot.connectedModule)
        {
            GetComponentInChildren <FuelPack>().AddFuel(500f);
        }
    }