This commit is contained in:
2025-05-13 05:19:58 +03:00
parent 853edaf0b4
commit 472b2aee18
1034 changed files with 41844 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 2cd557e46f7c780438294cdbcf4f4df6
NativeFormatImporter:
userData:
assetBundleName:
@@ -0,0 +1,17 @@
using UnityEngine;
using System.Collections;
public class GameOverUIController : UiController {
public void OnContinueClick(){
}
public void OnMainMenuClick(){
Application.LoadLevel(0);
}
public void OnExitClick(){
Escape.Quit();
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3e59db71214b1aa429a0fba1f26234c9
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
@@ -0,0 +1,115 @@
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class InventoryUIController : UiController {
public Inventory inventory;
public ItemsView itemsView;
public UnityEngine.UI.Image selectionImage;
public UnityEngine.UI.Text selectionText;
public UnityEngine.UI.Button removeButton;
public UnityEngine.UI.Button equipButton;
private ItemViewController _selectedItem;
public void Rebuild() {
itemsView.Items = inventory.Items;
ResetFocus();
}
public void ResetFocus() {
var es = EventSystemManager.currentSystem;
if (itemsView.Views.Count > 0) {
es.SetSelectedGameObject(itemsView.Views[0].itemButton.gameObject, new BaseEventData(es));
}
}
// Use this for initialization
void Start () {
if (itemsView == null) {
Debug.LogWarning("Items view not set up! Inventory UI would not function properly!");
}
else {
itemsView.SelectionChanged += itemsView_SelectionChanged;
}
if (equipButton != null) {
equipButton.onClick.AddListener(OnEquipClick);
}
else {
Debug.LogWarning("Equip button not assigned!");
}
}
void OnEquipClick(UnityEngine.UI.Button button) {
EquippedChange();
}
void EquippedChange() {
var item = itemsView.Selection.item;
if (item != null && item.description.IsEquippable) {
if (item.equipped) {
inventory.UnequipItem(item);
} else {
inventory.EquipItem(item);
}
}
}
void itemsView_SelectionChanged(ItemsView container) {
if (_selectedItem == container.Selection) {
EquippedChange();
}
else {
_selectedItem = container.Selection;
selectionImage.sprite = container.Selection.item.inventoryIcon;
selectionText.text = container.Selection.item.description.Description;
}
UpdateButtons();
}
private void UpdateButtons() {
if (itemsView == null || itemsView.Selection == null || itemsView.Selection.item == null) {
if (equipButton != null) {
equipButton.gameObject.SetActive(false);
}
if (removeButton != null) {
removeButton.gameObject.SetActive(false);
}
}
else {
var item = itemsView.Selection.item;
//update equip button
if (!item.description.IsEquippable) {
equipButton.gameObject.SetActive(false);
}
else {
equipButton.gameObject.SetActive(true);
if (item.equipped) {
equipButton.GetComponentInChildren<Text>().text = "Unequip";
}
else {
equipButton.GetComponentInChildren<Text>().text = "Equip";
}
}
}
}
// Update is called once per frame
void Update () {
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0015e48a4cfa91f4a8b0dabbdaac9ed0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+30
View File
@@ -0,0 +1,30 @@
using UnityEngine;
using System.Collections;
public class ItemViewController : MonoBehaviour {
public UnityEngine.UI.Image itemImageView;
public UnityEngine.UI.Text itemEquippedText;
public UnityEngine.UI.Text itemCountText;
public UnityEngine.UI.Button itemButton;
public PickableItem item;
// Use this for initialization
void Start () {
itemCountText.text = "";
itemEquippedText.text = "";
}
// Update is called once per frame
void Update () {
if (item != null) {
//itemCountText.text = item.description.IsEquippable && item.equipped ? "E" : "";
itemEquippedText.text = item.description.IsEquippable && item.equipped ? "E" : "";
if (itemImageView != null) {
itemImageView.sprite = item.inventoryIcon;
}
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 717748885f3d1874cae663d6806e83b4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+110
View File
@@ -0,0 +1,110 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class RectTransformTools {
public static Vector2 Size(this RectTransform tf) {
Vector3[] c = new Vector3[4];
tf.GetLocalCorners(c);
return new Vector2(c[2].x - c[0].x, c[1].y - c[0].y);
}
}
public class ItemViewReference : MonoBehaviour {
public ItemViewController itemView;
}
public delegate void ItemsViewDelegate(ItemsView container);
public class ItemsView : MonoBehaviour {
public RectTransform container;
private IEnumerable<PickableItem> _items;
public GameObject itemViewPrototype;
private List<ItemViewController> _views = new List<ItemViewController>();
public List<ItemViewController> Views {
get { return _views; }
}
public float itemsMargin = 5.0f;
public event ItemsViewDelegate SelectionChanged;
private ItemViewController _selection;
public ItemViewController Selection {
get { return _selection; }
}
protected virtual void OnSelectionChanged() {
ItemsViewDelegate handler = SelectionChanged;
if (handler != null) {
handler(this);
}
}
public IEnumerable<PickableItem> Items {
get { return _items; }
set {
_items = value;
RebuildUI();
}
}
private void Start() {
var t = itemViewPrototype.GetComponent<RectTransform>();
var tfSize = t.anchoredPosition;
}
void OnClick(UnityEngine.UI.Button b) {
var view = b.gameObject.GetComponent<ItemViewReference>().itemView;
_selection = view;
OnSelectionChanged();
}
public void RebuildUI() {
//remove old items view
foreach (var view in _views) {
Destroy(view.gameObject);
}
_views.Clear();
//create new views
if (itemViewPrototype != null) {
foreach (var item in _items) {
var view = Instantiate<GameObject>(itemViewPrototype).GetComponent<ItemViewController>();
view.item = item;
_views.Add(view);
view.GetComponent<RectTransform>().parent = container;
var reference = view.itemButton.gameObject.AddComponent<ItemViewReference>();
reference.itemView = view;
view.itemButton.onClick.AddListener(OnClick);
}
}
else {
Debug.LogWarning("Can't create items view! Prototype not assigned!");
}
ArrangeItems();
}
public void ArrangeItems() {
var areaSize = container.Size();
var itemSize = itemViewPrototype.GetComponent<RectTransform>().Size();
int hCount = (int)((areaSize.x - itemsMargin) / (itemSize.x + itemsMargin));
for (int i = 0; i < _views.Count; ++i) {
var view = _views[i];
var tf = view.GetComponent<RectTransform>();
int row = i/hCount;
int column = i%hCount;
tf.anchoredPosition = new Vector2(column * (itemSize.x + itemsMargin) + itemsMargin + itemSize.x * 0.5f, -(row * (itemSize.y + itemsMargin) + itemsMargin + itemSize.y * 0.5f));
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 290656d8e5aa63d4fb058ab6a110af3a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+47
View File
@@ -0,0 +1,47 @@
using UnityEngine;
using System.Collections;
public class MainMenuController : MonoBehaviour {
public AudioClip newGameSound;
private AudioSource _source;
public GameObject fadeImage;
public void OnButtonExit(){
Application.Quit();
}
public void OnButtonNewGame(){
Invoke("NewGameLoad", 5);
if(_source != null & newGameSound != null){
_source.PlayOneShot(newGameSound);
}
//fadeImage.GetComponent<UnityEngine.image
try {
fadeImage.SetActive(true);
fadeImage.GetComponent<Animator>().SetTrigger("Fade");
}
catch {
}
}
private void NewGameLoad(){
Debug.Log("Load level");
Application.LoadLevel("Level0");
}
// Use this for initialization
void Start () {
Time.timeScale = 1;
_source = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update () {
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 511befb185f4cef429c7c08edfe10b4d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
Binary file not shown.
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: d62c226b11260e14a81fda9615c6924d
NativeFormatImporter:
userData:
assetBundleName:
Binary file not shown.
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: b0fcff03f5d7e3442a72590d0a2668ef
NativeFormatImporter:
userData:
assetBundleName: