Separated walk AI from demon/patron reactions.
This commit is contained in:
parent
0a866b7574
commit
1be47add34
11 changed files with 464 additions and 886 deletions
19
Assets/Scripts/Demon.cs
Normal file
19
Assets/Scripts/Demon.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Demon : MonoBehaviour {
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
|
||||
//Instantiate(explosion, transform.position, transform.rotation);
|
||||
if (other.tag == "Shank")
|
||||
{
|
||||
//Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
if (other.tag == "VVAura") {
|
||||
renderer.material.color = Color.red;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Scripts/Demon.cs.meta
Normal file
8
Assets/Scripts/Demon.cs.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40684efec06376d45b9c87a038a40253
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
|||
|
||||
public class NavPoint : MonoBehaviour {
|
||||
void OnTriggerEnter(Collider other) {
|
||||
Patron p = other.gameObject.GetComponent<Patron>();
|
||||
WalkAI p = other.gameObject.GetComponent<WalkAI>();
|
||||
if(p != null)
|
||||
p.NextDest();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,28 +3,6 @@ using System.Collections;
|
|||
|
||||
public class Patron : MonoBehaviour {
|
||||
|
||||
public GameObject[] destinations;
|
||||
public int currentDestIndex = 0;
|
||||
public Material evilMat;
|
||||
public Material neutralMat;
|
||||
|
||||
private NavMeshAgent nva;
|
||||
|
||||
void Awake() {
|
||||
nva = GetComponent<NavMeshAgent>();
|
||||
nva.updateRotation = false;
|
||||
nva.SetDestination(destinations[currentDestIndex].transform.position);
|
||||
}
|
||||
|
||||
public void NextDest() {
|
||||
if(currentDestIndex + 1 < destinations.Length)
|
||||
++currentDestIndex;
|
||||
else
|
||||
currentDestIndex = 0;
|
||||
|
||||
nva.SetDestination(destinations[currentDestIndex].transform.position);
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
|
||||
//Instantiate(explosion, transform.position, transform.rotation);
|
||||
|
|
@ -33,14 +11,5 @@ public class Patron : MonoBehaviour {
|
|||
//Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
if (other.tag == "VVAura") {
|
||||
renderer.material = evilMat;
|
||||
}
|
||||
|
||||
// gameController.AddScore (scoreValue);
|
||||
//
|
||||
// Destroy (other.gameObject);
|
||||
// Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,10 @@ public class PlayerController : MonoBehaviour {
|
|||
animator.SetBool("isWalking", true);
|
||||
}
|
||||
|
||||
if (moveHorizontal < 0)
|
||||
if (moveHorizontal < 0) {
|
||||
playerAngle.eulerAngles = new Vector3(0f, -180f, 0f);
|
||||
|
||||
}
|
||||
if (moveHorizontal > 0)
|
||||
playerAngle.eulerAngles = new Vector3(0f, 0f, 0f);
|
||||
if (moveVertical < 0)
|
||||
|
|
@ -70,8 +72,8 @@ public class PlayerController : MonoBehaviour {
|
|||
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
|
||||
|
||||
rigidbody.MovePosition (rigidbody.position + movement * speed * Time.deltaTime);
|
||||
rigidbody.position.Normalize ();
|
||||
|
||||
rigidbody.freezeRotation = true;
|
||||
rigidbody.position.Normalize ();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Assets/Scripts/WalkAI.cs
Normal file
27
Assets/Scripts/WalkAI.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class WalkAI : MonoBehaviour {
|
||||
|
||||
public GameObject[] destinations;
|
||||
public int currentDestIndex = 0;
|
||||
public Material evilMat;
|
||||
public Material neutralMat;
|
||||
|
||||
private NavMeshAgent nva;
|
||||
|
||||
void Awake() {
|
||||
nva = GetComponent<NavMeshAgent>();
|
||||
nva.updateRotation = false;
|
||||
nva.SetDestination(destinations[currentDestIndex].transform.position);
|
||||
}
|
||||
|
||||
public void NextDest() {
|
||||
if(currentDestIndex + 1 < destinations.Length)
|
||||
++currentDestIndex;
|
||||
else
|
||||
currentDestIndex = 0;
|
||||
|
||||
nva.SetDestination(destinations[currentDestIndex].transform.position);
|
||||
}
|
||||
}
|
||||
8
Assets/Scripts/WalkAI.cs.meta
Normal file
8
Assets/Scripts/WalkAI.cs.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc3037736f75b53479f5da8bd507b6eb
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Loading…
Add table
Add a link
Reference in a new issue