Quest Update
This commit is contained in:
BIN
Assets/Script/.DS_Store
vendored
BIN
Assets/Script/.DS_Store
vendored
Binary file not shown.
@@ -1,22 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharSelectionManager : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject[] characterPrefabs;
|
||||
|
||||
public void ChangeCharacter(int index)
|
||||
{
|
||||
for (int i = 0; i < characterPrefabs.Length; i++)
|
||||
{
|
||||
characterPrefabs[i].SetActive(false);
|
||||
}
|
||||
characterPrefabs[index].SetActive(true);
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharSelectionManager : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject[] characterPrefabs;
|
||||
|
||||
public void ChangeCharacter(int index)
|
||||
{
|
||||
for (int i = 0; i < characterPrefabs.Length; i++)
|
||||
{
|
||||
characterPrefabs[i].SetActive(false);
|
||||
}
|
||||
characterPrefabs[index].SetActive(true);
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a566385cb2a34466a99b7610070385e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 4a566385cb2a34466a99b7610070385e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class CharacterCusomizationBridge : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
|
||||
public static string characterJson;
|
||||
|
||||
public static CharacterCusomizationBridge instance;
|
||||
void Awake(){
|
||||
if(instance!=null && instance!=this){
|
||||
Destroy(instance.gameObject);
|
||||
}
|
||||
|
||||
instance=this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
// if(Input.GetKeyDown(KeyCode.Space)){
|
||||
// LoadToGame();
|
||||
// }
|
||||
}
|
||||
|
||||
public void LoadToGame(){
|
||||
CharacterSelection.selectedCharJson = character.ToJson();
|
||||
SceneManager.LoadScene("MenuScene");
|
||||
CharacterSelection.SaveCharacterSkinCloud();
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class CharacterCusomizationBridge : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
|
||||
public static string characterJson;
|
||||
|
||||
public static CharacterCusomizationBridge instance;
|
||||
void Awake(){
|
||||
if(instance!=null && instance!=this){
|
||||
Destroy(instance.gameObject);
|
||||
}
|
||||
|
||||
instance=this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
// if(Input.GetKeyDown(KeyCode.Space)){
|
||||
// LoadToGame();
|
||||
// }
|
||||
}
|
||||
|
||||
public void LoadToGame(){
|
||||
CharacterSelection.selectedCharJson = character.ToJson();
|
||||
SceneManager.LoadScene("MenuScene");
|
||||
CharacterSelection.SaveCharacterSkinCloud();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eacf460e0d7a143309db001657914f66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: eacf460e0d7a143309db001657914f66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/CharacterData", order = 1)]
|
||||
public class CharacterDataSO : ScriptableObject
|
||||
{
|
||||
public string jsonCharData;
|
||||
public string charName;
|
||||
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/CharacterData", order = 1)]
|
||||
public class CharacterDataSO : ScriptableObject
|
||||
{
|
||||
public string jsonCharData;
|
||||
public string charName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b7d6ca0a7bac48388c4c141a7548d78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 2b7d6ca0a7bac48388c4c141a7548d78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dc705c90c00842369b81dac75b580d8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 4dc705c90c00842369b81dac75b580d8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChangeCharacterOnSelection : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
void Start(){
|
||||
CharacterSelection.OnCharacterChanged += RefreshCharacter;
|
||||
RefreshCharacter();
|
||||
}
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
CharacterSelection.OnCharacterChanged -= RefreshCharacter;
|
||||
}
|
||||
|
||||
void RefreshCharacter(){
|
||||
if(CharacterSelection.selectedCharJson == null){return;}
|
||||
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
|
||||
character.FromJson(CharacterSelection.selectedCharJson, true);
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChangeCharacterOnSelection : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
void Start(){
|
||||
CharacterSelection.OnCharacterChanged += RefreshCharacter;
|
||||
RefreshCharacter();
|
||||
}
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
CharacterSelection.OnCharacterChanged -= RefreshCharacter;
|
||||
}
|
||||
|
||||
void RefreshCharacter(){
|
||||
if(CharacterSelection.selectedCharJson == null){return;}
|
||||
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
|
||||
character.FromJson(CharacterSelection.selectedCharJson, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a01bf626125f48b38c14bb319871b4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 1a01bf626125f48b38c14bb319871b4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.Firestore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterSelection : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] public static string selectedCharJson = "";
|
||||
public List<CharacterDataSO> predefinedCharacterJsons;
|
||||
public List<Button> predefinedCharacterButtons;
|
||||
|
||||
public static Action OnCharacterChanged;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
|
||||
{
|
||||
int tempI = i;
|
||||
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
|
||||
}
|
||||
LoadCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public void LoadCharacterFromString(string characterData)
|
||||
{
|
||||
selectedCharJson = characterData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPredefinedCharButtonPress(int i)
|
||||
{
|
||||
selectedCharJson = predefinedCharacterJsons[i].jsonCharData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
SaveCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public static void SaveCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
PlayerPrefs.SetString("skinData", selectedCharJson);
|
||||
PlayerPrefs.Save();
|
||||
#else
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
|
||||
Dictionary<string,object> skindataDictionary = new Dictionary<string, object>();
|
||||
skindataDictionary.Add("json", selectedCharJson);
|
||||
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.SetAsync(skindataDictionary).ContinueWithOnMainThread(task => {
|
||||
if(task.IsCompleted){
|
||||
Debug.Log("**** Save Completed Firestore ****");
|
||||
}
|
||||
else{
|
||||
Debug.Log("**** Failed to save data to firestore ****");
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void LoadCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (PlayerPrefs.HasKey("skinData"))
|
||||
{
|
||||
LoadCharacterFromString(PlayerPrefs.GetString("skinData"));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task => {
|
||||
DocumentSnapshot snapshot = task.Result;
|
||||
if(snapshot.Exists){
|
||||
|
||||
LoadCharacterFromString(snapshot.GetValue<string>("json"));
|
||||
|
||||
}else{
|
||||
//show error previous data doesnt exists to load
|
||||
Debug.Log("**** No previous data to load ****");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.Firestore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CharacterSelection : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] public static string selectedCharJson = "";
|
||||
public List<CharacterDataSO> predefinedCharacterJsons;
|
||||
public List<Button> predefinedCharacterButtons;
|
||||
|
||||
public static Action OnCharacterChanged;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
|
||||
{
|
||||
int tempI = i;
|
||||
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
|
||||
}
|
||||
LoadCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public void LoadCharacterFromString(string characterData)
|
||||
{
|
||||
selectedCharJson = characterData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
void OnPredefinedCharButtonPress(int i)
|
||||
{
|
||||
selectedCharJson = predefinedCharacterJsons[i].jsonCharData;
|
||||
OnCharacterChanged?.Invoke();
|
||||
SaveCharacterSkinCloud();
|
||||
}
|
||||
|
||||
public static void SaveCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
PlayerPrefs.SetString("skinData", selectedCharJson);
|
||||
PlayerPrefs.Save();
|
||||
#else
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
|
||||
Dictionary<string,object> skindataDictionary = new Dictionary<string, object>();
|
||||
skindataDictionary.Add("json", selectedCharJson);
|
||||
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.SetAsync(skindataDictionary).ContinueWithOnMainThread(task => {
|
||||
if(task.IsCompleted){
|
||||
Debug.Log("**** Save Completed Firestore ****");
|
||||
}
|
||||
else{
|
||||
Debug.Log("**** Failed to save data to firestore ****");
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void LoadCharacterSkinCloud()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (PlayerPrefs.HasKey("skinData"))
|
||||
{
|
||||
LoadCharacterFromString(PlayerPrefs.GetString("skinData"));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
|
||||
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
|
||||
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task => {
|
||||
DocumentSnapshot snapshot = task.Result;
|
||||
if(snapshot.Exists){
|
||||
|
||||
LoadCharacterFromString(snapshot.GetValue<string>("json"));
|
||||
|
||||
}else{
|
||||
//show error previous data doesnt exists to load
|
||||
Debug.Log("**** No previous data to load ****");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f46cf614fdb6e410695e435f02bfcd44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: f46cf614fdb6e410695e435f02bfcd44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -81,8 +81,9 @@ public class InventoryManager : MonoBehaviour
|
||||
return count;
|
||||
}
|
||||
|
||||
public void RemoveItem(string type)
|
||||
public void RemoveItem(string type, int amount = 1)
|
||||
{
|
||||
int leftToRemove = amount;
|
||||
for (int i = 0; i < inventorySlots.Length; i++)
|
||||
{
|
||||
ItemInventory itemInSlot = inventorySlots[i].GetComponentInChildren<ItemInventory>();
|
||||
@@ -91,7 +92,10 @@ public class InventoryManager : MonoBehaviour
|
||||
if (itemInSlot.item.type == type)
|
||||
{
|
||||
Destroy(itemInSlot.gameObject);
|
||||
return;
|
||||
leftToRemove--;
|
||||
if(leftToRemove <= 0){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemInventory : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler
|
||||
{
|
||||
public item item;
|
||||
[HideInInspector]
|
||||
public Transform parentAfterDrag;
|
||||
|
||||
public Image image;
|
||||
|
||||
InventoryManager inventoryManager = new InventoryManager();
|
||||
|
||||
public void Set(item newItem, InventoryManager man)
|
||||
{
|
||||
inventoryManager = man;
|
||||
Debug.Log("Setting new item to this slot " + newItem.type, gameObject);
|
||||
item = newItem;
|
||||
image.sprite = newItem.image;
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
||||
// UnityEditor.EditorApplication.delayCall += () =>
|
||||
// {
|
||||
// DestroyImmediate(gameObject);
|
||||
// };
|
||||
}
|
||||
|
||||
public void Drop()
|
||||
{
|
||||
inventoryManager.
|
||||
DropItem(item);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
image.raycastTarget = false;
|
||||
parentAfterDrag = transform.parent;
|
||||
transform.SetParent(transform.parent.parent.parent.parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
transform.position = eventData.position;
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Dropping into " + parentAfterDrag.name, parentAfterDrag.gameObject);
|
||||
if(parentAfterDrag == transform.parent)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
image.raycastTarget = true;
|
||||
transform.SetParent(parentAfterDrag);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
|
||||
//inventoryManager.SelectItem(item);
|
||||
if (item.isUsable == false)return;
|
||||
if (inventoryManager.UseItem(item))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemInventory : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler
|
||||
{
|
||||
public item item;
|
||||
[HideInInspector]
|
||||
public Transform parentAfterDrag;
|
||||
|
||||
public Image image;
|
||||
|
||||
InventoryManager inventoryManager = new InventoryManager();
|
||||
|
||||
public void Set(item newItem, InventoryManager man)
|
||||
{
|
||||
inventoryManager = man;
|
||||
Debug.Log("Setting new item to this slot " + newItem.type, gameObject);
|
||||
item = newItem;
|
||||
image.sprite = newItem.image;
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
||||
// UnityEditor.EditorApplication.delayCall += () =>
|
||||
// {
|
||||
// DestroyImmediate(gameObject);
|
||||
// };
|
||||
}
|
||||
|
||||
public void Drop()
|
||||
{
|
||||
inventoryManager.
|
||||
DropItem(item);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
image.raycastTarget = false;
|
||||
parentAfterDrag = transform.parent;
|
||||
transform.SetParent(transform.parent.parent.parent.parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
transform.position = eventData.position;
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Dropping into " + parentAfterDrag.name, parentAfterDrag.gameObject);
|
||||
if(parentAfterDrag == transform.parent)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
image.raycastTarget = true;
|
||||
transform.SetParent(parentAfterDrag);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
|
||||
//inventoryManager.SelectItem(item);
|
||||
if (item.isUsable == false)return;
|
||||
if (inventoryManager.UseItem(item))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[CreateAssetMenu(fileName = "InventoryItem", menuName = "ScriptableObjects/InventoryItem", order = 2)]
|
||||
public class item : ScriptableObject
|
||||
{
|
||||
public string type;
|
||||
public bool isUsable;
|
||||
public Sprite image;
|
||||
public GameObject prefab;
|
||||
public int count;
|
||||
public int spawnProbability = 50;
|
||||
public int healthIncrease = 10;
|
||||
|
||||
|
||||
|
||||
|
||||
// public InventoryItemType type;
|
||||
// public InventoryItemAction action;
|
||||
|
||||
// public enum InventoryItemType{
|
||||
|
||||
// }
|
||||
|
||||
// public enum InventoryItemAction{
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[CreateAssetMenu(fileName = "InventoryItem", menuName = "ScriptableObjects/InventoryItem", order = 2)]
|
||||
public class item : ScriptableObject
|
||||
{
|
||||
public string type;
|
||||
public bool isUsable;
|
||||
public Sprite image;
|
||||
public GameObject prefab;
|
||||
public int count;
|
||||
public int spawnProbability = 50;
|
||||
public int healthIncrease = 10;
|
||||
|
||||
|
||||
|
||||
|
||||
// public InventoryItemType type;
|
||||
// public InventoryItemAction action;
|
||||
|
||||
// public enum InventoryItemType{
|
||||
|
||||
// }
|
||||
|
||||
// public enum InventoryItemAction{
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NpcUI : MonoBehaviour
|
||||
{
|
||||
public Button btnNext;
|
||||
public void Start(){
|
||||
btnNext.onClick.AddListener(onNext);
|
||||
}
|
||||
|
||||
void onNext(){
|
||||
npcScript.activeNpc.NextLine();
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NpcUI : MonoBehaviour
|
||||
{
|
||||
public Button btnNext;
|
||||
public void Start(){
|
||||
btnNext.onClick.AddListener(onNext);
|
||||
}
|
||||
|
||||
void onNext(){
|
||||
npcScript.activeNpc.NextLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ public class QuestAction : MonoBehaviour
|
||||
if(playerNetwork.localPlayerTransform.GetComponent<Inventory>().inventoryManager.GetStock(entry.resource.type) < entry.amount){
|
||||
|
||||
}else{
|
||||
for(int i=0; i < entry.amount; i++)
|
||||
{
|
||||
playerNetwork.localPlayerTransform.GetComponent<Inventory>().inventoryManager.RemoveItem(entry.resource.type);
|
||||
}
|
||||
playerNetwork.localPlayerTransform.GetComponent<Inventory>().inventoryManager.RemoveItem(entry.resource.type, entry.amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Common;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Data;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Enums;
|
||||
using Assets.HeroEditor4D.InventorySystem.Scripts.Elements;
|
||||
using UnityEngine;
|
||||
|
||||
public class characterManager : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
public AnimationManager anim;
|
||||
public Character front, back, left, right;
|
||||
|
||||
float xMove , yMove;
|
||||
|
||||
void Start(){
|
||||
// if(CharacterCusomizationBridge.instance!=null && CharacterCusomizationBridge.characterJson!=null){
|
||||
// GetComponent<Character4D>().FromJson(CharacterCusomizationBridge.characterJson, false);
|
||||
// }
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.M)){
|
||||
// ChangeWeapon();
|
||||
EquipBow();
|
||||
}
|
||||
}
|
||||
int weaponIndex = 52;
|
||||
public int bowIndex =0;
|
||||
public void EquipBow(){
|
||||
// bowIndex++;
|
||||
// if(bowIndex >= character.SpriteCollection.Bow.Count){
|
||||
// bowIndex=0;
|
||||
// }
|
||||
// Debug.Log("Equipping bow index " + bowIndex + " out of " + character.SpriteCollection.Bow.Count);
|
||||
|
||||
var item = character.SpriteCollection.Bow[16];
|
||||
EquipForAll(item, EquipmentPart.Bow);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ChangeWeapon(){
|
||||
|
||||
// if(weaponIndex < character.SpriteCollection.MeleeWeapon1H.Count){
|
||||
// weaponIndex++;
|
||||
// }else{
|
||||
// weaponIndex = 0;
|
||||
// }
|
||||
// Debug.Log(weaponIndex);
|
||||
var item = character.SpriteCollection.MeleeWeapon1H[weaponIndex];
|
||||
// var sprite = character.SpriteCollection.MeleeWeapon1H.FindSprite("FireMageWand");
|
||||
|
||||
EquipForAll(item,EquipmentPart.MeleeWeapon1H);
|
||||
}
|
||||
|
||||
void EquipForAll(ItemSprite item, EquipmentPart type){
|
||||
front.Equip(item, type);
|
||||
back.Equip(item, type);
|
||||
left.Equip(item, type);
|
||||
right.Equip(item, type);
|
||||
|
||||
}
|
||||
|
||||
public void SetActiveWeapon(int i){
|
||||
weaponIndex = i;
|
||||
ChangeWeapon();
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.HeroEditor4D.Common.Scripts.CharacterScripts;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Common;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Data;
|
||||
using Assets.HeroEditor4D.Common.Scripts.Enums;
|
||||
using Assets.HeroEditor4D.InventorySystem.Scripts.Elements;
|
||||
using UnityEngine;
|
||||
|
||||
public class characterManager : MonoBehaviour
|
||||
{
|
||||
public Character4D character;
|
||||
public AnimationManager anim;
|
||||
public Character front, back, left, right;
|
||||
|
||||
float xMove , yMove;
|
||||
|
||||
void Start(){
|
||||
// if(CharacterCusomizationBridge.instance!=null && CharacterCusomizationBridge.characterJson!=null){
|
||||
// GetComponent<Character4D>().FromJson(CharacterCusomizationBridge.characterJson, false);
|
||||
// }
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.M)){
|
||||
// ChangeWeapon();
|
||||
EquipBow();
|
||||
}
|
||||
}
|
||||
int weaponIndex = 52;
|
||||
public int bowIndex =0;
|
||||
public void EquipBow(){
|
||||
// bowIndex++;
|
||||
// if(bowIndex >= character.SpriteCollection.Bow.Count){
|
||||
// bowIndex=0;
|
||||
// }
|
||||
// Debug.Log("Equipping bow index " + bowIndex + " out of " + character.SpriteCollection.Bow.Count);
|
||||
|
||||
var item = character.SpriteCollection.Bow[16];
|
||||
EquipForAll(item, EquipmentPart.Bow);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ChangeWeapon(){
|
||||
|
||||
// if(weaponIndex < character.SpriteCollection.MeleeWeapon1H.Count){
|
||||
// weaponIndex++;
|
||||
// }else{
|
||||
// weaponIndex = 0;
|
||||
// }
|
||||
// Debug.Log(weaponIndex);
|
||||
var item = character.SpriteCollection.MeleeWeapon1H[weaponIndex];
|
||||
// var sprite = character.SpriteCollection.MeleeWeapon1H.FindSprite("FireMageWand");
|
||||
|
||||
EquipForAll(item,EquipmentPart.MeleeWeapon1H);
|
||||
}
|
||||
|
||||
void EquipForAll(ItemSprite item, EquipmentPart type){
|
||||
front.Equip(item, type);
|
||||
back.Equip(item, type);
|
||||
left.Equip(item, type);
|
||||
right.Equip(item, type);
|
||||
|
||||
}
|
||||
|
||||
public void SetActiveWeapon(int i){
|
||||
weaponIndex = i;
|
||||
ChangeWeapon();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class rangeEnemyFinder : MonoBehaviour
|
||||
{
|
||||
public float radius = 10;
|
||||
public enemyScript[] enemies;
|
||||
|
||||
public Transform lockIndicator;
|
||||
|
||||
private void OnDrawGizmos() {
|
||||
Gizmos.DrawWireSphere(transform.position, radius);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public enemyScript targetEnemy;
|
||||
|
||||
void Update()
|
||||
{
|
||||
enemies = FindObjectsOfType<enemyScript>();
|
||||
float closestDist = radius * 10f;
|
||||
targetEnemy = null;
|
||||
foreach(enemyScript enemy in enemies){
|
||||
float dist = Vector3.Distance((Vector2)enemy.transform.position,(Vector2)transform.position);
|
||||
if(dist < radius){
|
||||
if(dist < closestDist){
|
||||
targetEnemy = enemy;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lockIndicator.gameObject.SetActive(targetEnemy!= null);
|
||||
|
||||
if(targetEnemy != null){
|
||||
//show indicator
|
||||
lockIndicator.position = targetEnemy.transform.position + new Vector3 (0, 0.62f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class rangeEnemyFinder : MonoBehaviour
|
||||
{
|
||||
public float radius = 10;
|
||||
public enemyScript[] enemies;
|
||||
|
||||
public Transform lockIndicator;
|
||||
|
||||
private void OnDrawGizmos() {
|
||||
Gizmos.DrawWireSphere(transform.position, radius);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public enemyScript targetEnemy;
|
||||
|
||||
void Update()
|
||||
{
|
||||
enemies = FindObjectsOfType<enemyScript>();
|
||||
float closestDist = radius * 10f;
|
||||
targetEnemy = null;
|
||||
foreach(enemyScript enemy in enemies){
|
||||
float dist = Vector3.Distance((Vector2)enemy.transform.position,(Vector2)transform.position);
|
||||
if(dist < radius){
|
||||
if(dist < closestDist){
|
||||
targetEnemy = enemy;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lockIndicator.gameObject.SetActive(targetEnemy!= null);
|
||||
|
||||
if(targetEnemy != null){
|
||||
//show indicator
|
||||
lockIndicator.position = targetEnemy.transform.position + new Vector3 (0, 0.62f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdca2649edb8b4c0184a4d565a4fafa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: fdca2649edb8b4c0184a4d565a4fafa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Reference in New Issue
Block a user