Browse Source

Added scoring system

Added player 3
master
Joshua Reason 9 years ago
parent
commit
11743d1552
27 changed files with 197 additions and 293 deletions
  1. BIN
      playable/Assets/Horn2.fbx
  2. +127
    -0
      playable/Assets/Horn2.fbx.meta
  3. BIN
      playable/Assets/Lachlan_jump_work.unity
  4. BIN
      playable/Assets/Pinata.controller
  5. +5
    -0
      playable/Assets/Prefabs.meta
  6. BIN
      playable/Assets/Prefabs/Confetti.prefab
  7. +0
    -0
      playable/Assets/Prefabs/Confetti.prefab.meta
  8. +0
    -0
      playable/Assets/Prefabs/Heart 1.prefab
  9. +0
    -0
      playable/Assets/Prefabs/Heart 1.prefab.meta
  10. +0
    -0
      playable/Assets/Prefabs/Heart.prefab
  11. +0
    -0
      playable/Assets/Prefabs/Heart.prefab.meta
  12. BIN
      playable/Assets/Prefabs/candy.prefab
  13. +4
    -0
      playable/Assets/Prefabs/candy.prefab.meta
  14. +0
    -21
      playable/Assets/Scripts/P2_weapon.cs
  15. +0
    -8
      playable/Assets/Scripts/P2_weapon.cs.meta
  16. +0
    -115
      playable/Assets/Scripts/PlayerControler.cs
  17. +43
    -0
      playable/Assets/Scripts/collectable.cs
  18. +1
    -1
      playable/Assets/Scripts/collectable.cs.meta
  19. +0
    -116
      playable/Assets/Scripts/player2_controls.cs
  20. +0
    -8
      playable/Assets/Scripts/player2_controls.cs.meta
  21. +17
    -0
      playable/Assets/Scripts/playerController.cs
  22. +0
    -16
      playable/Assets/Scripts/sc.cs
  23. +0
    -8
      playable/Assets/Scripts/sc.cs.meta
  24. +0
    -0
      playable/Assets/Scripts/stickController.cs
  25. +0
    -0
      playable/Assets/Scripts/stickController.cs.meta
  26. BIN
      playable/ProjectSettings/InputManager.asset
  27. BIN
      playable/ProjectSettings/TagManager.asset

BIN
playable/Assets/Horn2.fbx View File


+ 127
- 0
playable/Assets/Horn2.fbx.meta View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 23756e737f935a140810973e4e080871
ModelImporter:
serializedVersion: 16
fileIDToRecycleName:
100000: //RootNode
100002: pCube1
100004: pTorus1
100006: pTorus10
100008: pTorus11
100010: pTorus12
100012: pTorus13
100014: pTorus2
100016: pTorus3
100018: pTorus4
100020: pTorus5
100022: pTorus6
100024: pTorus8
100026: pTorus9
400000: //RootNode
400002: pCube1
400004: pTorus1
400006: pTorus10
400008: pTorus11
400010: pTorus12
400012: pTorus13
400014: pTorus2
400016: pTorus3
400018: pTorus4
400020: pTorus5
400022: pTorus6
400024: pTorus8
400026: pTorus9
2300000: pCube1
2300002: pTorus1
2300004: pTorus10
2300006: pTorus11
2300008: pTorus12
2300010: pTorus13
2300012: pTorus2
2300014: pTorus3
2300016: pTorus4
2300018: pTorus5
2300020: pTorus6
2300022: pTorus8
2300024: pTorus9
3300000: pCube1
3300002: pTorus1
3300004: pTorus10
3300006: pTorus11
3300008: pTorus12
3300010: pTorus13
3300012: pTorus2
3300014: pTorus3
3300016: pTorus4
3300018: pTorus5
3300020: pTorus6
3300022: pTorus8
3300024: pTorus9
4300000: pCube1
4300002: pTorus1
4300004: pTorus2
4300006: pTorus3
4300008: pTorus4
4300010: pTorus5
4300012: pTorus6
4300014: pTorus8
4300016: pTorus9
4300018: pTorus10
4300020: pTorus11
4300022: pTorus12
4300024: pTorus13
9500000: //RootNode
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
optimizeGameObjects: 0
motionNodeName:
animationCompression: 1
animationRotationError: .5
animationPositionError: .5
animationScaleError: .5
animationWrapMode: 0
extraExposedTransformPaths: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: .00999999978
meshCompression: 0
addColliders: 0
importBlendShapes: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
weldVertices: 1
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
tangentSpace:
normalSmoothAngle: 60
splitTangentsAcrossUV: 1
normalImportMode: 0
tangentImportMode: 1
importAnimation: 1
copyAvatar: 0
humanDescription:
human: []
skeleton: []
armTwist: .5
foreArmTwist: .5
upperLegTwist: .5
legTwist: .5
armStretch: .0500000007
legStretch: .0500000007
feetSpacing: 0
rootMotionBoneName:
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
additionalBone: 0
userData:

BIN
playable/Assets/Lachlan_jump_work.unity View File


BIN
playable/Assets/Pinata.controller View File


+ 5
- 0
playable/Assets/Prefabs.meta View File

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: fb9b0f999f81a7a47b113adc8c0d8d8e
folderAsset: yes
DefaultImporter:
userData:

BIN
playable/Assets/Confetti.prefab → playable/Assets/Prefabs/Confetti.prefab View File


playable/Assets/Confetti.prefab.meta → playable/Assets/Prefabs/Confetti.prefab.meta View File


playable/Assets/Heart 1.prefab → playable/Assets/Prefabs/Heart 1.prefab View File


playable/Assets/Heart 1.prefab.meta → playable/Assets/Prefabs/Heart 1.prefab.meta View File


playable/Assets/Heart.prefab → playable/Assets/Prefabs/Heart.prefab View File


playable/Assets/Heart.prefab.meta → playable/Assets/Prefabs/Heart.prefab.meta View File


BIN
playable/Assets/Prefabs/candy.prefab View File


+ 4
- 0
playable/Assets/Prefabs/candy.prefab.meta View File

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 6b96e1a2024a3434ca84415e0bdba2bc
NativeFormatImporter:
userData:

+ 0
- 21
playable/Assets/Scripts/P2_weapon.cs View File

@ -1,21 +0,0 @@
using UnityEngine;
using System.Collections;
public class P2_weapon : MonoBehaviour {
// Use this for initialization
void Start () {
}
void Update (){
if (Input.GetKeyDown("space"))
transform.Translate (Vector3.right);
else if (Input.GetKeyUp("space"))
transform.Translate (Vector3.left);
}
// Update is called once per frame
}

+ 0
- 8
playable/Assets/Scripts/P2_weapon.cs.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f348d28f3452e574c9fe07574e3ca5ee
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 0
- 115
playable/Assets/Scripts/PlayerControler.cs View File

@ -1,115 +0,0 @@
using UnityEngine;
using System.Collections;
public class PlayerControler : MonoBehaviour {
public Animator animator;
// Use this for initialization
void Start () {
}
public float speed;
public Vector2 jumpVector;
public int health = 0;
private int displayedHealth = 0;
private bool updateHealth = false;
private float curDirection = -1;
public GameObject bullet;
public GameObject heart;
bool canJump = true;
public GameObject newConfetti;
void Update() {
Vector2 velo = rigidbody2D.velocity;
velo.x = Input.GetAxis ("Horizontal_P1") * speed;
rigidbody2D.velocity = velo;
animator.SetFloat("Velocity",velo.magnitude);
animator.SetBool ("Fall", !canJump);
if (curDirection != Input.GetAxisRaw ("Horizontal_P1"))
applyPlayerDirection (Input.GetAxisRaw ("Horizontal_P1"));
if (displayedHealth != health) {
updateHealth = true;
}
if (updateHealth)
displayHealth (health);
if (health == 0)
death();
if (Input.GetKey (KeyCode.UpArrow)){
if (canJump == true){
rigidbody2D.velocity = jumpVector;
canJump = false;
}
}
//if (Input.GetKey (KeyCode.Space)){
//shoot
//GameObject bulletGO = Instantiate (bullet) as GameObject;
//bulletGO.transform.position = transform.position;
//}
}
private void displayHealth(int health){
GameObject[] hearts = GameObject.FindGameObjectsWithTag("heartUI2");
foreach (GameObject desHeart in hearts)
GameObject.Destroy (desHeart);
for (int i=1; i<= health; i++) {
GameObject heartCanister = Instantiate (heart) as GameObject;
Vector3 heartPos = new Vector3 (1-(i * 0.033f), 0.95f, 0);
heartCanister.transform.position = heartPos;
}
displayedHealth = health;
updateHealth = false;
}
private void applyPlayerDirection(float moveHorizontal)
{
if (moveHorizontal != 0)
{
transform.Rotate(0,180,0);
curDirection = moveHorizontal;
}
}
private void Confettishoot(Vector3 target,float size){
Debug.Log ("Creating Confetti");
target.y += 1.5f;
for (int i = 0; i <size; i++) {
Instantiate (newConfetti, target, transform.rotation);
}
}
private void death(){
if (health == 0) {
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0);
health = 3;
transform.position = spawnPos;
rigidbody2D.velocity = Vector2.zero;
}
}
void OnCollisionEnter2D(Collision2D col){
if (col.collider.tag == "ground")
canJump = true;
else if (col.collider.tag == "Player") {
canJump = true;
if(transform.position.y>col.transform.position.y){
col.gameObject.GetComponent<player2_controls>().health --;
Confettishoot(col.gameObject.transform.position,20.0f);
//health --;
rigidbody2D.velocity = jumpVector;
canJump = false;
}
}
}
}

+ 43
- 0
playable/Assets/Scripts/collectable.cs View File

@ -0,0 +1,43 @@
using UnityEngine;
using System.Collections;
public class collectable : MonoBehaviour {
// Use this for initialization
void Start () {
float rand = Random.Range (0, 7);
int randColour = Mathf.FloorToInt (rand);
switch (randColour) {
case 0:
renderer.material.color = Color.cyan;
break;
case 1:
renderer.material.color = Color.red;
break;
case 2:
renderer.material.color = Color.blue;
break;
case 3:
renderer.material.color = Color.green;
break;
case 4:
renderer.material.color = Color.yellow;
break;
case 5:
renderer.material.color = Color.magenta;
break;
default:
renderer.material.color = Color.black;
break;
}
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (15, 30, 45) * Time.deltaTime);
}
}

playable/Assets/Scripts/PlayerControler.cs.meta → playable/Assets/Scripts/collectable.cs.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2f110149822ba46b39723c6d01336581
guid: de1432d88ba03a641ab648872aee7e07
MonoImporter:
serializedVersion: 2
defaultReferences: []

+ 0
- 116
playable/Assets/Scripts/player2_controls.cs View File

@ -1,116 +0,0 @@
using UnityEngine;
using System.Collections;
public class player2_controls : MonoBehaviour {
public Animator animator;
void Start () {
}
public float speed;
public Vector2 jumpVector;
public int health = 0;
private int displayedHealth = 0;
private bool updateHealth = false;
private float curDirection = 1;
public GameObject bullet;
public GameObject heart;
bool canJump = true;
public string HorizontalBtn;
public GameObject newConfetti;
//Horizontal_P2
void Update() {
Vector2 velo = rigidbody2D.velocity;
velo.x = Input.GetAxis (HorizontalBtn) * speed;
rigidbody2D.velocity = velo;
animator.SetFloat("Velocity",velo.magnitude);
animator.SetBool ("Fall", !canJump);
if (curDirection != Input.GetAxisRaw (HorizontalBtn))
applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn));
if (displayedHealth != health) {
updateHealth = true;
}
if (updateHealth)
displayHealth (health);
if (health == 0)
death();
if (Input.GetKey (KeyCode.W)){
if (canJump == true){
rigidbody2D.velocity = jumpVector;
canJump = false;
}
}
//if (Input.GetKey (KeyCode.Space)){
//shoot
//GameObject bulletGO = Instantiate (bullet) as GameObject;
//bulletGO.transform.posplayteition = transform.position;
//}
}
private void displayHealth(int health){
GameObject[] hearts = GameObject.FindGameObjectsWithTag("heartUI");
foreach (GameObject desHeart in hearts)
GameObject.Destroy (desHeart);
for (int i=1; i<= health; i++) {
GameObject heartCanister = Instantiate (heart) as GameObject;
Vector3 heartPos = new Vector3 ((i * 0.033f), 0.95f, 0);
heartCanister.transform.position = heartPos;
}
displayedHealth = health;
updateHealth = false;
}
//Changes direction of sprite according to key pressed
private void applyPlayerDirection(float moveHorizontal)
{
if (moveHorizontal != 0)
{
transform.Rotate(0,180,0);
curDirection = moveHorizontal;
}
}
private void Confettishoot(Vector3 target,float size){
Debug.Log ("Creating Confetti");
target.y += 1.5f;
for (int i = 0; i <size; i++) {
Instantiate (newConfetti, target, transform.rotation);
}
}
private void death(){
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0);
health = 3;
transform.position = spawnPos;
}
void OnCollisionEnter2D(Collision2D col){
if (col.collider.tag == "ground")
canJump = true;
else if (col.collider.tag == "Player") {
if(transform.position.y>col.transform.position.y){
col.gameObject.GetComponent<PlayerControler>().health --;
Confettishoot(col.gameObject.transform.position,20.0f);
//health --;
rigidbody2D.velocity = jumpVector;
canJump = false;
}
}
}
}

+ 0
- 8
playable/Assets/Scripts/player2_controls.cs.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e1ccee01ee999524e8c0e99f0e5ac3d8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 17
- 0
playable/Assets/Scripts/playerController.cs View File

@ -11,7 +11,9 @@ public class playerController : MonoBehaviour {
public Animator animator; //Holds animator for Pinata
public GameObject heart; //Health sprites
public GameObject newConfetti; //confetti when hit
public GameObject newCandy;
public stickController stick; //controller for stick
public GUIText scoreDisplay;
public float runSpeed; //run speed
public float jumpHeight; //jump height
@ -30,6 +32,7 @@ public class playerController : MonoBehaviour {
private bool isSpinning = false; //checks if player is spin attacking
private float lastHit;
private float lastAttack;
private int score;
void Start(){
@ -118,6 +121,9 @@ public class playerController : MonoBehaviour {
//respawns player if they die
private void death(){
if (health <= 0) {
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation);
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
health = 3; //resets life
transform.position = spawnPos; //changes position
@ -177,6 +183,17 @@ public class playerController : MonoBehaviour {
}
}
void OnTriggerEnter2D(Collider2D trig)
{
Debug.Log (trig.gameObject.tag);
if (trig.gameObject.tag == "candy")
{
trig.gameObject.SetActive (false);
score++;
scoreDisplay.text = "score: " + score.ToString ();
}
}

+ 0
- 16
playable/Assets/Scripts/sc.cs View File

@ -1,16 +0,0 @@
using UnityEngine;
using System.Collections;
public class sc : MonoBehaviour {
Quaternion rotation;
// Use this for initialization
void Awake () {
rotation = transform.rotation;
}
// Update is called once per frame
void LateUpdate () {
transform.rotation = rotation;
}
}

+ 0
- 8
playable/Assets/Scripts/sc.cs.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8664bb421145d654e8a7367a64b7ca5e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

playable/Assets/stickController.cs → playable/Assets/Scripts/stickController.cs View File


playable/Assets/stickController.cs.meta → playable/Assets/Scripts/stickController.cs.meta View File


BIN
playable/ProjectSettings/InputManager.asset View File


BIN
playable/ProjectSettings/TagManager.asset View File


Loading…
Cancel
Save