Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
FireballsClone
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731021
FireballsClone
Commits
642ebc8d
Commit
642ebc8d
authored
Mar 16, 2021
by
Parsa Rahmaty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved Level Editor
parent
faa3aa11
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
22 deletions
+133
-22
SampleScene.unity
Assets/Scenes/SampleScene.unity
+43
-12
ObstacleCircle.cs
Assets/Scripts/Object Related/ObstacleCircle.cs
+90
-10
No files found.
Assets/Scenes/SampleScene.unity
View file @
642ebc8d
...
@@ -724,10 +724,11 @@ MonoBehaviour:
...
@@ -724,10 +724,11 @@ MonoBehaviour:
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
3b7824bf54e24584faed3e1b18a49e3c
,
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
3b7824bf54e24584faed3e1b18a49e3c
,
type
:
3
}
type
:
3
}
numberOfUnits
:
60
numberOfUnits
:
60
rotationOffset
:
0
rotationOffsets
:
rotationSpeed
:
-
90
-
40
rotationTimes
:
-
40
-
90
rotationSpeedCurve
:
[]
levelEditor
:
levelEditor
:
-
o10e20o10e20
-
o10e20o10e20
-
o5e55
-
o5e55
...
@@ -931,10 +932,41 @@ MonoBehaviour:
...
@@ -931,10 +932,41 @@ MonoBehaviour:
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
f9e114fc26bfeb34bb2e60d1b2a8741b
,
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
f9e114fc26bfeb34bb2e60d1b2a8741b
,
type
:
3
}
type
:
3
}
numberOfUnits
:
48
numberOfUnits
:
48
rotationOffset
:
0
rotationOffsets
:
[]
rotationSpeed
:
rotationTimes
:
[]
-
60
rotationSpeedCurve
:
-
60
-
serializedVersion
:
2
m_Curve
:
-
serializedVersion
:
3
time
:
0
value
:
0
inSlope
:
-0
outSlope
:
2.2586784
tangentMode
:
5
weightedMode
:
0
inWeight
:
0
outWeight
:
0.07278481
-
serializedVersion
:
3
time
:
0.49741524
value
:
3.0121965
inSlope
:
0.038463842
outSlope
:
0.0014007525
tangentMode
:
1
weightedMode
:
0
inWeight
:
0.1666667
outWeight
:
0.33333334
-
serializedVersion
:
3
time
:
1
value
:
0.0017318726
inSlope
:
-2.6255615
outSlope
:
-2.6255615
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.05031461
outWeight
:
0
m_PreInfinity
:
2
m_PostInfinity
:
2
m_RotationOrder
:
0
levelEditor
:
levelEditor
:
-
e21o9e15
-
e21o9e15
-
o3e45
-
o3e45
...
@@ -1787,10 +1819,9 @@ MonoBehaviour:
...
@@ -1787,10 +1819,9 @@ MonoBehaviour:
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
5c46f08dc2ad2dd499ad70a5584a387d
,
obstacle
:
{
fileID
:
1346351848409056502
,
guid
:
5c46f08dc2ad2dd499ad70a5584a387d
,
type
:
3
}
type
:
3
}
numberOfUnits
:
72
numberOfUnits
:
72
rotationOffset
:
0
rotationOffsets
:
[]
rotationSpeed
:
rotationTimes
:
[]
-
20
rotationSpeedCurve
:
[]
-
20
levelEditor
:
levelEditor
:
-
o15e21o15e21
-
o15e21o15e21
-
o5e67
-
o5e67
...
...
Assets/Scripts/Object Related/ObstacleCircle.cs
View file @
642ebc8d
...
@@ -6,8 +6,10 @@ public class ObstacleCircle : MonoBehaviour
...
@@ -6,8 +6,10 @@ public class ObstacleCircle : MonoBehaviour
{
{
[
SerializeField
]
private
GameObject
obstacle
=
null
;
[
SerializeField
]
private
GameObject
obstacle
=
null
;
[
SerializeField
]
private
int
numberOfUnits
=
0
;
[
SerializeField
]
private
int
numberOfUnits
=
0
;
[
SerializeField
]
private
float
rotationOffset
=
0f
;
[
SerializeField
]
private
float
[]
rotationOffsets
=
null
;
[
SerializeField
]
private
float
[]
rotationSpeed
=
null
;
[
SerializeField
]
private
float
[]
rotationTimes
=
null
;
// The values are read from 0 to 1
[
SerializeField
]
private
AnimationCurve
[]
rotationSpeedCurve
=
null
;
// 'o' means obstacle, followed by the number of adjacent of them.
// 'o' means obstacle, followed by the number of adjacent of them.
// 'e' means empty or no obstacle, followed by the number of empty units
// 'e' means empty or no obstacle, followed by the number of empty units
// the sum of all numbers in an string should be equal to the numberOfUnits field;
// the sum of all numbers in an string should be equal to the numberOfUnits field;
...
@@ -15,30 +17,103 @@ public class ObstacleCircle : MonoBehaviour
...
@@ -15,30 +17,103 @@ public class ObstacleCircle : MonoBehaviour
private
float
initialRotationY
;
private
float
initialRotationY
;
private
ArrayList
obstacles
=
new
ArrayList
();
private
ArrayList
obstacles
=
new
ArrayList
();
private
int
levelIndex
=
0
;
private
int
nextLevelIndex
=
0
;
private
int
rotationSpeedMultiplier
=
50
;
private
float
time
=
0f
;
private
float
defaultRotationTime
=
2.0f
;
private
float
defaultRotationSpeed
=
1f
;
private
void
Awake
()
private
void
Awake
()
{
{
initialRotationY
=
transform
.
localEulerAngles
.
y
;
initialRotationY
=
transform
.
localEulerAngles
.
y
;
// If rotationOffsets is not all initialized
if
(
rotationOffsets
.
Length
<
levelEditor
.
Length
)
{
if
(
rotationOffsets
.
Length
==
0
)
{
rotationOffsets
=
new
float
[
levelEditor
.
Length
];
for
(
int
i
=
0
;
i
<
levelEditor
.
Length
;
i
++)
rotationOffsets
[
i
]
=
0f
;
}
else
{
float
[]
tmp
=
rotationOffsets
;
rotationOffsets
=
new
float
[
levelEditor
.
Length
];
tmp
.
CopyTo
(
rotationOffsets
,
0
);
for
(
int
i
=
tmp
.
Length
;
i
<
levelEditor
.
Length
;
i
++)
rotationOffsets
[
i
]
=
0f
;
}
}
// If rotationTimes is not all initialized
if
(
rotationTimes
.
Length
<
levelEditor
.
Length
)
{
if
(
rotationTimes
.
Length
==
0
)
{
rotationTimes
=
new
float
[
levelEditor
.
Length
];
for
(
int
i
=
0
;
i
<
levelEditor
.
Length
;
i
++)
rotationTimes
[
i
]
=
defaultRotationTime
;
}
else
{
float
[]
tmp
=
rotationTimes
;
rotationTimes
=
new
float
[
levelEditor
.
Length
];
tmp
.
CopyTo
(
rotationTimes
,
0
);
for
(
int
i
=
tmp
.
Length
;
i
<
levelEditor
.
Length
;
i
++)
rotationTimes
[
i
]
=
defaultRotationTime
;
}
}
// If rotationSpeedCurve is not all initialized
if
(
rotationSpeedCurve
.
Length
<
levelEditor
.
Length
)
{
if
(
rotationSpeedCurve
.
Length
==
0
)
{
rotationSpeedCurve
=
new
AnimationCurve
[
levelEditor
.
Length
];
for
(
int
i
=
0
;
i
<
levelEditor
.
Length
;
i
++)
{
rotationSpeedCurve
[
i
]
=
new
AnimationCurve
();
rotationSpeedCurve
[
i
].
AddKey
(
new
Keyframe
(
0f
,
defaultRotationSpeed
));
rotationSpeedCurve
[
i
].
AddKey
(
new
Keyframe
(
1f
,
defaultRotationSpeed
));
}
}
else
{
AnimationCurve
[]
tmp
=
rotationSpeedCurve
;
rotationSpeedCurve
=
new
AnimationCurve
[
levelEditor
.
Length
];
tmp
.
CopyTo
(
rotationSpeedCurve
,
0
);
for
(
int
i
=
tmp
.
Length
;
i
<
levelEditor
.
Length
;
i
++)
{
rotationSpeedCurve
[
i
]
=
new
AnimationCurve
();
rotationSpeedCurve
[
i
].
AddKey
(
new
Keyframe
(
0f
,
defaultRotationSpeed
));
rotationSpeedCurve
[
i
].
AddKey
(
new
Keyframe
(
1f
,
defaultRotationSpeed
));
}
}
}
}
}
private
void
Start
()
private
void
Start
()
{
{
transform
.
localEulerAngles
+=
new
Vector3
(
0f
,
rotationOffset
,
0f
);
transform
.
localEulerAngles
+=
new
Vector3
(
0f
,
rotationOffset
s
[
0
]
,
0f
);
if
(
levelEditor
.
Length
!=
0
)
if
(
levelEditor
.
Length
!=
0
)
MakeNextLevel
();
MakeNextLevel
();
GameEvents
.
instance
.
onNextLevelEvent
+=
NextLevel
;
GameEvents
.
instance
.
onNextLevelEvent
+=
NextLevel
;
GameEvents
.
instance
.
onGameRestartEvent
+=
Restart
;
GameEvents
.
instance
.
onGameRestartEvent
+=
Restart
;
}
}
private
void
Fixed
Update
()
private
void
Update
()
{
{
transform
.
localEulerAngles
+=
new
Vector3
(
0f
,
(
rotationSpeed
.
Length
!=
0
)?(
rotationSpeed
[
levelIndex
]
*
Time
.
fixedDeltaTime
):(
0f
),
0f
);
// Rotate the obstacles based on the animation curve in rotationTime of that level
time
+=
Time
.
deltaTime
/
rotationTimes
[
currentLevelIndex
()];
if
(
time
>
rotationTimes
[
currentLevelIndex
()])
time
=
0f
;
transform
.
localEulerAngles
+=
new
Vector3
(
0f
,
rotationSpeedCurve
[
currentLevelIndex
()].
Evaluate
(
time
/
rotationTimes
[
currentLevelIndex
()])
*
rotationSpeedMultiplier
*
Time
.
deltaTime
,
0f
);
}
}
private
void
MakeNextLevel
()
private
void
MakeNextLevel
()
{
{
string
level
=
levelEditor
[
l
evelIndex
];
string
level
=
levelEditor
[
nextL
evelIndex
];
char
[]
legalChars
=
{
'o'
,
'e'
};
char
[]
legalChars
=
{
'o'
,
'e'
};
string
leftover
=
level
;
string
leftover
=
level
;
int
currentUnitIndex
=
0
;
int
currentUnitIndex
=
0
;
...
@@ -78,12 +153,12 @@ public class ObstacleCircle : MonoBehaviour
...
@@ -78,12 +153,12 @@ public class ObstacleCircle : MonoBehaviour
currentUnitIndex
++;
currentUnitIndex
++;
}
}
}
}
levelIndex
=
(
l
evelIndex
+
1
)
%
levelEditor
.
Length
;
nextLevelIndex
=
(
nextL
evelIndex
+
1
)
%
levelEditor
.
Length
;
}
}
private
void
Restart
()
private
void
Restart
()
{
{
l
evelIndex
=
0
;
nextL
evelIndex
=
0
;
NextLevel
();
NextLevel
();
}
}
...
@@ -95,8 +170,13 @@ public class ObstacleCircle : MonoBehaviour
...
@@ -95,8 +170,13 @@ public class ObstacleCircle : MonoBehaviour
Destroy
(
element
);
Destroy
(
element
);
}
}
obstacles
=
new
ArrayList
();
obstacles
=
new
ArrayList
();
transform
.
localEulerAngles
=
new
Vector3
(
0f
,
initialRotationY
+
rotationOffset
,
0f
);
transform
.
localEulerAngles
=
new
Vector3
(
0f
,
initialRotationY
+
rotationOffset
s
[
nextLevelIndex
]
,
0f
);
if
(
levelEditor
.
Length
!=
0
)
if
(
levelEditor
.
Length
!=
0
)
MakeNextLevel
();
MakeNextLevel
();
}
}
private
int
currentLevelIndex
()
{
return
(
nextLevelIndex
-
1
<
0
)
?
(
levelEditor
.
Length
-
1
)
:
(
nextLevelIndex
-
1
);
}
}
}
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