Merge branch 'master' of https://github.com/Steffo99/LD44
This commit is contained in:
commit
85aa6a5598
8 changed files with 234 additions and 34 deletions
|
@ -1,8 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 0460346d99d385241a6d87bbd10aceb8
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
|
@ -1,8 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: e823a56cb429e4b49becdc740fba66b9
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
|
@ -10,7 +10,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 8229417268116166537}
|
- component: {fileID: 8229417268116166537}
|
||||||
- component: {fileID: -4227728170108252613}
|
- component: {fileID: -4227728170108252613}
|
||||||
- component: {fileID: -7336024761621732000}
|
- component: {fileID: 6575694489730919195}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Skeleton
|
m_Name: Skeleton
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -80,7 +80,7 @@ SpriteRenderer:
|
||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &-7336024761621732000
|
--- !u!114 &6575694489730919195
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
@ -89,18 +89,18 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 8811060229651695861}
|
m_GameObject: {fileID: 8811060229651695861}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3}
|
m_Script: {fileID: 11500000, guid: 08019d8cb8af79544a488e243ab1fec4, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
hpTrueMax: 6
|
hpTrueMax: 10
|
||||||
overlappable: 0
|
overlappable: 0
|
||||||
hpMax: 0
|
hpMax: 10
|
||||||
hp: 0
|
hp: 10
|
||||||
monsterName: Skeleton
|
monsterName: Skeleton Swordsman
|
||||||
moveChance: 0.9
|
moveChance: 0.1
|
||||||
visionRange: 5
|
visionRange: 5
|
||||||
attackRange: 1
|
attackRange: 1
|
||||||
damage: 3
|
damage: 2
|
||||||
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
|
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
|
||||||
type: 3}
|
type: 3}
|
||||||
upSprite: {fileID: 21300000, guid: 5c2d2fa90021e444aaac3dd540becacb, type: 3}
|
upSprite: {fileID: 21300000, guid: 5c2d2fa90021e444aaac3dd540becacb, type: 3}
|
||||||
|
|
|
@ -10,7 +10,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4565250353192838926}
|
- component: {fileID: 4565250353192838926}
|
||||||
- component: {fileID: 7689595554396751579}
|
- component: {fileID: 7689595554396751579}
|
||||||
- component: {fileID: 7361680276203333039}
|
- component: {fileID: 2344911077221548336}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Watcher
|
m_Name: Watcher
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -80,7 +80,7 @@ SpriteRenderer:
|
||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &7361680276203333039
|
--- !u!114 &2344911077221548336
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
@ -89,18 +89,19 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 2071995852067845502}
|
m_GameObject: {fileID: 2071995852067845502}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 1ce1b6adc640d6f46bbf4d7072735b7f, type: 3}
|
m_Script: {fileID: 11500000, guid: d03e35d46ecc79e45a2b1a4735094763, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
hpTrueMax: 10
|
hpTrueMax: 15
|
||||||
overlappable: 0
|
overlappable: 0
|
||||||
hpMax: 0
|
hpMax: 15
|
||||||
hp: 0
|
hp: 15
|
||||||
monsterName: Watcher
|
monsterName: Watcher
|
||||||
moveChance: 0.2
|
moveChance: 0.1
|
||||||
visionRange: 12
|
visionRange: 5
|
||||||
attackRange: 1
|
attackRange: 1
|
||||||
damage: 5
|
damage: 2
|
||||||
|
dash_chance_starting: 0.5
|
||||||
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
|
attackAnimation: {fileID: 5896060810164205279, guid: 602b69921902efc44ab8a008655b6574,
|
||||||
type: 3}
|
type: 3}
|
||||||
upSprite: {fileID: 21300000, guid: 82bebf5d3f0f9864ea1f8f7a58b67bb7, type: 3}
|
upSprite: {fileID: 21300000, guid: 82bebf5d3f0f9864ea1f8f7a58b67bb7, type: 3}
|
||||||
|
|
85
Assets/Scripts/EntityMonsterSkeletonSwordsman.cs
Normal file
85
Assets/Scripts/EntityMonsterSkeletonSwordsman.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/EntityMonsterSkeletonSwordsman.cs.meta
Normal file
11
Assets/Scripts/EntityMonsterSkeletonSwordsman.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08019d8cb8af79544a488e243ab1fec4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
108
Assets/Scripts/EntityMonsterWatcher.cs
Normal file
108
Assets/Scripts/EntityMonsterWatcher.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/EntityMonsterWatcher.cs.meta
Normal file
11
Assets/Scripts/EntityMonsterWatcher.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d03e35d46ecc79e45a2b1a4735094763
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in a new issue