전투 100% 완성
This commit is contained in:
parent
47eb0679bd
commit
225a6d0d49
|
|
@ -1193,9 +1193,10 @@ GameObject:
|
||||||
- component: {fileID: 317772269}
|
- component: {fileID: 317772269}
|
||||||
- component: {fileID: 317772270}
|
- component: {fileID: 317772270}
|
||||||
- component: {fileID: 317772271}
|
- component: {fileID: 317772271}
|
||||||
|
- component: {fileID: 317772272}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: MyBase
|
m_Name: MyBase
|
||||||
m_TagString: Untagged
|
m_TagString: player_home
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
@ -1280,7 +1281,52 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
isEnemy: 0
|
isEnemy: 0
|
||||||
unit: {fileID: 0}
|
unit: {fileID: 3138165653453361519, guid: e1d051ae38295a04a96d0ad555c11500, type: 3}
|
||||||
|
--- !u!61 &317772272
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 317772268}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_ForceSendLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ForceReceiveLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ContactCaptureLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_CallbackLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
oldSize: {x: 5.12, y: 5.12}
|
||||||
|
newSize: {x: 1, y: 1}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 2.5, y: 10}
|
||||||
|
m_EdgeRadius: 0
|
||||||
--- !u!1 &397872210
|
--- !u!1 &397872210
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -4039,9 +4085,10 @@ GameObject:
|
||||||
- component: {fileID: 1578748161}
|
- component: {fileID: 1578748161}
|
||||||
- component: {fileID: 1578748162}
|
- component: {fileID: 1578748162}
|
||||||
- component: {fileID: 1578748163}
|
- component: {fileID: 1578748163}
|
||||||
|
- component: {fileID: 1578748164}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: EnemyBase
|
m_Name: EnemyBase
|
||||||
m_TagString: Untagged
|
m_TagString: enemy_home
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|
@ -4127,6 +4174,51 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
isEnemy: 1
|
isEnemy: 1
|
||||||
unit: {fileID: 3138165653453361519, guid: e1d051ae38295a04a96d0ad555c11500, type: 3}
|
unit: {fileID: 3138165653453361519, guid: e1d051ae38295a04a96d0ad555c11500, type: 3}
|
||||||
|
--- !u!61 &1578748164
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1578748160}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_ForceSendLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ForceReceiveLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ContactCaptureLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_CallbackLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
oldSize: {x: 5.12, y: 5.12}
|
||||||
|
newSize: {x: 1, y: 1}
|
||||||
|
adaptiveTilingThreshold: 0.5
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 2.5, y: 10}
|
||||||
|
m_EdgeRadius: 0
|
||||||
--- !u!1 &1599027060
|
--- !u!1 &1599027060
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ public class SummonsUnit : MonoBehaviour
|
||||||
public bool isEnemy;
|
public bool isEnemy;
|
||||||
public List<BuildingInfo> buildings;
|
public List<BuildingInfo> buildings;
|
||||||
|
|
||||||
|
//테스트용도
|
||||||
|
public UnitCtrl unit;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
buildings = new List<BuildingInfo>();
|
buildings = new List<BuildingInfo>();
|
||||||
|
|
@ -17,7 +20,7 @@ public class SummonsUnit : MonoBehaviour
|
||||||
buildings.Add(new BuildingInfo());
|
buildings.Add(new BuildingInfo());
|
||||||
buildings.Add(new BuildingInfo());
|
buildings.Add(new BuildingInfo());
|
||||||
}
|
}
|
||||||
public UnitCtrl unit;
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
if (isEnemy)
|
if (isEnemy)
|
||||||
|
|
@ -37,7 +40,12 @@ public class SummonsUnit : MonoBehaviour
|
||||||
public void Summons(int count)
|
public void Summons(int count)
|
||||||
{
|
{
|
||||||
BuildingInfo buildingInfo = buildings[count];
|
BuildingInfo buildingInfo = buildings[count];
|
||||||
int listCount = buildingInfo.units.Count;
|
int listCount;
|
||||||
|
if (buildingInfo.units == null)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
listCount = buildingInfo.units.Count;
|
||||||
|
|
||||||
for (int n = 0; n < listCount; n++)
|
for (int n = 0; n < listCount; n++)
|
||||||
{
|
{
|
||||||
if (isEnemy) //Àû¼Òȯ
|
if (isEnemy) //Àû¼Òȯ
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -8,10 +9,20 @@ public class UnitCtrl : MonoBehaviour
|
||||||
public UnitInfo unit;
|
public UnitInfo unit;
|
||||||
public Animator anim;
|
public Animator anim;
|
||||||
public GameObject defensObj;
|
public GameObject defensObj;
|
||||||
bool isAttack;
|
bool isHomeAttack;
|
||||||
|
|
||||||
|
List<UnitCtrl> enemyUnits;
|
||||||
|
|
||||||
public bool isEnemy;
|
public bool isEnemy;
|
||||||
|
|
||||||
|
float delay;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
enemyUnits = new List<UnitCtrl>();
|
||||||
|
isHomeAttack = false;
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
if(isEnemy)
|
if(isEnemy)
|
||||||
|
|
@ -21,9 +32,30 @@ public class UnitCtrl : MonoBehaviour
|
||||||
}
|
}
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (isAttack)
|
delay -= Time.deltaTime;
|
||||||
|
if (delay > 0)
|
||||||
|
return;
|
||||||
|
if (enemyUnits.Count != 0 || isHomeAttack)
|
||||||
|
{
|
||||||
|
if (enemyUnits.Count == 0)
|
||||||
{
|
{
|
||||||
anim.SetTrigger("att");
|
anim.SetTrigger("att");
|
||||||
|
Debug.Log("캠프 공격");
|
||||||
|
delay = unit.attackSpeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (enemyUnits[0] != null)
|
||||||
|
{
|
||||||
|
anim.SetTrigger("att");
|
||||||
|
enemyUnits[0].Attack(unit.attack);
|
||||||
|
delay = unit.attackSpeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enemyUnits.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -37,25 +69,39 @@ public class UnitCtrl : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (collision.gameObject.CompareTag("player"))
|
if (collision.gameObject.CompareTag("player"))
|
||||||
{
|
{
|
||||||
Debug.Log("Ãæµ¹");
|
enemyUnits.Add(collision.gameObject.GetComponentInParent<UnitCtrl>());
|
||||||
isAttack = true;
|
}
|
||||||
|
if (collision.gameObject.CompareTag("player_home"))
|
||||||
|
{
|
||||||
|
isHomeAttack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (collision.gameObject.CompareTag("enemy"))
|
if (collision.gameObject.CompareTag("enemy"))
|
||||||
{
|
{
|
||||||
Debug.Log("Ãæµ¹");
|
enemyUnits.Add(collision.gameObject.GetComponentInParent<UnitCtrl>());
|
||||||
isAttack = true;
|
}
|
||||||
|
if (collision.gameObject.CompareTag("enemy_home"))
|
||||||
|
{
|
||||||
|
isHomeAttack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void OnTriggerExit2D(Collider2D collision)
|
/// <summary>
|
||||||
//{
|
/// 공격을 받았을때 호출되게 만들기
|
||||||
// Debug.Log("Ãæµ¹Á¾·á");
|
/// </summary>
|
||||||
// isAttack = false;
|
/// <param name="dmg">공격 대미지</param>
|
||||||
//}
|
public void Attack(int dmg)
|
||||||
|
{
|
||||||
|
unit.hp -= (dmg - unit.defense);
|
||||||
|
Debug.Log($"{dmg - unit.defense}데미지! {unit.hp}남음.");
|
||||||
|
if(unit.hp <= 0)
|
||||||
|
{
|
||||||
|
//임시로 삭제하게 처리 추후 재활용 할수 있게 처리할것
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ public class UnitInfo
|
||||||
public string name;
|
public string name;
|
||||||
public int hp;
|
public int hp;
|
||||||
public int attack;
|
public int attack;
|
||||||
//public float attackSpeed;
|
public float attackSpeed;
|
||||||
public int defense;
|
public int defense;
|
||||||
public float moveSpeed;
|
public float moveSpeed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,7 @@ MonoBehaviour:
|
||||||
name: "\uC232\uB3CC\uC774"
|
name: "\uC232\uB3CC\uC774"
|
||||||
hp: 100
|
hp: 100
|
||||||
attack: 30
|
attack: 30
|
||||||
|
attackSpeed: 2
|
||||||
defense: 10
|
defense: 10
|
||||||
moveSpeed: 3
|
moveSpeed: 3
|
||||||
anim: {fileID: 95599084440857112}
|
anim: {fileID: 95599084440857112}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -6,6 +6,8 @@ TagManager:
|
||||||
tags:
|
tags:
|
||||||
- player
|
- player
|
||||||
- enemy
|
- enemy
|
||||||
|
- player_home
|
||||||
|
- enemy_home
|
||||||
layers:
|
layers:
|
||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue