This commit is contained in:
Anonymous Raccoon
2018-08-13 12:01:21 +02:00
parent 86c51f7e79
commit 6a0b647fdd
5 changed files with 144 additions and 18 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+88
View File
@@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: 15e9c50c00f46904e9b25a24bfaa07e7
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
+32 -2
View File
@@ -13089,7 +13089,7 @@ MonoBehaviour:
- {fileID: 292199874}
- {fileID: 798873072}
items:
- type: 1
- type: 3
description: LE POKETEXTE OUIIIIIIIII
icon: {fileID: 21300000, guid: 1a3fcd6f2906efa41923bcca16b00933, type: 3}
tiles:
@@ -13109,6 +13109,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: ca64649711c32e045acc87a7b826744b, type: 2}
- {fileID: 11400000, guid: 802eedf913287cc4596701ec2a9c034e, type: 2}
- {fileID: 0}
canOverrideTree: 0
canBePlacedOn: 1
count: 0
- type: 0
description:
@@ -13130,8 +13132,10 @@ MonoBehaviour:
- {fileID: 11400000, guid: c2990fc2c1e85b84b8bb7b8ce8e0a1c6, type: 2}
- {fileID: 11400000, guid: af72725ced11a594f8d5bc859c9a25f0, type: 2}
- {fileID: 11400000, guid: b37f3e5d6ce1f044dbdc9fa665c7041a, type: 2}
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
- type: 4
description:
icon: {fileID: 21300000, guid: ea8d23bb37b53c9459b9d37b980d9ebf, type: 3}
tiles:
@@ -13151,6 +13155,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 9cb1415fe0889b34b85613c01a46b855, type: 2}
- {fileID: 11400000, guid: f9daa4e1889a5c94eb3bc185cb5f6fb3, type: 2}
- {fileID: 0}
canOverrideTree: 8
canBePlacedOn: 3
count: 0
- type: 0
description:
@@ -13172,6 +13178,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: e1695f67b739bf443b93716fadeb206e, type: 2}
- {fileID: 11400000, guid: 55c50fef1803b224d9b32a7a3ed9fb86, type: 2}
- {fileID: 0}
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
@@ -13193,6 +13201,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 2f5bb6339b119ee47930776f411ce4e3, type: 2}
- {fileID: 11400000, guid: e4aa9d2fd8a0726488dc847599ec3991, type: 2}
- {fileID: 0}
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
@@ -13214,6 +13224,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 119c16f591540494f873ab8c65a59a0a, type: 2}
- {fileID: 11400000, guid: 77555c2999367d9428a207ba9b2cddd4, type: 2}
- {fileID: 0}
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
@@ -13235,46 +13247,64 @@ MonoBehaviour:
- {fileID: 11400000, guid: 243ae876f400f2c42a3ba557e0a451ef, type: 2}
- {fileID: 11400000, guid: fd076919d896a0e458ac9a145833807b, type: 2}
- {fileID: 0}
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
- type: 0
description:
icon: {fileID: 0}
tiles: []
canOverrideTree: 0
canBePlacedOn: 0
count: 0
plots:
- type: 17
+22 -16
View File
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.Tilemaps;
public class InventoryManager : MonoBehaviour
@@ -26,13 +25,13 @@ public class InventoryManager : MonoBehaviour
if (draggedPosition != -1)
{
slots[draggedPosition].transform.GetChild(1).position = Input.mousePosition;
DisplaySelector(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, selectorMap.transform.parent.position.z)));
DisplaySelector(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, selectorMap.transform.parent.position.z)), items[draggedPosition]);
}
}
else if(draggedPosition != -1)
{
HideSelector(selectorPos);
if (CanPlantAt(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, treeMap.transform.parent.position.z))))
if (CanPlantAt(cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, treeMap.transform.parent.position.z)), items[draggedPosition]))
{
PlaceTree(items[draggedPosition], cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, treeMap.transform.parent.position.z)));
items[draggedPosition].count -= 1;
@@ -46,12 +45,12 @@ public class InventoryManager : MonoBehaviour
}
}
private bool CanPlantAt(Vector3 position)
private bool CanPlantAt(Vector3 position, TreeItem item)
{
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)].type & PlotType.Normal) != 0)
if (GetPlotIndex(pos) != -1 && plots[GetPlotIndex(pos)].treePlaced == TreeType.Nothing && (plots[GetPlotIndex(pos)].type & item.canBePlacedOn) != 0)
{
return true;
}
@@ -80,15 +79,22 @@ public class InventoryManager : MonoBehaviour
i++;
}
}
//switch (item.type)
//{
// case TreeType.AppleTree:
// break;
// default:
// break;
//}
switch (item.type)
{
case TreeType.AppleTree:
break;
default:
break;
}
CallPowers();
}
private void CallPowers()
{
}
public void StartDraggin(int index)
@@ -107,7 +113,7 @@ public class InventoryManager : MonoBehaviour
// }
//}
private void DisplaySelector(Vector3 position)
private void DisplaySelector(Vector3 position, TreeItem item)
{
Vector3Int pos = selectorMap.WorldToCell(position);
Vector2Int plotPos = GetPlotPosition(pos);
@@ -123,7 +129,7 @@ public class InventoryManager : MonoBehaviour
if (plotPos.x == 999 || plotPos.y == 999)
return;
bool canPlant = CanPlantAt(position);
bool canPlant = CanPlantAt(position, item);
selectorPos = plotPos;
int i = -1;
for (int y = 0; y > -4; y--)
+2
View File
@@ -8,6 +8,8 @@ public class TreeItem
public string description;
public Sprite icon;
public TileBase[] tiles = new TileBase[16];
[EnumFlags] public TreeType canOverrideTree;
[EnumFlags] public PlotType canBePlacedOn;
public int count;
}