Ejemplo n.º 1
0
    public void DispatchPart(ShipBuilderPart part, ShipBuilder.TransferMode mode)
    {
        var culledInfo = ShipBuilder.CullSpatialValues(part.info);

        if (!builderPartDict.ContainsKey(culledInfo))
        {
            int size = ResourceManager.GetAsset <PartBlueprint>(part.info.partID).size;
            ShipBuilderInventoryScript builderPartDictInvButton = Instantiate(buttonPrefab,
                                                                              contentsArray[size]).GetComponent <ShipBuilderInventoryScript>();
            builderPartDict.Add(culledInfo, builderPartDictInvButton);
            contentTexts[size].SetActive(true);
            builderPartDict[culledInfo].part   = culledInfo;
            builderPartDict[culledInfo].cursor = cursorScript;
        }
        builderPartDict[culledInfo].IncrementCount();
        cursorScript.buildValue -= EntityBlueprint.GetPartValue(part.info);
        cursorScript.parts.Remove(part);
        Destroy(part.gameObject);
    }
Ejemplo n.º 2
0
    void PlaceCurrentPart()
    {
        currentPart.SetMaskable(true);
        var editorMode = (builder as ShipBuilder) != null && !(builder as ShipBuilder).Equals(null) && (builder as ShipBuilder).editorMode;
        var dispatch   = false;

        ShipBuilder.TransferMode mode = ShipBuilder.TransferMode.Return;
        if (cursorMode != BuilderMode.Workshop)
        {
            if (traderInventory.gameObject.activeSelf && (!editorMode || !Input.GetKey(KeyCode.LeftControl)) &&
                RectTransformUtility.RectangleContainsScreenPoint(traderInventory, Input.mousePosition))
            {
                dispatch = true;
                mode     = (currentPart.mode == BuilderMode.Yard
                                        ? ShipBuilder.TransferMode.Sell : ShipBuilder.TransferMode.Return);
            }
            else if ((!editorMode || !Input.GetKey(KeyCode.LeftControl)) &&
                     RectTransformUtility.RectangleContainsScreenPoint(playerInventory, Input.mousePosition))
            {
                dispatch = true;
                mode     = (currentPart.mode == BuilderMode.Yard
                                        ? ShipBuilder.TransferMode.Return : ShipBuilder.TransferMode.Buy);
            }
            else if (!RectTransformUtility.RectangleContainsScreenPoint(grid, Input.mousePosition) && !editorMode)
            {
                dispatch = true;
                mode     = ShipBuilder.TransferMode.Return;
            }
            else if (builder.CheckPartIntersectsWithShell(currentPart) && currentPart.GetLastValidPos() == null)
            {
                dispatch = true;
                mode     = ShipBuilder.TransferMode.Return;
            }
            else
            {
                PlaceCurrentPartInGrid();
            }
        }
        else
        {
            if (RectTransformUtility.RectangleContainsScreenPoint(playerInventory, Input.mousePosition))
            {
                dispatch = true;
                mode     = ShipBuilder.TransferMode.Return;
            }
            else
            {
                PlaceCurrentPartInGrid();
            }
        }
        if (dispatch)
        {
            builder.DispatchPart(currentPart, mode);
            if (symmetryCurrentPart)
            {
                builder.DispatchPart(symmetryCurrentPart, mode);
            }
        }

        if (handler && currentAbilities != null)
        {
            UpdateHandler();
        }
    }