Items effects template

This commit is contained in:
kabix09 2022-12-22 03:38:00 +01:00
parent 2591ed3e74
commit a84dcf0dcb
26 changed files with 10407 additions and 35 deletions

View File

@ -16,8 +16,13 @@ MonoBehaviour:
name: Chestplate
description:
level: 1
value: 0
image: {fileID: 4404702397685382865, guid: 52aa424fe853b154a95a8f677de1a275, type: 3}
itemModel: {fileID: 8687962458953192462, guid: ae7e7f7d0d926174a8edae16f7f4d305, type: 3}
price: 0
useEffect:
m_PersistentCalls:
m_Calls: []
StrengthBonus: 0
AgilityBonus: 0
InteligenceBonus: 0

View File

@ -16,8 +16,25 @@ MonoBehaviour:
name: Pickaxe
description:
level: 1
value: 0
image: {fileID: 8959118705387878318, guid: 25e473b59d2d7534e803be0a2825e0f7, type: 3}
itemModel: {fileID: 9081071845930167562, guid: 0bccd32818043074d9785f6d90ebdcb3, type: 3}
price: 0
useEffect:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
StrengthBonus: 5
AgilityBonus: 0
InteligenceBonus: 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -42476,6 +42476,69 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1327986481}
m_CullTransparentMesh: 1
--- !u!1 &1367266905
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1367266906}
- component: {fileID: 1367266908}
- component: {fileID: 1367266907}
m_Layer: 0
m_Name: ItemActionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1367266906
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367266905}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1602706375}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1367266907
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367266905}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 465d2a23e8d8ff0469cc1c2d210721b8, type: 3}
m_Name:
m_EditorClassIdentifier:
itemEvent:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1367266908
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1367266905}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 951d8a52404400448801ddc260a9d1d0, type: 3}
m_Name:
m_EditorClassIdentifier:
itemEvent:
m_PersistentCalls:
m_Calls: []
--- !u!1 &1374645920
GameObject:
m_ObjectHideFlags: 0
@ -43520,6 +43583,7 @@ Transform:
- {fileID: 1273555370}
- {fileID: 121907411}
- {fileID: 279975746}
- {fileID: 1367266906}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -28700,6 +28700,7 @@ Transform:
- {fileID: 2042768023}
- {fileID: 543241739}
- {fileID: 100013501}
- {fileID: 1565604591}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -31773,6 +31774,70 @@ Tilemap:
e31: 0
e32: 0
e33: 1
--- !u!1 &1565604590
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1565604591}
- component: {fileID: 1565604592}
- component: {fileID: 1565604593}
m_Layer: 0
m_Name: ItemActionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1565604591
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1565604590}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1144548810}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1565604592
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1565604590}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 951d8a52404400448801ddc260a9d1d0, type: 3}
m_Name:
m_EditorClassIdentifier:
itemEvent:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1565604593
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1565604590}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 465d2a23e8d8ff0469cc1c2d210721b8, type: 3}
m_Name:
m_EditorClassIdentifier:
itemEvent:
m_PersistentCalls:
m_Calls: []
Instance: {fileID: 0}
--- !u!1 &1565887880
GameObject:
m_ObjectHideFlags: 0
@ -38193,7 +38258,9 @@ MonoBehaviour:
- ChestName: Wooden 2
ChestPrefab: {fileID: 3972494989842158579, guid: 7e5ccad877bb9da41a844878dab01357, type: 3}
Position: {x: 5.85, y: -6, z: 10}
Content: []
Content:
- Key: 0
Value: {fileID: 11400000, guid: 43fcc69d78c8c3847bbedde817f35b45, type: 2}
convertedData: []
--- !u!1 &2063226728
GameObject:

View File

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5230e28d0bc75e741bd830f82054f898
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 923bb8fb9e5fe7d408b61bf1d244f2d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
public class ItemEffectsManager : MonoBehaviour
{
public static ItemEffectsManager Instance { get; private set; }
public UseItemEvent itemEvent;
public virtual void Awake()
{
if(Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public virtual void UseItemEffect(ItemSlot itemSlot, PanelTypeEnum originPanel)
{
DetectItemActionGroup(itemSlot, originPanel);
// origin panel is passed for script to be able to recognize from witch list remove object etc...
// use other actions binded to item - not here becaues here item should be removed from chest xd
}
public void DetectItemActionGroup(ItemSlot itemSlot, PanelTypeEnum originPanel)
{
var type = itemSlot?.Item.EquipmentType;
switch (type)
{
case EquipmentTypeEnum.Potion:
{
(PotionEffectsManager.Instance).UseItemEffect(itemSlot, originPanel);
break;
}
default:
{
Debug.LogError($"Event for item of type - {type} - is not implemented");
break;
}
// TODO add case for next type to handle action for other items ;)
}
}
public UIWarehouseManager DetectOriginPanel(PanelTypeEnum originPanel)
{
// don't handle other types because there effects aren't allowed (and source class type is different xd - complicated)
switch(originPanel)
{
case PanelTypeEnum.Inventory:
{
return InventoryUIManager.Instance;
}
case PanelTypeEnum.Equippment:
{
return EquipmentUIManager.Instance;
}
default:
{
Debug.LogError($"Event for item of type - {originPanel} - is not implemented");
break;
}
}
return UIWarehouseManager.Instance;
}
}

View File

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

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
class PotionEffectsManager : ItemEffectsManager
{
public static new PotionEffectsManager Instance;
public override void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
public override void UseItemEffect(ItemSlot itemSlot, PanelTypeEnum originPanel)
{
// origin panel is passed for script to be able to recognize from witch list remove object etc...
DetectPotionType();
// use other actions binded to item 2
itemSlot.Item?.InvokeEffectAction();
// remove potion from slot in specific panel...
var panelUiManager = DetectOriginPanel(originPanel);
panelUiManager.RemoveByPosition(itemSlot.Number);
panelUiManager.UpdateList(); // refresh view
}
public void DetectPotionType()
{
// detect potion and use mached action
// if( ... )
// Health....Potion();
}
// use below function in one above - depending on the condition
public void HealthBigPotion()
{
}
public void HealthSmallPotion()
{
}
// Add and invoke you own functions
}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cc2864990a42156428f28b03e83c69dd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.Events;
[Serializable]
public class UseItemEvent : UnityEvent<ItemSlot> { }
[Serializable]
public class UseItemFromPanelEvent : UnityEvent<ItemSlot, PanelTypeEnum> { }

View File

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

View File

@ -7,6 +7,8 @@ using UnityEngine.UI;
public abstract class DraggablePanelController : PanelController<IndexValuePair<int, EquippableItem>>, DraggablePanelInterface
{
protected PanelTypeEnum Type = PanelTypeEnum.None;
public bool AllowToUseItemInPanel = true;
[SerializeField] protected new List<ISlot> ChildBoxList = new List<ISlot>();

View File

@ -28,8 +28,12 @@ public abstract class WarehousePanelController : DraggablePanelController
public override void DoubleLeftMouseClick(ItemSlot itemSlot)
{
Debug.Log("Used item");
if(AllowToUseItemInPanel)
itemSlot.Item?.InvokeEffectAction();
{
ItemEffectsManager.Instance.UseItemEffect(itemSlot, Type);
}
//itemSlot.Item?.InvokeEffectAction();
}

View File

@ -8,6 +8,7 @@ using System;
public class ChestPanelController : WarehousePanelController
{
protected override UIBaseManager<IndexValuePair<int, EquippableItem>> FetchUiManager()
{
return GameObject.FindObjectOfType<ChestContentUIManager>();
@ -26,6 +27,8 @@ public class ChestPanelController : WarehousePanelController
private void Start()
{
AllowToUseItemInPanel = false;
Type = PanelTypeEnum.Chest;
}
// 1. Prepare empty panel

View File

@ -14,6 +14,12 @@ public class EquipmentPanelController : DraggablePanelController
return GameObject.FindObjectOfType<EquipmentUIManager>();
}
private void Start()
{
AllowToUseItemInPanel = false;
Type = PanelTypeEnum.Shop;
}
public override void BuildPanelSlots()
{
InitSlotsList();

View File

@ -8,6 +8,12 @@ using System;
public class InventoryPanelController : WarehousePanelController
{
public void Start()
{
AllowToUseItemInPanel = true;
Type = PanelTypeEnum.Inventory;
}
protected override UIBaseManager<IndexValuePair<int, EquippableItem>> FetchUiManager()
{
var uiManager = GameObject.FindObjectOfType<InventoryUIManager>();

View File

@ -26,6 +26,7 @@ public class ShopPanelController : WarehousePanelController
private void Start()
{
AllowToUseItemInPanel = false;
Type = PanelTypeEnum.Shop;
}
// 1. Prepare empty panel

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
[Serializable]
public enum PanelTypeEnum
{
None,
Inventory,
Equippment,
Chest,
Shop
}

View File

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

View File

@ -108,4 +108,10 @@ public class Item : ScriptableObject
Debug.Log($"Use {name} effect");
useEffect.Invoke();
}
public void InvokeEffectAction(int slotNumber)
{
Debug.Log($"Use {name} effect");
useEffect.Invoke();
}
}