Conflicts:
	Assets/Audio/beneath-surface-4.ogg.meta
	Assets/Scripts/PlayerController.cs
This commit is contained in:
Wilson Leong 2014-04-26 21:59:52 -06:00
commit 65e43434b9
20 changed files with 561 additions and 284 deletions

View file

@ -0,0 +1,40 @@
using UnityEngine;
using System.Collections;
public class AnimateSprite : MonoBehaviour {
public int columns = 2;
public int rows = 2;
public float framesPerSecond = 10f;
//the current frame to display
private int index = 0;
void Start()
{
StartCoroutine(updateTiling());
//set the tile size of the texture (in UV units), based on the rows and columns
Vector2 size = new Vector2(1f / columns, 1f / rows);
renderer.sharedMaterial.SetTextureScale("_MainTex", size);
}
private IEnumerator updateTiling()
{
while (true)
{
//move to the next index
index++;
if (index >= rows * columns)
index = 0;
//split into x and y indexes
Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
(index / columns) / (float)rows); //y index
renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
yield return new WaitForSeconds(1f / framesPerSecond);
}
}
}

View file

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

View file

@ -0,0 +1,41 @@
using UnityEngine;
using System.Collections;
public class AnimateTexture : MonoBehaviour {
public int columns = 2;
public int rows = 2;
public float framesPerSecond = 10f;
//the current frame to display
private int index = 0;
void Start()
{
StartCoroutine(updateTiling());
//set the tile size of the texture (in UV units), based on the rows and columns
Vector2 size = new Vector2(1f / columns, 1f / rows);
renderer.sharedMaterial.SetTextureScale("_MainTex", size);
}
private IEnumerator updateTiling()
{
while (true)
{
//move to the next index
index++;
if (index >= rows * columns)
index = 0;
//split into x and y indexes
Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
(index / columns) / (float)rows); //y index
renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
yield return new WaitForSeconds(1f / framesPerSecond);
}
}
}

View file

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

View file

@ -0,0 +1,27 @@
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
public int swigs;
public GUIText swigText;
// Use this for initialization
void Start () {
UpdateSwigText ();
}
// Update is called once per frame
void Update () {
}
public void TakeSwig() {
swigs -= 1;
UpdateSwigText();
}
void UpdateSwigText() {
swigText.text = "Swigs Left: " + swigs;
}
}

View file

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

View file

@ -11,7 +11,16 @@ public class PlayerController : MonoBehaviour {
public Transform shankSpawn;
public GameObject vvAura;
public int swigCounter;
private int swigs = 0;
private GameController gameController;
void Start() {
GameObject gameControllerObject = GameObject.FindWithTag("GameController");
if (gameControllerObject != null)
gameController = gameControllerObject.GetComponent <GameController> ();
else
Debug.Log("Cannot find GameController script.");
}
private Animator animator;
@ -24,19 +33,17 @@ public class PlayerController : MonoBehaviour {
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
//audio.Play ();
nextFire = Time.time + delay;
Instantiate(shank, shankSpawn.position, playerAngle.rotation);
//animator.SetInteger("state", 3);
animator.Play("player_shank");
}
if (Input.GetButton("ActivateVV") && swigs < swigCounter && Time.time > nextFire)
if (Input.GetButton("ActivateVV") && gameController.swigs > 0 && Time.time > nextFire)
{
nextFire = Time.time + delay * 2;
Instantiate (vvAura, rigidbody.position, rigidbody.rotation);
swigs++;
//animator.SetInteger("state", 1);
gameController.TakeSwig();
animator.Play("player_swig");
}
}
@ -56,11 +63,11 @@ public class PlayerController : MonoBehaviour {
if (moveHorizontal < 0)
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
else if (moveHorizontal > 0)
if (moveHorizontal > 0)
playerAngle.eulerAngles = new Vector3(0f, 0f, 0f);
else if (moveVertical < 0)
if (moveVertical < 0)
playerAngle.eulerAngles = new Vector3(0f, -270f, 0f);
else if (moveVertical > 0)
if (moveVertical > 0)
playerAngle.eulerAngles = new Vector3(0f, -90f, 0f);
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);