recuperiamo il titanic
This commit is contained in:
parent
1328c130f9
commit
11850537ac
15 changed files with 87 additions and 5 deletions
16
Assets/Scripts/DestroySelfAfterSomeTime.cs
Normal file
16
Assets/Scripts/DestroySelfAfterSomeTime.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class DestroySelfAfterSomeTime : MonoBehaviour {
|
||||||
|
[BeforeStartAttribute]
|
||||||
|
public float time = 1f;
|
||||||
|
|
||||||
|
protected void Start() {
|
||||||
|
Invoke(DestroySelf, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DestroySelf() {
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,6 @@ public class EntityItem : Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnPickup(EntityPlayer player) {
|
public virtual void OnPickup(EntityPlayer player) {
|
||||||
Debug.LogWarning("OnPickup not overridden");
|
|
||||||
messageBar.Write("Picked up: " + Name, Color.yellow);
|
messageBar.Write("Picked up: " + Name, Color.yellow);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class EntityItemHeart : EntityItem
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPickup(EntityPlayer player) {
|
public override void OnPickup(EntityPlayer player) {
|
||||||
messageBar.Write("You used: " + Name, Color.yellow);
|
messageBar.Write("Picked up: " + Name, Color.lime);
|
||||||
player.hp += regen;
|
player.hp += regen;
|
||||||
if (player.hp > player.hpMax) player.hp = player.hpMax;
|
if (player.hp > player.hpMax) player.hp = player.hpMax;
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class EntityItemPoisonHeart : EntityItem
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPickup(EntityPlayer player) {
|
public override void OnPickup(EntityPlayer player) {
|
||||||
messageBar.Write("You used: " + Name, Color.yellow);
|
messageBar.Write("Picked up: " + Name, Color.orange);
|
||||||
player.hp -= damage;
|
player.hp -= damage;
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
27
Assets/Scripts/EntityItemShop.cs
Normal file
27
Assets/Scripts/EntityItemShop.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class EntityItemShop : EntityItem {
|
||||||
|
public float hpChange = -1f;
|
||||||
|
public float maxHpChange = -1f;
|
||||||
|
|
||||||
|
protected EntityPlayer player;
|
||||||
|
|
||||||
|
protected override void Start() {
|
||||||
|
base.Start();
|
||||||
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnPurchase() {
|
||||||
|
Debug.LogWarning("OnPurchase not overridden");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPickup() {
|
||||||
|
player.hp += hpChange;
|
||||||
|
player.maxHpChange += maxHpChange;
|
||||||
|
OnPurchase();
|
||||||
|
messageBar.Write("Bought: " + Name, Color.yellow);
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
21
Assets/Scripts/EntityItemShopSword.cs
Normal file
21
Assets/Scripts/EntityItemShopSword.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class EntityItemShopSword : EntityItemShop {
|
||||||
|
|
||||||
|
public float damage = 3f;
|
||||||
|
|
||||||
|
public override string Name {
|
||||||
|
get {
|
||||||
|
return "Sword (" + damage.ToString() + " dmg)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPurchase() {
|
||||||
|
Destroy(player.GetComponent<PlayerAttack>());
|
||||||
|
player.AddComponent(PlayerAttackMelee);
|
||||||
|
PlayerAttackMelee pam = player.GetComponent<PlayerAttackMelee>();
|
||||||
|
pam.damage = this.damage;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ public class EntityMonster : Entity
|
||||||
Debug.LogWarning("No name given to a monster");
|
Debug.LogWarning("No name given to a monster");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnTurn(){
|
public virtual void OnTurn(){
|
||||||
Debug.LogWarning("OnTurn() not overridden");
|
Debug.LogWarning("OnTurn() not overridden");
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class EntityMonsterMage : EntityMonster
|
||||||
|
|
||||||
public float moveChance = 0.5f;
|
public float moveChance = 0.5f;
|
||||||
public float visionRange = 7f;
|
public float visionRange = 7f;
|
||||||
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
protected new void Start() {
|
protected new void Start() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class EntityMonsterSkeletonArcher : EntityMonster
|
||||||
|
|
||||||
public float moveChance = 0f;
|
public float moveChance = 0f;
|
||||||
public float visionRange = 5f;
|
public float visionRange = 5f;
|
||||||
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
protected new void Start() {
|
protected new void Start() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class EntityMonsterSkeletonSwordsman : EntityMonster
|
||||||
|
|
||||||
public float moveChance = 0f;
|
public float moveChance = 0f;
|
||||||
public float visionRange = 4f;
|
public float visionRange = 4f;
|
||||||
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
protected new void Start() {
|
protected new void Start() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class EntityMonsterSlime : EntityMonster
|
||||||
|
|
||||||
public float moveChance = 0.5f;
|
public float moveChance = 0.5f;
|
||||||
public float visionRange = 4f;
|
public float visionRange = 4f;
|
||||||
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
protected new void Start() {
|
protected new void Start() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class EntityMonsterWatcher : EntityMonster
|
||||||
|
|
||||||
public float moveChance = 0f;
|
public float moveChance = 0f;
|
||||||
public float visionRange = 12f;
|
public float visionRange = 12f;
|
||||||
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
protected new void Start() {
|
protected new void Start() {
|
||||||
|
|
|
@ -245,9 +245,16 @@ public class Map : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlacePlayer() {
|
private void PlacePlayer() {
|
||||||
|
//Check for an existing player
|
||||||
MapRoom room = rooms[Random.Range(0, rooms.Count)];
|
MapRoom room = rooms[Random.Range(0, rooms.Count)];
|
||||||
Vector2Int point = room.RandomPoint();
|
Vector2Int point = room.RandomPoint();
|
||||||
GameObject playerObject = Instantiate(playerPrefab, turnHandler.transform);
|
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
|
||||||
|
if(playerObject == null) {
|
||||||
|
playerObject = Instantiate(playerPrefab, turnHandler.transform);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
playerObject.transform.parent = turnHandler.transform;
|
||||||
|
}
|
||||||
playerObject.name = "Player";
|
playerObject.name = "Player";
|
||||||
playerObject.transform.position = new Vector3(point.x, point.y, 0);
|
playerObject.transform.position = new Vector3(point.x, point.y, 0);
|
||||||
}
|
}
|
||||||
|
|
7
Assets/Scripts/NextLevel.cs
Normal file
7
Assets/Scripts/NextLevel.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class NextLevel : MonoBehaviour {
|
||||||
|
//TODO
|
||||||
|
}
|
Loading…
Reference in a new issue