From 536df032a32560a6239e023d6219a3c1d20878ce Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Tue, 5 May 2015 19:00:46 +1000 Subject: [PATCH 1/3] Player has millisecond of invulnerability after getting hit. added rest time between attacks --- playable/Assets/Lachlan_jump_work.unity | Bin 147340 -> 147780 bytes playable/Assets/Scripts/PlayerControler.cs | 1 + playable/Assets/Scripts/playerController.cs | 25 +++++++++++++++++++- playable/Assets/stickController.cs | 4 +++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/playable/Assets/Lachlan_jump_work.unity b/playable/Assets/Lachlan_jump_work.unity index 0ba32460bfbe831facebf999c16e54457dee501f..b893a0b44981f6f8b3b33973113ccf86ce22354a 100644 GIT binary patch delta 5530 zcmZYD4^&gv9S89H03nd52r5*uprS*q5&irBpR9_!ls^UmK}E#^zG$b7 zf2tIAO6F?KJnM?Kw$yZmxpqd|I#yc`h=0=d92dLV#dclUJZFtNN7?rR4}Ul1oCnD# z-}mmlzkBaX!l6FRM|;8}8S^~Pf)*}fjD_Q|^QFja*PgOo$<;OTw&Y3-afOU2t*Elp zu(D0tw^ghxt1Mw5$fh^n3VS5dQd46oDqmwMtLaArFnY?WrJHIDtZb_ZDj_-#2mj%Z z*;4+Cv3t!ECro!On&=I7eWkm+VGOUudiNESW+KjS$JMJc%f5A zy&k>CXHFW19+F;4!@!5zi+M9{;;T zPQ1=b&krrk4?Bd%>b&b<_EF-38xC{B_+nEBHv-0@#09+K4^^^a1k%#v0G%*eh2%SL z%6?eoU`Kdo^e}6*n41lA!(_a!PE!gjVYE0US=D{A35G?e42>=u=mgf|WOZ~7XN)Cb zjKp$bY88GBtA)|BUif5%#S@VG5T+k1=05H@VQGX}hOUSDUj+JrwBf(NYGcH59lzUc z>3}s3+`0O1Tub+RpEZpW=lw~T6GkgI-5F8j56I1c?Xr8@>WdnjlU|56lkZyF{6YU;H@k`?{zNNE>#-G>?iGY$`Mt z%dlUNhMQq-7@d+c-o3>M@#6Jduv!?&DeS+>(P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h&cR=Z25XjCl^=1~90L&P4S z2}pyd3KliGVPiLov3teD7;B?gz;}`abHeC%3+LM!Qw#ZA5zGi{k1Ts|{nN?@8ht>z z;by~hMSO#beZ-@IZc_r4D~y9{)0>KGEfH664n+TZ}N-<$Cqg% zO!Fw;@jJE0n=CMTBHo30qjL8B2}bQ>^d5lv{~p)}q%+Qw=NsAM{I6I(OoY+gSNr0( zI$^ZquVKnn{6vZyHg7e;=n`vTE-5N_?%Ng3>R<5<{t0G=(T*Pu=$buIxy3L|37@-q z;!LvzMhAEe<_+h@pZ~lmA8gY;AuyRd!)>ql-S)w!_($y)nD*EFqjoFI1H=b9-Sn7|p$^P__7@a=kEJ zDPI}?l*O%mr4rxZJs{KZ4Q5~XpjCv?0p`G*QMpgwyWE;u#_yRMFcXX}-G_g^-s*yd zj&bn(2Y3HpfZB3CcphehiTFJ7L^BBU!{|BQmR__|^(;TY-@r^T+A%9K?{r1wBmtQD z93Na_&uo)nbjDdQcT`SttZq}U=5sR445J;t;;U@)!03J908Fz6&wq67_BM-cwl#c% z`(Qp8&6Pi9Xw$9b|KYe1cd*T~j{ojWnC5wYFtPE6+bpoLyJ-0S9|vUX`CvRu52NKz zfH`5b{CR5*wtHaoH)7=EopwVde{x1)URXDlGx#GEygrqHrYipE+<^7N3J@6kFO{*I zFdvK@9X9xWT!&iZH{1}+0;A*k0`|p>qN{92mMKlqLw%dxz45G^>19(W|{J%yT?bra diff --git a/playable/Assets/Scripts/PlayerControler.cs b/playable/Assets/Scripts/PlayerControler.cs index 4c7cf86..63d996f 100644 --- a/playable/Assets/Scripts/PlayerControler.cs +++ b/playable/Assets/Scripts/PlayerControler.cs @@ -92,6 +92,7 @@ public class PlayerControler : MonoBehaviour { Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); health = 3; transform.position = spawnPos; + rigidbody2D.velocity = Vector2.zero; } } diff --git a/playable/Assets/Scripts/playerController.cs b/playable/Assets/Scripts/playerController.cs index e560130..fe2aacd 100644 --- a/playable/Assets/Scripts/playerController.cs +++ b/playable/Assets/Scripts/playerController.cs @@ -18,6 +18,9 @@ public class playerController : MonoBehaviour { public float health; //holds health public int confettiOnHit; //amount of confetti created on hit public Vector2 healthPos; + public float invulTime; + public float attackWait; + public bool isHit; private float displayedHealth = 3; //currently displayed health private bool updateHealth = true; //if the health bar needs updating @@ -25,6 +28,8 @@ public class playerController : MonoBehaviour { private bool canJump = true; // if player can jump private List hearts = new List (); //list which holds health sprites; private bool isSpinning = false; //checks if player is spin attacking + private float lastHit; + private float lastAttack; void Start(){ @@ -42,6 +47,7 @@ public class playerController : MonoBehaviour { displayHealth (); death (); applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn)); + damage (); } void FixedUpdate() { @@ -59,8 +65,10 @@ public class playerController : MonoBehaviour { }//end if if (Input.GetAxisRaw (StrongAttackBtn)==1) { - if (!isSpinning) + if (!isSpinning && (lastAttack+attackWait) < Time.time){ + lastAttack = Time.time; StartCoroutine (spinAttack (Vector3.down * 360, 0.2f)); + } } @@ -113,6 +121,7 @@ public class playerController : MonoBehaviour { 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 + rigidbody2D.velocity = Vector2.zero; }//end if }//end death @@ -126,6 +135,17 @@ public class playerController : MonoBehaviour { } } + private void damage (){ + if (isHit) { + gameObject.GetComponent ().enabled = false; + isHit = false; + lastHit = Time.time; + } + if (lastHit+invulTime < Time.time) + gameObject.GetComponent ().enabled = true; + + + } IEnumerator spinAttack(Vector3 byAngles, float inTime) { isSpinning = true; stick.isAttacking = true; @@ -144,6 +164,9 @@ public class playerController : MonoBehaviour { isSpinning = false; stick.isAttacking = false; } + + + void OnCollisionEnter2D(Collision2D col){ diff --git a/playable/Assets/stickController.cs b/playable/Assets/stickController.cs index d413aa0..9bcbabc 100644 --- a/playable/Assets/stickController.cs +++ b/playable/Assets/stickController.cs @@ -38,9 +38,11 @@ public class stickController : MonoBehaviour { if(transform.position.y>col.transform.position.y){ if (isAttacking){ col.gameObject.GetComponent().health --; + col.gameObject.GetComponent().isHit = true; Confettishoot(col.gameObject.transform.position,col.gameObject.GetComponent().confettiOnHit); + Vector2 velocity = col.rigidbody.velocity; - velocity.y = 22; + velocity.y = 20; col.rigidbody.velocity = velocity; } } From fcb83b69369c74ba7a7782f8cd5dd96fae90d751 Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Tue, 5 May 2015 19:36:49 +1000 Subject: [PATCH 2/3] Added Xbox controller compatibility for player 1 and 2 --- playable/Assets/Lachlan_jump_work.unity | Bin 147780 -> 147780 bytes playable/Assets/Scripts/playerController.cs | 2 +- playable/ProjectSettings/InputManager.asset | Bin 5680 -> 5720 bytes 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/playable/Assets/Lachlan_jump_work.unity b/playable/Assets/Lachlan_jump_work.unity index b893a0b44981f6f8b3b33973113ccf86ce22354a..283b1a778ec26ec79c9d6c8be5bc9b18f60d7558 100644 GIT binary patch delta 69 zcmX@o#CfENvtbM449n>a28aOBofWf3Rd^VPu@X*OJj3NPV?r%x7fWo@&JyITuLpzs@+7 VZ+e3Pqr~KfM=aY5o-tmD0st4a7#siq diff --git a/playable/Assets/Scripts/playerController.cs b/playable/Assets/Scripts/playerController.cs index fe2aacd..3bafde4 100644 --- a/playable/Assets/Scripts/playerController.cs +++ b/playable/Assets/Scripts/playerController.cs @@ -46,7 +46,7 @@ public class playerController : MonoBehaviour { displayHealth (); death (); - applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn)); + applyPlayerDirection (Input.GetAxis (HorizontalBtn)); damage (); } diff --git a/playable/ProjectSettings/InputManager.asset b/playable/ProjectSettings/InputManager.asset index 3320af6415ef1fedf568ff441e0967b7f450e2a1..d1c057cff9992ecdc62c603eb51a6a7d3b21a9f5 100644 GIT binary patch delta 267 zcmdm>b3=!Nfq^ZNfk7-{BS#DyX9ODq11|#*Z!Tn;%sIJ%jb$^7KnU|>4gs0THEbfH zML+B985kOXn1O)_L;wNfPBA~&EIq?BTKpq01m}~^Il?iC8 Y@Z=4G0;o0{q1wzexlvSlvV-Uc02+xpd;kCd delta 227 zcmcbivq6W0fq^ZNfkDh*BS#DyrvV!S11|#*Z!Tn;%sIJ%jb$^7KnOD*7f{S2zbLaR zKd&S)XL2E%oJvf;lN|#?gFR4&feA!F0nk8(u+*ZG%w(`a87;U%MuOV3;f?CdF(3r1eD<#XzDkB}T|f6eb&q$W8ttC^K0_OoSOI1yVlQMMwh7H-_?8 Lh{{aP5d8oE>mVpO From 363a01052741b07544a8485429e3b84f5ec8a75b Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Tue, 5 May 2015 21:31:57 +1000 Subject: [PATCH 3/3] Fixed issue with keyboard controls messing with joystick --- playable/Assets/Scripts/playerController.cs | 2 +- .../ProjectSettings/QualitySettings.asset | Bin 4568 -> 4568 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/playable/Assets/Scripts/playerController.cs b/playable/Assets/Scripts/playerController.cs index 3bafde4..fe2aacd 100644 --- a/playable/Assets/Scripts/playerController.cs +++ b/playable/Assets/Scripts/playerController.cs @@ -46,7 +46,7 @@ public class playerController : MonoBehaviour { displayHealth (); death (); - applyPlayerDirection (Input.GetAxis (HorizontalBtn)); + applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn)); damage (); } diff --git a/playable/ProjectSettings/QualitySettings.asset b/playable/ProjectSettings/QualitySettings.asset index 9cd45cbbd32cce4756f0f7db126f288306543a2d..7b8d57c2d2e8634b7196277c0eb0037392c2ae00 100644 GIT binary patch delta 12 Tcmcbid_#GH1f$7D$^C)=ASeWG delta 12 Tcmcbid_#GH1f%gr$^C)=AR`2A