Charles

Added basics for combat

......@@ -304,6 +304,7 @@ GameObject:
- component: {fileID: 362990462}
- component: {fileID: 362990469}
- component: {fileID: 362990467}
- component: {fileID: 362990472}
- component: {fileID: 362990468}
- component: {fileID: 362990470}
- component: {fileID: 362990471}
......@@ -479,9 +480,22 @@ MonoBehaviour:
m_EditorClassIdentifier:
maxHP: 100
damage:
baseValue: 0
baseValue: 10
armor:
baseValue: 0
baseValue: 2
--- !u!114 &362990472
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 362990461}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a5b91367176638e49b651a6da5a010c3, type: 3}
m_Name:
m_EditorClassIdentifier:
attackSpeed: 1
--- !u!1001 &435474458
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -1588,6 +1602,9 @@ GameObject:
- component: {fileID: 909129330}
- component: {fileID: 909129329}
- component: {fileID: 909129332}
- component: {fileID: 909129333}
- component: {fileID: 909129334}
- component: {fileID: 909129335}
m_Layer: 0
m_Name: Enemy
m_TagString: Untagged
......@@ -1675,6 +1692,50 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
lookRadius: 8
--- !u!114 &909129333
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 909129327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48feec6a314f1c54599daf0fe95856d7, type: 3}
m_Name:
m_EditorClassIdentifier:
radius: 1.7
interactionTransform: {fileID: 909129331}
--- !u!114 &909129334
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 909129327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7f7cf98fe8ad8b147a3498c0e3f791bd, type: 3}
m_Name:
m_EditorClassIdentifier:
maxHP: 100
damage:
baseValue: 5
armor:
baseValue: 3
--- !u!114 &909129335
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 909129327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a5b91367176638e49b651a6da5a010c3, type: 3}
m_Name:
m_EditorClassIdentifier:
attackSpeed: 1
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterCombat : MonoBehaviour
{
Character_Stats myStats;
public float attackSpeed = 1f;
private float attackCooldown = 0f;
private void Start()
{
myStats = GetComponent<Character_Stats>();
}
private void Update()
{
attackCooldown -= Time.deltaTime;
}
public void Attacked (Character_Stats targetStats)
{
if (attackCooldown <= 0f)
{
targetStats.TakeDam(myStats.damage.GetValue());
attackCooldown = 1f / attackSpeed;
}
}
}
fileFormatVersion: 2
guid: a5b91367176638e49b651a6da5a010c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -30,9 +30,9 @@ public class Character_Stats : MonoBehaviour
damage = Mathf.Clamp(damage, 0, int.MaxValue);
curHP -= damage;
//Debug.Log()
Debug.Log(gameObject + " takes " + damage + " damage");
if(curHP <= 0)
if (curHP <= 0)
{
Die();
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : Interactable
{
PlayerManager playerManager;
Character_Stats myStats;
private void Start()
{
playerManager = PlayerManager.instance;
myStats = GetComponent<Character_Stats>();
}
public override void Interact(GameObject interactor)
{
base.Interact(interactor);
//CharacterCombat playerCombat = playerManager.player1.GetComponent<CharacterCombat>();
CharacterCombat playerCombat = interactor.GetComponent<CharacterCombat>();
if (playerCombat != null)
{
playerCombat.Attacked(myStats);
}
}
}
fileFormatVersion: 2
guid: 48feec6a314f1c54599daf0fe95856d7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: