Slimes should attack, but for some reason they don't
No idea
This commit is contained in:
parent
95d63ac62b
commit
897df5f308
5 changed files with 31 additions and 54 deletions
|
@ -195,7 +195,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 0cb881aee511ed643880a50159d731b7, type: 3}
|
m_Script: {fileID: 11500000, guid: 0cb881aee511ed643880a50159d731b7, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
damage: 1
|
damage: 4
|
||||||
--- !u!95 &7684473867237801912
|
--- !u!95 &7684473867237801912
|
||||||
Animator:
|
Animator:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
|
|
|
@ -98,4 +98,4 @@ MonoBehaviour:
|
||||||
hp: 1
|
hp: 1
|
||||||
hpChange: -1
|
hpChange: -1
|
||||||
maxHpChange: -1
|
maxHpChange: -1
|
||||||
damage: 3
|
damage: 7
|
||||||
|
|
|
@ -151,7 +151,7 @@ RectTransform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8182065399967645508}
|
m_Father: {fileID: 8182065399967645508}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 1, y: 0}
|
m_AnchorMin: {x: 1, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 0}
|
m_AnchorMax: {x: 1, y: 0}
|
||||||
|
@ -184,7 +184,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_Color: {r: 0, g: 1, b: 0, a: 1}
|
m_Color: {r: 1, g: 0, b: 0, a: 1}
|
||||||
m_RaycastTarget: 0
|
m_RaycastTarget: 0
|
||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
@ -195,10 +195,10 @@ MonoBehaviour:
|
||||||
m_Type: 3
|
m_Type: 3
|
||||||
m_PreserveAspect: 0
|
m_PreserveAspect: 0
|
||||||
m_FillCenter: 1
|
m_FillCenter: 1
|
||||||
m_FillMethod: 2
|
m_FillMethod: 0
|
||||||
m_FillAmount: 1
|
m_FillAmount: 1
|
||||||
m_FillClockwise: 1
|
m_FillClockwise: 1
|
||||||
m_FillOrigin: 0
|
m_FillOrigin: 1
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
--- !u!222 &1332612188
|
--- !u!222 &1332612188
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
@ -239,7 +239,7 @@ RectTransform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8182065399967645508}
|
m_Father: {fileID: 8182065399967645508}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 1, y: 0}
|
m_AnchorMin: {x: 1, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 0}
|
m_AnchorMax: {x: 1, y: 0}
|
||||||
|
@ -272,7 +272,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_Color: {r: 1, g: 0, b: 0, a: 1}
|
m_Color: {r: 0.3962264, g: 0, b: 0, a: 1}
|
||||||
m_RaycastTarget: 0
|
m_RaycastTarget: 0
|
||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
@ -283,10 +283,10 @@ MonoBehaviour:
|
||||||
m_Type: 3
|
m_Type: 3
|
||||||
m_PreserveAspect: 0
|
m_PreserveAspect: 0
|
||||||
m_FillCenter: 1
|
m_FillCenter: 1
|
||||||
m_FillMethod: 2
|
m_FillMethod: 0
|
||||||
m_FillAmount: 1
|
m_FillAmount: 1
|
||||||
m_FillClockwise: 1
|
m_FillClockwise: 1
|
||||||
m_FillOrigin: 0
|
m_FillOrigin: 1
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
--- !u!222 &2051317737
|
--- !u!222 &2051317737
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
@ -338,7 +338,6 @@ GameObject:
|
||||||
- component: {fileID: 7203168577643633308}
|
- component: {fileID: 7203168577643633308}
|
||||||
- component: {fileID: 4061326455747354953}
|
- component: {fileID: 4061326455747354953}
|
||||||
- component: {fileID: 2984726599447885319}
|
- component: {fileID: 2984726599447885319}
|
||||||
- component: {fileID: 2392633072578011031}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Filled HP Bar
|
m_Name: Filled HP Bar
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -346,19 +345,6 @@ GameObject:
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
--- !u!114 &2392633072578011031
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1313580544782099720}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: cbf8b0d2fd980e14f9956f5345d82ddc, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
max: 0
|
|
||||||
--- !u!114 &2984726599447885319
|
--- !u!114 &2984726599447885319
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -413,7 +399,7 @@ RectTransform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8182065399967645508}
|
m_Father: {fileID: 8182065399967645508}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
@ -609,7 +595,7 @@ RectTransform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 8182065399967645508}
|
m_Father: {fileID: 8182065399967645508}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 1, y: 0}
|
m_AnchorMin: {x: 1, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 0}
|
m_AnchorMax: {x: 1, y: 0}
|
||||||
|
@ -721,10 +707,10 @@ RectTransform:
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 7203168577643633308}
|
|
||||||
- {fileID: 3195245192869872480}
|
- {fileID: 3195245192869872480}
|
||||||
- {fileID: 2051317734}
|
- {fileID: 2051317734}
|
||||||
- {fileID: 1332612185}
|
- {fileID: 1332612185}
|
||||||
|
- {fileID: 7203168577643633308}
|
||||||
m_Father: {fileID: 8182065398968123531}
|
m_Father: {fileID: 8182065398968123531}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
|
@ -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 float damage = 1f;
|
||||||
public GameObject attackAnimation;
|
public GameObject attackAnimation;
|
||||||
protected EntityPlayer player;
|
protected EntityPlayer player;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ public class EntityMonsterSlime : EntityMonster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(Vector3.Distance(player.transform.position, transform.position) > 2){
|
||||||
int direction = Random.Range(0, 4);
|
int direction = Random.Range(0, 4);
|
||||||
if (direction == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
|
if (direction == 0 && map.CanMoveTo(MapPosition + Vector2Int.left)){
|
||||||
transform.Translate(Vector3.left);
|
transform.Translate(Vector3.left);
|
||||||
|
@ -52,6 +54,11 @@ public class EntityMonsterSlime : EntityMonster
|
||||||
transform.Translate(Vector3.down);
|
transform.Translate(Vector3.down);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
float damage_done = Random.value * damage;
|
||||||
|
player.hp -= damage;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanSeePlayer(){
|
public bool CanSeePlayer(){
|
||||||
|
|
|
@ -9,8 +9,6 @@ public enum ControlMode {
|
||||||
|
|
||||||
public class EntityPlayer : Entity
|
public class EntityPlayer : Entity
|
||||||
{
|
{
|
||||||
public Dictionary<InventoryItems, int> inventory;
|
|
||||||
public InventoryItems selectedItem;
|
|
||||||
protected ControlMode controlMode;
|
protected ControlMode controlMode;
|
||||||
protected Animator animator;
|
protected Animator animator;
|
||||||
|
|
||||||
|
@ -18,29 +16,15 @@ public class EntityPlayer : Entity
|
||||||
base.Start();
|
base.Start();
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
controlMode = ControlMode.Move;
|
controlMode = ControlMode.Move;
|
||||||
//Init inventory
|
|
||||||
inventory.Add(InventoryItems.HealthPotion, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Update()
|
protected void Update()
|
||||||
{
|
{
|
||||||
CheckForControlModeChange();
|
CheckForControlModeChange();
|
||||||
CheckForInventoryInput();
|
|
||||||
if(controlMode == ControlMode.Move) CheckForMovementInput();
|
if(controlMode == ControlMode.Move) CheckForMovementInput();
|
||||||
if(controlMode == ControlMode.Attack) CheckForAttackInput();
|
if(controlMode == ControlMode.Attack) CheckForAttackInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CheckForInventoryInput() {
|
|
||||||
if(Input.GetKeyDown(KeyCode.X)) {
|
|
||||||
if(selectedItem == InventoryItems.Empty) {
|
|
||||||
selectedItem = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
selectedItem += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CheckForControlModeChange() {
|
protected void CheckForControlModeChange() {
|
||||||
if(Input.GetKeyDown(KeyCode.Escape)) {
|
if(Input.GetKeyDown(KeyCode.Escape)) {
|
||||||
controlMode = ControlMode.Move;
|
controlMode = ControlMode.Move;
|
||||||
|
|
Loading…
Reference in a new issue