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,116 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
public class HomeSrceen : MonoBehaviour
{
public Button primaryButton;
public Button playButton;
public Button shopButton;
public Button homeButton;
public Button battlepassButton;
public Button settingsButton;
public Button selectButton;
public Button profileButton;
public Button missionButton;
public GameObject homeScreen;
public GameObject selectionScreen;
public GameObject battlepassScreen;
public GameObject settingsScreen;
public GameObject shopScreen;
public GameObject modeScreen;
public GameObject profileScreen;
public GameObject setModeScreen;
public GameObject missionScreen;
private GameObject activeScreen;
public ModeSelection modeSelectionScript;
public GameObject singlePlayerEventSystem;
private void Awake()
{
primaryButton.Select();
playButton.onClick.AddListener(OnPlayButtonClick);
shopButton.onClick.AddListener(OnShopButtonClick);
homeButton.onClick.AddListener(OnHomeButtonClick);
battlepassButton.onClick.AddListener(OnBattlePassButtonClick);
settingsButton.onClick.AddListener(OnSettingsButtonClick);
selectButton.onClick.AddListener(OnSelectButtonClick);
profileButton.onClick.AddListener(OnProfileButtonClick);
missionButton.onClick.AddListener(OnMissionButtonClick);
// Set the initial active screen to home screen
activeScreen = homeScreen;
activeScreen.SetActive(true);
}
private void OnEnable()
{
primaryButton.Select();
}
public void OnPlayButtonClick()
{
ActivateScreen(setModeScreen);
}
public void TestButton()
{
gameObject.SetActive(true);
}
public void OnShopButtonClick()
{
// ActivateScreen(shopScreen);
}
public void OnHomeButtonClick()
{
ActivateScreen(homeScreen);
}
public void OnBattlePassButtonClick()
{
//ActivateScreen(battlepassScreen);
}
public void OnSettingsButtonClick()
{
ActivateScreen(settingsScreen);
}
public void OnSelectButtonClick()
{
// ActivateScreen(selectionScreen);
}
public void OnProfileButtonClick()
{
ActivateScreen(profileScreen);
}
public void OnMissionButtonClick()
{
ActivateScreen(missionScreen);
}
public void ActivateScreen(GameObject screen)
{
homeScreen.SetActive(false);
selectionScreen.SetActive(false);
battlepassScreen.SetActive(false);
settingsScreen.SetActive(false);
shopScreen.SetActive(false);
modeScreen.SetActive(false);
profileScreen.SetActive(false);
missionScreen.SetActive(false);
screen.SetActive(true);
}
}

View File

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

View File

@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ProfileScreen : MonoBehaviour
{
public LevelSystem levelSystem;
public TextMeshProUGUI levelText;
public TextMeshProUGUI xpText;
public Image profilePhoto;
public Button changePhotoButton;
public Slider xpSlider;
private void Start()
{
UpdateLevelDisplay();
changePhotoButton.onClick.AddListener(ChangePhotoButtonClick);
LoadProfilePhoto();
}
private void UpdateLevelDisplay()
{
int currentLevel = levelSystem.GetCurrentLevel();
int currentXP = levelSystem.GetCurrentXP();
int totalXP = levelSystem.GetTotalXPNeededForLevel(currentLevel);
RankSystem rankSystem = new RankSystem();
rankSystem.GetRank(currentLevel);
Debug.Log("Player Rank: " + rankSystem.GetRank(currentLevel));
levelText.text = "Level " + currentLevel.ToString();
xpText.text = currentXP.ToString() + "/" + totalXP.ToString();
xpSlider.maxValue = totalXP;
xpSlider.value = currentXP;
}
public void ChangePhotoButtonClick()
{
// Open a file browser to let the user select an image file
#if UNITY_EDITOR
string path = UnityEditor.EditorUtility.OpenFilePanel("Select Profile Photo", "", "png,jpg,jpeg");
// Load the image into a texture
byte[] fileData = System.IO.File.ReadAllBytes(path);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(fileData);
// Set the profile photo to the loaded texture
profilePhoto.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
// Save the image to a file on disk
string savePath = Application.persistentDataPath + "/profile_photo.png";
System.IO.File.WriteAllBytes(savePath, fileData);
#endif
}
private void LoadProfilePhoto()
{
string path = Application.persistentDataPath + "/profile_photo.png";
if (System.IO.File.Exists(path))
{
byte[] fileData = System.IO.File.ReadAllBytes(path);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(fileData);
profilePhoto.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
}
}
}

View File

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

View File

@@ -0,0 +1,29 @@
using UnityEngine;
using UnityEngine.UI;
public class UIMenuItem : MonoBehaviour
{
public delegate void MenuItemAction();
public event MenuItemAction action;
public bool IsSelected { get; private set; }
private Image background;
private void Awake()
{
background = GetComponent<Image>();
}
public void SetSelected(bool selected)
{
IsSelected = selected;
background.color = selected ? Color.gray : Color.white;
}
public void OnClick()
{
action?.Invoke();
}
}

View File

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