Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
four
Commits
17ee1245
Commit
17ee1245
authored
Nov 19, 2016
by
Luke Smith
Browse files
Changed map tool to use prefabs
parent
d0e3b581
Changes
1
Hide whitespace changes
Inline
Side-by-side
Assets/Scripts/MapTool/MapLoader.cs
View file @
17ee1245
...
...
@@ -19,7 +19,10 @@ public class MapLoader : MonoBehaviour {
int
x
=
int
.
Parse
(
coords
[
0
].
ToString
());
int
y
=
int
.
Parse
(
coords
[
1
].
ToString
());
Tile
[,]
map
=
GenerateTiles
(
x
,
y
);
Tile
[,]
map
=
new
Tile
[
y
,
x
];
float
startx
;
float
starty
;
for
(
int
i
=
1
;
i
<
lines
.
Length
-
1
;
i
++)
{
...
...
@@ -29,14 +32,15 @@ public class MapLoader : MonoBehaviour {
y
=
int
.
Parse
(
args
[
1
]);
map
[
x
,
y
].
walkable
=
bool
.
Parse
(
args
[
2
]);
map
[
x
,
y
].
weight
=
float
.
Parse
(
args
[
3
]);
if
(
map
[
x
,
y
].
walkable
){
Destroy
(
map
[
x
,
y
].
GetComponent
<
BoxCollider2D
>
());
}
map
[
x
,
y
]
=
((
GameObject
)
Instantiate
(
Resources
.
Load
<
GameObject
>
(
"Prefabs/"
+
args
[
4
]))).
GetComponent
<
Tile
>
();
map
[
x
,
y
].
weight
=
float
.
Parse
(
args
[
3
]);
startx
=
(
float
)
x
-
(
float
)
map
.
GetLength
(
0
)
/
2f
;
starty
=
(
float
)
y
-
(
float
)
map
.
GetLength
(
1
)
/
2f
;
map
[
x
,
y
].
transform
.
position
=
new
Vector3
(
startx
,
starty
,
0
);
map
[
x
,
y
].
GetComponent
<
SpriteRenderer
>
().
sprite
=
Resources
.
Load
<
Sprite
>
(
"Tiles/"
+
args
[
4
]);
}
Map
.
map
=
map
;
...
...
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