mirror of
https://github.com/ConjureETS/VZ.git
synced 2026-03-24 02:11:15 +00:00
Merge branch 'master' of github.com:ConjureETS/VZ
This commit is contained in:
commit
49470678d8
13
Assets/Prefabs/Node_1.prefab
Normal file
13
Assets/Prefabs/Node_1.prefab
Normal file
@ -0,0 +1,13 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 0}
|
||||
m_IsPrefabParent: 1
|
||||
8
Assets/Prefabs/Node_1.prefab.meta
Normal file
8
Assets/Prefabs/Node_1.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f3ac2d6f98b5d14b9b49ad004510568
|
||||
timeCreated: 1439582583
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Scenes/gab.meta
Normal file
9
Assets/Scenes/gab.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3b64e062cff77344b510dbbb76be08b
|
||||
folderAsset: yes
|
||||
timeCreated: 1439236349
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CharacterMovement : MonoBehaviour {
|
||||
|
||||
public int player;
|
||||
|
||||
public MovementManager mm;
|
||||
// code mis en commentaire par sam, raison : cannot convert from string to int (on ne pouvait pas compiler les scnènes dans unity sans mettre cette ligne en commentaire.)
|
||||
//enum direction { up = "Up",down = "Down", left = "Left", right = "Right", stop = "Stop" };
|
||||
enum direction { up, down, left, right, stop};
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
public void UpdateDirection()
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bee059a115db707408e1a8a8214d1c4c
|
||||
timeCreated: 1439332359
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -3,26 +3,50 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
/**
|
||||
* gere les inputs
|
||||
*
|
||||
* a placer sur les players
|
||||
*/
|
||||
|
||||
public class MovementManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public Queue<string> p1MovBuffer = new Queue<string>(4); // Buffer de mouvement pour le player 1
|
||||
public Queue<string> p2MovBuffer = new Queue<string>(4); //Buffer de mouvement pour le player 2
|
||||
public Queue<String> p1MovBuffer = new Queue<String>(4); // Buffer de mouvement pour le player 1
|
||||
//public Queue<String> p2MovBuffer = new Queue<String>(4); //Buffer de mouvement pour le player 2
|
||||
|
||||
// Use this for initialization
|
||||
void Awake()
|
||||
{
|
||||
p1MovBuffer.Enqueue("Stop");
|
||||
p2MovBuffer.Enqueue("Stop");
|
||||
|
||||
p1MovBuffer.Enqueue("Up");
|
||||
// p2MovBuffer.Enqueue("Up");
|
||||
|
||||
p1MovBuffer.Enqueue("Right");
|
||||
// p2MovBuffer.Enqueue("Right");
|
||||
|
||||
p1MovBuffer.Enqueue("Down");
|
||||
// p2MovBuffer.Enqueue("Down");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
string[] test = p1MovBuffer.ToArray();
|
||||
|
||||
|
||||
Debug.Log(test[0] + " " + test[1] + " " + test[2] + " " + test[3] + " ");
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
ReadMovement();
|
||||
Debug.Log(p1MovBuffer.Peek() + " " + p2MovBuffer.Peek());
|
||||
|
||||
Debug.Log(p1MovBuffer.Peek());
|
||||
|
||||
Debug.Log(Input.GetAxisRaw("Vertical1"));
|
||||
}
|
||||
|
||||
void ReadMovement()
|
||||
@ -31,15 +55,15 @@ public class MovementManager : MonoBehaviour
|
||||
{
|
||||
p1MovBuffer.Enqueue("Up");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.A))
|
||||
if (Input.GetKeyDown(KeyCode.A))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Left");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Down");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.D))
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Right");
|
||||
}
|
||||
@ -48,39 +72,58 @@ public class MovementManager : MonoBehaviour
|
||||
{
|
||||
p1MovBuffer.Enqueue("Up");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.J))
|
||||
if (Input.GetKeyDown(KeyCode.J))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Left");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.K))
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Down");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.L))
|
||||
if (Input.GetKeyDown(KeyCode.L))
|
||||
{
|
||||
p1MovBuffer.Enqueue("Right");
|
||||
}
|
||||
|
||||
|
||||
// Debug.Log(p1MovBuffer.First.ToString() + " " + p2MovBuffer.First.ToString());
|
||||
}
|
||||
|
||||
string getNextDirection(int playerID)
|
||||
public string[] TransferBuffer(int playerId)
|
||||
{
|
||||
try
|
||||
/* switch (playerId)
|
||||
{
|
||||
if (playerID == 1)
|
||||
{
|
||||
return p1MovBuffer.Dequeue();
|
||||
}
|
||||
else if (playerID == 2)
|
||||
{
|
||||
return p2MovBuffer.Dequeue();
|
||||
}
|
||||
}catch(InvalidOperationException exception)
|
||||
{
|
||||
Debug.LogError("Reached the end of the queue we stop by default!: " + exception);
|
||||
case 1:
|
||||
|
||||
return "Stop";
|
||||
fillBuffWithEmpty(1, 4 - p1MovBuffer.Count);
|
||||
return p1MovBuffer.ToArray();
|
||||
|
||||
case 2:
|
||||
fillBuffWithEmpty(2, 4 - p2MovBuffer.Count);
|
||||
return p2MovBuffer.ToArray();
|
||||
}*/
|
||||
|
||||
|
||||
fillBuffWithEmpty(1, 4 - p1MovBuffer.Count);
|
||||
return p1MovBuffer.ToArray();
|
||||
}
|
||||
return null;
|
||||
|
||||
void fillBuffWithEmpty(int id, int num)
|
||||
{
|
||||
for (int u = 0; u < num; u++)
|
||||
{
|
||||
if(id == 1){
|
||||
p1MovBuffer.Enqueue("Stop");
|
||||
}
|
||||
/* else if(id ==2){
|
||||
p2MovBuffer.Enqueue("Stop");
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ResetBuffer()
|
||||
{
|
||||
p1MovBuffer = new Queue<string>(4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ public class Node : MonoBehaviour {
|
||||
public Node n_down;
|
||||
public Node n_right;
|
||||
|
||||
SquadMovement validSquad;
|
||||
|
||||
public Vector3 pos;
|
||||
|
||||
void Start()
|
||||
@ -32,4 +34,66 @@ public class Node : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == "VampirePlayer" || other.tag == "ZombiePlayer")
|
||||
{
|
||||
validSquad = other.GetComponent<SquadMovement>();
|
||||
Node newTarget = sendNextNode(validSquad.ChangeDirection());
|
||||
validSquad.changeTarget(newTarget);
|
||||
Debug.Log((int)validSquad.dir);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
validSquad = null;
|
||||
}
|
||||
|
||||
public Node sendNextNode(int direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 1: //up
|
||||
|
||||
if (n_up != null)
|
||||
{
|
||||
return n_up;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2: //down
|
||||
|
||||
if (n_down != null)
|
||||
{
|
||||
return n_down;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: //left
|
||||
|
||||
if (n_left != null)
|
||||
{
|
||||
return n_left;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: //right
|
||||
|
||||
if (n_right != null)
|
||||
{
|
||||
return n_right;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: //stop
|
||||
|
||||
//validSquad.UpdateDirection();
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef5779c31ae1e344e918bafb5061a31e
|
||||
timeCreated: 1439240437
|
||||
timeCreated: 1439498965
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Path{
|
||||
|
||||
Node start;
|
||||
Node end;
|
||||
|
||||
public Path(Node start,Node end){
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
|
||||
//TODO fonction de points
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vector3 getNext()
|
||||
{
|
||||
|
||||
return Vector3.one;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5515fca9c85963498137a7a41550f13
|
||||
timeCreated: 1439240491
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Pathfinding : MonoBehaviour {
|
||||
|
||||
public Transform target;
|
||||
NavMeshAgent agent;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
agent = GetComponent<NavMeshAgent> ();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
agent.SetDestination (target.position);
|
||||
|
||||
}
|
||||
}
|
||||
103
Assets/Scripts/SquadMovement.cs
Normal file
103
Assets/Scripts/SquadMovement.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
/**
|
||||
* gere les deplacements des squads
|
||||
* entre les nodes.
|
||||
*
|
||||
* a attacher aux squads
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
public class SquadMovement : MonoBehaviour {
|
||||
|
||||
public float speed;
|
||||
|
||||
String[] movementBuffer = new String[5];
|
||||
|
||||
int bufferIndex = 0;
|
||||
|
||||
public enum direction : int { up = 1, down = 2, left = 3, right = 4, stop = 5 };
|
||||
public direction dir = direction.stop;
|
||||
|
||||
public MovementManager mm;
|
||||
|
||||
Node target;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
movementBuffer[4] = "stop";
|
||||
|
||||
getNewBuffet();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if(target!=null)
|
||||
{
|
||||
|
||||
transform.position = Vector3.MoveTowards(transform.position, target.pos, speed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
getNewBuffet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void changeTarget(Node newTarget)
|
||||
{
|
||||
target = newTarget;
|
||||
}
|
||||
|
||||
public int ChangeDirection()
|
||||
{
|
||||
string newDir = movementBuffer[bufferIndex];
|
||||
|
||||
|
||||
if (newDir.ToLower().Equals("up"))
|
||||
{
|
||||
dir = direction.up;
|
||||
}
|
||||
else if (newDir.ToLower().Equals("down"))
|
||||
{
|
||||
dir = direction.down;
|
||||
}
|
||||
else if (newDir.ToLower().Equals("left"))
|
||||
{
|
||||
dir = direction.left;
|
||||
}
|
||||
else if (newDir.ToLower().Equals("right"))
|
||||
{
|
||||
dir = direction.right;
|
||||
}
|
||||
else //if (newDir.ToLower().Equals("stop") || newDir == null)
|
||||
{
|
||||
dir = direction.stop;
|
||||
|
||||
}
|
||||
|
||||
movementBuffer[bufferIndex] = "stop";
|
||||
|
||||
if (bufferIndex < 5)
|
||||
{
|
||||
bufferIndex++;
|
||||
}
|
||||
|
||||
return (int)dir;
|
||||
}
|
||||
|
||||
public void getNewBuffet()
|
||||
{
|
||||
string[] newBuffer = mm.TransferBuffer(0);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
movementBuffer[i] = newBuffer[i];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f200319be173a744b3096ba4d6a1673
|
||||
timeCreated: 1439238331
|
||||
guid: 2aef95dc5d20b9940b40da72e3a41995
|
||||
timeCreated: 1439574844
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@ -77,6 +77,7 @@ PlayerSettings:
|
||||
metroEnableIndependentInputSource: 0
|
||||
metroEnableLowLatencyPresentationAPI: 0
|
||||
xboxOneDisableKinectGpuReservation: 0
|
||||
virtualRealitySupported: 0
|
||||
productGUID: 54ead80470c104b4682c53a4f7f867b5
|
||||
AndroidBundleVersionCode: 1
|
||||
AndroidMinSdkVersion: 9
|
||||
@ -254,7 +255,6 @@ PlayerSettings:
|
||||
psp2InfoBarOnStartup: 0
|
||||
psp2InfoBarColor: 0
|
||||
psmSplashimage: {fileID: 0}
|
||||
virtualRealitySupported: 0
|
||||
spritePackerPolicy:
|
||||
scriptingDefineSymbols: {}
|
||||
metroPackageName: VZ
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 5.1.0f3
|
||||
m_EditorVersion: 5.1.2f1
|
||||
m_StandardAssetsVersion: 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user