35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
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<string> FinalProducts = new List<string>(); //lista w której zamisano to co klięt kupi
|
|
List<int> IndexProducts = new List<int>();
|
|
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]);
|
|
}
|
|
*/
|
|
}
|
|
|
|
} |