From cbba36ed33c68f90394f00a51550d1cbde3509a9 Mon Sep 17 00:00:00 2001 From: kusoaraiguma Date: Sun, 8 Sep 2024 15:59:27 +0000 Subject: [PATCH] upload file --- choiceproduct.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 choiceproduct.cs diff --git a/choiceproduct.cs b/choiceproduct.cs new file mode 100644 index 0000000..870c052 --- /dev/null +++ b/choiceproduct.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Choicepr : MonoBehaviour +{ + static string[] Products = { "apple", "sword", "bow", "arrow", "dog" }; //zamist tego wpisać zmienną w której będą rzeczy które są w sklepie + List FinalProducts = new List(); //lista w której zamisano to co klięt kupi + List IndexProducts = new List(); + int Index; + + void Start() + { + for(int i = 0; i < Products.Length; i++) + { + IndexProducts.Add(i); + } + + int AmountProducts = Random.Range(1, Products.Length + 1); + + for (int i = 0; i < AmountProducts; i++) + { + Index = Random.Range(0, IndexProducts.Count); + FinalProducts.Add(Products[IndexProducts[Index]]); + IndexProducts.RemoveAt(Index); + } + /* dla testu + for (int i = 0; i < FinalProducts.Count; i++) + { + Debug.Log("Product " + i + ": " + FinalProducts[i]); + } + */ + } + +} \ No newline at end of file