Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Suck It
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GameDevWeek
W
Wintersemester 2018-2019
Unity
Suck It
Commits
fb0af611
Commit
fb0af611
authored
Mar 27, 2019
by
Michael But
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SavePoint und PlayerSpawnPoint Script erstellt und ist Funktiontüchtig.
parent
d636cd6a
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
515 additions
and
196 deletions
+515
-196
Assets/_Game/Data/Player Data.meta
Assets/_Game/Data/Player Data.meta
+8
-0
Assets/_Game/Scenes/MainLevel Michi.unity
Assets/_Game/Scenes/MainLevel Michi.unity
+448
-190
Assets/_Game/Scripts/Player/MovementController.cs
Assets/_Game/Scripts/Player/MovementController.cs
+1
-1
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs
+41
-0
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs.meta
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs.meta
+11
-0
Assets/_Game/Scripts/SaveAndLoad/SaveSystem.cs
Assets/_Game/Scripts/SaveAndLoad/SaveSystem.cs
+6
-5
No files found.
Assets/_Game/Data/Player Data.meta
0 → 100644
View file @
fb0af611
fileFormatVersion: 2
guid: 29c3b47bb1f689d40953870d9f90e2c4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Game/Scenes/MainLevel Michi.unity
View file @
fb0af611
This diff is collapsed.
Click to expand it.
Assets/_Game/Scripts/Player/MovementController.cs
View file @
fb0af611
...
...
@@ -54,7 +54,7 @@ public class MovementController : MonoBehaviour {
m_TempJumpCount
=
m_MaxJumpCount
;
if
(!
wasGrounded
)
OnLandEvent
.
Invoke
();
Debug
.
Log
(
m_Grounded
);
//
Debug.Log(m_Grounded);
}
}
}
...
...
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs
0 → 100644
View file @
fb0af611
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
namespace
PlayerSpawnPointScript
{
public
class
PlayerSpawnPoint
:
MonoBehaviour
{
public
static
PlayerSpawnPoint
psp
;
public
static
Transform
startPoint
;
// Start is called before the first frame update
void
Start
()
{
if
(
GameObject
.
Find
(
"StartPoint"
)
!=
null
)
{
startPoint
=
GameObject
.
Find
(
"StartPoint"
).
transform
;
}
SetPlayerPosition
();
}
// Update is called once per frame
void
Update
()
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
N
))
{
SaveSystem
.
NewGame
();
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
O
))
{
SetPlayerPosition
();
}
}
private
void
SetPlayerPosition
()
{
SavePointData
savePosition
=
SaveSystem
.
LoadSavePoint
();
transform
.
position
=
new
Vector3
(
savePosition
.
position
[
0
],
savePosition
.
position
[
1
],
0
);
}
}
}
Assets/_Game/Scripts/Player/PlayerSpawnPoint.cs.meta
0 → 100644
View file @
fb0af611
fileFormatVersion: 2
guid: c55e49070d8a526499f890e88caa37a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Game/Scripts/SaveAndLoad/SaveSystem.cs
View file @
fb0af611
...
...
@@ -3,6 +3,7 @@ using System.IO;
using
System.Runtime.Serialization.Formatters.Binary
;
using
UnityEngine
;
using
UnityEngine.SceneManagement
;
using
PlayerSpawnPointScript
;
public
class
SaveSystem
...
...
@@ -10,7 +11,7 @@ public class SaveSystem
public
static
void
SavePointUpdate
(
SavePoint
save
)
{
BinaryFormatter
formatter
=
new
BinaryFormatter
();
string
path
=
Application
.
persistentDataPath
+
"/SP.txt"
;
string
path
=
Application
.
persistentDataPath
+
"/SP.txt"
;
FileStream
stream
=
new
FileStream
(
path
,
FileMode
.
Create
);
SavePointData
data
=
new
SavePointData
(
save
);
...
...
@@ -35,18 +36,18 @@ public class SaveSystem
}
else
{
Debug
.
LogError
(
"WuWu"
);
return
null
;
}
}
public
static
void
NewGame
(
Vector2
vec
)
public
static
void
NewGame
()
{
BinaryFormatter
formatter
=
new
BinaryFormatter
();
string
path
=
Application
.
persistentDataPath
+
"/SP.txt"
;
FileStream
stream
=
new
FileStream
(
path
,
FileMode
.
Create
);
SavePointData
data
=
new
SavePointData
(
vec
);
SavePointData
data
=
new
SavePointData
(
new
Vector2
(
PlayerSpawnPointScript
.
PlayerSpawnPoint
.
startPoint
.
transform
.
position
.
x
,
PlayerSpawnPointScript
.
PlayerSpawnPoint
.
startPoint
.
transform
.
position
.
y
));
//SavePointData data = new SavePointData(new Vector2(GameObject.Find("StartPoint").transform.position.x, GameObject.Find("StartPoint").transform.position.y));
formatter
.
Serialize
(
stream
,
data
);
stream
.
Close
();
}
...
...
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