1
Fork 0

comment stuff

This commit is contained in:
Steffo 2019-04-27 17:28:38 +02:00
parent 09dd536edf
commit 8af505138f
5 changed files with 121 additions and 20 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/*
public class Consumabile : Object public class Consumabile : Object
{ {
// Start is called before the first frame update // Start is called before the first frame update
@ -30,3 +31,4 @@ public class Consumabile : Object
} }
} }
} }
*/

View file

@ -154,8 +154,8 @@ public class Map : MonoBehaviour
return tile; return tile;
} }
private void InitTile(int x, int y, bool walkable, Sprite tileSprite, bool roomPart) { private void InitTile(Vector2Int position, bool walkable, Sprite tileSprite, bool roomPart) {
Tile tile = GetTile(new Vector2Int(x, y)); Tile tile = GetTile(position);
tile.walkable = walkable; tile.walkable = walkable;
tile.sprite = tileSprite; tile.sprite = tileSprite;
tile.roomPart = roomPart; tile.roomPart = roomPart;
@ -178,7 +178,7 @@ public class Map : MonoBehaviour
private void PlaceRoom(MapRoom mr) { private void PlaceRoom(MapRoom mr) {
for(int x = mr.start.x; x <= mr.end.x; x++) { for(int x = mr.start.x; x <= mr.end.x; x++) {
for(int y = mr.start.y; y <= mr.end.y; y++) { for(int y = mr.start.y; y <= mr.end.y; y++) {
InitTile(x, y, true, roomSprite, true); InitTile(new Vector2Int(x, y), true, roomSprite, true);
} }
} }
} }
@ -187,7 +187,7 @@ public class Map : MonoBehaviour
//Returns true if the room can be safely placed //Returns true if the room can be safely placed
for(int x = Mathf.Clamp(mr.start.x-1, 0, mapSize-1); x <= Mathf.Clamp(mr.end.x+1, 0, mapSize-1); x++) { for(int x = Mathf.Clamp(mr.start.x-1, 0, mapSize-1); x <= Mathf.Clamp(mr.end.x+1, 0, mapSize-1); x++) {
for(int y = Mathf.Clamp(mr.start.y-1, 0, mapSize-1); y <= Mathf.Clamp(mr.end.y+1, 0, mapSize-1); y++) { for(int y = Mathf.Clamp(mr.start.y-1, 0, mapSize-1); y <= Mathf.Clamp(mr.end.y+1, 0, mapSize-1); y++) {
if(GetTile(x, y).roomPart) { if(GetTile(new Vector2Int(x, y)).roomPart) {
return false; return false;
} }
} }
@ -197,17 +197,17 @@ public class Map : MonoBehaviour
private void PlaceCorridor(MapCorridor mc) { private void PlaceCorridor(MapCorridor mc) {
Vector2Int cursor = new Vector2Int(mc.start.x, mc.start.y); Vector2Int cursor = new Vector2Int(mc.start.x, mc.start.y);
InitTile(cursor.x, cursor.y, true, corridorSprite, false); InitTile(cursor, true, corridorSprite, false);
if(mc.horizontal_priority) { if(mc.horizontal_priority) {
while(cursor.x != mc.end.x) { while(cursor.x != mc.end.x) {
if(cursor.x > mc.end.x) cursor.x--; if(cursor.x > mc.end.x) cursor.x--;
else cursor.x++; else cursor.x++;
InitTile(cursor.x, cursor.y, true, corridorSprite, false); InitTile(cursor, true, corridorSprite, false);
} }
while(cursor.y != mc.end.y) { while(cursor.y != mc.end.y) {
if(cursor.y > mc.end.y) cursor.y--; if(cursor.y > mc.end.y) cursor.y--;
else cursor.y++; else cursor.y++;
InitTile(cursor.x, cursor.y, true, corridorSprite, false); InitTile(cursor, true, corridorSprite, false);
} }
} }
else else
@ -215,12 +215,12 @@ public class Map : MonoBehaviour
while(cursor.y != mc.end.y) { while(cursor.y != mc.end.y) {
if(cursor.y > mc.end.y) cursor.y--; if(cursor.y > mc.end.y) cursor.y--;
else cursor.y++; else cursor.y++;
InitTile(cursor.x, cursor.y, true, corridorSprite, false); InitTile(cursor, true, corridorSprite, false);
} }
while(cursor.x != mc.end.x) { while(cursor.x != mc.end.x) {
if(cursor.x > mc.end.x) cursor.x--; if(cursor.x > mc.end.x) cursor.x--;
else cursor.x++; else cursor.x++;
InitTile(cursor.x, cursor.y, true, corridorSprite, false); InitTile(cursor, true, corridorSprite, false);
} }
} }
} }

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/*
public class Mostro : MonoBehaviour public class Mostro : MonoBehaviour
{ {
public string nome; public string nome;
@ -60,3 +61,4 @@ public class Mostro : MonoBehaviour
return tile.walkable; return tile.walkable;
} }
} }
*/

View file

@ -18,33 +18,40 @@ public class Player : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
playerMovement(); CheckForMovementInput();
} }
void playerMovement() void CheckForMovementInput()
{ {
bool hasMoved = false;
if (Input.GetKeyDown(KeyCode.A)) if (Input.GetKeyDown(KeyCode.A))
{ {
if (CanMoveTo(Vector2Int.left)) transform.Translate(Vector3.left); if (CanMoveTo(Vector2Int.left)) {
transform.Translate(Vector3.left);}
} }
if (Input.GetKeyDown(KeyCode.D)) else if (Input.GetKeyDown(KeyCode.D))
{ {
if (CanMoveTo(Vector2Int.right)) transform.Translate(Vector3.right); if (CanMoveTo(Vector2Int.right)) {
transform.Translate(Vector3.right);
}
} }
if (Input.GetKeyDown(KeyCode.W)) else if (Input.GetKeyDown(KeyCode.W))
{ {
if (CanMoveTo(Vector2Int.up)) transform.Translate(Vector3.up); if (CanMoveTo(Vector2Int.up)) {
transform.Translate(Vector3.up);
}
} }
if (Input.GetKeyDown(KeyCode.S)) else if (Input.GetKeyDown(KeyCode.S))
{ {
if (CanMoveTo(Vector2Int.down)) transform.Translate(Vector3.down); if (CanMoveTo(Vector2Int.down)) {
transform.Translate(Vector3.down);
}
} }
// Qui c'è da aggiungere la condizione per il controllo degli hp
} }
bool CanMoveTo(Vector2Int direction) bool CanMoveTo(Vector2Int direction)
{ {
Tile tile;
return map.GetTile(direction).walkable; return map.GetTile(direction).walkable;
} }
} }

View file

@ -0,0 +1,90 @@
fileFormatVersion: 2
guid: fa4c9841fd8a5fb4f94ff78c95301065
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: -1
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: 100
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
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 1f47e62ae7a531443a5dba842e499602
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: