유닛 전투 50% 작업 완료
This commit is contained in:
parent
1cec7db511
commit
92a4999b1c
|
|
@ -4,5 +4,5 @@ using UnityEngine;
|
|||
|
||||
public class BuildingInfo
|
||||
{
|
||||
List<UnitCtrl> units;
|
||||
public List<UnitCtrl> units;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SummonsUnit : MonoBehaviour
|
||||
{
|
||||
public bool isEnemy;
|
||||
public List<BuildingInfo> buildings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
buildings = new List<BuildingInfo>();
|
||||
|
||||
buildings.Add(new BuildingInfo());
|
||||
buildings.Add(new BuildingInfo());
|
||||
buildings.Add(new BuildingInfo());
|
||||
buildings.Add(new BuildingInfo());
|
||||
buildings.Add(new BuildingInfo());
|
||||
}
|
||||
public UnitCtrl unit;
|
||||
private void Start()
|
||||
{
|
||||
if (isEnemy)
|
||||
PlayCtrl.Instance.enemy = this;
|
||||
else
|
||||
PlayCtrl.Instance.player = this;
|
||||
|
||||
//테스트용
|
||||
List<UnitCtrl> units = new List<UnitCtrl>();
|
||||
for (int m = 0; m < 5; m++)
|
||||
{
|
||||
units.Add(PlayCtrl.Instance.unit.GetComponent<UnitCtrl>());
|
||||
}
|
||||
buildings[0].units = units;
|
||||
}
|
||||
|
||||
public void Summons(int count)
|
||||
{
|
||||
BuildingInfo buildingInfo = buildings[count];
|
||||
int listCount = buildingInfo.units.Count;
|
||||
for (int n = 0; n < listCount; n++)
|
||||
{
|
||||
if (isEnemy) //적소환
|
||||
Instantiate(buildingInfo.units[n].gameObject, new Vector3(Random.Range(44.0f, 46.0f), Random.Range(-5.0f, 0.0f), 0), Quaternion.identity).GetComponent<UnitCtrl>().isEnemy = isEnemy;
|
||||
else //아군 유닛 소환
|
||||
Instantiate(buildingInfo.units[n].gameObject, new Vector3(Random.Range(-44.0f, -46.0f), Random.Range(-5.0f, 0.0f), 0), Quaternion.identity).GetComponent<UnitCtrl>().isEnemy = isEnemy;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cafe624fe74cb1b4c9c85fb6325c9c87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,16 +1,61 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class UnitCtrl : MonoBehaviour
|
||||
{
|
||||
public UnitInfo unit;
|
||||
public Animator anim;
|
||||
public GameObject defensObj;
|
||||
bool isAttack;
|
||||
|
||||
public bool isEnemy;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(isEnemy)
|
||||
defensObj.tag = "enemy";
|
||||
else
|
||||
defensObj.tag = "player";
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (isAttack)
|
||||
{
|
||||
anim.SetTrigger("att");
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position += Vector3.left * unit.moveSpeed * Time.deltaTime * (isEnemy ? 1 : -1);
|
||||
}
|
||||
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (isEnemy)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("player"))
|
||||
{
|
||||
Debug.Log("Ãæµ¹");
|
||||
isAttack = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (collision.gameObject.CompareTag("enemy"))
|
||||
{
|
||||
Debug.Log("Ãæµ¹");
|
||||
isAttack = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private void OnTriggerExit2D(Collider2D collision)
|
||||
//{
|
||||
// Debug.Log("Ãæµ¹Á¾·á");
|
||||
// isAttack = false;
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayCtrl : MonoBehaviour
|
||||
public class PlayCtrl : SingletonMonoBehaviour<PlayCtrl>
|
||||
{
|
||||
public GameObject camera;
|
||||
public float speed;
|
||||
|
|
@ -16,9 +16,11 @@ public class PlayCtrl : MonoBehaviour
|
|||
|
||||
public GameObject unit;
|
||||
|
||||
private void Awake()
|
||||
public SummonsUnit player;
|
||||
public SummonsUnit enemy;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
//ÃʱâÈ
|
||||
summons = 0.1f;
|
||||
slider.value = 0;
|
||||
}
|
||||
|
|
@ -36,7 +38,7 @@ public class PlayCtrl : MonoBehaviour
|
|||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
camera.transform.position += Vector3.left * speed * deltaTime * move;
|
||||
if(camera.transform.position.x < -40)
|
||||
if (camera.transform.position.x < -40)
|
||||
{
|
||||
camera.transform.position = new Vector3(-40, 0, -10);
|
||||
}
|
||||
|
|
@ -45,19 +47,16 @@ public class PlayCtrl : MonoBehaviour
|
|||
camera.transform.position = new Vector3(40, 0, -10);
|
||||
}
|
||||
slider.value += Time.deltaTime / 30;
|
||||
if(slider.value >= 1)
|
||||
if (slider.value >= 1)
|
||||
{
|
||||
slider.value -= 1;
|
||||
summons = 0.1f;
|
||||
}
|
||||
if(summons < slider.value)
|
||||
if (summons < slider.value)
|
||||
{
|
||||
Debug.Log("¼Òȯ");
|
||||
Instantiate(unit, new Vector3(Random.Range(-44.0f,-46.0f), Random.Range(-5.0f,0.0f), 0), Quaternion.identity);
|
||||
Instantiate(unit, new Vector3(Random.Range(-44.0f,-46.0f), Random.Range(-5.0f,0.0f), 0), Quaternion.identity);
|
||||
Instantiate(unit, new Vector3(Random.Range(-44.0f,-46.0f), Random.Range(-5.0f,0.0f), 0), Quaternion.identity);
|
||||
Instantiate(unit, new Vector3(Random.Range(-44.0f,-46.0f), Random.Range(-5.0f,0.0f), 0), Quaternion.identity);
|
||||
Instantiate(unit, new Vector3(Random.Range(-44.0f,-46.0f), Random.Range(-5.0f,0.0f), 0), Quaternion.identity);
|
||||
int count = (int)(summons / 0.2);
|
||||
player.Summons(count);
|
||||
enemy.Summons(count);
|
||||
summons += 0.2f;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,9 +191,11 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 4669062451464906}
|
||||
- component: {fileID: 3138165653453361519}
|
||||
m_Layer: 0
|
||||
- component: {fileID: 633896494163313035}
|
||||
- component: {fileID: 924228214329906313}
|
||||
m_Layer: 7
|
||||
m_Name: champion Mushroom 0048
|
||||
m_TagString: Untagged
|
||||
m_TagString: GameController
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
|
@ -212,6 +214,7 @@ Transform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4917161157123006}
|
||||
- {fileID: 1602317403802003956}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3138165653453361519
|
||||
|
|
@ -231,8 +234,82 @@ MonoBehaviour:
|
|||
hp: 100
|
||||
attack: 30
|
||||
defense: 10
|
||||
moveSpeed: 1
|
||||
moveSpeed: 3
|
||||
anim: {fileID: 95599084440857112}
|
||||
defensObj: {fileID: 8888950729539466495}
|
||||
isEnemy: 0
|
||||
--- !u!61 &633896494163313035
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1056691736844118}
|
||||
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: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 650}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1500, y: 1300}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!50 &924228214329906313
|
||||
Rigidbody2D:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1056691736844118}
|
||||
m_BodyType: 1
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDrag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_GravityScale: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
--- !u!1 &1062490047755888
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2490,3 +2567,80 @@ Transform:
|
|||
- {fileID: 4835441770178698}
|
||||
m_Father: {fileID: 4849431348176380}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &8888950729539466495
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1602317403802003956}
|
||||
- component: {fileID: 3180685837361523623}
|
||||
m_Layer: 0
|
||||
m_Name: defens
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1602317403802003956
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8888950729539466495}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4669062451464906}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &3180685837361523623
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8888950729539466495}
|
||||
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: 600}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 700, y: 1200}
|
||||
m_EdgeRadius: 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"MonoBehaviour": {
|
||||
"Version": 4,
|
||||
"EnableBurstCompilation": true,
|
||||
"EnableOptimisations": true,
|
||||
"EnableSafetyChecks": false,
|
||||
"EnableDebugInAllBuilds": false,
|
||||
"DebugDataKind": 1,
|
||||
"EnableArmv9SecurityFeatures": false,
|
||||
"CpuMinTargetX32": 0,
|
||||
"CpuMaxTargetX32": 0,
|
||||
"CpuMinTargetX64": 0,
|
||||
"CpuMaxTargetX64": 0,
|
||||
"CpuTargetsArm64": 512,
|
||||
"OptimizeFor": 0
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"MonoBehaviour": {
|
||||
"Version": 4,
|
||||
"EnableBurstCompilation": true,
|
||||
"EnableOptimisations": true,
|
||||
"EnableSafetyChecks": false,
|
||||
"EnableDebugInAllBuilds": false,
|
||||
"DebugDataKind": 1,
|
||||
"EnableArmv9SecurityFeatures": false,
|
||||
"CpuMinTargetX32": 0,
|
||||
"CpuMaxTargetX32": 0,
|
||||
"CpuMinTargetX64": 0,
|
||||
"CpuMaxTargetX64": 0,
|
||||
"CpuTargetsX32": 6,
|
||||
"CpuTargetsX64": 72,
|
||||
"OptimizeFor": 0
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"MonoBehaviour": {
|
||||
"Version": 4,
|
||||
"DisabledWarnings": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &1
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 53
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
assetDefaultFramerate: 60
|
||||
m_DefaultFrameRate: 60
|
||||
Loading…
Reference in New Issue