Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
ld33
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ludum-dare
ld33
Commits
c761176b
Commit
c761176b
authored
Aug 06, 2016
by
Tom Koole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce parallax tiles to 9 indefinitely
parent
6737dd62
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
25 deletions
+24
-25
SpaceParallaxLayerBehavior.cs
Assets/Game/Scripts/SpaceParallaxLayerBehavior.cs
+23
-18
PhysicsMaterials.meta
Assets/Standard Assets/Characters/PhysicsMaterials.meta
+0
-6
ClusterInputManager.asset
ProjectSettings/ClusterInputManager.asset
+0
-0
ProjectSettings.asset
ProjectSettings/ProjectSettings.asset
+0
-0
ProjectVersion.txt
ProjectSettings/ProjectVersion.txt
+1
-1
UnityAdsSettings.asset
ProjectSettings/UnityAdsSettings.asset
+0
-0
UnityConnectSettings.asset
ProjectSettings/UnityConnectSettings.asset
+0
-0
No files found.
Assets/Game/Scripts/SpaceParallaxLayerBehavior.cs
View file @
c761176b
...
...
@@ -7,12 +7,30 @@ public class SpaceParallaxLayerBehavior : MonoBehaviour {
public
GameObject
m_StarLayerPrefab
=
null
;
public
float
m_ParallaxMultiplier
=
1.0f
;
float
m_Scale
=
0.0f
;
public
GameObject
m_Container
;
List
<
SpaceParallaxTileBehavior
>
m_Tiles
=
new
List
<
SpaceParallaxTileBehavior
>();
// 3x3 parallax tiles around the camera, don't need more
SpaceParallaxTileBehavior
[,]
m_Tiles
=
new
SpaceParallaxTileBehavior
[
3
,
3
];
// Use this for initialization
void
Start
()
{
m_Scale
=
m_StarLayerPrefab
.
transform
.
localScale
.
x
;
Vector3
cameraPosition
=
Camera
.
main
.
gameObject
.
transform
.
position
;
int
xPos
=
(
int
)(
cameraPosition
.
x
/
m_Scale
);
int
yPos
=
(
int
)(
cameraPosition
.
y
/
m_Scale
);
for
(
int
y
=
-
1
;
y
<=
1
;
y
++)
{
for
(
int
x
=
-
1
;
x
<=
1
;
x
++)
{
Vector3
realSpace
=
new
Vector3
((
xPos
+
x
)
*
m_Scale
,
(
yPos
+
y
)
*
m_Scale
,
0
);
GameObject
obj
=
Instantiate
<
GameObject
>
(
m_StarLayerPrefab
);
obj
.
transform
.
parent
=
m_Container
.
transform
;
SpaceParallaxTileBehavior
pl
=
obj
.
GetComponent
<
SpaceParallaxTileBehavior
>
();
pl
.
OriginalPosition
=
realSpace
;
m_Tiles
[
y
+
1
,
x
+
1
]
=
pl
;
}
}
}
// Update is called once per frame
...
...
@@ -20,7 +38,7 @@ public class SpaceParallaxLayerBehavior : MonoBehaviour {
Vector3
cameraPosition
=
Camera
.
main
.
gameObject
.
transform
.
position
;
// add new tiles if necessary
AddTile
s
(
cameraPosition
);
UpdateTilePosition
s
(
cameraPosition
);
// update the layer offset for each tile
Vector3
offset
=
cameraPosition
*
m_ParallaxMultiplier
;
...
...
@@ -30,7 +48,7 @@ public class SpaceParallaxLayerBehavior : MonoBehaviour {
}
// add new tiles if necessary
void
AddTile
s
(
Vector3
cameraPosition
)
{
void
UpdateTilePosition
s
(
Vector3
cameraPosition
)
{
int
xPos
=
(
int
)(
cameraPosition
.
x
/
m_Scale
);
int
yPos
=
(
int
)(
cameraPosition
.
y
/
m_Scale
);
...
...
@@ -38,21 +56,7 @@ public class SpaceParallaxLayerBehavior : MonoBehaviour {
for
(
int
y
=
-
1
;
y
<=
1
;
y
++)
{
for
(
int
x
=
-
1
;
x
<=
1
;
x
++)
{
Vector3
realSpace
=
new
Vector3
((
xPos
+
x
)
*
m_Scale
,
(
yPos
+
y
)
*
m_Scale
,
0
);
bool
found
=
false
;
foreach
(
SpaceParallaxTileBehavior
tile
in
m_Tiles
)
{
if
(
closeEnough
(
tile
.
OriginalPosition
,
realSpace
))
{
found
=
true
;
break
;
}
}
if
(!
found
)
{
GameObject
obj
=
Instantiate
<
GameObject
>(
m_StarLayerPrefab
);
SpaceParallaxTileBehavior
pl
=
obj
.
GetComponent
<
SpaceParallaxTileBehavior
>();
pl
.
OriginalPosition
=
realSpace
;
m_Tiles
.
Add
(
pl
);
}
m_Tiles
[
y
+
1
,
x
+
1
].
OriginalPosition
=
realSpace
;
}
}
...
...
@@ -61,6 +65,7 @@ public class SpaceParallaxLayerBehavior : MonoBehaviour {
bool
closeEnough
(
Vector3
a
,
Vector3
b
)
{
return
closeEnough
(
a
.
x
,
b
.
x
)
&&
closeEnough
(
a
.
y
,
b
.
y
);
}
bool
closeEnough
(
float
a
,
float
b
)
{
return
(
a
>=
b
-
m_Scale
*
0.25f
&&
a
<=
b
+
m_Scale
*
0.25f
);
}
...
...
Assets/Standard Assets/Characters/PhysicsMaterials.meta
deleted
100644 → 0
View file @
6737dd62
fileFormatVersion: 2
guid: ea2a5216ffb8d4b319d09e8d7782120c
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:
ProjectSettings/ClusterInputManager.asset
0 → 100644
View file @
c761176b
File added
ProjectSettings/ProjectSettings.asset
View file @
c761176b
No preview for this file type
ProjectSettings/ProjectVersion.txt
View file @
c761176b
m_EditorVersion: 5.
1.0f3
m_EditorVersion: 5.
3.6f1
m_StandardAssetsVersion: 0
ProjectSettings/UnityAdsSettings.asset
0 → 100644
View file @
c761176b
File added
ProjectSettings/UnityConnectSettings.asset
0 → 100644
View file @
c761176b
File added
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