示例#1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.M) && vehicleMain.Inventory.UsedCapacity < vehicleMain.Inventory.Capacity && vehicleMain.Selected)
        {
            if (vehicleMain.PartExists(PartType.Drill))
            {
                ToggleMinerMode(minerMode);
            }

            vehicleMain.VehicleGraphics.RefreshUiInv();
        }

        if (vehicleMain.Inventory.UsedCapacity >= vehicleMain.Inventory.Capacity && minerMode)
        {
            ToggleMinerMode(true);
        }

        if (Input.GetMouseButtonDown(1) && vehicleMain.Selected && vehicleMain.HasPart(PartType.Wheels))
        {
            AddTargetPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        }
        else if (((Input.GetMouseButtonDown(2) || Input.GetKeyDown(KeyCode.X)) && vehicleMain.Selected) || vehicleMain.Fuel <= 0)
        {
            ClearPath();
        }

        if (targetPositions.Count > 0)
        {
            if (!vehicleMain.Selected && targetPositions[0].activeInHierarchy)
            {
                foreach (GameObject item in targetPositions)
                {
                    item.SetActive(false);
                }
            }
            else if (vehicleMain.Selected && !targetPositions[0].activeInHierarchy)
            {
                foreach (GameObject item in targetPositions)
                {
                    item.SetActive(true);
                }
            }
        }

        if (direction != Vector2.zero)
        {
            drillPosition     = rb.position + direction * drillRange;
            drillBit.position = drillPosition;
        }
        Debug.DrawLine(rb.position, drillBit.position, Color.blue);

        if (!vehicleMain.HasPart(PartType.Wheels) || vehicleMain.Crew[0] == null)
        {
            speed = 0;
            ClearPath();
        }
        if (vehicleMain.Inventory.GetFuelAmount() <= 0 && (speed > 0 || minerMode))
        {
            speed = 0;
            ClearPath();
            ToggleMinerMode(true);
        }

        if (speed > 5)
        {
            vehicleMain.Audio.PlayAudio(VehicleSounds.Movement);
        }
        else if (speed <= 5)
        {
            vehicleMain.Audio.StopAudio(VehicleSounds.Movement);
        }
    }