public override void OnPointerDown(PointerEventData eventData)
    {
        if (Input.GetKey(KeyCode.LeftShift))
        {
#if UNITY_EDITOR
#endif
        }

        if (count > 0)
        {
            var builderPart = InstantiatePart();
            DecrementCount();
            if (Input.GetKey(KeyCode.LeftShift))
            {
                if (mode == BuilderMode.Yard && cursor.builder.GetMode() == BuilderMode.Trader)
                {
                    cursor.builder.DispatchPart(builderPart, ShipBuilder.TransferMode.Sell);
                    return;
                }
                else if (mode == BuilderMode.Trader)
                {
                    cursor.buildCost += EntityBlueprint.GetPartValue(builderPart.info);
                    cursor.builder.DispatchPart(builderPart, ShipBuilder.TransferMode.Buy);
                    return;
                }
            }

            ShipBuilderPart symmetryPart = count > 0 && cursor.symmetryMode != ShipBuilderCursorScript.SymmetryMode.Off ? InstantiatePart() : null;
            if (symmetryPart)
            {
                //if(cursor.symmetryMode == ShipBuilderCursorScript.SymmetryMode.X)
                symmetryPart.info.mirrored = !builderPart.info.mirrored;
                if (cursor.symmetryMode == ShipBuilderCursorScript.SymmetryMode.Y)
                {
                    symmetryPart.info.rotation = 180;
                }
            }

            cursor.GrabPart(builderPart, symmetryPart);
            if (symmetryPart)
            {
                DecrementCount();
            }

            cursor.buildValue += EntityBlueprint.GetPartValue(part);
            if (symmetryPart)
            {
                cursor.buildValue += EntityBlueprint.GetPartValue(part);
            }

            if (mode == BuilderMode.Trader)
            {
                cursor.buildCost += EntityBlueprint.GetPartValue(part);
                if (symmetryPart)
                {
                    cursor.buildCost += EntityBlueprint.GetPartValue(part);
                }
            }
        }
    }
Example #2
0
    public void DisplayPartInfo(EntityBlueprint.PartInfo info)
    {
        if (info.abilityID != 0)
        {
            if (info.tier != 0)
            {
                abilityTier.gameObject.SetActive(true);
                abilityTier.sprite = ResourceManager.GetAsset <Sprite>("AbilityTier" + info.tier);
                if (abilityTier.sprite)
                {
                    abilityTier.rectTransform.sizeDelta = abilityTier.sprite.bounds.size * 20;
                }

                abilityTier.color = new Color(1, 1, 1, 0.4F);
            }
            else
            {
                abilityTier.gameObject.SetActive(false);
            }

            abilityImage.sprite = AbilityUtilities.GetAbilityImageByID(info.abilityID, info.secondaryData);
            abilityImage.gameObject.SetActive(true);
            abilityText.text = AbilityUtilities.GetAbilityNameByID(info.abilityID, info.secondaryData) + (info.tier > 0 ? " " + info.tier : "");
            abilityText.gameObject.SetActive(true);
            abilityBox.gameObject.SetActive(true);

            string description = "";

            description += AbilityUtilities.GetAbilityNameByID(info.abilityID, info.secondaryData) + (info.tier > 0 ? " " + info.tier : "") + "\n";
            description += AbilityUtilities.GetDescriptionByID(info.abilityID, info.tier, info.secondaryData);
            buttonScript.abilityInfo = description;
        }
        else
        {
            abilityTier.gameObject.SetActive(false);
            abilityBox.gameObject.SetActive(false);
            abilityImage.gameObject.SetActive(false);
            abilityText.gameObject.SetActive(false);
        }

        image.gameObject.SetActive(true);
        partName.gameObject.SetActive(true);
        partStats.gameObject.SetActive(true);
        string partID = info.partID;

        partName.text = partID;
        var   blueprint = ResourceManager.GetAsset <PartBlueprint>(partID);
        float mass      = blueprint.mass;
        float health    = blueprint.health;
        int   value     = EntityBlueprint.GetPartValue(info);

        partStats.text = $"PART SHELL: {health / 2}\nPART CORE: {health / 4}\nPART WEIGHT: {mass * Entity.weightMultiplier}\nPART VALUE: \n{value} CREDITS";
        image.sprite   = ResourceManager.GetAsset <Sprite>(partID + "_sprite");
        image.rectTransform.sizeDelta = image.sprite.bounds.size * 50;
        image.color = info.shiny ? FactionManager.GetFactionShinyColor(0) : FactionManager.GetFactionColor(0);
    }
Example #3
0
    public int GetBuildValue()
    {
        var value = 0;

        foreach (var part in blueprint.parts)
        {
            value += EntityBlueprint.GetPartValue(part);
        }

        return(value);
    }
    void OnEnable()
    {
        compactMode      = Screen.width == 1024;
        buildCost        = 0;
        currentAbilities = new List <Ability>();

        grid.anchoredPosition = Vector2.zero;
        buildValue            = 0;
        foreach (ShipBuilderPart part in parts)
        {
            buildValue += EntityBlueprint.GetPartValue(part.info);
        }
    }
 public override void AssignDisplay(EntityBlueprint blueprint, DroneSpawnData data, int faction = 0)
 {
     base.AssignDisplay(blueprint, data);
     statsDisplay.gameObject.SetActive(true);
     droneDesc.enabled = true;
     droneDesc.text    = ("DRONE TYPE: " + data.type).ToUpper()
                         + "\nUNIQUE CHARACTERISTIC:\n" + "<color=lime>"
                         + DroneUtilities.GetUniqueCharacteristic(data.type) + "</color>"
                         + "\nPART LIMIT: " + DroneUtilities.GetPartLimit(data.type)
                         + "\nSPAWNING COOLDOWN: " + DroneUtilities.GetCooldown(data.type)
                         + "\nSPAWNING DELAY: " + DroneUtilities.GetDelay(data.type)
                         + "\nSPAWNING ENERGY COST: " + DroneUtilities.GetEnergyCost(data.type);
     foreach (DisplayPart part in parts)
     {
         buildValue += EntityBlueprint.GetPartValue(part.info);
     }
 }
Example #6
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);
    }
Example #7
0
    public override void OnPointerDown(PointerEventData eventData)
    {
        if (Input.GetKey(KeyCode.LeftShift))
        {
            #if UNITY_EDITOR
            Debug.Log(part.secondaryData);
            #endif
        }

        if (count > 0)
        {
            var builderPart = Instantiate(SBPrefab, cursor.transform.parent).GetComponent <ShipBuilderPart>();
            builderPart.info         = part;
            builderPart.cursorScript = cursor;
            builderPart.mode         = mode;
            cursor.parts.Add(builderPart);
            cursor.GrabPart(builderPart);
            count--;
            cursor.buildValue += EntityBlueprint.GetPartValue(part);
            if (mode == BuilderMode.Trader)
            {
                cursor.buildCost += EntityBlueprint.GetPartValue(part);
            }

            if (Input.GetKey(KeyCode.LeftShift))
            {
                if (mode == BuilderMode.Yard && cursor.builder.GetMode() == BuilderMode.Trader)
                {
                    cursor.builder.DispatchPart(builderPart, ShipBuilder.TransferMode.Sell);
                }
                else if (mode == BuilderMode.Trader)
                {
                    cursor.builder.DispatchPart(builderPart, ShipBuilder.TransferMode.Buy);
                }
            }
        }
    }
    public override void AssignDisplay(EntityBlueprint blueprint, DroneSpawnData data, int faction = 0)
    {
        base.AssignDisplay(blueprint, data);
        statsDisplay.gameObject.SetActive(true);
        droneDesc.enabled = true;

        string description = string.Join("\n", new string[]
        {
            ($"DRONE TYPE: {data.type}").ToUpper(),
            "UNIQUE CHARACTERISTIC:",
            $"<color=lime>{DroneUtilities.GetUniqueCharacteristic(data.type)}</color>",
            $"PART LIMIT: {DroneUtilities.GetPartLimit(data.type)}",
            $"SPAWNING COOLDOWN: {DroneUtilities.GetCooldown(data.type)}",
            $"SPAWNING DELAY: {DroneUtilities.GetDelay(data.type)}",
            $"SPAWNING ENERGY COST: {DroneUtilities.GetEnergyCost(data.type)}",
        });

        droneDesc.text = description;

        foreach (DisplayPart part in parts)
        {
            buildValue += EntityBlueprint.GetPartValue(part.info);
        }
    }
Example #9
0
    public void DispatchPart(ShipBuilderPart part, TransferMode transferMode)
    {
        var culledInfo = CullSpatialValues(part.info);
        Dictionary <EntityBlueprint.PartInfo, ShipBuilderInventoryScript> dict;

        Transform[]  dictContentsArray;
        GameObject[] dictContentTexts;
        switch (transferMode)
        {
        case TransferMode.Sell:
            cursorScript.buildCost -= EntityBlueprint.GetPartValue(part.info);
            dictContentsArray       = traderContentsArray;
            dict             = traderPartDict;
            dictContentTexts = traderContentTexts;
            break;

        case TransferMode.Buy:
            dictContentsArray = contentsArray;
            dict             = partDict;
            dictContentTexts = contentTexts;
            break;

        default:                 // transfer back to original inventory
            if (part.mode == BuilderMode.Trader)
            {
                cursorScript.buildCost -= EntityBlueprint.GetPartValue(part.info);
            }
            dict = (part.mode == BuilderMode.Yard ? partDict : traderPartDict);
            dictContentsArray = (part.mode == BuilderMode.Yard ? contentsArray : traderContentsArray);
            dictContentTexts  = (part.mode == BuilderMode.Yard ? contentTexts : traderContentTexts);
            break;
        }
        if (!dict.ContainsKey(culledInfo))
        {
            int size = ResourceManager.GetAsset <PartBlueprint>(part.info.partID).size;
            ShipBuilderInventoryScript dictInvButton = Instantiate(buttonPrefab,
                                                                   dictContentsArray[size]).GetComponent <ShipBuilderInventoryScript>();
            switch (transferMode)              // set the new button's transfer mode
            {
            case TransferMode.Buy:
                dictInvButton.mode = BuilderMode.Yard;
                break;

            case TransferMode.Sell:
                dictInvButton.mode = BuilderMode.Trader;
                break;

            case TransferMode.Return:
                dictInvButton.mode = part.mode;
                break;
            }
            dict.Add(culledInfo, dictInvButton);
            dictContentTexts[size].SetActive(true);
            dict[culledInfo].part   = culledInfo;
            dict[culledInfo].cursor = cursorScript;
        }
        dict[culledInfo].IncrementCount();
        cursorScript.buildValue -= EntityBlueprint.GetPartValue(part.info);
        cursorScript.parts.Remove(part);
        Destroy(part.gameObject);
    }