Commit 0a222f89 authored by Danny Huang's avatar Danny Huang
Browse files

updated comments

parent 44698136
......@@ -4,8 +4,10 @@ using System.Collections;
public class HeroDeathCtrl : DeathCtrl
{
/* Component to display notification that Hero is dead */
public Text deathTextUI;
/* Gun prefab for Hero to always spawn with */
public GameObject reviveStartingGun;
protected bool isDead;
......@@ -37,6 +39,7 @@ public class HeroDeathCtrl : DeathCtrl
return this.isDead;
}
/* Freeze and hide the Hero. Any carried items will be dropped. Death message will appear. */
public override void Die()
{
base.Die();
......@@ -58,6 +61,7 @@ public class HeroDeathCtrl : DeathCtrl
this.heroHealthCtrl.numLives--;
}
/* Unfreeze and reveal the Hero. The Hero will be moved to the PlayerSpawn gameObject. */
public void Revive()
{
base.Die();
......
......@@ -6,6 +6,7 @@ public class HeroHealthCtrl : HealthCtrl
{
public Text healthTextUI;
/* Number of lives. Feature is unimplemented. */
public int numLives;
protected Rigidbody2D rb;
......@@ -29,6 +30,10 @@ public class HeroHealthCtrl : HealthCtrl
this.healthTextUI.text = "Health: " + this.currentHealth;
}
/* Call this function whenever the Hero touches an environmental hazard.
*
* @amount - value to ADD to hero health. To deduce health, use a negative value.
*/
public void TakeEnvironmentDamage(int amount)
{
if (!((HeroDeathCtrl)this.deathCtrl).IsDead())
......@@ -43,6 +48,7 @@ public class HeroHealthCtrl : HealthCtrl
this.currentHealth = this.startingHealth;
}
/* Handle any collision with a projectile. */
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Projectile"))
......
......@@ -93,6 +93,7 @@ public class HeroMovement : MonoBehaviour {
}
}
/* Update the Hero's facing direction based on the location of the mouse cursor */
public void UpdateHeroDirection(Vector3 mouseWorldPos=default(Vector3))
{
Vector2 direction = mouseWorldPos - this.transform.position;
......
......@@ -13,6 +13,8 @@ public class RandomItemCtrl : MonoBehaviour {
void Start ()
{
/* Spawn a random item and delete myself */
this.itemGenCtrl = GameObject.FindGameObjectWithTag("ItemGenerator").GetComponent<ItemGeneratorCtrl>();
Item item = (Item)this.itemGenCtrl.GetRandomItem(this.type, this.subtype, this.rarity);
......
......@@ -4,13 +4,20 @@ using System.Collections;
public class TypewriterEffect : MonoBehaviour {
/* Message to display */
[TextArea]
public string message;
/* Speed of the message reveal */
public float charPerSec;
/* Time when the next char will be revealed */
protected float nextCharRevealTime;
/* Index of next char to reveal*/
protected int nextCharIdx;
/* Component to display the text */
protected Text textComp;
void Start ()
......@@ -22,7 +29,10 @@ public class TypewriterEffect : MonoBehaviour {
void Update ()
{
/* If the message isn't completely revealed */
if (textComp.text != this.message) {
/* Reveal the next character if it's time or the next char to reveal is a whitespace */
if (Time.time > this.nextCharRevealTime || char.IsWhiteSpace(this.message[nextCharIdx])) {
this.textComp.text += message[nextCharIdx];
......
......@@ -3,6 +3,8 @@ using System.Collections;
public class Hazard : MonoBehaviour
{
/* Attach this script to any enviromental hazard */
public bool isInstantDeathZone = false;
void OnCollisionEnter2D(Collision2D other)
......
......@@ -3,6 +3,8 @@ using System.Collections;
public class BackgroundMusicCtrl : MonoBehaviour
{
/* Loop a song that's labelled "Background" in the child speaker object. */
protected SpeakerCtrl speakerCtrl;
void Start ()
......
......@@ -4,6 +4,8 @@ using System.Collections;
public class BounceText : MonoBehaviour
{
/* Add this script to a Text UI gameObject. It will make the text bounce up and down */
public float speed;
public float maxUpDist;
......
......@@ -12,6 +12,7 @@ public class HeroConstWalk : MonoBehaviour
void Update ()
{
/* Make the character always playing its walking animation */
this.anim.SetFloat ("Speed", 1);
}
}
\ No newline at end of file
using UnityEngine;
using System.Collections;
public class ScrollingGroundCtrl : MonoBehaviour {
public class ScrollingGroundCtrl : MonoBehaviour
{
/* Attach this script to any background gameObject to make it move left and right and reset
its position whenever reaches a specific position.x
*/
public float speed;
public bool isMovingRight;
public float resetPos_x;
/* Reset position when this position.x is reached */
public float resetPos_x;
protected Vector3 originalPos;
......@@ -17,10 +23,12 @@ public class ScrollingGroundCtrl : MonoBehaviour {
void Update ()
{
/* Move background */
Vector3 newPos = this.transform.position;
newPos.x -= this.speed;
this.transform.position = newPos;
/* Reset background position if exceeded limit */
if (this.isMovingRight) {
if (this.transform.position.x < resetPos_x) {
this.transform.position = this.originalPos;
......
Supports Markdown
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