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
8d61ac10
Commit
8d61ac10
authored
Jun 05, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autoformat everything: Einrückung mit 2 Leerzeichen, keine Tabs.
parent
d87c20d0
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
76 additions
and
57 deletions
+76
-57
GamePad.cs
Assets/GamePadInput/GamePad.cs
+0
-0
Bullet.cs
Assets/Scripts/Bullet.cs
+3
-2
FireScript.cs
Assets/Scripts/FireScript.cs
+4
-2
GameMaster.cs
Assets/Scripts/GameMaster.cs
+5
-3
GameStateTracker.cs
Assets/Scripts/GameStateTracker.cs
+4
-2
DeserializedLevelsCrossChecker.cs
...Scripts/LevelManagement/DeserializedLevelsCrossChecker.cs
+7
-6
DeserializedLevelsLoader.cs
Assets/Scripts/LevelManagement/DeserializedLevelsLoader.cs
+9
-9
DeserializedLevelsSaver.cs
Assets/Scripts/LevelManagement/DeserializedLevelsSaver.cs
+8
-8
XmlIO.cs
Assets/Scripts/LevelManagement/XmlIO.cs
+4
-4
Menu.cs
Assets/Scripts/Menu.cs
+6
-6
PlayerControl.cs
Assets/Scripts/PlayerControl.cs
+0
-0
PlayerHealth.cs
Assets/Scripts/PlayerHealth.cs
+7
-4
PlayerInputMapping.cs
Assets/Scripts/PlayerInputMapping.cs
+3
-2
PowerUpScript.cs
Assets/Scripts/PowerUpScript.cs
+2
-1
Rocket.cs
Assets/Scripts/Rocket.cs
+5
-3
ShieldScript.cs
Assets/Scripts/ShieldScript.cs
+2
-1
Turret.cs
Assets/Scripts/Turret.cs
+4
-2
TurretButton.cs
Assets/Scripts/TurretButton.cs
+3
-2
No files found.
Assets/GamePadInput/GamePad.cs
View file @
8d61ac10
Assets/Scripts/Bullet.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
Bullet
:
MonoBehaviour
{
public
class
Bullet
:
MonoBehaviour
{
public
int
healingPoints
=
10
;
public
bool
destroyTrap
=
false
;
...
...
@@ -14,7 +15,7 @@ public class Bullet : MonoBehaviour {
/// <param name="direction"></param>
public
void
shoot
(
Vector2
direction
)
{
GetComponent
<
Rigidbody2D
>().
velocity
=
(
float
)
speed
*
direction
.
normalized
;
GetComponent
<
Rigidbody2D
>().
velocity
=
(
float
)
speed
*
direction
.
normalized
;
}
void
OnTriggerEnter2D
(
Collider2D
other
)
...
...
Assets/Scripts/FireScript.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
FireScript
:
MonoBehaviour
{
public
class
FireScript
:
MonoBehaviour
{
PlayerHealth
parentHealth
;
...
...
@@ -18,7 +19,8 @@ public class FireScript : MonoBehaviour {
}
// Update is called once per frame
void
Update
()
{
void
Update
()
{
if
(
parentHealth
)
{
parentHealth
.
changeHealthBy
(-
constantDamagepoints
*
Time
.
deltaTime
);
...
...
Assets/Scripts/GameMaster.cs
View file @
8d61ac10
...
...
@@ -3,7 +3,8 @@ using System.Collections;
using
System.Collections.Generic
;
using
UnityEngine.UI
;
public
class
GameMaster
:
MonoBehaviour
{
public
class
GameMaster
:
MonoBehaviour
{
DeserializedLevelsLoader
levelLoader
;
public
PlayerControl
[]
playerPrefabs
;
...
...
@@ -11,7 +12,8 @@ public class GameMaster : MonoBehaviour {
public
Text
rankingText
;
// Use this for initialization
void
Start
()
{
void
Start
()
{
levelLoader
=
new
DeserializedLevelsLoader
();
levelLoader
.
load
();
}
...
...
@@ -48,7 +50,7 @@ public class GameMaster : MonoBehaviour {
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
PlayerControl
player
=
(
PlayerControl
)
Object
.
Instantiate
(
PlayerControl
player
=
(
PlayerControl
)
Object
.
Instantiate
(
playerPrefabs
[
i
%
playerPrefabs
.
Length
],
startPositions
[
i
].
transform
.
position
,
Quaternion
.
identity
);
...
...
Assets/Scripts/GameStateTracker.cs
View file @
8d61ac10
...
...
@@ -2,7 +2,8 @@
using
System.Collections
;
using
System.Collections.Generic
;
public
class
GameStateTracker
:
MonoBehaviour
{
public
class
GameStateTracker
:
MonoBehaviour
{
private
int
numberOfPlayers
;
...
...
@@ -24,7 +25,8 @@ public class GameStateTracker : MonoBehaviour {
}
// Use this for initialization
void
Start
()
{
void
Start
()
{
gameMaster
=
GetComponent
<
GameMaster
>();
}
...
...
Assets/Scripts/LevelManagement/DeserializedLevelsCrossChecker.cs
View file @
8d61ac10
...
...
@@ -6,11 +6,12 @@ using System.IO;
using
System.Xml
;
using
System.Linq
;
public
class
DeserializedLevelsCrossChecker
{
public
class
DeserializedLevelsCrossChecker
{
//Hallo Tim und Philipp. Die Datei kuckt nur ob irgendwas mit den Prefabs komisch ist.
// cross check /Resources/Prefabs and Levels.xml if there are any item prefabs that exist only in one but not the other
public
void
crossCheck
()
public
void
crossCheck
()
{
// create a list of /Resources/Prefabs for resources and Levels.Xml
List
<
string
>
resPrefabList
=
new
List
<
string
>();
...
...
@@ -34,15 +35,15 @@ public class DeserializedLevelsCrossChecker {
// Add each prefab's file name to prefabList and truncate the .prefab extension from the end
foreach
(
FileInfo
fileInfo
in
fileInfos
)
resPrefabList
.
Add
(
fileInfo
.
Name
.
Substring
(
0
,
fileInfo
.
Name
.
Length
-
".prefab"
.
Length
));
resPrefabList
.
Add
(
fileInfo
.
Name
.
Substring
(
0
,
fileInfo
.
Name
.
Length
-
".prefab"
.
Length
));
// Cross checks
foreach
(
string
prefab
in
xmlPrefabList
.
Except
(
resPrefabList
).
ToList
())
Debug
.
LogError
(
prefab
+
" is missing in the /Resorces/Prefabs folder but used in Levels.xml"
);
Debug
.
LogError
(
prefab
+
" is missing in the /Resorces/Prefabs folder but used in Levels.xml"
);
foreach
(
string
prefab
in
resPrefabList
.
Except
(
xmlPrefabList
).
ToList
())
Debug
.
Log
(
prefab
+
" exists in the /Resorces/Prefabs folder but not used in Levels.xml"
);
Debug
.
Log
(
prefab
+
" exists in the /Resorces/Prefabs folder but not used in Levels.xml"
);
Debug
.
Log
(
"Cross Check Done"
);
Debug
.
Log
(
"Cross Check Done"
);
}
}
Assets/Scripts/LevelManagement/DeserializedLevelsLoader.cs
View file @
8d61ac10
...
...
@@ -34,7 +34,7 @@ public class DeserializedLevelsLoader
// Cache prefabs in prefabDict
Dictionary
<
string
,
GameObject
>
prefabPool
;
Dictionary
<
string
,
GameObject
>
prefabPool
;
// Cache all items with locations
List
<
ItemStruct
>
sceneItemsList
;
...
...
@@ -43,12 +43,12 @@ public class DeserializedLevelsLoader
public
const
string
xmlItemsGOName
=
"XmlItems"
;
public
void
load
()
public
void
load
()
{
deserializedLevels
=
XmlIO
.
LoadXml
<
DeserializedLevels
>(
"Levels"
);
}
public
int
getLevelCount
()
public
int
getLevelCount
()
{
if
(
deserializedLevels
==
null
)
throw
new
System
.
InvalidOperationException
();
...
...
@@ -56,7 +56,7 @@ public class DeserializedLevelsLoader
return
deserializedLevels
.
levels
.
Length
;
}
public
void
loadLevel
(
int
levelIndex
=
0
)
public
void
loadLevel
(
int
levelIndex
=
0
)
{
if
(
deserializedLevels
==
null
)
throw
new
System
.
InvalidOperationException
();
...
...
@@ -68,8 +68,8 @@ public class DeserializedLevelsLoader
sceneItemsList
=
new
List
<
ItemStruct
>();
// if the XmlItems gameobject folder remained in the Hierarcy, then delete it
while
(
GameObject
.
Find
(
xmlItemsGOName
)
!=
null
)
MonoBehaviour
.
DestroyImmediate
(
GameObject
.
Find
(
xmlItemsGOName
));
while
(
GameObject
.
Find
(
xmlItemsGOName
)
!=
null
)
MonoBehaviour
.
DestroyImmediate
(
GameObject
.
Find
(
xmlItemsGOName
));
parentOfXmlItems
=
new
GameObject
(
xmlItemsGOName
).
transform
;
...
...
@@ -167,12 +167,12 @@ public class DeserializedLevelsLoader
// DONE, these are only helper functions below
// if no value then return zero or one, otherwise convert to float
float
toFloatZeroIfNull
(
string
value
)
{
return
value
==
null
?
0
:
float
.
Parse
(
value
);
}
float
toFloatOneIfNull
(
string
value
)
{
return
value
==
null
?
1
:
float
.
Parse
(
value
);
}
float
toFloatZeroIfNull
(
string
value
)
{
return
value
==
null
?
0
:
float
.
Parse
(
value
);
}
float
toFloatOneIfNull
(
string
value
)
{
return
value
==
null
?
1
:
float
.
Parse
(
value
);
}
void
setPos2D
(
GameObject
g
,
Vector2
pos
)
{
g
.
transform
.
position
=
new
Vector2
(
g
.
transform
.
position
=
new
Vector2
(
pos
.
x
,
pos
.
y
);
...
...
Assets/Scripts/LevelManagement/DeserializedLevelsSaver.cs
View file @
8d61ac10
...
...
@@ -6,19 +6,19 @@ public class DeserializedLevelsSaver
{
public
const
string
xmlItemsToExportGOName
=
"XmlItemsToExport"
;
public
void
saveExportItems
()
public
void
saveExportItems
()
{
// Create XmlItemsToExport if does not exist yet
if
(
GameObject
.
Find
(
xmlItemsToExportGOName
)
==
null
)
if
(
GameObject
.
Find
(
xmlItemsToExportGOName
)
==
null
)
new
GameObject
(
xmlItemsToExportGOName
);
GameObject
xmlItemsToExportGO
=
GameObject
.
Find
(
xmlItemsToExportGOName
);
GameObject
xmlItemsToExportGO
=
GameObject
.
Find
(
xmlItemsToExportGOName
);
var
xmlItemsToExportGOchildren
=
xmlItemsToExportGO
.
GetComponentsInChildren
<
Transform
>();
// Check if any children exist
if
(
xmlItemsToExportGOchildren
.
Length
==
0
)
Debug
.
LogError
(
"Add the prefabs to "
+
xmlItemsToExportGOName
);
Debug
.
LogError
(
"Add the prefabs to "
+
xmlItemsToExportGOName
);
DeserializedLevels
.
Level
levelXml
=
new
DeserializedLevels
.
Level
();
...
...
@@ -87,12 +87,12 @@ public class DeserializedLevelsSaver
XmlIO
.
SaveXml
<
DeserializedLevels
>(
levelsXmlToExport
,
"./Assets/Resources/"
+
xmlItemsToExportGOName
+
".xml"
);
}
string
toStringNullIfZero
(
float
num
)
{
return
num
==
0
?
null
:
mathRound
(
num
,
2
).
ToString
();
}
string
toStringNullIfOne
(
float
num
)
{
return
num
==
1
?
null
:
mathRound
(
num
,
2
).
ToString
();
}
string
toStringNullIfZero
(
float
num
)
{
return
num
==
0
?
null
:
mathRound
(
num
,
2
).
ToString
();
}
string
toStringNullIfOne
(
float
num
)
{
return
num
==
1
?
null
:
mathRound
(
num
,
2
).
ToString
();
}
float
mathRound
(
float
round
,
int
decimals
)
float
mathRound
(
float
round
,
int
decimals
)
{
return
Mathf
.
Round
(
round
*
Mathf
.
Pow
(
10
,
decimals
))
/
Mathf
.
Pow
(
10
,
decimals
);
return
Mathf
.
Round
(
round
*
Mathf
.
Pow
(
10
,
decimals
))
/
Mathf
.
Pow
(
10
,
decimals
);
}
}
Assets/Scripts/LevelManagement/XmlIO.cs
View file @
8d61ac10
...
...
@@ -5,9 +5,9 @@ using UnityEngine; // necessary for TextAsset
public
static
class
XmlIO
{
public
static
void
SaveXml
<
T
>
(
this
object
deserializedXml
,
string
path
)
where
T
:
class
public
static
void
SaveXml
<
T
>(
this
object
deserializedXml
,
string
path
)
where
T
:
class
{
using
(
var
stream
=
new
FileStream
(
path
,
FileMode
.
Create
))
using
(
var
stream
=
new
FileStream
(
path
,
FileMode
.
Create
))
{
var
s
=
new
XmlSerializer
(
typeof
(
T
));
s
.
Serialize
(
stream
,
deserializedXml
);
...
...
@@ -16,9 +16,9 @@ public static class XmlIO
public
static
T
LoadXml
<
T
>(
string
textAssetName
)
where
T
:
class
{
TextAsset
xmlTextAsset
=
(
TextAsset
)
Resources
.
Load
(
textAssetName
,
typeof
(
TextAsset
));
TextAsset
xmlTextAsset
=
(
TextAsset
)
Resources
.
Load
(
textAssetName
,
typeof
(
TextAsset
));
using
(
var
stream
=
new
StringReader
(
xmlTextAsset
.
text
))
using
(
var
stream
=
new
StringReader
(
xmlTextAsset
.
text
))
{
var
s
=
new
XmlSerializer
(
typeof
(
T
));
T
deserializedXml
=
s
.
Deserialize
(
stream
)
as
T
;
...
...
Assets/Scripts/Menu.cs
View file @
8d61ac10
...
...
@@ -76,7 +76,7 @@ public class Menu : MonoBehaviour
int
playerNumber
=
addPlayer
();
if
(
playerNumber
>
0
)
{
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
WASD
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
WASD
);
WASDAdded
=
true
;
}
}
...
...
@@ -96,7 +96,7 @@ public class Menu : MonoBehaviour
if
(
playerNumber
>
0
)
{
ArrowAdded
=
true
;
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
ARROWS
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
ARROWS
);
}
}
...
...
@@ -116,7 +116,7 @@ public class Menu : MonoBehaviour
if
(
playerNumber
>
0
)
{
GP1Added
=
true
;
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD1
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD1
);
}
}
...
...
@@ -136,7 +136,7 @@ public class Menu : MonoBehaviour
if
(
playerNumber
>
0
)
{
GP2Added
=
true
;
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD2
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD2
);
}
}
...
...
@@ -156,7 +156,7 @@ public class Menu : MonoBehaviour
if
(
playerNumber
>
0
)
{
GP3Added
=
true
;
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD3
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD3
);
}
}
}
...
...
@@ -175,7 +175,7 @@ public class Menu : MonoBehaviour
if
(
playerNumber
>
0
)
{
GP4Added
=
true
;
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD4
);
inputMappings
[
playerNumber
-
1
].
set
(
controlType
.
GAMEPAD4
);
}
}
}
...
...
Assets/Scripts/PlayerControl.cs
View file @
8d61ac10
Assets/Scripts/PlayerHealth.cs
View file @
8d61ac10
...
...
@@ -2,7 +2,8 @@
using
System.Collections
;
using
UnityEngine.UI
;
public
class
PlayerHealth
:
MonoBehaviour
{
public
class
PlayerHealth
:
MonoBehaviour
{
public
float
maxHealth
=
100
;
...
...
@@ -33,12 +34,13 @@ public class PlayerHealth : MonoBehaviour {
}
// Update is called once per frame
void
Update
()
{
void
Update
()
{
if
(
alive
&&
currentHealth
<=
0
)
{
Debug
.
Log
(
"Player "
+
name
+
" dead."
);
alive
=
false
;
((
GameStateTracker
)
Object
.
FindObjectOfType
(
typeof
(
GameStateTracker
))).
playerDied
(
name
);
((
GameStateTracker
)
Object
.
FindObjectOfType
(
typeof
(
GameStateTracker
))).
playerDied
(
name
);
healthbar
.
gameObject
.
SetActive
(
false
);
//hide healthbar
Destroy
(
gameObject
);
}
...
...
@@ -71,7 +73,8 @@ public class PlayerHealth : MonoBehaviour {
updateHealthbar
();
}
public
void
setShield
(
bool
s
)
{
public
void
setShield
(
bool
s
)
{
Debug
.
Log
(
"Shield "
+
s
+
" accepted"
);
hasShield
=
s
;
}
...
...
Assets/Scripts/PlayerInputMapping.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
using
GamepadInput
;
public
enum
controlType
:
int
{
WASD
=
0
,
ARROWS
=
1
,
GAMEPAD1
=
2
,
GAMEPAD2
=
3
,
GAMEPAD3
=
4
,
GAMEPAD4
=
5
}
public
enum
controlType
:
int
{
WASD
=
0
,
ARROWS
=
1
,
GAMEPAD1
=
2
,
GAMEPAD2
=
3
,
GAMEPAD3
=
4
,
GAMEPAD4
=
5
}
public
class
PlayerInputMapping
:
MonoBehaviour
{
public
class
PlayerInputMapping
:
MonoBehaviour
{
private
enum
Keys
:
int
{
Left
=
0
,
Right
,
Up
,
Down
,
Jump
,
Dash
,
Shoot
};
...
...
Assets/Scripts/PowerUpScript.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
PowerUpScript
:
MonoBehaviour
{
public
class
PowerUpScript
:
MonoBehaviour
{
/// <summary>
/// sollte übereinstimmen mit PlayerControl.POWERUP_XXX
...
...
Assets/Scripts/Rocket.cs
View file @
8d61ac10
...
...
@@ -17,12 +17,14 @@ public class Rocket : MonoBehaviour
#
endregion
// Use this for initialization
void
Start
()
{
void
Start
()
{
body
=
GetComponent
<
Rigidbody2D
>();
}
// Update is called once per frame
void
Update
()
{
void
Update
()
{
if
(!
target
)
return
;
//update direction:
...
...
@@ -43,7 +45,7 @@ public class Rocket : MonoBehaviour
otherBody
.
AddForce
(
body
.
velocity
.
normalized
*
pushForce
);
//explosion effect:
explosion
=
GameObject
.
Instantiate
(
explosionAnimator
.
gameObject
,
transform
.
position
,
transform
.
rotation
)
as
GameObject
;
explosion
=
GameObject
.
Instantiate
(
explosionAnimator
.
gameObject
,
transform
.
position
,
transform
.
rotation
)
as
GameObject
;
gameObject
.
GetComponent
<
SpriteRenderer
>().
enabled
=
false
;
gameObject
.
GetComponent
<
Collider2D
>().
enabled
=
false
;
...
...
Assets/Scripts/ShieldScript.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
ShieldScript
:
MonoBehaviour
{
public
class
ShieldScript
:
MonoBehaviour
{
PlayerHealth
parentHealth
;
...
...
Assets/Scripts/Turret.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
Turret
:
MonoBehaviour
{
public
class
Turret
:
MonoBehaviour
{
public
GameObject
rocketPrefab
;
private
Transform
target
;
...
...
@@ -9,7 +10,8 @@ public class Turret : MonoBehaviour {
// Update is called once per frame
void
Update
()
{
void
Update
()
{
if
(!
target
)
return
;
Vector3
direction
=
target
.
position
-
transform
.
position
;
...
...
Assets/Scripts/TurretButton.cs
View file @
8d61ac10
using
UnityEngine
;
using
System.Collections
;
public
class
TurretButton
:
MonoBehaviour
{
public
class
TurretButton
:
MonoBehaviour
{
public
Turret
cannon
;
// die entsprechende turret-cannon.
void
OnCollisionEnter2D
(
Collision2D
coll
)
{
//soll nur von oben ausloesen:
if
(
coll
.
gameObject
.
tag
==
"Player"
&&
coll
.
relativeVelocity
.
x
<
0.001f
&&
coll
.
relativeVelocity
.
y
>
0.2f
)
if
(
coll
.
gameObject
.
tag
==
"Player"
&&
coll
.
relativeVelocity
.
x
<
0.001f
&&
coll
.
relativeVelocity
.
y
>
0.2f
)
{
cannon
.
setTarget
(
coll
.
gameObject
.
transform
);
cannon
.
shoot
();
...
...
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