Patrons now spawn in and are randomly assigned demon status.

This commit is contained in:
shakurass 2014-04-27 19:49:21 -06:00
commit 5d203d1e9d
12 changed files with 111 additions and 1189 deletions

View file

@ -6,14 +6,14 @@ public class GameController : MonoBehaviour {
public int swigs;
public GUIText swigText;
public GUIText scoreText;
public int patronCount;
public int maxPatrons;
public float spawnWait;
public float startWait;
public float waveWait;
public GameObject[] patron;
public GameObject[] patronObjects;
private int score = 0;
private int patrons = 0;
private int patronCounter = 0;
// Use this for initialization
void Start () {
@ -34,14 +34,14 @@ public class GameController : MonoBehaviour {
while (true)
{
if (patrons < patronCount)
if (patronCounter < maxPatrons)
{
Vector3 spawnPosition = new Vector3 (40f, 2.5f, 10f);
Vector3 spawnPosition = new Vector3 (8f, 9.7f, -3f);
Quaternion spawnRotation = Quaternion.identity;
GameObject patron = Instantiate (patron[Random.Range (0, patron.Length)], spawnPosition, spawnRotation);
Instantiate (patronObjects[Random.Range (0, patronObjects.Length-1)], spawnPosition, spawnRotation);
patrons++;
patronCounter++;
yield return new WaitForSeconds (spawnWait);
}
@ -58,11 +58,13 @@ public class GameController : MonoBehaviour {
public void AddScore() {
score += 100;
UpdateScoreText ();
patronCounter--;
}
public void DetractScore() {
score -= 150;
UpdateScoreText ();
patronCounter--;
}
void UpdateSwigText() {

View file

@ -2,8 +2,10 @@
using System.Collections;
public class Patron : MonoBehaviour {
public Renderer characterSprite;
private GameController gameController;
private bool isDemon = false;
void Start() {
GameObject gameControllerObject = GameObject.FindWithTag("GameController");
@ -12,6 +14,9 @@ public class Patron : MonoBehaviour {
gameController = gameControllerObject.GetComponent <GameController> ();
else
Debug.Log("Cannot find GameController script.");
if (Random.value > 0.6)
isDemon = true;
}
void OnTriggerEnter(Collider other) {
@ -20,7 +25,14 @@ public class Patron : MonoBehaviour {
{
//Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
Destroy(gameObject);
gameController.DetractScore ();
if(isDemon)
gameController.AddScore ();
else
gameController.DetractScore ();
}
if (other.tag == "VVAura" && isDemon) {
characterSprite.renderer.material.color = Color.red;
}
}
}

View file

@ -60,57 +60,69 @@ public class PlayerController : MonoBehaviour {
gameController.TakeSwig();
animator.Play("player_swig");
}
}
void FixedUpdate() {
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
if (moveVertical > 0){ // Walking up
if (moveHorizontal < 0 && moveVertical > 0) { // left up
playerAngle.eulerAngles = new Vector3(0f, -135, 0f);
MakePlayerSpriteFace(Direction.Left);
animator.SetBool("isWalkingUp", true);
animator.SetBool("isWalking", false);
}
else if (!Mathf.Approximately (moveHorizontal, 0) || moveVertical < 0) { // walking sideways
else if (moveHorizontal < 0 && moveVertical < 0) {// left down
playerAngle.eulerAngles = new Vector3(0f, -225f, 0f);
MakePlayerSpriteFace(Direction.Left);
animator.SetBool("isWalking", true);
animator.SetBool("isWalkingUp", false);
}
else if (moveHorizontal > 0 && moveVertical > 0) {//right up
playerAngle.eulerAngles = new Vector3(0f, -45f, 0f);
MakePlayerSpriteFace(Direction.Right);
animator.SetBool("isWalkingUp", true);
animator.SetBool("isWalking", false);
}
else if (moveHorizontal > 0 && moveVertical < 0) {//right down
playerAngle.eulerAngles = new Vector3(0f, 45f, 0f);
MakePlayerSpriteFace(Direction.Right);
animator.SetBool("isWalking", true);
animator.SetBool("isWalkingUp", false);
}
else if (moveHorizontal < 0) { // Stab left
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
MakePlayerSpriteFace(Direction.Left);
animator.SetBool("isWalking", true);
animator.SetBool("isWalkingUp", false);
}
else if (moveHorizontal > 0) { // Stab right
playerAngle.eulerAngles = new Vector3 (0f, 0f, 0f);
MakePlayerSpriteFace(Direction.Right);
animator.SetBool("isWalking", true);
animator.SetBool("isWalkingUp", false);
}
else if (moveVertical < 0) {// Stab down
playerAngle.eulerAngles = new Vector3(0f, -270f, 0f);
animator.SetBool("isWalking", true);
animator.SetBool("isWalkingUp", false);
}
else if (moveVertical > 0) // Stab up
{
playerAngle.eulerAngles = new Vector3(0f, -90f, 0f);
animator.SetBool("isWalkingUp", true);
animator.SetBool("isWalking", false);
}
else {
animator.SetBool("isWalking", false);
animator.SetBool("isWalkingUp", false);
}
if (moveHorizontal < 0 && moveVertical > 0) { // left up
playerAngle.eulerAngles = new Vector3(0f, -135, 0f);
MakePlayerSpriteFace(Direction.Left);
}
else if (moveHorizontal < 0 && moveVertical < 0) {// left down
playerAngle.eulerAngles = new Vector3(0f, -225f, 0f);
MakePlayerSpriteFace(Direction.Left);
}
else if (moveHorizontal > 0 && moveVertical > 0) {//right up
playerAngle.eulerAngles = new Vector3(0f, -45f, 0f);
MakePlayerSpriteFace(Direction.Right);
}
else if (moveHorizontal > 0 && moveVertical < 0) {//right down
playerAngle.eulerAngles = new Vector3(0f, 45f, 0f);
MakePlayerSpriteFace(Direction.Right);
}
else if (moveHorizontal < 0) { // Stab left
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
MakePlayerSpriteFace(Direction.Left);
}
else if (moveHorizontal > 0) { // Stab right
playerAngle.eulerAngles = new Vector3 (0f, 0f, 0f);
MakePlayerSpriteFace(Direction.Right);
}
else if (moveVertical < 0) // Stab down
playerAngle.eulerAngles = new Vector3(0f, -270f, 0f);
else if (moveVertical > 0) // Stab up
playerAngle.eulerAngles = new Vector3(0f, -90f, 0f);
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
rigidbody.freezeRotation = true;
}
void FixedUpdate() {
}
}

View file

@ -3,12 +3,23 @@ using System.Collections;
public class WalkAI : MonoBehaviour {
public GameObject[] destinations;
private GameObject[] destinations;
public int currentDestIndex = 0;
private NavMeshAgent nva;
void Awake() {
GameObject[] allPois = GameObject.FindGameObjectsWithTag("pois");
GameObject poi1 = allPois[Random.Range (0, allPois.Length)];
GameObject poi2 = allPois[Random.Range (0, allPois.Length)];
destinations = new GameObject[2] {
poi1,
poi2
};
nva = GetComponent<NavMeshAgent>();
nva.updateRotation = false;
nva.SetDestination(destinations[currentDestIndex].transform.position);