示例#1
0
    public void UpdateChain()
    {
        SetReconstructButton(cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type) ?
                             ReconstructButtonStatus.PastPartLimit : ReconstructButtonStatus.Valid);
        var shellRect = ShipBuilder.GetRect(shellImage.rectTransform);

        shellRect.Expand(10);
        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            shipPart.isInChain = false;
            var partBounds = ShipBuilder.GetRect(shipPart.rectTransform);
            shipPart.isInChain = partBounds.Intersects(shellRect);
        }
        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (shipPart.isInChain)
            {
                UpdateChainHelper(shipPart);
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (!shipPart.isInChain || !shipPart.validPos)
            {
                SetReconstructButton(ReconstructButtonStatus.PartInvalidPosition);
                return;
            }
        }
    }
 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);
     }
 }
示例#3
0
    public void Deinitialize()
    {
        if (cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type))
        {
            return;
        }
        bool invalidState = false;

        foreach (ShipBuilderPart part in cursorScript.parts)
        {
            if (!part.validPos || !part.isInChain)
            {
                invalidState = true;
                break;
            }
        }
        if (!invalidState)
        {
            Export();
            CloseUI(true);
        }
    }
    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);
        }
    }
示例#5
0
    public void UpdateChain()
    {
        SetReconstructButton(cursorScript.parts.Count > DroneUtilities.GetPartLimit(currentData.type) ? ReconstructButtonStatus.PastPartLimit : ReconstructButtonStatus.Valid);

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            shipPart.isInChain = false;
            CheckPartIntersectsWithShell(shipPart);
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (shipPart.isInChain)
            {
                UpdateChainHelper(shipPart);
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            CheckPartIntersectsWithShell(shipPart);
        }

        foreach (ShipBuilderPart part in cursorScript.parts)
        {
            if (part.validPos)
            {
                foreach (var part2 in cursorScript.parts)
                {
                    if (part != part2 && PartIsTooClose(part, part2))
                    {
                        part.validPos = false;
                        break;
                    }
                }
            }
            else
            {
                bool stillTouching = false;
                foreach (ShipBuilderPart part2 in cursorScript.parts)
                {
                    if (part2 != part && PartIsTooClose(part, part2))
                    {
                        stillTouching = true;
                        break;
                    }
                }

                if (!stillTouching)
                {
                    part.validPos = true;
                }
            }
        }

        foreach (ShipBuilderPart shipPart in cursorScript.parts)
        {
            if (!shipPart.isInChain || !shipPart.validPos)
            {
                SetReconstructButton(ReconstructButtonStatus.PartInvalidPosition);
                return;
            }
        }
    }