Exemple #1
0
 void LeftClickActions(RaycastResult result)
 {
     if (heldItem != null && result.gameObject.tag == "PartComponent" && heldItem.type == ContentType.Part)
     {
         VehicleEditorComponent _component = result.gameObject.GetComponentInParent <VehicleEditorComponent>();
         if (heldItem.partContent is PartDrill && _component.partType == PartType.Drill)
         {
             uiAudio.PlaySound(UIsounds.Upgrade);
             _component.AddPart(heldItem.partContent);
             Drop();
             editorTabs[openEditorIndex].FinalizeChanges();
             return;
         }
         else if (heldItem.partContent is PartCabin && _component.partType == PartType.Cabin)
         {
             uiAudio.PlaySound(UIsounds.Upgrade);
             _component.AddPart(heldItem.partContent);
             Drop();
             editorTabs[openEditorIndex].FinalizeChanges();
             return;
         }
         else if (heldItem.partContent is PartEngine && _component.partType == PartType.Engine)
         {
             uiAudio.PlaySound(UIsounds.Upgrade);
             _component.AddPart(heldItem.partContent);
             Drop();
             editorTabs[openEditorIndex].FinalizeChanges();
             return;
         }
         else if (heldItem.partContent is PartWheel && _component.partType == PartType.Wheels)
         {
             uiAudio.PlaySound(UIsounds.Upgrade);
             _component.AddPart(heldItem.partContent);
             Drop();
             editorTabs[openEditorIndex].FinalizeChanges();
             return;
         }
         else if (heldItem.partContent is PartUpgrade && _component.partType == PartType.Upgrade)
         {
             uiAudio.PlaySound(UIsounds.Upgrade);
             _component.AddPart(heldItem.partContent);
             Drop();
             editorTabs[openEditorIndex].FinalizeChanges();
             return;
         }
         else
         {
             Drop();
         }
     }
     else if (heldItem != null && result.gameObject.tag == "WorkerComponent" && heldItem.type == ContentType.Worker)
     {
         EditorWorkerComponent _component = result.gameObject.GetComponentInParent <EditorWorkerComponent>();
         editorTabs[openEditorIndex].vehicle.GetPart(out PartCabin _cabin);
         bool canEquipAuxillary = _cabin != null || _component.station == WorkStation.Cabin;
         if (editorTabs[openEditorIndex].vehicle.CrewCount < editorTabs[openEditorIndex].vehicle.CrewCountMax && canEquipAuxillary)
         {
             _component.AddWorker(heldItem.workerContent);
             Drop();
             editorTabs[openEditorIndex].EquipWorker(_component.station);
         }
         else
         {
             Drop();
         }
     }
     else
     {
         Drop();
     }
 }
Exemple #2
0
    void RightClickActions()
    {
        PointerEventData _pointerEvenData = new PointerEventData(eventSystem);

        _pointerEvenData.position = Input.mousePosition;
        List <RaycastResult> results = new List <RaycastResult>();

        gfxRaycast.Raycast(_pointerEvenData, results);
        PlayerController _player = FindObjectOfType <PlayerController>();

        foreach (RaycastResult result in results)
        {
            if (heldItem == null && result.gameObject.tag == "PartComponent")
            {
                VehicleEditorComponent editorComponent = result.gameObject.GetComponentInParent <VehicleEditorComponent>();
                editorTabs[openEditorIndex].vehicle.GetPart(out PartCabin _cabin);
                if (_player.PartsInventory.ItemCount < _player.PartsInventory.MaxItems && editorComponent.partType != PartType.Cabin)
                {
                    _player.AddPart(editorComponent.installedPart);
                    editorComponent.RemovePart();
                    editorTabs[openEditorIndex].FinalizeChanges();
                    uiAudio.PlaySound(UIsounds.Upgrade);
                    return;
                }
                else if (_player.PartsInventory.ItemCount < _player.PartsInventory.MaxItems && editorComponent.partType == PartType.Cabin && _cabin != null)
                {
                    int cabinmates = 0;
                    for (int c = 1; c < editorTabs[openEditorIndex].vehicle.Crew.Length; c++)
                    {
                        if (editorTabs[openEditorIndex].vehicle.Crew[c] != null)
                        {
                            cabinmates++;
                        }
                    }
                    print("Cabin mates " + cabinmates);
                    if (_player.WorkersInventory.ItemCount + cabinmates < _player.WorkersInventory.MaxItems)
                    {
                        for (int c = 1; c < editorTabs[openEditorIndex].vehicle.Crew.Length; c++)
                        {
                            if (editorTabs[openEditorIndex].vehicle.Crew[c] != null)
                            {
                                _player.AddWorker(editorTabs[openEditorIndex].vehicle.Crew[c]);
                                editorTabs[openEditorIndex].vehicle.AssignWorker(c, null);
                            }
                        }
                        _player.AddPart(editorComponent.installedPart);
                        editorComponent.RemovePart();
                        editorTabs[openEditorIndex].FinalizeChanges();
                        uiAudio.PlaySound(UIsounds.Upgrade);
                        return;
                    }
                    else if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
                    {
                        for (int c = 1; c < selectedShip.Crew.Length; c++)
                        {
                            if (selectedShip.Crew[c] != null)
                            {
                                editorTabs[openEditorIndex].vehicle.AssignWorker(c, null);
                            }
                        }
                        _player.AddPart(editorComponent.installedPart);
                        editorComponent.RemovePart();
                        editorTabs[openEditorIndex].FinalizeChanges();
                        uiAudio.PlaySound(UIsounds.Upgrade);
                        return;
                    }
                }
            }
            else if (heldItem == null && result.gameObject.tag == "WorkerComponent")
            {
                EditorWorkerComponent editorWorkerComponent = result.gameObject.GetComponentInParent <EditorWorkerComponent>();
                if (_player.WorkersInventory.ItemCount < _player.WorkersInventory.MaxItems && editorWorkerComponent.assignedWorker != null)
                {
                    _player.AddWorker(editorTabs[openEditorIndex].vehicle.GetWorker(editorWorkerComponent.station));
                    editorWorkerComponent.RemoveWorker();
                    editorTabs[openEditorIndex].EquipWorker(editorWorkerComponent.station);
                    return;
                }
            }
            else
            {
                Drop();
            }
        }
    }