1
Fork 0

Add a massive mess

Bunch of unfinished code
This commit is contained in:
Lorenzo Balugani 2019-04-27 17:18:44 +02:00
parent d4a876097d
commit 32c2382e06
14 changed files with 216 additions and 49 deletions

56
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Consumabile : Object
{
// Start is called before the first frame update
public enum Tipo {Cura, Danno};
public GameObject player;
public Player player;
public int valore;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void use(){
if (Tipo == Tipo.Cura){
player.hp += valore;
if (player.hp >= player.maxhp) player.hp = player.maxhp;
}
if (Tipo == Tipo.Danno){
player.hp -= valore;
}
}
}

View file

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

View file

@ -3,7 +3,11 @@ guid: 052bc569472779a429bfc51246f723d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- wallSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- roomSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- corridorSprite: {fileID: 21300000, guid: e0e60c9a4ff0b8e429e6cfe316da9bbf, type: 3}
- tilePrefab: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:

62
Assets/Scripts/Mostro.cs Normal file
View file

@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mostro : MonoBehaviour
{
public string nome;
public Sprite sprite;
public int hpmax, hp, exp;
public bool is_undead;
public enum speed {slow, standard, fast};
private bool player_spotted;
public Map map;
// Start is called before the first frame update
void Start()
{
map = gameObjectMappa.GetComponent<Map>();
player_spotted = false;
}
// Update is called once per frame
void Update()
{
if (!player_spotted){
roam();
}
//Da mettere il pathfinding per quando trova il personaggio
}
void roam(){
while (true)
{
int direction = Random.Range(1, 5);
if (direction==1 && is_valid_movement("left")){
transform.Translate(Vector3.left);
break;
}
else if (direction==2 && is_valid_movement("right")){
transform.Translate(Vector3.right);
break;
}
else if (direction==3 && is_valid_movement("up")){
transform.Translate(Vector3.up);
break;
}
else if (is_valid_movement("down")){
transform.Translate(Vector3.up);
break;
}
}
}
bool is_valid_movement(string direction)
{
Tile tile;
int posX = (int) transform.position.x;
int posY = (int) transform.position.y;
if (direction == "left") tile = map.GetTile(posX - 1, posY);
else if (direction == "right") tile = map.GetTile(posX + 1, posY);
else if (direction == "up") tile = map.GetTile(posX, posY + 1);
else tile = map.GetTile(posX, posY - 1);
return tile.walkable;
}
}

View file

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

20
Assets/Scripts/Object.cs Normal file
View file

@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Object : MonoBehaviour
{
public string nome;
public int costo;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View file

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

View file

@ -4,8 +4,7 @@ using UnityEngine;
public class Player : MonoBehaviour
{
private int exp, level, hp;
public GameObject player;
private int exp, level, hp, maxhp;
public int startingHp;
public Map map;
//TODO: Aggiungi gli oggetti in inventario
@ -26,27 +25,28 @@ public class Player : MonoBehaviour
{
if (Input.GetKey(KeyCode.A))
{
if (is_valid_movement("left")) player.transform.Translate(Vector3.left);
if (is_valid_movement("left")) transform.Translate(Vector3.left);
}
if (Input.GetKey(KeyCode.D))
{
if (is_valid_movement("right")) player.transform.Translate(Vector3.right);
if (is_valid_movement("right")) transform.Translate(Vector3.right);
}
if (Input.GetKey(KeyCode.W))
{
if (is_valid_movement("up")) player.transform.Translate(Vector3.up);
if (is_valid_movement("up")) transform.Translate(Vector3.up);
}
if (Input.GetKey(KeyCode.S))
{
if (is_valid_movement("down")) player.transform.Translate(Vector3.down);
if (is_valid_movement("down")) transform.Translate(Vector3.down);
}
// Qui c'è da aggiungere la condizione per il controllo degli hp
}
bool is_valid_movement(string direction)
{
Tile tile;
int posX = (int) player.transform.position.x;
int posY = (int) player.transform.position.y;
int posX = (int) transform.position.x;
int posY = (int) transform.position.y;
if (direction == "left") tile = map.GetTile(posX - 1, posY);
else if (direction == "right") tile = map.GetTile(posX + 1, posY);
else if (direction == "up") tile = map.GetTile(posX, posY + 1);

View file

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