Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dyingIsMainstream
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gamejam-gpn15
dyingIsMainstream
Commits
df91e3b8
Commit
df91e3b8
authored
Jun 05, 2015
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow querying level count in loader
parent
28ad94b1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
GameMaster.cs
Assets/Scripts/GameMaster.cs
+1
-0
DeserializedLevelsLoader.cs
Assets/Scripts/LevelManagement/DeserializedLevelsLoader.cs
+21
-11
No files found.
Assets/Scripts/GameMaster.cs
View file @
df91e3b8
...
@@ -13,6 +13,7 @@ public class GameMaster : MonoBehaviour {
...
@@ -13,6 +13,7 @@ public class GameMaster : MonoBehaviour {
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
levelLoader
=
new
DeserializedLevelsLoader
();
levelLoader
=
new
DeserializedLevelsLoader
();
levelLoader
.
load
();
}
}
public
void
loadLevel
(
int
numberOfPlayers
,
int
level
=
-
1
)
public
void
loadLevel
(
int
numberOfPlayers
,
int
level
=
-
1
)
...
...
Assets/Scripts/LevelManagement/DeserializedLevelsLoader.cs
View file @
df91e3b8
...
@@ -7,9 +7,7 @@ using UnityEngine;
...
@@ -7,9 +7,7 @@ using UnityEngine;
public
class
DeserializedLevelsLoader
public
class
DeserializedLevelsLoader
{
{
// Levels deserialized
// Levels deserialized
private
DeserializedLevels
deserializedLevels
;
private
DeserializedLevels
deserializedLevels
=
null
;
private
int
currentLevelIndex
=
0
;
private
const
string
prefabsFolder
=
"Prefabs/"
;
private
const
string
prefabsFolder
=
"Prefabs/"
;
...
@@ -33,8 +31,27 @@ public class DeserializedLevelsLoader
...
@@ -33,8 +31,27 @@ public class DeserializedLevelsLoader
public
const
string
xmlItemsGOName
=
"XmlItems"
;
public
const
string
xmlItemsGOName
=
"XmlItems"
;
public
void
load
()
{
deserializedLevels
=
XmlIO
.
LoadXml
<
DeserializedLevels
>(
"Levels"
);
}
public
int
getLevelCount
()
{
if
(
deserializedLevels
==
null
)
throw
new
System
.
InvalidOperationException
();
return
deserializedLevels
.
levels
.
Length
;
}
public
void
loadLevel
(
int
levelIndex
=
0
)
public
void
loadLevel
(
int
levelIndex
=
0
)
{
{
if
(
deserializedLevels
==
null
)
throw
new
System
.
InvalidOperationException
();
if
(
levelIndex
>=
deserializedLevels
.
levels
.
Length
)
throw
new
System
.
ArgumentException
();
prefabPool
=
new
Dictionary
<
string
,
GameObject
>();
prefabPool
=
new
Dictionary
<
string
,
GameObject
>();
sceneItemsList
=
new
List
<
ItemStruct
>();
sceneItemsList
=
new
List
<
ItemStruct
>();
...
@@ -44,14 +61,7 @@ public class DeserializedLevelsLoader
...
@@ -44,14 +61,7 @@ public class DeserializedLevelsLoader
parentOfXmlItems
=
new
GameObject
(
xmlItemsGOName
).
transform
;
parentOfXmlItems
=
new
GameObject
(
xmlItemsGOName
).
transform
;
deserializedLevels
=
XmlIO
.
LoadXml
<
DeserializedLevels
>(
"Levels"
);
DeserializedLevels
.
Level
currentLevel
=
deserializedLevels
.
levels
[
levelIndex
];
// if startlevel is in the XML i.e. <Developer StartLevel="3" /> then get level from there
// otherwise start with level 1
currentLevelIndex
=
(
levelIndex
>
deserializedLevels
.
levels
.
Length
-
1
)
?
0
:
levelIndex
;
DeserializedLevels
.
Level
currentLevel
=
deserializedLevels
.
levels
[
currentLevelIndex
];
sceneItemsList
.
Clear
();
sceneItemsList
.
Clear
();
...
...
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