Example #1
0
    private void UpdateColorsAround()
    {
        timeSinceColorRefresh = 0;

        var playerPos = new Vector2(ClassManager.MainScript.mainTexture.width / 2 - ClassManager.MainScript.transform.position.x, ClassManager.MainScript.mainTexture.height / 2 - ClassManager.MainScript.transform.position.y);

        var colorsAround = ClassManager.MapReadService.GetFromTexture(playerPos, new Vector2Int(20, 20));

        MachineBlocks = 0;
        OverBlocks    = 0;
        UnderBlocks   = 0;

        foreach (var col in colorsAround)
        {
            if (MachineColors.Any(c => MapReadService.ColorNear(c, col)))
            {
                MachineBlocks++;
            }
            else if (OverColors.Any(c => MapReadService.ColorNear(c, col)))
            {
                OverBlocks++;
            }
            else if (UnderColors.Any(c => MapReadService.ColorNear(c, col)))
            {
                UnderBlocks++;
            }
        }

        if (MachineBlocks == 0 && OverBlocks == 0 && UnderBlocks == 0)
        {
            OverBlocks = 1;
        }
    }
Example #2
0
 public static void Clear()
 {
     WaitingToLaunch         = 0;
     MainScript              = null;
     InventoryScript         = null;
     CharacterMovementScript = null;
     MiningScript            = null;
     DrawingScript           = null;
     MapReadService          = null;
     InventoryPanel          = null;
     SoundScript             = null;
 }
Example #3
0
    void SellItemsInShopArea()
    {
        Color[] items = GetSoldItemsInShopArea();
        ClearItemsInShopArea();
        int price = items.Sum(i => Pricing.FirstOrDefault(p => MapReadService.ColorNear(i, p.Item1)).Item2);

        if (price != 0)
        {
            Debug.Log($"Sold items for {price}$");

            var textPrefab = Instantiate(SellTextPrefab, ClassManager.InventoryScript.MoneyText.transform.parent);
            textPrefab.GetComponent <Text>().text = $"{price}$";
            ClassManager.InventoryScript.Money.AddAmount(price);
        }
    }