mirror of
https://github.com/zoriya/Magical-Garden.git
synced 2025-12-06 07:16:15 +00:00
Merge branch 'master' of https://github.com/AnonymusRaccoon/New-Unity-Project
This commit is contained in:
@@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.37311992, g: 0.38074034, b: 0.35872713, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@@ -8659,6 +8659,162 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1472403156812664, guid: 89e9215b05511f648b3306ce05aae35f,
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 718058456}
|
||||
--- !u!1 &972967526
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 972967527}
|
||||
- component: {fileID: 972967529}
|
||||
- component: {fileID: 972967528}
|
||||
m_Layer: 5
|
||||
m_Name: Turn Count
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &972967527
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 972967526}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 2138102597}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 215.23999, y: 50}
|
||||
m_SizeDelta: {x: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &972967528
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 972967526}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_text: 'Turn: 01'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: ec3cd6eedf31b8240acafae391fca301, type: 2}
|
||||
m_sharedMaterial: {fileID: 21461864525935096, guid: ec3cd6eedf31b8240acafae391fca301,
|
||||
type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_outlineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4278190080
|
||||
m_fontSize: 36
|
||||
m_fontSizeBase: 36
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_textAlignment: 514
|
||||
m_isAlignmentEnumConverted: 1
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_firstOverflowCharacterIndex: -1
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
m_isLinkedTextComponent: 0
|
||||
m_isTextTruncated: 0
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_ignoreRectMaskCulling: 0
|
||||
m_ignoreCulling: 1
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_firstVisibleCharacter: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_textInfo:
|
||||
textComponent: {fileID: 972967528}
|
||||
characterCount: 8
|
||||
spriteCount: 0
|
||||
spaceCount: 1
|
||||
wordCount: 2
|
||||
linkCount: 0
|
||||
lineCount: 1
|
||||
pageCount: 1
|
||||
materialCount: 1
|
||||
m_havePropertiesChanged: 0
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_spriteAnimator: {fileID: 0}
|
||||
m_isInputParsingRequired: 0
|
||||
m_inputSource: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_subTextObjects:
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
- {fileID: 0}
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!222 &972967529
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 972967526}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &997557026
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -13271,6 +13427,7 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 8078b45f9a3232446956ed5fdd47ddb8, type: 2}
|
||||
- {fileID: 11400000, guid: 8078b45f9a3232446956ed5fdd47ddb8, type: 2}
|
||||
- {fileID: 11400000, guid: 372baa95be60a3c479f80c3e34781e9d, type: 2}
|
||||
turnCount: {fileID: 972967528}
|
||||
slots:
|
||||
- {fileID: 793124532}
|
||||
- {fileID: 1181635282}
|
||||
@@ -13309,9 +13466,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: ca64649711c32e045acc87a7b826744b, type: 2}
|
||||
- {fileID: 11400000, guid: 802eedf913287cc4596701ec2a9c034e, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 1
|
||||
count: 0
|
||||
maxInstanceForWin: 8
|
||||
- type: 2
|
||||
description:
|
||||
icon: {fileID: 21300000, guid: 7467489d95ee4604690203dd25ef1061, type: 3}
|
||||
@@ -13333,9 +13490,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: c2990fc2c1e85b84b8bb7b8ce8e0a1c6, type: 2}
|
||||
- {fileID: 11400000, guid: af72725ced11a594f8d5bc859c9a25f0, type: 2}
|
||||
- {fileID: 11400000, guid: b37f3e5d6ce1f044dbdc9fa665c7041a, type: 2}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 16
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 3
|
||||
description: This tree got super fast metabolism witch allow it to replicate himself
|
||||
very quicly
|
||||
@@ -13358,10 +13515,10 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 9cb1415fe0889b34b85613c01a46b855, type: 2}
|
||||
- {fileID: 11400000, guid: f9daa4e1889a5c94eb3bc185cb5f6fb3, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 3
|
||||
count: 0
|
||||
- type: 0
|
||||
maxInstanceForWin: 10
|
||||
- type: 4
|
||||
description:
|
||||
icon: {fileID: 21300000, guid: bd94c803c8d0053459513209a51b6626, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 024f54f424e5378489e582232317a8f1, type: 3}
|
||||
@@ -13382,9 +13539,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: e1695f67b739bf443b93716fadeb206e, type: 2}
|
||||
- {fileID: 11400000, guid: 55c50fef1803b224d9b32a7a3ed9fb86, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 5
|
||||
description: This tree swap it's position with it's surrounding tree
|
||||
icon: {fileID: 21300000, guid: 632fdd0b5928dfc40b00b5cb328dab12, type: 3}
|
||||
@@ -13406,10 +13563,10 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 2f5bb6339b119ee47930776f411ce4e3, type: 2}
|
||||
- {fileID: 11400000, guid: e4aa9d2fd8a0726488dc847599ec3991, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 1
|
||||
count: 0
|
||||
- type: 0
|
||||
maxInstanceForWin: 4
|
||||
- type: 6
|
||||
description:
|
||||
icon: {fileID: 21300000, guid: c456bf1a77abe7f4a976c2730660784a, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: d994c9c58127290458278a8461e10c96, type: 3}
|
||||
@@ -13430,9 +13587,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 119c16f591540494f873ab8c65a59a0a, type: 2}
|
||||
- {fileID: 11400000, guid: 77555c2999367d9428a207ba9b2cddd4, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: -1
|
||||
canBePlacedOn: 32
|
||||
count: 0
|
||||
maxInstanceForWin: 2
|
||||
- type: 7
|
||||
description: This dry treedesperately need water
|
||||
icon: {fileID: 21300000, guid: 435e6a6ec8a286642b6e3d806a4df4a2, type: 3}
|
||||
@@ -13454,9 +13611,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 243ae876f400f2c42a3ba557e0a451ef, type: 2}
|
||||
- {fileID: 11400000, guid: fd076919d896a0e458ac9a145833807b, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 16
|
||||
count: 0
|
||||
maxInstanceForWin: 5
|
||||
- type: 8
|
||||
description: This tree canboth be placed on dry tile and regular tile
|
||||
icon: {fileID: 21300000, guid: 3db57d319be56e549bcab5adcebba956, type: 3}
|
||||
@@ -13478,65 +13635,65 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: e42074b508e12604b930ba296aebfb7e, type: 2}
|
||||
- {fileID: 11400000, guid: 479a6c0ea55dd864aa07a48020a25d5d, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 3
|
||||
count: 0
|
||||
maxInstanceForWin: 8
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 0
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
iconGris: {fileID: 0}
|
||||
icon: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
iconGris: {fileID: 21300000, guid: 52d3d999fa1532f49a760c8bf33124ab, type: 3}
|
||||
tiles: []
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
- type: 16
|
||||
description:
|
||||
icon: {fileID: 0}
|
||||
@@ -13558,9 +13715,9 @@ MonoBehaviour:
|
||||
- {fileID: 11400000, guid: 64e7875e478cd274a858b5612237db49, type: 2}
|
||||
- {fileID: 11400000, guid: 64668e68641695d4fb75f355287379c1, type: 2}
|
||||
- {fileID: 0}
|
||||
canOverrideTree: 0
|
||||
canBePlacedOn: 0
|
||||
count: 0
|
||||
maxInstanceForWin: 0
|
||||
plots:
|
||||
- type: 17
|
||||
treePlaced: 0
|
||||
@@ -13650,9 +13807,9 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b4b4a071451fb1c47af7fedbbf6a4179, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
difficulte: 3
|
||||
MinArbre: 1
|
||||
MaxArbre: 5
|
||||
difficulte: 5
|
||||
minDrop: 1
|
||||
itemDrop: 5
|
||||
--- !u!1 &1774186325 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1472403156812664, guid: 89e9215b05511f648b3306ce05aae35f,
|
||||
@@ -14363,6 +14520,7 @@ RectTransform:
|
||||
- {fileID: 1827063419}
|
||||
- {fileID: 1475634575}
|
||||
- {fileID: 1169353275}
|
||||
- {fileID: 972967527}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class InventoryManager : MonoBehaviour
|
||||
public Tilemap treeMap;
|
||||
public Tilemap selectorMap;
|
||||
public TileBase[] selector;
|
||||
public TextMeshProUGUI turnCount;
|
||||
|
||||
[Space]
|
||||
public GameObject[] slots;
|
||||
@@ -47,7 +48,7 @@ public class InventoryManager : MonoBehaviour
|
||||
items[draggedPosition].count -= 1;
|
||||
slots[draggedPosition].transform.GetChild(1).position = defaultPos;
|
||||
TextMeshProUGUI CompteurItem = slots[draggedPosition].GetComponentInChildren<TextMeshProUGUI>();
|
||||
CompteurItem.text = items[draggedPosition].count.ToString();
|
||||
CompteurItem.text = items[draggedPosition].count.ToString().Length < 10 ? "0" + items[draggedPosition].count.ToString() : items[draggedPosition].count.ToString();
|
||||
if (items[draggedPosition].count < 1)
|
||||
{
|
||||
slots[draggedPosition].transform.GetChild(1).GetComponent<Image>().sprite = items[draggedPosition].iconGris;
|
||||
@@ -66,7 +67,7 @@ public class InventoryManager : MonoBehaviour
|
||||
Vector3Int pos = treeMap.WorldToCell(position);
|
||||
if (-8 <= pos.x && pos.x <= 11 && -15 <= pos.y && pos.y <= 4)
|
||||
{
|
||||
if (GetPlotIndex(pos) != -1 && (plots[GetPlotIndex(pos)].treePlaced == TreeType.Nothing || (plots[GetPlotIndex(pos)].treePlaced & item.canOverrideTree) != 0) && (plots[GetPlotIndex(pos)].type & item.canBePlacedOn) != 0)
|
||||
if (GetPlotIndex(pos) != -1 && plots[GetPlotIndex(pos)].treePlaced == TreeType.Nothing && (plots[GetPlotIndex(pos)].type & item.canBePlacedOn) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -279,6 +280,27 @@ public class InventoryManager : MonoBehaviour
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
else if (plots[i].treePlaced == TreeType.GluttonTree)
|
||||
{
|
||||
List<int> plot = new List<int>();
|
||||
|
||||
if (i - 1 >= 0 && i % 5 != 0 && plots[i - 1].treePlaced != TreeType.Nothing)
|
||||
plot.Add(i - 1);
|
||||
if (i + 1 <= 24 && i % 5 != 4 && plots[i + 1].treePlaced != TreeType.Nothing)
|
||||
plot.Add(i + 1);
|
||||
if (i - 5 >= 0 && plots[i - 5].treePlaced != TreeType.Nothing)
|
||||
plot.Add(i - 5);
|
||||
if (i + 5 <= 24 && plots[i + 5].treePlaced != TreeType.Nothing)
|
||||
plot.Add(i + 5);
|
||||
|
||||
if (plot.Count > 0)
|
||||
{
|
||||
foreach(int index in plot)
|
||||
PlaceTree(items[(int)TreeType.Trunk - 1], index);
|
||||
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UserHasWon())
|
||||
@@ -289,6 +311,9 @@ public class InventoryManager : MonoBehaviour
|
||||
|
||||
private bool UserHasWon()
|
||||
{
|
||||
int turn = int.Parse(turnCount.text.Substring(5)) + 1;
|
||||
turnCount.text = "Turn: " + (turn < 10 ? "0" + turn.ToString() : turn.ToString());
|
||||
GetComponent<Pokedex>().UpdateMissionText();
|
||||
foreach (KeyValuePair<TreeType, int> pair in GetComponent<Mission>().Objectifs)
|
||||
{
|
||||
if (plots.Count(x => x.treePlaced == pair.Key) < pair.Value)
|
||||
@@ -299,12 +324,34 @@ public class InventoryManager : MonoBehaviour
|
||||
|
||||
public void StartDraggin(int index)
|
||||
{
|
||||
//if(items[index].count > 0)
|
||||
//{
|
||||
if (items[index].count > 0)
|
||||
{
|
||||
slots[index].transform.SetAsLastSibling();
|
||||
draggedPosition = index;
|
||||
defaultPos = slots[draggedPosition].transform.position;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
for (int i = 0; i < slots.Length; i++)
|
||||
{
|
||||
slots[i].GetComponentInChildren<TextMeshProUGUI>().text = items[i].count.ToString().Length < 10 ? "0" + items[i].count.ToString(): items[i].count.ToString();
|
||||
if(items[i].count == 0)
|
||||
slots[i].transform.GetChild(1).GetComponent<Image>().sprite = items[i].iconGris;
|
||||
else
|
||||
slots[i].transform.GetChild(1).GetComponent<Image>().sprite = items[i].icon;
|
||||
}
|
||||
}
|
||||
|
||||
public int TreePlaced(TreeType type)
|
||||
{
|
||||
int x = 0;
|
||||
foreach (Plot plot in plots)
|
||||
if (plot.treePlaced == type)
|
||||
x++;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
//public void AddItem(TreeItem item)
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class Mission : MonoBehaviour {
|
||||
|
||||
string Missiontext = null;
|
||||
TreeItem[] items;
|
||||
public float difficulte;
|
||||
public int minDrop;
|
||||
public int itemDrop;
|
||||
public Dictionary<TreeType, int> Objectifs = new Dictionary<TreeType, int>();
|
||||
public int MinArbre = 1;
|
||||
public int MaxArbre = 10;
|
||||
private void Start()
|
||||
{
|
||||
items = GetComponent<InventoryManager>().items;
|
||||
@@ -30,28 +27,63 @@ public class Mission : MonoBehaviour {
|
||||
}
|
||||
|
||||
}
|
||||
public void GenerateMission()
|
||||
private void GenerateMission()
|
||||
{
|
||||
|
||||
for (int i = 0; i < difficulte; i++)
|
||||
{
|
||||
Objectifs.Add(ChoisirUnTypeDarbre(), Random.Range(MinArbre, MaxArbre));
|
||||
AddTree();
|
||||
}
|
||||
string mission = null;
|
||||
foreach (KeyValuePair<TreeType,int> i in Objectifs)
|
||||
{
|
||||
Missiontext = Missiontext + "Place: " + i.Value + " " + i.Key.ToString() +"\n";
|
||||
mission = mission + "Place: " + i.Value + " " + i.Key.ToString() +"\n";
|
||||
}
|
||||
|
||||
GiveTrees();
|
||||
}
|
||||
|
||||
private void GiveTrees()
|
||||
{
|
||||
InventoryManager manager = GetComponent<InventoryManager>();
|
||||
for (int i = 0; i < manager.items.Length; i++)
|
||||
{
|
||||
if (manager.items[i].type == TreeType.Nothing)
|
||||
continue;
|
||||
|
||||
manager.items[i].count = Random.Range(minDrop, itemDrop);
|
||||
|
||||
if (Objectifs.ContainsKey(manager.items[i].type))
|
||||
{
|
||||
int minCount;
|
||||
Objectifs.TryGetValue(manager.items[i].type, out minCount);
|
||||
if(manager.items[i].count < minCount)
|
||||
manager.items[i].count += minCount;
|
||||
|
||||
}
|
||||
}
|
||||
manager.UpdateUI();
|
||||
}
|
||||
|
||||
public string GetMissionText()
|
||||
{
|
||||
return Missiontext;
|
||||
string mission = null;
|
||||
foreach (KeyValuePair<TreeType, int> i in Objectifs)
|
||||
{
|
||||
mission = mission + "Place: " + i.Value + " " + i.Key.ToString() + " (" + (i.Value - GetComponent<InventoryManager>().TreePlaced(i.Key)) + " Left)\n";
|
||||
}
|
||||
return mission;
|
||||
}
|
||||
|
||||
public TreeType ChoisirUnTypeDarbre()
|
||||
private void AddTree()
|
||||
{
|
||||
TreeType arbre = items.Where(x => !Objectifs.ContainsKey(x.type) && x.type != TreeType.Nothing).ToArray()[Random.Range(0, items.Where(x => !Objectifs.ContainsKey(x.type) && x.type != TreeType.Nothing).ToArray().Length)].type;
|
||||
return arbre;
|
||||
TreeItem[] trees = items.Where(x => !Objectifs.ContainsKey(x.type) && x.type != TreeType.Nothing).ToArray();
|
||||
if (trees.Length > 0)
|
||||
{
|
||||
int i = Random.Range(0, trees.Length);
|
||||
TreeType type = trees[i].type;
|
||||
int number = Random.Range(items[i].maxInstanceForWin / 2, items[i].maxInstanceForWin);
|
||||
Objectifs.Add(type, number);
|
||||
}
|
||||
}
|
||||
|
||||
public void HasWon()
|
||||
|
||||
@@ -9,20 +9,20 @@ public class TreeItem
|
||||
public Sprite icon;
|
||||
public Sprite iconGris;
|
||||
public TileBase[] tiles = new TileBase[16];
|
||||
[EnumFlags] public TreeType canOverrideTree;
|
||||
[EnumFlags] public PlotType canBePlacedOn;
|
||||
public int count;
|
||||
public int maxInstanceForWin;
|
||||
}
|
||||
|
||||
public enum TreeType
|
||||
{
|
||||
Nothing,
|
||||
AppleTree,
|
||||
ChameleonTree,
|
||||
TribbleTree,
|
||||
Unamed0,
|
||||
SwapTree,
|
||||
TribbleTree,
|
||||
Unamed1,
|
||||
SwapTree,
|
||||
GluttonTree,
|
||||
ThirstyTree,
|
||||
Cactus,
|
||||
Trunk = 16
|
||||
|
||||
Reference in New Issue
Block a user