add some extra assets FX and SFX
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class craftingUISystem : ingameMenuPanel
|
||||
{
|
||||
@@ -16,6 +17,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
public int amountOnRepareIngredientsButtonsToSpawn = 30;
|
||||
public int amountOfObjectStatsButtonToSpawn = 0;
|
||||
public int amountOfObjectToCraftInTimeButtonToSpawn = 20;
|
||||
public int amountOfDisassembleIngredientsToSpawn = 20;
|
||||
|
||||
[Space]
|
||||
[Header ("Workbench Settings")]
|
||||
@@ -125,6 +127,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
public bool menuOpenedFromWorkbench;
|
||||
|
||||
public bool allowToCraftAllObjectsOnCurrentBench;
|
||||
|
||||
public List<string> objectCategoriesToCraftAvailableOnCurrentBench = new List<string> ();
|
||||
|
||||
public craftingWorkbenchSystem currentCraftingWorkbenchSystem;
|
||||
@@ -145,6 +149,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
public List<objectStatButtonInfo> objectStatButtonInfoList = new List<objectStatButtonInfo> ();
|
||||
|
||||
public List<craftingObjectButtonInfo> currentDisassembleIngredientsInfoList = new List<craftingObjectButtonInfo> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public List<craftObjectInTimeInfo> craftObjectInTimeInfoList = new List<craftObjectInTimeInfo> ();
|
||||
@@ -158,6 +164,16 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnShowObjectPanelInfo;
|
||||
public UnityEvent eventOnShowObjectPanelInfo;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnShowPressedObjectInfo;
|
||||
public UnityEvent eventOnShowPressedObjectInfo;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnOpenUpgradeObjectPanel;
|
||||
public UnityEvent eventOnCloseUpgradeObjectPanel;
|
||||
|
||||
@@ -195,11 +211,15 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
public RawImage currentObjectSelectedImage;
|
||||
|
||||
public GameObject craftObjectPanel;
|
||||
|
||||
public GameObject disassembleButton;
|
||||
public GameObject repairButton;
|
||||
|
||||
public GameObject repairIngredientsPanel;
|
||||
|
||||
public GameObject disassembleIngredientsPanel;
|
||||
|
||||
[Space]
|
||||
[Header ("UI Repair Components")]
|
||||
[Space]
|
||||
@@ -249,6 +269,13 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
public GameObject inventoryPanelListElementPrefab;
|
||||
|
||||
[Space]
|
||||
[Header ("Disassemble Ingredients Components")]
|
||||
[Space]
|
||||
|
||||
public RectTransform disassembleIngredientsPanelList;
|
||||
public GameObject isassembleIngredientsPanelListElementPrefab;
|
||||
|
||||
|
||||
GameObject currentButtonObjectPressed;
|
||||
|
||||
@@ -293,6 +320,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
repairIngredientsPanel.SetActive (false);
|
||||
|
||||
disassembleIngredientsPanel.SetActive (false);
|
||||
|
||||
eventOnShowBlueprintList.Invoke ();
|
||||
|
||||
updateCategoryObjectPanelInfo ();
|
||||
@@ -305,6 +334,17 @@ public class craftingUISystem : ingameMenuPanel
|
||||
disassembleButton.SetActive (false);
|
||||
|
||||
repairButton.SetActive (false);
|
||||
|
||||
setCraftObjectPanelActiveState (true);
|
||||
}
|
||||
|
||||
void setCraftObjectPanelActiveState (bool state)
|
||||
{
|
||||
if (craftObjectPanel != null) {
|
||||
if (craftObjectPanel.activeSelf != state) {
|
||||
craftObjectPanel.SetActive (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Upgrade Functions
|
||||
@@ -733,7 +773,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
eventOnObjectCreated.Invoke (newMessage);
|
||||
|
||||
checkButtonPressed (currentButtonObjectPressed);
|
||||
checkButtonPressedOnEventSystem (currentButtonObjectPressed);
|
||||
|
||||
mainCraftingSystem.checkStateOnCraftObject ();
|
||||
} else {
|
||||
@@ -831,17 +871,37 @@ public class craftingUISystem : ingameMenuPanel
|
||||
foreach (craftingWorkbenchSystem currentWorkbench in craftingWorkbenchSystemList) {
|
||||
if (currentWorkbench.getWorkbenchID () == workbenchID) {
|
||||
if (currentWorkbench.storeCraftedObjectsOnInventoryBank) {
|
||||
currentWorkbench.addInventoryObjectByName (objectName, amountToObtain);
|
||||
bool storeObjectOnWorkbenchResult = true;
|
||||
|
||||
storeObjectOnPlayerInventoryResult = false;
|
||||
if (currentWorkbench.storeCraftedObjectsOnInventoryBankOnlyIfPlayerInventoryIsFull) {
|
||||
if (!mainCraftingSystem.checkIfPlayerInventoryIsFull (objectName, amountToObtain)) {
|
||||
storeObjectOnWorkbenchResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (storeObjectOnWorkbenchResult) {
|
||||
currentWorkbench.addInventoryObjectByName (objectName, amountToObtain);
|
||||
|
||||
storeObjectOnPlayerInventoryResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (currentCraftingWorkbenchSystem.storeCraftedObjectsOnInventoryBank) {
|
||||
currentCraftingWorkbenchSystem.addInventoryObjectByName (objectName, amountToObtain);
|
||||
if (currentCraftingWorkbenchSystem != null && currentCraftingWorkbenchSystem.storeCraftedObjectsOnInventoryBank) {
|
||||
bool storeObjectOnWorkbenchResult = true;
|
||||
|
||||
storeObjectOnPlayerInventoryResult = false;
|
||||
if (currentCraftingWorkbenchSystem.storeCraftedObjectsOnInventoryBankOnlyIfPlayerInventoryIsFull) {
|
||||
if (!mainCraftingSystem.checkIfPlayerInventoryIsFull (objectName, amountToObtain)) {
|
||||
storeObjectOnWorkbenchResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (storeObjectOnWorkbenchResult) {
|
||||
currentCraftingWorkbenchSystem.addInventoryObjectByName (objectName, amountToObtain);
|
||||
|
||||
storeObjectOnPlayerInventoryResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -990,7 +1050,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
eventOnObjectCreated.Invoke (newMessage);
|
||||
|
||||
checkButtonPressed (currentButtonObjectPressed);
|
||||
checkButtonPressedOnEventSystem (currentButtonObjectPressed);
|
||||
}
|
||||
|
||||
craftObjectInTimeInfoList.Remove (newCraftObjectInTimeInfo);
|
||||
@@ -1048,7 +1108,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
{
|
||||
if (showAllCategoriesActive) {
|
||||
if (showingInventoryList) {
|
||||
checkButtonPressed (currentInventoryInfoList [0].buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentInventoryInfoList [0].buttonGameObject);
|
||||
} else {
|
||||
if (useOnlyBlueprintsUnlocked) {
|
||||
for (int i = 0; i < craftingObjectButtonInfoList.Count; i++) {
|
||||
@@ -1056,8 +1116,9 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
if (blueprintsUnlockedList.Contains (currentCraftingInfo.objectName)) {
|
||||
if (isCurrentObjectCategoryAvailable (currentCraftingInfo.objectCategoryName)) {
|
||||
checkButtonPressed (currentCraftingInfo.buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentCraftingInfo.buttonGameObject);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1066,7 +1127,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
craftingObjectButtonInfo currentCraftingInfo = craftingObjectButtonInfoList [i];
|
||||
|
||||
if (isCurrentObjectCategoryAvailable (currentCraftingInfo.objectCategoryName)) {
|
||||
checkButtonPressed (currentCraftingInfo.buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentCraftingInfo.buttonGameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1084,7 +1145,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
if (firstObjectIndexActive == -1 && currentInventoryInfo.buttonGameObject.activeSelf) {
|
||||
if (canObjectBeCreated (currentInventoryInfo.objectCategoryName, currentInventoryInfo.objectName, 1, false)) {
|
||||
checkButtonPressed (currentInventoryInfo.buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentInventoryInfo.buttonGameObject);
|
||||
|
||||
return;
|
||||
} else {
|
||||
@@ -1094,7 +1155,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
}
|
||||
|
||||
if (firstObjectIndexActive != -1) {
|
||||
checkButtonPressed (currentInventoryInfoList [firstObjectIndexActive].buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentInventoryInfoList [firstObjectIndexActive].buttonGameObject);
|
||||
} else {
|
||||
removeObjectPanelInfoContent ();
|
||||
}
|
||||
@@ -1105,7 +1166,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
if (firstObjectIndexActive == -1 && currentCraftingInfo.buttonGameObject.activeSelf) {
|
||||
if (isCurrentObjectCategoryAvailable (currentCraftingInfo.objectCategoryName) &&
|
||||
canObjectBeCreated (currentCraftingInfo.objectCategoryName, currentCraftingInfo.objectName, 1, false)) {
|
||||
checkButtonPressed (currentCraftingInfo.buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (currentCraftingInfo.buttonGameObject);
|
||||
|
||||
return;
|
||||
} else {
|
||||
@@ -1115,7 +1176,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
}
|
||||
|
||||
if (firstObjectIndexActive != -1) {
|
||||
checkButtonPressed (craftingObjectButtonInfoList [firstObjectIndexActive].buttonGameObject);
|
||||
checkButtonPressedOnEventSystem (craftingObjectButtonInfoList [firstObjectIndexActive].buttonGameObject);
|
||||
} else {
|
||||
removeObjectPanelInfoContent ();
|
||||
}
|
||||
@@ -1238,6 +1299,24 @@ public class craftingUISystem : ingameMenuPanel
|
||||
checkButton (buttonObject);
|
||||
}
|
||||
|
||||
void checkButtonPressedOnEventSystem (GameObject buttonObject)
|
||||
{
|
||||
if (buttonObject != null) {
|
||||
|
||||
Button currentButton = buttonObject.GetComponent<Button> ();
|
||||
|
||||
if (currentButton != null) {
|
||||
if (showDebugPrint) {
|
||||
print (buttonObject.name);
|
||||
}
|
||||
|
||||
currentButton.onClick.Invoke ();
|
||||
|
||||
EventSystem.current.SetSelectedGameObject (buttonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkButtonPressed (GameObject buttonObject)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
@@ -1406,6 +1485,7 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
disassembleButton.SetActive (canSetDisassembleUIElementsResult);
|
||||
|
||||
updateDisassembleIngredientsPanel (canSetDisassembleUIElementsResult);
|
||||
|
||||
//check repair UI elements
|
||||
bool canSetRepairUIElementsResult = currentObjectIsBroken;
|
||||
@@ -1454,6 +1534,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
upgradeButton.SetActive (objectCanBeUpgradedResult);
|
||||
}
|
||||
} else {
|
||||
updateDisassembleIngredientsPanel (false);
|
||||
}
|
||||
|
||||
checkIfShowCurrentObjectMesh (true);
|
||||
@@ -1466,6 +1548,72 @@ public class craftingUISystem : ingameMenuPanel
|
||||
if (upgradePanelActive) {
|
||||
updateObjectStatsPanelListInfo ();
|
||||
}
|
||||
|
||||
if (useEventOnShowPressedObjectInfo) {
|
||||
eventOnShowPressedObjectInfo.Invoke ();
|
||||
}
|
||||
|
||||
if (!showingInventoryList) {
|
||||
setCraftObjectPanelActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
void updateDisassembleIngredientsPanel (bool state)
|
||||
{
|
||||
if (state) {
|
||||
disassembleIngredientsPanel.SetActive (true);
|
||||
|
||||
for (int i = 0; i < currentDisassembleIngredientsInfoList.Count; i++) {
|
||||
craftingObjectButtonInfo currentDisassembleIngredientInfo = currentDisassembleIngredientsInfoList [i];
|
||||
|
||||
if (currentDisassembleIngredientInfo.buttonGameObject.activeSelf) {
|
||||
currentDisassembleIngredientInfo.buttonGameObject.SetActive (false);
|
||||
|
||||
currentDisassembleIngredientInfo.objectAssigned = false;
|
||||
}
|
||||
}
|
||||
|
||||
int currentCategoryIndex = craftingBlueprintInfoTemplateDataList.FindIndex (s => s.Name.Equals (currentObjectCategorySelectedName));
|
||||
|
||||
if (currentCategoryIndex > -1) {
|
||||
|
||||
int currentIndex = craftingBlueprintInfoTemplateDataList [currentCategoryIndex].craftingBlueprintInfoTemplateList.FindIndex (s => s.Name.Equals (currentObjectSelectedName));
|
||||
|
||||
if (currentIndex > -1) {
|
||||
currentObjectCanBePlaced = craftingBlueprintInfoTemplateDataList [currentCategoryIndex].craftingBlueprintInfoTemplateList [currentIndex].useObjectToPlace;
|
||||
|
||||
List<craftingIngredientObjectInfo> disassembleIngredientObjectInfoList = craftingBlueprintInfoTemplateDataList [currentCategoryIndex].craftingBlueprintInfoTemplateList [currentIndex].disassembleIngredientObjectInfoList;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("list of ingredients found " + disassembleIngredientObjectInfoList.Count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < disassembleIngredientObjectInfoList.Count; i++) {
|
||||
int currentAmount = mainCraftingSystem.getInventoryObjectAmountByName (disassembleIngredientObjectInfoList [i].Name);
|
||||
|
||||
if (currentAmount < 0) {
|
||||
currentAmount = 0;
|
||||
}
|
||||
|
||||
craftingObjectButtonInfo currentCraftingObjectButtonInfo = currentDisassembleIngredientsInfoList [i];
|
||||
|
||||
currentCraftingObjectButtonInfo.buttonGameObject.SetActive (true);
|
||||
|
||||
currentCraftingObjectButtonInfo.objectAssigned = true;
|
||||
|
||||
currentCraftingObjectButtonInfo.objectNameText.text = disassembleIngredientObjectInfoList [i].Name;
|
||||
|
||||
currentCraftingObjectButtonInfo.objectImage.texture = mainCraftingSystem.getInventoryObjectIconByName (disassembleIngredientObjectInfoList [i].Name);
|
||||
|
||||
currentCraftingObjectButtonInfo.amountAvailableToCreateText.text =
|
||||
(disassembleIngredientObjectInfoList [i].amountRequired.ToString ());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disassembleIngredientsPanel.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool canObjectBePlaced (string objectCategoryName, string objectName)
|
||||
@@ -1522,6 +1670,16 @@ public class craftingUISystem : ingameMenuPanel
|
||||
currentObjectDescriptionText.text = "";
|
||||
|
||||
currentObjectSelectedImage.texture = null;
|
||||
|
||||
if (showingInventoryList) {
|
||||
disassembleButton.SetActive (false);
|
||||
|
||||
repairButton.SetActive (false);
|
||||
|
||||
placeObjectButton.SetActive (false);
|
||||
} else {
|
||||
setCraftObjectPanelActiveState (false);
|
||||
}
|
||||
}
|
||||
|
||||
void updateRepairIngredientsPanelListInfo ()
|
||||
@@ -1774,6 +1932,10 @@ public class craftingUISystem : ingameMenuPanel
|
||||
currentList [i].buttonGameObject.SetActive (setActiveResult);
|
||||
}
|
||||
}
|
||||
|
||||
if (useEventOnShowObjectPanelInfo) {
|
||||
eventOnShowObjectPanelInfo.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void initializeMenuPanel ()
|
||||
@@ -1801,7 +1963,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
}
|
||||
}
|
||||
|
||||
public void setOpenFromWorkbenchState (bool state, List<string> newObjectCategoriesToCraftAvailableOnCurrentBench)
|
||||
public void setOpenFromWorkbenchState (bool state, List<string> newObjectCategoriesToCraftAvailableOnCurrentBench,
|
||||
bool allowToCraftAllObjectsOnCurrentBenchValue)
|
||||
{
|
||||
if (menuOpenedFromWorkbench == state) {
|
||||
return;
|
||||
@@ -1809,6 +1972,8 @@ public class craftingUISystem : ingameMenuPanel
|
||||
|
||||
menuOpenedFromWorkbench = state;
|
||||
|
||||
allowToCraftAllObjectsOnCurrentBench = allowToCraftAllObjectsOnCurrentBenchValue;
|
||||
|
||||
if (menuOpenedFromWorkbench) {
|
||||
objectCategoriesToCraftAvailableOnCurrentBench = newObjectCategoriesToCraftAvailableOnCurrentBench;
|
||||
} else {
|
||||
@@ -2141,6 +2306,17 @@ public class craftingUISystem : ingameMenuPanel
|
||||
currentCraftObjectInTimeInfoList.Add (currentCraftingObjectButtonInfo);
|
||||
}
|
||||
|
||||
for (int i = 0; i < amountOfDisassembleIngredientsToSpawn; i++) {
|
||||
GameObject newButton = (GameObject)Instantiate (isassembleIngredientsPanelListElementPrefab, Vector3.zero, Quaternion.identity, disassembleIngredientsPanelList);
|
||||
|
||||
newButton.transform.localScale = Vector3.one;
|
||||
newButton.transform.localPosition = Vector3.zero;
|
||||
|
||||
craftingObjectButtonInfo currentCraftingObjectButtonInfo = newButton.GetComponent<craftingObjectButtonInfo> ();
|
||||
|
||||
currentDisassembleIngredientsInfoList.Add (currentCraftingObjectButtonInfo);
|
||||
}
|
||||
|
||||
UIElementSpawned = true;
|
||||
}
|
||||
}
|
||||
@@ -2182,9 +2358,15 @@ public class craftingUISystem : ingameMenuPanel
|
||||
return true;
|
||||
} else {
|
||||
if (menuOpenedFromWorkbench) {
|
||||
if (objectCategoriesToCraftAvailableOnCurrentBench.Count > 0) {
|
||||
if (objectCategoriesToCraftAvailableOnCurrentBench.Contains (categoryName)) {
|
||||
return true;
|
||||
if (allowToCraftAllObjectsOnCurrentBench) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (objectCategoriesToCraftAvailableOnCurrentBench != null) {
|
||||
if (objectCategoriesToCraftAvailableOnCurrentBench.Count > 0) {
|
||||
if (objectCategoriesToCraftAvailableOnCurrentBench.Contains (categoryName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user