Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
af48caf8
Commit
af48caf8
authored
Jan 24, 2019
by
15김민규
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
몬스터 지정 위치 소환 구현. 오브젝트 풀로 동작.
parent
32786ad2
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
126 additions
and
90 deletions
+126
-90
DummyScorpion.prefab
Assets/Prefabs/Characters/DummyScorpion.prefab
+3
-1
Enemy.prefab
Assets/Prefabs/Characters/Enemy.prefab
+0
-53
Room Start_enemyAdded.prefab
...ts/Prefabs/Rooms/SpecialRoom/Room Start_enemyAdded.prefab
+16
-2
testEnemyPattern.unity
Assets/Scenes/testEnemyPattern.unity
+18
-2
Animator State.meta
Assets/Scripts/Characters/Animator State.meta
+3
-3
Enemy.cs
Assets/Scripts/Characters/Enemy.cs
+13
-28
EnemyManager.cs
Assets/Scripts/Characters/EnemyManager.cs
+55
-1
enemySpot.cs
Assets/Scripts/enemySpot.cs
+7
-0
enemySpot.cs.meta
Assets/Scripts/enemySpot.cs.meta
+11
-0
No files found.
Assets/Prefabs/Characters/DummyScorpion.prefab
View file @
af48caf8
...
...
@@ -186,7 +186,9 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
2d73d07fdab522c4aa045e1cb6a92e8c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
playerMaxHealth
:
0
monsterID
:
42
maxHealth
:
0
weight
:
0
---
!u!212
&212906216626823524
SpriteRenderer
:
m_ObjectHideFlags
:
1
...
...
Assets/Prefabs/Characters/Enemy.prefab
deleted
100644 → 0
View file @
32786ad2
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1001
&100100000
Prefab
:
m_ObjectHideFlags
:
1
serializedVersion
:
2
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
[]
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
0
}
m_RootGameObject
:
{
fileID
:
1840123207372878
}
m_IsPrefabAsset
:
1
---
!u!1
&1840123207372878
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
4193857223660800
}
-
component
:
{
fileID
:
114770369240601290
}
m_Layer
:
0
m_Name
:
Enemy
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&4193857223660800
Transform
:
m_ObjectHideFlags
:
1
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1840123207372878
}
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_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&114770369240601290
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1840123207372878
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d73d07fdab522c4aa045e1cb6a92e8c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
Assets/Prefabs/Rooms/SpecialRoom/Room Start_enemyAdded.prefab
View file @
af48caf8
...
...
@@ -56,8 +56,9 @@ GameObject:
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
4563828945259690
}
-
component
:
{
fileID
:
114027967998875402
}
m_Layer
:
0
m_Name
:
scorpion
-1
m_Name
:
scorpion
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
...
...
@@ -107,7 +108,7 @@ GameObject:
m_Component
:
-
component
:
{
fileID
:
4282728791369600
}
m_Layer
:
0
m_Name
:
enemy
location
m_Name
:
enemy
spot
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
...
...
@@ -1016,6 +1017,19 @@ MonoBehaviour:
leftDoorInfo
:
010101
rightDoorInfo
:
010101
concept
:
01010101
---
!u!114
&114027967998875402
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1295684641764716
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
2d27745292051704a87740def5391766
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
enemyPrefab
:
{
fileID
:
1346522711063220
,
guid
:
e4298313f9e94c44fb057542ec7ad273
,
type
:
2
}
---
!u!251
&251975355083752976
PlatformEffector2D
:
m_ObjectHideFlags
:
1
...
...
Assets/Scenes/testEnemyPattern.unity
View file @
af48caf8
...
...
@@ -767,6 +767,16 @@ Prefab:
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
-
target
:
{
fileID
:
114768470604838176
,
guid
:
54c1a7b414e41724197333a9e17dd49b
,
type
:
2
}
propertyPath
:
enemyPrefab.Array.size
value
:
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
114768470604838176
,
guid
:
54c1a7b414e41724197333a9e17dd49b
,
type
:
2
}
propertyPath
:
dropItemList.Array.size
value
:
16
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4613509870180406
,
guid
:
54c1a7b414e41724197333a9e17dd49b
,
type
:
2
}
propertyPath
:
m_LocalPosition.x
value
:
0
...
...
@@ -804,6 +814,12 @@ Prefab:
propertyPath
:
dropTableData
value
:
objectReference
:
{
fileID
:
4900000
,
guid
:
6216895c658a2af40890a4446cc10a8c
,
type
:
3
}
-
target
:
{
fileID
:
114768470604838176
,
guid
:
54c1a7b414e41724197333a9e17dd49b
,
type
:
2
}
propertyPath
:
enemyPrefab.Array.data[0]
value
:
objectReference
:
{
fileID
:
1346522711063220
,
guid
:
e4298313f9e94c44fb057542ec7ad273
,
type
:
2
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
54c1a7b414e41724197333a9e17dd49b
,
type
:
2
}
m_IsPrefabAsset
:
0
...
...
@@ -961,11 +977,11 @@ Prefab:
m_Modifications
:
-
target
:
{
fileID
:
4884929250924374
,
guid
:
e6794ab8e2e4c6340a23b382e9497cbb
,
type
:
2
}
propertyPath
:
m_LocalPosition.x
value
:
-
955.5
value
:
-
398
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4884929250924374
,
guid
:
e6794ab8e2e4c6340a23b382e9497cbb
,
type
:
2
}
propertyPath
:
m_LocalPosition.y
value
:
-5
30
value
:
-5
68
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
4884929250924374
,
guid
:
e6794ab8e2e4c6340a23b382e9497cbb
,
type
:
2
}
propertyPath
:
m_LocalPosition.z
...
...
Assets/
Prefabs/Characters/Enemy.prefab
.meta
→
Assets/
Scripts/Characters/Animator State
.meta
View file @
af48caf8
fileFormatVersion: 2
guid: 9b5ddc79f9c10db4791cfabc9f744a67
NativeFormatImporter:
guid: 8c086f6d5e8a93542b5b6d3d56d87609
folderAsset: yes
DefaultImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Characters/Enemy.cs
View file @
af48caf8
...
...
@@ -6,19 +6,9 @@ using Random = UnityEngine.Random;
public
class
Enemy
:
MonoBehaviour
{
// data
// health
private
readonly
float
maxHealth
;
private
readonly
float
weight
;
public
float
playerMaxHealth
;
//다른 스크립트에 있는 플레이어 최대체력 가져와야함
private
float
currHealth
;
// unit distance when get damaged
// data
// static
static
readonly
float
unitDist
=
3
;
// debuff
float
[]
immunity_time
=
new
float
[
5
]
{
0.0f
,
3.0f
,
6.0f
,
6.0f
,
6.0f
};
//면역 시간
bool
[]
immunity
=
new
bool
[]
{
false
,
};
//현재 에너미가 디버프 상태에 대해서 면역인지를 체크하는 변수
enum
debuffCase
{
fire
,
ice
,
stun
,
blind
,
charm
};
struct
EnemyDebuffed
{
...
...
@@ -26,11 +16,21 @@ public class Enemy : MonoBehaviour {
public
float
debuffTime
;
}
// stat
public
int
monsterID
;
public
float
maxHealth
;
public
float
weight
;
private
float
playerMaxHealth
;
//다른 스크립트에 있는 플레이어 최대체력 가져와야함
private
float
currHealth
;
// debuff
float
[]
immunity_time
=
new
float
[
5
]
{
0.0f
,
3.0f
,
6.0f
,
6.0f
,
6.0f
};
//면역 시간
bool
[]
immunity
=
new
bool
[]
{
false
,
};
//현재 에너미가 디버프 상태에 대해서 면역인지를 체크하는 변수
// enemy manager
private
readonly
EnemyManager
enemyManager
=
EnemyManager
.
Instance
;
// drop item
// private readonly EnemyManager.DropItemInfo dropItem; // [item ID, probability]
// data for ignoring collision
Vector2
lastPosition
;
...
...
@@ -44,10 +44,6 @@ public class Enemy : MonoBehaviour {
this
.
maxHealth
=
maxHealth
;
this
.
weight
=
weight
;
this
.
currHealth
=
maxHealth
;
// EnemyManager.DropItemInfo dropItem_temp;
// this.dropItem = (enemyManager.dropTableByID.TryGetValue(id, out dropItem_temp)) ?
// dropItem_temp : new EnemyManager.DropItemInfo(-1, -1);
}
// ignore collision with player
...
...
@@ -73,17 +69,6 @@ public class Enemy : MonoBehaviour {
public
void
GetDamaged
(
float
damage
)
{
currHealth
-=
damage
;
if
(
currHealth
<=
0
)
{
/*
if (dropItem.id != -1)
{
float dropProb = Random.Range(0.0f, 1.0f);
if (dropProb < dropItem.prob)
{
// spawn a item that has ID
}
}
*/
Destroy
(
gameObject
);
return
;
}
...
...
Assets/Scripts/Characters/EnemyManager.cs
View file @
af48caf8
...
...
@@ -8,6 +8,9 @@ using UnityEngine.Assertions;
public
class
EnemyManager
:
Singleton
<
EnemyManager
>
{
// data
// static
private
static
readonly
int
poolSize
=
10
;
// data of drop item
public
TextAsset
dropTableData
;
public
Dictionary
<
int
,
int
[
]>
dropTableByID
=
new
Dictionary
<
int
,
int
[
]>
();
...
...
@@ -15,6 +18,7 @@ public class EnemyManager : Singleton<EnemyManager>
// enemy prefab
public
GameObject
[]
enemyPrefab
;
public
Dictionary
<
GameObject
,
GameObject
[
]>
enemyPool
=
new
Dictionary
<
GameObject
,
GameObject
[
]>
();
// method
// Constructor - protect calling raw constructor
...
...
@@ -24,12 +28,62 @@ public class EnemyManager : Singleton<EnemyManager>
private
void
Awake
()
{
LoadDropTable
(
dropTableData
);
createEnemyPool
();
}
// Spawn Enemy to Map
public
void
SpawnEnemy
()
{
GameObject
spawnLocation
=
MapManager
.
currentRoom
.
roomInGame
.
transform
.
Find
(
"enemy location"
).
gameObject
;
Transform
enemySpots
=
MapManager
.
currentRoom
.
roomInGame
.
transform
.
Find
(
"enemy spot"
);
foreach
(
Transform
enemySpot
in
enemySpots
)
{
GameObject
enemy
=
enemySpot
.
gameObject
.
GetComponent
<
enemySpot
>().
enemyPrefab
;
foreach
(
Transform
location
in
enemySpot
)
{
GameObject
clone
=
pickFromPool
(
enemy
);
clone
.
transform
.
position
=
location
.
position
;
}
}
}
// Object Pool
private
void
createEnemyPool
()
{
foreach
(
GameObject
eachEnemy
in
enemyPrefab
)
{
GameObject
[]
pool
=
new
GameObject
[
poolSize
];
for
(
int
i
=
0
;
i
<
pool
.
Length
;
i
++)
{
pool
[
i
]
=
Instantiate
(
eachEnemy
);
pool
[
i
].
SetActive
(
false
);
}
enemyPool
.
Add
(
eachEnemy
,
pool
);
}
}
private
GameObject
pickFromPool
(
GameObject
enemy
)
{
GameObject
[]
pool
=
enemyPool
[
enemy
];
foreach
(
GameObject
obj
in
pool
)
{
if
(!
obj
.
activeSelf
)
{
obj
.
SetActive
(
true
);
return
obj
;
}
}
int
beforeExtend
=
pool
.
Length
;
Array
.
Resize
(
ref
pool
,
pool
.
Length
+
poolSize
);
for
(
int
i
=
beforeExtend
;
i
<
pool
.
Length
;
i
++)
{
pool
[
i
]
=
Instantiate
(
enemy
);
pool
[
i
].
SetActive
(
false
);
}
enemyPool
[
enemy
]
=
pool
;
pool
[
beforeExtend
].
SetActive
(
true
);
return
pool
[
beforeExtend
];
}
// Load Dictionary
...
...
Assets/Scripts/enemySpot.cs
0 → 100644
View file @
af48caf8
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
enemySpot
:
MonoBehaviour
{
public
GameObject
enemyPrefab
;
}
Assets/Scripts/enemySpot.cs.meta
0 → 100644
View file @
af48caf8
fileFormatVersion: 2
guid: 2d27745292051704a87740def5391766
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment