1
Fork 0
This commit is contained in:
Francesca Peres 2019-04-29 21:41:01 +02:00
commit 5e8dab74ff
18 changed files with 256 additions and 49 deletions

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

@ -96,8 +96,8 @@ MonoBehaviour:
overlappable: 1
hpMax: 1
hp: 1
hpChange: -1
maxHpChange: -1
hpChange: -2
maxHpChange: -2
damage: 3
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
type: 3}

View file

@ -96,8 +96,8 @@ MonoBehaviour:
overlappable: 1
hpMax: 1
hp: 0
hpChange: -1
maxHpChange: -1
hpChange: -6
maxHpChange: -6
damage: 5
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
type: 3}

View file

@ -10,7 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 8229417268116166537}
- component: {fileID: -4227728170108252613}
- component: {fileID: -7336024761621732000}
- component: {fileID: 6575694489730919195}
m_Layer: 0
m_Name: Skeleton
m_TagString: Untagged
@ -80,7 +80,7 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &-7336024761621732000
--- !u!114 &6575694489730919195
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -89,18 +89,18 @@ MonoBehaviour:
m_GameObject: {fileID: 8811060229651695861}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3}
m_Script: {fileID: 11500000, guid: 08019d8cb8af79544a488e243ab1fec4, type: 3}
m_Name:
m_EditorClassIdentifier:
hpTrueMax: 6
hpTrueMax: 10
overlappable: 0
hpMax: 0
hp: 0
monsterName: Skeleton
moveChance: 0.9
hpMax: 10
hp: 10
monsterName: Skeleton Swordsman
moveChance: 0.1
visionRange: 5
attackRange: 1
damage: 3
damage: 2
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
type: 3}
upSprite: {fileID: 21300000, guid: 5c2d2fa90021e444aaac3dd540becacb, type: 3}

View file

@ -10,7 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 4565250353192838926}
- component: {fileID: 7689595554396751579}
- component: {fileID: 7361680276203333039}
- component: {fileID: 2344911077221548336}
m_Layer: 0
m_Name: Watcher
m_TagString: Untagged
@ -80,7 +80,7 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &7361680276203333039
--- !u!114 &2344911077221548336
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -89,18 +89,19 @@ MonoBehaviour:
m_GameObject: {fileID: 2071995852067845502}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3}
m_Script: {fileID: 11500000, guid: d03e35d46ecc79e45a2b1a4735094763, type: 3}
m_Name:
m_EditorClassIdentifier:
hpTrueMax: 10
hpTrueMax: 15
overlappable: 0
hpMax: 0
hp: 0
hpMax: 15
hp: 15
monsterName: Watcher
moveChance: 0.2
visionRange: 12
moveChance: 0.1
visionRange: 5
attackRange: 1
damage: 5
damage: 2
dash_chance_starting: 0.5
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
type: 3}
upSprite: {fileID: 21300000, guid: 82bebf5d3f0f9864ea1f8f7a58b67bb7, type: 3}

View file

@ -15,9 +15,8 @@ public class EntityItemShopSword : EntityItemShop {
protected override void OnPurchase(EntityPlayer player) {
Destroy(player.GetComponent<PlayerAttack>());
player.gameObject.AddComponent<PlayerAttackMelee>();
PlayerAttackMelee pam = player.GetComponent<PlayerAttackMelee>();
PlayerAttackMelee pam = player.gameObject.AddComponent<PlayerAttackMelee>();
pam.damage = this.damage;
pam.attackAnimation = attackAnimation;
pam.attackAnimation = this.attackAnimation;
}
}

View file

@ -6,8 +6,8 @@ public class EntityMonster : Entity
{
public string monsterName;
public virtual void OnTurn(){
Debug.LogWarning("OnTurn() not overridden");
public virtual void OnTurn() {
//Do nothing.
}
public override void Die() {

View file

@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EntityMonsterSkeletonSwordsman : EntityMonster
{
public float moveChance = 1f;
public float visionRange = 5f;
public float attackRange = 1f;
public float damage = 2f;
public GameObject attackAnimation;
protected EntityPlayer player;
[BeforeStartAttribute]
public Sprite upSprite;
[BeforeStartAttribute]
public Sprite downSprite;
private bool has_attacked = false;
protected new void Start() {
base.Start();
player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>();
}
public override void OnTurn(){
if(Random.value < moveChance) return;
if (CanSeePlayer() && !has_attacked){
Vector2Int distance = player.MapPosition - MapPosition;
if(distance.magnitude <= attackRange) {
float actualDamage = Random.value * damage;
player.hp -= actualDamage;
Instantiate(attackAnimation, player.transform);
messageBar.Write("Took " + actualDamage.ToString("0.0") + " damage!", Color.red);
has_attacked = true;
}
else if (distance.x < 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
transform.Translate(Vector3.left);
spriteRenderer.flipX = false;
}
else if (distance.x > 0 && map.CanMoveTo(MapPosition + Vector2Int.right)){
transform.Translate(Vector3.right);
spriteRenderer.flipX = true;
}
else if (distance.y > 0 && map.CanMoveTo(MapPosition + Vector2Int.up)){
transform.Translate(Vector3.up);
spriteRenderer.sprite = upSprite;
}
else if (distance.y < 0 && map.CanMoveTo(MapPosition + Vector2Int.down)){
transform.Translate(Vector3.down);
spriteRenderer.sprite = downSprite;
}
}
else {
int direction = Random.Range(0, 4);
if (direction == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
transform.Translate(Vector3.left);
spriteRenderer.flipX = false;
}
else if (direction == 1 && map.CanMoveTo(MapPosition + Vector2Int.right)){
transform.Translate(Vector3.right);
spriteRenderer.flipX = true;
}
else if (direction == 2 && map.CanMoveTo(MapPosition + Vector2Int.up)){
transform.Translate(Vector3.up);
spriteRenderer.sprite = upSprite;
}
else if (direction == 3 && map.CanMoveTo(MapPosition + Vector2Int.down)){
transform.Translate(Vector3.down);
spriteRenderer.sprite = downSprite;
}
has_attacked = false;
}
}
public bool CanSeePlayer(){
return Vector3.Distance(player.transform.position, transform.position) < visionRange;
}
private void OnDrawGizmosSelected() {
Gizmos.color = Color.cyan;
Gizmos.DrawWireSphere(transform.position, visionRange);
}
}

View file

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

View file

@ -0,0 +1,108 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EntityMonsterWatcher : EntityMonster
{
public float moveChance = 1f;
public float visionRange = 5f;
public float attackRange = 1f;
public float damage = 2f;
public float dash_chance_starting = 0.5f;
private float dash_chance_current;
public GameObject attackAnimation;
protected EntityPlayer player;
[BeforeStartAttribute]
public Sprite upSprite;
[BeforeStartAttribute]
public Sprite downSprite;
protected new void Start() {
base.Start();
player = GameObject.FindGameObjectWithTag("Player").GetComponent<EntityPlayer>();
dash_chance_current=dash_chance_starting;
}
public override void OnTurn(){
if(Random.value < moveChance) return;
if (CanSeePlayer()){
Vector2Int distance = player.MapPosition - MapPosition;
if(distance.magnitude <= attackRange) {
float actualDamage = Random.value * damage;
player.hp -= actualDamage;
Instantiate(attackAnimation, player.transform);
messageBar.Write("Took " + actualDamage.ToString("0.0") + " damage!", Color.red);
if(Random.value < dash_chance_current){
int direction_dash = Random.Range(0, 4);
if (direction_dash == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
transform.Translate(Vector3.left);
spriteRenderer.flipX = false;
}
else if (direction_dash == 1 && map.CanMoveTo(MapPosition + Vector2Int.right)){
transform.Translate(Vector3.right);
spriteRenderer.flipX = true;
}
else if (direction_dash == 2 && map.CanMoveTo(MapPosition + Vector2Int.up)){
transform.Translate(Vector3.up);
spriteRenderer.sprite = upSprite;
}
else if (direction_dash == 3 && map.CanMoveTo(MapPosition + Vector2Int.down)){
transform.Translate(Vector3.down);
spriteRenderer.sprite = downSprite;
}
dash_chance_current=dash_chance_starting;
}
else{
dash_chance_current-=0.1f;
}
}
else if (distance.x < 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
transform.Translate(Vector3.left);
spriteRenderer.flipX = false;
}
else if (distance.x > 0 && map.CanMoveTo(MapPosition + Vector2Int.right)){
transform.Translate(Vector3.right);
spriteRenderer.flipX = true;
}
else if (distance.y > 0 && map.CanMoveTo(MapPosition + Vector2Int.up)){
transform.Translate(Vector3.up);
spriteRenderer.sprite = upSprite;
}
else if (distance.y < 0 && map.CanMoveTo(MapPosition + Vector2Int.down)){
transform.Translate(Vector3.down);
spriteRenderer.sprite = downSprite;
}
}
else {
int direction = Random.Range(0, 4);
if (direction == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
transform.Translate(Vector3.left);
spriteRenderer.flipX = false;
}
else if (direction == 1 && map.CanMoveTo(MapPosition + Vector2Int.right)){
transform.Translate(Vector3.right);
spriteRenderer.flipX = true;
}
else if (direction == 2 && map.CanMoveTo(MapPosition + Vector2Int.up)){
transform.Translate(Vector3.up);
spriteRenderer.sprite = upSprite;
}
else if (direction == 3 && map.CanMoveTo(MapPosition + Vector2Int.down)){
transform.Translate(Vector3.down);
spriteRenderer.sprite = downSprite;
}
}
}
public bool CanSeePlayer(){
return Vector3.Distance(player.transform.position, transform.position) < visionRange;
}
private void OnDrawGizmosSelected() {
Gizmos.color = Color.cyan;
Gizmos.DrawWireSphere(transform.position, visionRange);
}
}

View file

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

View file

@ -131,7 +131,9 @@ public class Map : MonoBehaviour
public bool CanMoveTo(Vector2Int position)
{
try {
bool walkable = GetTile(position).walkable;
MapTile tile = GetTile(position);
if(tile == null) return false;
bool walkable = tile.walkable;
List<Entity> entities = turnHandler.GetEntitiesAtPosition(position);
bool free = true;
foreach(Entity entity in entities) {
@ -257,6 +259,9 @@ public class Map : MonoBehaviour
for(int i = 0; i < enemiesToSpawn; i++) {
MapRoom room = rooms[Random.Range(0, rooms.Count)];
Vector2Int point = room.RandomPoint();
if(turnHandler.GetEntitiesAtPosition(point).Count > 0) {
continue;
}
GameObject enemyPrefab = enemyPrefabs[Random.Range(0, enemyPrefabs.Count)];
GameObject enemyObject = Instantiate(enemyPrefab, turnHandler.transform);
enemyObject.name = "Enemy " + i.ToString();
@ -268,6 +273,9 @@ public class Map : MonoBehaviour
for(int i = 0; i < curiositiesToSpawn; i++) {
MapRoom room = rooms[Random.Range(0, rooms.Count)];
Vector2Int point = room.RandomPoint();
if(turnHandler.GetEntitiesAtPosition(point).Count > 0) {
continue;
}
GameObject curiosityPrefab = curiositiesPrefabs[Random.Range(0, curiositiesPrefabs.Count)];
GameObject curiosityObject = Instantiate(curiosityPrefab, turnHandler.transform);
curiosityObject.name = "Curiosity " + i.ToString();

View file

@ -97,7 +97,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: da5d40c84f8595f47b80dcea5d2deb3a
spriteID: 3e6eb75314db5e244bebb22f21c94026
internalID: 0
vertices: []
indices:

View file

@ -97,7 +97,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: b492c21463e3a0f4a9b0be683bd11dda
spriteID: 6be7daae85043be438bbec5cd6228385
internalID: 0
vertices: []
indices:

View file

@ -97,7 +97,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: 7c02f5004020e06428309e8025378000
spriteID: 386bca1aff16bf940a124f9e4fd86f4b
internalID: 0
vertices: []
indices:

View file

@ -97,7 +97,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: 9f0d734ca5077c34f8b6bfb253e68903
spriteID: 7021a274552590543af602108d3f2751
internalID: 0
vertices: []
indices:

View file

@ -97,7 +97,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: 554f6d8e091900346aa7a07426a523ee
spriteID: ac8a71570b1ff934596f7800b57ecfd2
internalID: 0
vertices: []
indices: