Commit ca2eb01f by Alisa Jung

Merge branch 'master' of ssh://git.breab.org:2222/gamejam-gpn15/dyingIsMainstream

Conflicts: Assets/Prefabs/Player.prefab Assets/Prefabs/Trap.prefab Assets/Scripts/PlayerControl.cs
parents 7bdbf578 9d58515b
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5fcd7bbd646a82a4b9e4aa5229a903e3 guid: 5fcd7bbd646a82a4b9e4aa5229a903e3
timeCreated: 1433444182 timeCreated: 1433446182
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
userData: userData:
......
fileFormatVersion: 2
guid: e0d90fce50c24884c8d83b9d365a5fe3
timeCreated: 1433446163
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -11,6 +11,8 @@ public class PlayerControl : MonoBehaviour ...@@ -11,6 +11,8 @@ public class PlayerControl : MonoBehaviour
public float groundDamping = 20f; // how fast do we change direction? higher means faster public float groundDamping = 20f; // how fast do we change direction? higher means faster
public float inAirDamping = 5f; public float inAirDamping = 5f;
public float targetJumpHeight = 2f; public float targetJumpHeight = 2f;
public bool canDash = true;
public float dashCoolDown = 0.25f;
// public float jumpWaitTime = 2.0; // public float jumpWaitTime = 2.0;
[HideInInspector] [HideInInspector]
...@@ -25,8 +27,7 @@ public class PlayerControl : MonoBehaviour ...@@ -25,8 +27,7 @@ public class PlayerControl : MonoBehaviour
public Vector3 velocity; public Vector3 velocity;
public int playerNumber = 1; //gibt an, ob es sich um player one, player two, etc. handelt. sollte nicht 0 sein; public int playerNumber = 1; //gibt an, ob es sich um player one, player two, etc. handelt. sollte nicht 0 sein;
KeyCode goRightKeyCode, goLeftKeyCode, jumpKeyCode, shootKeyCode; KeyCode goRightKeyCode, goLeftKeyCode, jumpKeyCode, dashKeyCode, shootKeyCode;
void Start() void Start()
{ {
_controller = GetComponent<CharacterController2D>(); _controller = GetComponent<CharacterController2D>();
...@@ -35,10 +36,10 @@ public class PlayerControl : MonoBehaviour ...@@ -35,10 +36,10 @@ public class PlayerControl : MonoBehaviour
switch (playerNumber) switch (playerNumber)
{ {
case 1: case 1:
setKeyCodes(KeyCode.D, KeyCode.A, KeyCode.W, KeyCode.LeftShift); setKeyCodes(KeyCode.D,KeyCode.A,KeyCode.W,KeyCode.S,KeyCode.LeftShift);
break; break;
case 2: case 2:
setKeyCodes(KeyCode.RightArrow, KeyCode.LeftArrow, KeyCode.UpArrow, KeyCode.RightShift); setKeyCodes(KeyCode.RightArrow, KeyCode.LeftArrow, KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.RightShift);
break; break;
//TODO player 3 and 4 //TODO player 3 and 4
default: default:
...@@ -46,18 +47,13 @@ public class PlayerControl : MonoBehaviour ...@@ -46,18 +47,13 @@ public class PlayerControl : MonoBehaviour
} }
} }
void OnCollisionEnter2D(Collision2D other) private void setKeyCodes(KeyCode right, KeyCode left, KeyCode up, KeyCode dash, KeyCode shoot)
{
Debug.Log("BLABLDKSFJH");
}
private void setKeyCodes(KeyCode right, KeyCode left, KeyCode up, KeyCode shoot)
{ {
goRightKeyCode = right; goRightKeyCode = right;
goLeftKeyCode = left; goLeftKeyCode = left;
jumpKeyCode = up; jumpKeyCode = up;
shootKeyCode = shoot; dashKeyCode = dash;
} shootKeyCode = shoot; }
void onControllerCollider(RaycastHit2D hit) void onControllerCollider(RaycastHit2D hit)
...@@ -103,6 +99,19 @@ public class PlayerControl : MonoBehaviour ...@@ -103,6 +99,19 @@ public class PlayerControl : MonoBehaviour
//if (_controller.isGrounded) //if (_controller.isGrounded)
} }
if (canDash && Input.GetKey (dashKeyCode))
{
float direction = Mathf.Sign (transform.localScale.x);
if (normalizedHorizontalSpeed != 0)
{
// player pressed a movement button so prefer the new direction
direction = Mathf.Sign (normalizedHorizontalSpeed);
}
normalizedHorizontalSpeed = 5 * direction;
canDash = false;
Invoke("EnableDash", dashCoolDown);
}
if (Input.GetKeyDown(jumpKeyCode)) if (Input.GetKeyDown(jumpKeyCode))
{ {
...@@ -139,12 +148,10 @@ public class PlayerControl : MonoBehaviour ...@@ -139,12 +148,10 @@ public class PlayerControl : MonoBehaviour
} }
void EnableDash()
{
canDash = true;
}
/*==========Power Ups // Bullet management ===*/ /*==========Power Ups // Bullet management ===*/
......
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour { public class PlayerHealth : MonoBehaviour {
...@@ -7,6 +8,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -7,6 +8,7 @@ public class PlayerHealth : MonoBehaviour {
public int currentHealth = 100; public int currentHealth = 100;
private bool alive = true; private bool alive = true;
public Scrollbar healthbar;
// Update is called once per frame // Update is called once per frame
...@@ -29,6 +31,16 @@ public class PlayerHealth : MonoBehaviour { ...@@ -29,6 +31,16 @@ public class PlayerHealth : MonoBehaviour {
public void setHealth(int newHealth) public void setHealth(int newHealth)
{ {
currentHealth = (newHealth > maxHealth) ? maxHealth : newHealth; currentHealth = (newHealth > maxHealth) ? maxHealth : newHealth;
updateHealthbar();
}
//updated die ui healthbar.
private void updateHealthbar()
{
if (healthbar)
{
healthbar.size = (float)currentHealth / (float)maxHealth;
}
} }
/// <summary> /// <summary>
...@@ -39,6 +51,7 @@ public class PlayerHealth : MonoBehaviour { ...@@ -39,6 +51,7 @@ public class PlayerHealth : MonoBehaviour {
{ {
currentHealth += h; currentHealth += h;
if (currentHealth > maxHealth) currentHealth = maxHealth; if (currentHealth > maxHealth) currentHealth = maxHealth;
updateHealthbar();
} }
} }
fileFormatVersion: 2
guid: 10af2cbda5bcf3c4c86571c6a0894783
timeCreated: 1433444482
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 400
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment