1
Fork 0

Update things

This commit is contained in:
Steffo 2019-04-28 14:11:21 +02:00
parent 013c9da7ae
commit ce348545df
28 changed files with 295 additions and 30 deletions

View file

@ -82,21 +82,27 @@ MonoBehaviour:
maxRoomIterations: 100
floorSprites:
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- {fileID: 21300000, guid: fa4c9841fd8a5fb4f94ff78c95301065, type: 3}
topWallSprites:
- {fileID: 21300000, guid: a6548c20c0b36384f9ba55aac5cd513d, type: 3}
- {fileID: 21300000, guid: de53d30fbdcfc2e458577832376fddc7, type: 3}
- {fileID: 0}
botWallSprites:
- {fileID: 21300000, guid: 9c493dd4f06f0e6448ca0485a0aec85b, type: 3}
- {fileID: 21300000, guid: 9f7113f83f58bbc4b80539190bfc99b8, type: 3}
- {fileID: 21300000, guid: 82ccea6ce8f2edf4cae6f99e1127b0c3, type: 3}
leftWallSprites:
- {fileID: 21300000, guid: 1c1ab193bd23fde40a1d3400075ccd26, type: 3}
- {fileID: 0}
rightWallSprites:
- {fileID: 21300000, guid: 47816dfcc9e4290499aa0189a04a5560, type: 3}
- {fileID: 0}
lCornerWallSprites:
- {fileID: 21300000, guid: 1f464248b697d4b459679fd8c4215983, type: 3}
- {fileID: 0}
rCornerWallSprites:
- {fileID: 21300000, guid: 424d116bfc9d297468486f10739cb1b3, type: 3}
- {fileID: 0}
tilePrefab: {fileID: 2955896503201886234, guid: 0e0b618b5499bbb40b076c0291d55487,
type: 3}
playerPrefab: {fileID: 2935319493830293412, guid: e8ff38be23e53db40a793f6959c6f4ec,

View file

@ -59,7 +59,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 7
orthographic size: 8
m_Depth: -1
m_CullingMask:
serializedVersion: 2

View file

@ -47,7 +47,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
hpMax: 0
hp: 0
sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3}
sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3}
exp: 0
level: 0
--- !u!212 &-5893075763862095451
@ -87,7 +87,7 @@ SpriteRenderer:
m_SortingLayerID: -522733599
m_SortingLayer: 1
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: fe9c8eab186d5004eaad446d8e220800, type: 3}
m_Sprite: {fileID: 21300000, guid: 88f4c277892ae9449a57b321cd810bce, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0

View file

@ -0,0 +1,98 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &470211819356819165
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 470211819356819163}
- component: {fileID: 470211819356819162}
- component: {fileID: 7501912107144583665}
m_Layer: 0
m_Name: TEST_ Item
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &470211819356819163
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 470211819356819165}
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: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &470211819356819162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 470211819356819165}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1f0883433553dbb4fa23a815949f596b, type: 3}
m_Name:
m_EditorClassIdentifier:
hpMax: 0
overlappable: 0
hp: 0
sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, type: 3}
--- !u!212 &7501912107144583665
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 470211819356819165}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 5e4d29e1adc2ea0429b199b82253416c, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1bd6e08f590fdd844854a34504aeaa4a
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -5,6 +5,7 @@ using UnityEngine;
public class Entity : MonoBehaviour
{
public int hpMax;
public bool overlappable = false;
[AfterStartAttribute]
public int hp;

14
Assets/Scripts/Item.cs Normal file
View file

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item : Entity
{
private new void Start() {
overlappable = true;
}
public virtual void OnPickup(Player player) {
Debug.LogWarning("OnPickup not overridden");
}
}

View file

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

View file

@ -138,7 +138,11 @@ public class Map : MonoBehaviour
{
try {
bool walkable = GetTile(position).walkable;
bool free = !(bool)turnHandler.GetEntityAtPosition(position);
List<Entity> entities = turnHandler.GetEntityAtPosition(position);
bool free = true;
foreach(Entity entity in entities) {
free &= entity.overlappable;
}
return walkable && free;
}
catch(System.IndexOutOfRangeException) {

View file

@ -20,6 +20,7 @@ public class Player : Entity
if (map.CanMoveTo(MapPosition + Vector2Int.left)) {
transform.Translate(Vector3.left);
hasMoved = true;
spriteRenderer.flipX = false;
}
}
else if (Input.GetKeyDown(KeyCode.D))
@ -27,6 +28,7 @@ public class Player : Entity
if (map.CanMoveTo(MapPosition + Vector2Int.right)) {
transform.Translate(Vector3.right);
hasMoved = true;
spriteRenderer.flipX = true;
}
}
else if (Input.GetKeyDown(KeyCode.W))
@ -44,6 +46,15 @@ public class Player : Entity
}
}
if(hasMoved) {
//Check for pickuppable items
List<Entity> entities = turnHandler.GetEntityAtPosition(MapPosition);
foreach(Entity entity in entities) {
if(entity is Item) {
Item item = entity as Item;
item.OnPickup(this);
}
}
//Turn happens!
turnHandler.OnTurn();
}
}

View file

@ -11,13 +11,14 @@ public class TurnHandler : MonoBehaviour
}
}
public Entity GetEntityAtPosition(Vector2Int position) {
public List<Entity> GetEntityAtPosition(Vector2Int position) {
Entity[] entities = GetComponentsInChildren<Entity>();
List<Entity> found = new List<Entity>();
foreach(Entity entity in entities) {
if(entity.MapPosition == position) {
return entity;
found.Add(entity);
}
}
return null;
return found;
}
}

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

View file

@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 2
aniso: -1
mipBias: -100
wrapU: 1

112
Assets/Sprites/pg.png.meta Normal file
View file

@ -0,0 +1,112 @@
fileFormatVersion: 2
guid: 88f4c277892ae9449a57b321cd810bce
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 10
mipmaps:
mipMapMode: 0
enableMipMap: 0
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: 2
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 30
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
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
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
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: ed1284666de20434aaac0772ac619792
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: