Exemple #1
0
    //Creates a shop Object -> sets its name cost and sprite from the Marble List
    public void DisplayShopItems()
    {
        Generate3ShopItems();
        int counter = 0;

        foreach (var item in shopMarbles)
        {
            GameObject shop = Instantiate(shopObject);
            shop.transform.SetParent(transform);
            Marble marble = item.GetComponent <Marble>();
            string name   = marble.commonName;
            string cost   = marble.cost.ToString();
            Sprite sprite = marble.marbleSprite;

            ShopObject newShopObject = shop.GetComponent <ShopObject>();
            newShopObject.marbleName.text             = name;
            newShopObject.marbleCost.text             = "$" + cost;
            newShopObject.marbleSpriteRenderer.sprite = sprite;

            if (counter < shopObjectLocations.Length)
            {
                shop.transform.position = shopObjectLocations[counter].position;
            }
            counter++;
        }
    }
Exemple #2
0
 public void VehicleBuyBack(InteractableVehicle vehicle)
 {
     try
     {
         if (vehicle.isLocked && vehicle.lockedOwner != CSteamID.Nil)
         {
             VehicleInfo info     = DShop.Instance.Database.GetVehicleInfo((ulong)vehicle.lockedOwner, vehicle.id);
             ShopObject  svehicle = DShop.Instance.Database.GetItem(ItemType.Vehicle, vehicle.id);
             if (info != null && svehicle.ItemID == vehicle.id && svehicle.RestrictBuySell != RestrictBuySell.BuyOnly)
             {
                 Uconomy.Instance.Database.CheckSetupAccount(vehicle.lockedOwner);
                 Uconomy.Instance.Database.IncreaseBalance(vehicle.lockedOwner.ToString(), Math.Round(decimal.Multiply(svehicle.BuyCost, svehicle.SellMultiplier), 2));
                 DShop.Instance.Database.DeleteVehicleInfo(info);
                 bool getPInfo = WreckingBall.isPlayerInfoLibLoaded;
                 Logger.Log(string.Format("Vehicle buyback successfull for: InstanceID: {0}, and Type: {1}({2}), at position: {3} , Sign By: {4}, Locked By: {5}.",
                                          vehicle.instanceID,
                                          vehicle.asset.vehicleName,
                                          vehicle.id, vehicle.transform.ToString(),
                                          DestructionProcessing.HasFlaggedElement(vehicle.transform, out ulong vFlagOwner) ? (getPInfo ? Instance.PInfoGenerateMessage(vFlagOwner) : vFlagOwner.ToString()) : "N/A",
                                          vehicle.isLocked ? (getPInfo ? Instance.PInfoGenerateMessage((ulong)vehicle.lockedOwner) : vehicle.lockedOwner.ToString()) : "N/A"));
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex, "There was an error with trying to process a vehicle buyback.");
     }
 }
    public void DisplayInfo(GameObject go)
    {
        currParentSO = GameObject.Find(go.transform.parent.name).GetComponent <ShopObject>();

        Name.text        = "Name: " + currParentSO.itemName;
        Balance.text     = "Cost: " + currParentSO.itemBalance;
        cost             = currParentSO.itemBalance;
        Points.text      = "Food Points: " + currParentSO.foodPoints;
        fPoints          = currParentSO.foodPoints;
        Description.text = "Description: " + currParentSO.description;
    }
Exemple #4
0
        private bool checkContains(ShopObject Item, ShopTag testTag)
        {
            foreach (var tag in Item.Tags)
            {
                if (tag == testTag)
                {
                    return(true);
                }
            }

            return(false);
        }
 private void Initialize(ShopObject shopObject)
 {
     CheckForSpawnable(shopObject, out IShopSpawnable spawnableObject);
     // Deduct funds from player.
     PlayerSettings.GetInstance().Funds -= shopObject.Cost;
     if (spawnableObject != null)
     {
         AmountOfFollowers++;
         // Instantiate the object and set it's position.
         spawnableObject.SpawnItem(spawnRange: shopObjectSpawnRange);
     }
 }
 public void SpawnObject(ShopObject shopObject)
 {
     if (shopObject.Cost > PlayerSettings.GetInstance().Funds)
     {
         NoFundsEventHandler.TriggerFundsOutPopUp(notEnoughFunds);
     }
     else if (maxAmountOfFollowers > AmountOfFollowers && shopObject.Prefab.TryGetComponent(out IShopSpawnable _))
     {
         NoFundsEventHandler.TriggerFundsOutPopUp(maxFollowersAchieved);
     }
     else
     {
         Initialize(shopObject);
     }
 }
Exemple #7
0
        public int percentageComparison(ShopObject Item)
        {
            float amountOfTags = positiveTags.Length;
            float tagsMatched  = 0;

            foreach (var tag in negativeTags)
            {
                if (checkContains(Item, tag))
                {
                    return(0);
                }
            }

            foreach (var tag in positiveTags)
            {
                if (checkContains(Item, tag))
                {
                    tagsMatched++;
                }
            }


            return(Mathf.RoundToInt(100 * (tagsMatched / amountOfTags)));
        }
Exemple #8
0
    public override void OnInspectorGUI()
    {
        // Debug.Log(Path);


        ShopObjectReference t = (ShopObjectReference)target;

        if (t.shopObject)
        {
            if (GUILayout.Button("Clear Shop Object"))
            {
                t.shopObject = null;
            }

            GUILayout.Label("Shop Object: " + t.shopObject.name);

            string tags = "";
            for (int i = 0; i < t.shopObject.Tags.Length - 1; i++)
            {
                tags += t.shopObject.Tags[i] + ", ";
            }
            tags += t.shopObject.Tags[t.shopObject.Tags.Length - 1] + ".";

            GUILayout.Label("Tags: " + tags);
        }
        else
        {
            mode = (Mode)EditorGUILayout.EnumPopup("Create: ", mode);

            switch (mode)
            {
            case Mode.New:
                EditorGUILayout.LabelField("New Tags");

                t._editorTagLength = EditorGUILayout.IntField(t._editorTagLength, "Number of Tags");

                t._toAdd = refactorTags(t._toAdd, t._editorTagLength);

                for (int i = 0; i < t._editorTagLength; i++)
                {
                    t._toAdd[i] = (ShopTag)EditorGUILayout.EnumPopup("Tag " + i + ": ", t._toAdd[i]);

                    //("Tag "+i+": ", t._toAdd);
                }

                if (t._toAdd.Length > 0)
                {
                    if (GUILayout.Button("Create"))
                    {
                        ShopObject newShopObject = new ShopObject();
                        newShopObject.Tags = t._toAdd;
                        newShopObject.name = t.gameObject.name;
                        newShopObject.Name = t.gameObject.name;
                        AssetDatabase.CreateAsset(newShopObject, "Assets/ShopTags/" + newShopObject.name + ".asset");
                        t.shopObject = newShopObject;
                    }
                }


                //    op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);



                break;

            case Mode.Copy:

                t.shopObject = (ShopObject)EditorGUILayout.ObjectField("Label:", t.shopObject, typeof(ShopObject), true);
                break;

            default:
                break;
            }



            serializedObject.ApplyModifiedProperties();

            //shopObj, new GUIContent("Shop Object"));


            //AssetDatabase.CreateAsset()
        }


        ShopTag[] refactorTags(ShopTag[] current, int length)
        {
            if (current == null)
            {
                current = new ShopTag[length];
            }

            ShopTag[] newTags = new ShopTag[length];
            if (current.Length < length)
            {
                for (int i = 0; i < current.Length; i++)
                {
                    newTags[i] = current[i];
                }

                for (int i = current.Length; i < length; i++)
                {
                    newTags[i] = ShopTag.Aubergine;
                }
            }
            if (current.Length > length)
            {
                for (int i = 0; i < length; i++)
                {
                    newTags[i] = current[i];
                }
            }
            if (current.Length == length)
            {
                newTags = current;
            }

            return(newTags);
        }

        //base.OnInspectorGUI();
    }
 private void CheckForSpawnable(ShopObject shopObject, out IShopSpawnable spawnableObject)
 {
     // Check if this item is spawnable by getting the interface component from it.
     spawnableObject = shopObject.Prefab.GetComponent <IShopSpawnable>();
 }