Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mr BigSock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gard Aleksander Furre
Mr BigSock
Commits
e8c1d0cf
Commit
e8c1d0cf
authored
2 years ago
by
Robin Ruud Kristensen
Browse files
Options
Downloads
Patches
Plain Diff
refacterd into more functions
parent
5fb051bf
No related branches found
Branches containing commit
No related tags found
1 merge request
!85
Merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MrBigsock/Assets/Code/FollowPlayer.cs
+64
-70
64 additions, 70 deletions
MrBigsock/Assets/Code/FollowPlayer.cs
with
64 additions
and
70 deletions
MrBigsock/Assets/Code/FollowPlayer.cs
+
64
−
70
View file @
e8c1d0cf
...
...
@@ -8,44 +8,30 @@ namespace Bigsock
{
public
class
FollowPlayer
:
MonoBehaviour
{
[
SerializeField
]
private
NeighbourMapGenerator
neighborMapGenerator
;
[
SerializeField
]
private
CinemachineConfiner2D
cameraMap
;
[
SerializeField
]
GameObject
VictoryScreen
;
[
SerializeField
]
NeighbourMapGenerator
neighborMapGenerator
;
[
SerializeField
]
CinemachineConfiner2D
cameraMap
;
[
SerializeField
]
GameObject
victoryScreen
;
private
int
levels
=
0
;
Vector3
offset
=
new
Vector3
(
0
,
0
,
-
10
);
int
i
=
0
;
//Unity varibles
private
GameObject
[]
boss
;
private
GameObject
player
;
private
GameObject
[]
enemies
;
private
GameObject
[]
Chest
;
private
List
<
GameObject
>
chests
;
private
GameObject
stair
;
GameObject
[]
boss
;
GameObject
player
;
GameObject
[]
enemies
;
GameObject
[]
Chest
;
List
<
GameObject
>
chests
;
GameObject
stair
;
int
finalLevel
=
2
;
//Normal variables
private
int
levels
=
0
;
private
static
int
LEVEL_CAP
=
2
;
private
int
roomNr
=
0
;
bool
stairs_down
;
int
h
=
0
;
private
bool
stairs_down
;
private
int
victoryHold
=
0
;
void
Start
()
{
chests
=
new
List
<
GameObject
>();
neighborMapGenerator
.
RunProceduralGeneration
();
player
=
GameObject
.
Find
(
"BigSock"
);
stair
=
GameObject
.
Find
(
"Stairs(Clone)"
);
Chest
=
GameObject
.
FindGameObjectsWithTag
(
"Chest"
);
foreach
(
GameObject
c
in
Chest
)
{
chests
.
Add
(
c
);
c
.
SetActive
(
false
);
}
stairs_down
=
stair
.
GetComponent
<
Stairs
>().
stairs_touch
;
stair
.
SetActive
(
false
);
InitializeLevel
();
}
void
LateUpdate
()
...
...
@@ -53,63 +39,30 @@ namespace Bigsock
boss
=
GameObject
.
FindGameObjectsWithTag
(
"Boss"
);
enemies
=
GameObject
.
FindGameObjectsWithTag
((
roomNr
).
ToString
());
if
(
boss
.
Length
==
0
&&
levels
<
2
)
if
(
boss
.
Length
==
0
&&
levels
<
LEVEL_CAP
)
{
if
(!
stair
.
activeInHierarchy
)
{
Debug
.
Log
(
"hei"
);
levels
++;
}
stair
.
SetActive
(
true
);
stairs_down
=
stair
.
GetComponent
<
Stairs
>().
stairs_touch
;
}
if
(
levels
==
finalLevel
&&
h
==
0
)
if
(
levels
==
LEVEL_CAP
&&
victoryHold
==
0
)
{
Time
.
timeScale
=
0
;
GameObject
canvas
=
GameObject
.
Find
(
"Canvas"
);
if
(
canvas
!=
null
)
{
Instantiate
(
VictoryScreen
,
canvas
.
transform
);
h
++;
}
VictoryScreen
();
victoryHold
++;
}
if
(
stairs_down
)
{
roomNr
=
0
;
foreach
(
GameObject
c
in
chests
)
{
DestroyImmediate
(
c
);
}
DestroyImmediate
(
stair
);
chests
.
Clear
();
TilemapGenerator
.
resetMaps
();
TilemapGenerator
.
SetRoomIDZero
();
ClearScene
();
player
.
transform
.
position
=
new
Vector3
(
9
,
5
,
0
);
neighborMapGenerator
.
RunProceduralGeneration
();
Chest
=
GameObject
.
FindGameObjectsWithTag
(
"Chest"
);
stair
=
GameObject
.
Find
(
"Stairs(Clone)"
);
stairs_down
=
stair
.
GetComponent
<
Stairs
>().
stairs_touch
;
foreach
(
GameObject
c
in
Chest
)
{
if
(
c
!=
null
)
{
c
.
SetActive
(
false
);
chests
.
Add
(
c
);
}
}
stair
.
SetActive
(
false
);
InitializeLevel
();
}
int
i
=
0
;
if
(
i
==
0
)
{
cameraMap
.
InvalidateCache
();
}
cameraMap
.
InvalidateCache
();
if
(
enemies
.
Length
==
0
)
{
...
...
@@ -126,16 +79,57 @@ namespace Bigsock
}
private
void
OnDestroy
()
{
ClearScene
();
}
/*
*Deletes all game objects from the scene that is not the player
*and also resets all arrays that have been made*/
private
void
ClearScene
()
{
roomNr
=
0
;
foreach
(
GameObject
c
in
chests
)
{
DestroyImmediate
(
c
);
}
chests
.
Clear
();
DestroyImmediate
(
stair
);
NeighbourMapGenerator
.
ClearRoomList
();
TilemapGenerator
.
SetRoomIDZero
();
TilemapGenerator
.
resetMaps
();
}
/*
*Initializes the victory screen*/
private
void
VictoryScreen
()
{
Time
.
timeScale
=
0
;
GameObject
canvas
=
GameObject
.
Find
(
"Canvas"
);
if
(
canvas
!=
null
)
{
Instantiate
(
victoryScreen
,
canvas
.
transform
);
}
}
/*
*Creates a level and adds objects to the different arrays */
private
void
InitializeLevel
()
{
neighborMapGenerator
.
RunProceduralGeneration
();
Chest
=
GameObject
.
FindGameObjectsWithTag
(
"Chest"
);
stair
=
GameObject
.
Find
(
"Stairs(Clone)"
);
stairs_down
=
stair
.
GetComponent
<
Stairs
>().
stairs_touch
;
foreach
(
GameObject
c
in
Chest
)
{
if
(
c
!=
null
)
{
c
.
SetActive
(
false
);
chests
.
Add
(
c
);
}
}
stairs_down
=
stair
.
GetComponent
<
Stairs
>().
stairs_touch
;
stair
.
SetActive
(
false
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment