chunk 1: core gameplay scripts scenes runtime assets

This commit is contained in:
2026-04-06 11:02:34 +03:00
parent fa0388bc79
commit 0d11a097d8
703 changed files with 2292651 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using UnityEngine.EventSystems;
using TMPro;
public class MainStore : MonoBehaviour{
public Button MenuTogglerButton; //Reference to the Button used to Toggle the Menu's state
public GameObject Menu; //Reference to the Menu to be shown
public GameObject[] ParentChildPrefab; //First item is Parent, Second item is Child
public GameObject ContainerParentChildPrefab; //Container for the Menu Items
public Sprite[] MenuDropdownSprites; //Icons for menu items which are dropdowns in the Menu, 0 = Caret down, 1 = Caret up
//Menu Items in the Menu, they will be added dynamically to the Menu in the Shop UI
private Dictionary<string, List<string>> menuData = new Dictionary<string, List<string>>()
{
{ "Outfits", new List<string> { "Maasai1", "Maasai2" } }, //Dropdown
{ "Coins", null }, //Not dropdown
{ "BattlePass", null }, //Not dropdown
{ "Characters", null }, //Not dropdown
};
void OnEnable(){
Menu.SetActive(false); //Sets initial state of Menu when the UI is activated
}
void Start(){
MenuTogglerButton.onClick.AddListener(() => ToggleMenu("toggle"));
PopulateMenu();
}
void PopulateMenu(){
foreach (var item in menuData){
string key = item.Key;
List<string> children = item.Value;
// Console.WriteLine(key);
if (children != null)
{
InstantiateMenuItem(key, "parent", "isDropdown");
Debug.Log(key); //Parent
foreach (string child in children)
{
InstantiateMenuItem(child, "child", "isDropdown");
Debug.Log(" - " + child); //Child
}
}
//If there are no children, not a dropdown
if (children == null){
InstantiateMenuItem(key, "parent", "isNotDropdown");
// isNotDropdown();
}
}
//Remove the Menu Item Prefabs
foreach (GameObject obj in ParentChildPrefab){
obj.SetActive(false);
}
}
void InstantiateMenuItem(string MenuItemName, string MenuItemType, string MenuItemParentType){
GameObject MenuItem_Instance;
switch(MenuItemType){
case "parent":
MenuItem_Instance = Instantiate(ParentChildPrefab[0], ContainerParentChildPrefab.transform);
if (MenuItemParentType == "isNotDropdown"){
ParentisNotDropdown(MenuItem_Instance);
}
(MenuItem_Instance.transform.Find("text")).GetComponent<TextMeshProUGUI>().text = MenuItemName;
MenuItem_Instance.name = MenuItemName;
break;
case "child":
MenuItem_Instance = Instantiate(ParentChildPrefab[1], ContainerParentChildPrefab.transform);
(MenuItem_Instance.transform.Find("text")).GetComponent<TextMeshProUGUI>().text = MenuItemName;
MenuItem_Instance.name = MenuItemName;
break;
}
}
//Changes state of the Menu, if Open then Closes it and vice versa
void ToggleMenu(string menuStatus){
bool isActive = Menu.activeSelf; //Check if the Menu is active
bool currentMenuStatus = !isActive;
if (menuStatus == "toggle"){
Menu.SetActive(currentMenuStatus); //Change the current state of the Menu, if false then true, and vice versa
}else if(menuStatus == "close"){
Menu.SetActive(false);
}
//Menu has been opened
if (currentMenuStatus == true){
// MenuIsOpen();
}
}
//When Menu is Opened, set the Selected Item within the Menu
void MenuIsOpen(){
// foreach(GameObject obj in MenuParents){
// setCaretDown(obj);
// }
// SetMenuSelectedGameObject(MenuParents[0]);
// ShowHideChildren(new GameObject[0]); //Pass empty array, so all children are hidden
}
void ParentisNotDropdown(GameObject MenuItem_Instance){
GameObject caret_GameObject = (MenuItem_Instance.transform.Find("caret")).gameObject;
caret_GameObject.SetActive(false);
Debug.Log("Parent is Not Dropdown");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c81c92b23c4f4345ac6054f351dcfec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,158 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System;
using System.Linq;
//ONLY FOR TESTING
#region
//Progress of missions
[System.Serializable]
public class ProductDetails{
public string productID; //records the week the player is at
public string productName;
public string productDescription; //records the week the player is at
public int productPrice; //records the week the player is at
public string productImage;
}
#endregion
public class PopulateStore : MonoBehaviour
{
public GameObject[] BBundle_Prefab; //Big Bundle, The 1st is Container, 2nd is Prefab
public GameObject[] SBundle_Prefab; //Big Bundle, The 1st is Container, 2nd is Prefab
public GameObject[] ProductPage; //0 is the gameobject for the individual product page, 1 is product page dismiss button
[HideInInspector]
public List<ProductDetails> retrievedProductDetails, retrievedBundleProductDetails;
public Sprite[] productSprites; // Array of product sprites
// private Dictionary<string, string, string> SamplePurchaseItems = new Dictionary<string, string, string>()
// {
// { "Outfit1", "1", "2" }, //Dropdown
// { "Outfit2", "3", "4" }, //Not dropdown
// { "Outfit3", "5", "6" }, //Not dropdown
// };
void onEnable(){
}
void Awake(){
Button ProductPageDismissBtn = ProductPage[1].GetComponent<Button>();
ProductPageDismissBtn.onClick.AddListener(BackButton_RemoveProductPage);
retrievedBundleProductDetails = new List<ProductDetails>{
new ProductDetails { productID = "com.ex.cat1", productName = "Cat", productDescription = "Cat Character", productPrice = 40, productImage = "Cat4X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cheetah2", productName = "Cheetah", productDescription = "Cheetah Character", productPrice = 50, productImage = "Cheetah5X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hyena3", productName = "Hyena", productDescription = "Hyena Character", productPrice = 60, productImage = "Heyna3X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cat1", productName = "Cat", productDescription = "Cat Character", productPrice = 40, productImage = "Cat4X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cheetah2", productName = "Cheetah", productDescription = "Cheetah Character", productPrice = 50, productImage = "Cheetah5X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hyena3", productName = "Hyena", productDescription = "Hyena Character", productPrice = 60, productImage = "Heyna3X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cat1", productName = "Cat", productDescription = "Cat Character", productPrice = 40, productImage = "Cat4X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cheetah2", productName = "Cheetah", productDescription = "Cheetah Character", productPrice = 50, productImage = "Cheetah5X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hyena3", productName = "Hyena", productDescription = "Hyena Character", productPrice = 60, productImage = "Heyna3X-removebg-preview 2" },
};
retrievedProductDetails = new List<ProductDetails>{
new ProductDetails { productID = "com.ex.cat", productName = "Cat", productDescription = "Cat Character", productPrice = 40, productImage = "Cat4X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.cheetah", productName = "Cheetah", productDescription = "Cheetah Character", productPrice = 50, productImage = "Cheetah5X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hyena", productName = "Hyena", productDescription = "Hyena Character", productPrice = 60, productImage = "Heyna3X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hippo", productName = "Hippo", productDescription = "Hippo Character", productPrice = 80, productImage = "Hipos2X-removebg-preview 2" },
new ProductDetails { productID = "com.ex.hammerhead", productName = "HammerHead", productDescription = "HammerHead Character", productPrice = 100, productImage = "hM3X-removebg-preview 2" },
};
}
// Start is called before the first frame update
void Start()
{
//Bundle
foreach (ProductDetails prodDet in retrievedBundleProductDetails){
GameObject MenuItem_Instance = Instantiate(BBundle_Prefab[1], BBundle_Prefab[0].transform);
Button GameObject_Button = MenuItem_Instance.GetComponent<Button>();
GameObject_Button.onClick.AddListener(() => ShowProductPage(prodDet));
Debug.Log(prodDet.productID + "\n");
}
BBundle_Prefab[1].SetActive(false);
//Small Product
foreach (ProductDetails prodDet in retrievedProductDetails){
GameObject MenuItem_Instance = Instantiate(SBundle_Prefab[1], SBundle_Prefab[0].transform);
Button GameObject_Button = MenuItem_Instance.GetComponent<Button>();
GameObject_Button.onClick.AddListener(() => ShowProductPage(prodDet));
Debug.Log(prodDet.productID + "\n");
}
SBundle_Prefab[1].SetActive(false);
}
void BackButton_RemoveProductPage(){
ProductPage[0].SetActive(false);
}
void ShowProductPage(ProductDetails productDetails)
{
ProductPage[0].SetActive(true);
Debug.Log($"Product ID: {productDetails.productID}\nProduct Name: {productDetails.productName}\nProduct Description: {productDetails.productDescription}\nProduct Price: {productDetails.productPrice}");
// Get the TextMeshProUGUI component from the "productName" GameObject
TextMeshProUGUI productNameText = ProductPage[0].transform.Find("CharacterPurchase/productName").GetComponent<TextMeshProUGUI>();
productNameText.text = productDetails.productName;
TextMeshProUGUI productPriceText = ProductPage[0].transform.Find("CharacterPurchase/GameObject (2)/productPrice/price").GetComponent<TextMeshProUGUI>();
productPriceText.text = (productDetails.productPrice).ToString();
// GameObject fkw = ProductPage[0].transform.Find("CharacterPurchase/Panel/item_image").gameObject;
// fkw.name = "fkw";
// Get the Image component from the "item_image" GameObject
Image itemImage = ProductPage[0].transform.Find("CharacterPurchase/Panel/item_image").GetComponent<Image>();
Sprite newSprite = FindSpriteByName(productDetails.productImage);
if (newSprite != null)
{
itemImage.sprite = newSprite;
}
else
{
Debug.LogError("Failed to load image with name: " + productDetails.productImage);
}
}
Sprite FindSpriteByName(string spriteName)
{
foreach (Sprite sprite in productSprites)
{
if (sprite.name == spriteName)
{
return sprite;
}
}
return null;
}
//API-ish
void GetProductDataByID(string productID){
// MissionInfo mission = missionInfo.Find(m => m.missionID == missionID);
// return mission.missionProgressCount;
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ffb34de054161748ad9a240bbe8b9ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: