mirror of
https://github.com/ConjureETS/VZ.git
synced 2026-03-25 10:51:14 +00:00
add move enqueuing to PlayerController
refactor of MovementManager to allow PlayerController to handle the player inputs. refactor of PlayerController to have only one script and identify the player in the editor.
This commit is contained in:
parent
e71ce63d66
commit
7d97ddcc5d
@ -9,6 +9,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- 4: {fileID: 464164}
|
- 4: {fileID: 464164}
|
||||||
- 114: {fileID: 11428944}
|
- 114: {fileID: 11428944}
|
||||||
|
- 114: {fileID: 11410490}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player1
|
m_Name: Player1
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -28,6 +29,17 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
|
--- !u!114 &11410490
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 126110}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 58bf12fc7f7dfb9419306d55b94c77b6, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!114 &11428944
|
--- !u!114 &11428944
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -39,6 +51,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: ab440c57173b5b343b5201cc8f701ff2, type: 3}
|
m_Script: {fileID: 11500000, guid: ab440c57173b5b343b5201cc8f701ff2, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
player: 1
|
||||||
squadCamera: {fileID: 0}
|
squadCamera: {fileID: 0}
|
||||||
squads:
|
squads:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- 4: {fileID: 455296}
|
- 4: {fileID: 455296}
|
||||||
- 114: {fileID: 11486914}
|
- 114: {fileID: 11486914}
|
||||||
|
- 114: {fileID: 11410742}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player2
|
m_Name: Player2
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -28,6 +29,17 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
|
--- !u!114 &11410742
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 101062}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 58bf12fc7f7dfb9419306d55b94c77b6, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!114 &11486914
|
--- !u!114 &11486914
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -36,9 +48,10 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 101062}
|
m_GameObject: {fileID: 101062}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 742e02efdaddce54e8bda108068bbb89, type: 3}
|
m_Script: {fileID: 11500000, guid: ab440c57173b5b343b5201cc8f701ff2, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
player: 2
|
||||||
squadCamera: {fileID: 0}
|
squadCamera: {fileID: 0}
|
||||||
squads:
|
squads:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
|||||||
@ -219,64 +219,6 @@ MonoBehaviour:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 1421464866}
|
m_PrefabInternal: {fileID: 1421464866}
|
||||||
m_Script: {fileID: 11500000, guid: ae1349c2c40a05449b456e20d48361aa, type: 3}
|
m_Script: {fileID: 11500000, guid: ae1349c2c40a05449b456e20d48361aa, type: 3}
|
||||||
--- !u!1001 &658517498
|
|
||||||
Prefab:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
m_TransformParent: {fileID: 0}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: 1000
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: m_RootOrder
|
|
||||||
value: 11
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: squadCamera
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 1558258210}
|
|
||||||
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: squads.Array.data[0]
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 79076741}
|
|
||||||
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: squads.Array.data[1]
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 694353573}
|
|
||||||
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
propertyPath: squads.Array.data[2]
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 2069028069}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
|
||||||
m_IsPrefabParent: 0
|
|
||||||
--- !u!114 &694353573
|
--- !u!114 &694353573
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9,
|
m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9,
|
||||||
@ -778,6 +720,64 @@ MonoBehaviour:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 2086876520}
|
m_PrefabInternal: {fileID: 2086876520}
|
||||||
m_Script: {fileID: 11500000, guid: c1cd93867b8a1d7459a4fb92cac63854, type: 3}
|
m_Script: {fileID: 11500000, guid: c1cd93867b8a1d7459a4fb92cac63854, type: 3}
|
||||||
|
--- !u!1001 &2009087786
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 1000
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 455296, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 11
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: squadCamera
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1558258210}
|
||||||
|
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: squads.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 79076741}
|
||||||
|
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: squads.Array.data[1]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 694353573}
|
||||||
|
- target: {fileID: 11486914, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
propertyPath: squads.Array.data[2]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 2069028069}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 100100000, guid: 2e61328c26d7dda4d8eb6ee2099bc806, type: 2}
|
||||||
|
m_IsPrefabParent: 0
|
||||||
--- !u!114 &2069028069
|
--- !u!114 &2069028069
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9,
|
m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9,
|
||||||
|
|||||||
@ -12,83 +12,91 @@ using System;
|
|||||||
public class MovementManager : MonoBehaviour
|
public class MovementManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
public Queue<String> p1MovBuffer = new Queue<String>(4); // Buffer de mouvement pour le player 1
|
public Queue<String> moveBuffer = new Queue<String>(4); // Buffer de mouvement
|
||||||
//public Queue<String> p2MovBuffer = new Queue<String>(4); //Buffer de mouvement pour le player 2
|
|
||||||
|
|
||||||
|
public const string UP = "Up";
|
||||||
|
public const string DOWN = "Down";
|
||||||
|
public const string LEFT = "Left";
|
||||||
|
public const string RIGHT = "Right";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
|
//test
|
||||||
|
moveBuffer.Enqueue("Up");
|
||||||
|
|
||||||
p1MovBuffer.Enqueue("Up");
|
moveBuffer.Enqueue("Right");
|
||||||
// p2MovBuffer.Enqueue("Up");
|
|
||||||
|
|
||||||
p1MovBuffer.Enqueue("Right");
|
|
||||||
// p2MovBuffer.Enqueue("Right");
|
|
||||||
|
|
||||||
p1MovBuffer.Enqueue("Down");
|
|
||||||
// p2MovBuffer.Enqueue("Down");
|
|
||||||
|
|
||||||
|
|
||||||
|
moveBuffer.Enqueue("Down");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
string[] test = p1MovBuffer.ToArray();
|
string[] test = moveBuffer.ToArray();
|
||||||
|
|
||||||
|
|
||||||
Debug.Log(test[0] + " " + test[1] + " " + test[2] + " " + test[3] + " ");
|
//Debug.Log(test[0] + " " + test[1] + " " + test[2] + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
ReadMovement();
|
//ReadMovement();
|
||||||
|
|
||||||
Debug.Log(p1MovBuffer.Peek());
|
//Debug.Log(moveBuffer.Peek());
|
||||||
|
|
||||||
Debug.Log(Input.GetAxisRaw("Vertical1"));
|
//Debug.Log(Input.GetAxisRaw("Vertical1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadMovement()
|
void ReadMovement()
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.W))
|
if (Input.GetKeyDown(KeyCode.W))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Up");
|
moveBuffer.Enqueue("Up");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.A))
|
if (Input.GetKeyDown(KeyCode.A))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Left");
|
moveBuffer.Enqueue("Left");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.S))
|
if (Input.GetKeyDown(KeyCode.S))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Down");
|
moveBuffer.Enqueue("Down");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.D))
|
if (Input.GetKeyDown(KeyCode.D))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Right");
|
moveBuffer.Enqueue("Right");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.I))
|
if (Input.GetKeyDown(KeyCode.I))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Up");
|
moveBuffer.Enqueue("Up");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.J))
|
if (Input.GetKeyDown(KeyCode.J))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Left");
|
moveBuffer.Enqueue("Left");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.K))
|
if (Input.GetKeyDown(KeyCode.K))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Down");
|
moveBuffer.Enqueue("Down");
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.L))
|
if (Input.GetKeyDown(KeyCode.L))
|
||||||
{
|
{
|
||||||
p1MovBuffer.Enqueue("Right");
|
moveBuffer.Enqueue("Right");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Debug.Log(p1MovBuffer.First.ToString() + " " + p2MovBuffer.First.ToString());
|
// Debug.Log(p1MovBuffer.First.ToString() + " " + p2MovBuffer.First.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnqueuMove(string move){
|
||||||
|
|
||||||
|
moveBuffer.Enqueue(move);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public string[] TransferBuffer(int playerId)
|
public string[] TransferBuffer(int playerId)
|
||||||
{
|
{
|
||||||
/* switch (playerId)
|
/* switch (playerId)
|
||||||
@ -104,8 +112,8 @@ public class MovementManager : MonoBehaviour
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
fillBuffWithEmpty(1, 4 - p1MovBuffer.Count);
|
fillBuffWithEmpty(1, 4 - moveBuffer.Count);
|
||||||
return p1MovBuffer.ToArray();
|
return moveBuffer.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillBuffWithEmpty(int id, int num)
|
void fillBuffWithEmpty(int id, int num)
|
||||||
@ -113,7 +121,7 @@ public class MovementManager : MonoBehaviour
|
|||||||
for (int u = 0; u < num; u++)
|
for (int u = 0; u < num; u++)
|
||||||
{
|
{
|
||||||
if(id == 1){
|
if(id == 1){
|
||||||
p1MovBuffer.Enqueue("Stop");
|
moveBuffer.Enqueue("Stop");
|
||||||
}
|
}
|
||||||
/* else if(id ==2){
|
/* else if(id ==2){
|
||||||
p2MovBuffer.Enqueue("Stop");
|
p2MovBuffer.Enqueue("Stop");
|
||||||
@ -124,6 +132,6 @@ public class MovementManager : MonoBehaviour
|
|||||||
|
|
||||||
void ResetBuffer()
|
void ResetBuffer()
|
||||||
{
|
{
|
||||||
p1MovBuffer = new Queue<string>(4);
|
moveBuffer = new Queue<string>(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
public class Player1Controller : MonoBehaviour {
|
|
||||||
|
|
||||||
public SquadCamera squadCamera;
|
|
||||||
public Squad[] squads;
|
|
||||||
|
|
||||||
// Use this for initialization
|
|
||||||
void Start () {
|
|
||||||
squadCamera.SetTarget(squads[0].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update () {
|
|
||||||
|
|
||||||
if (Input.GetAxisRaw("Opt1-1") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[0].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
else if (Input.GetAxisRaw("Opt2-1") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[1].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
else if (Input.GetAxisRaw("Opt3-1") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[2].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
public class Player2Controller : MonoBehaviour {
|
|
||||||
|
|
||||||
public SquadCamera squadCamera;
|
|
||||||
public Squad[] squads;
|
|
||||||
|
|
||||||
// Use this for initialization
|
|
||||||
void Start () {
|
|
||||||
squadCamera.SetTarget(squads[0].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update () {
|
|
||||||
|
|
||||||
if (Input.GetAxisRaw("Opt1-2") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[0].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
else if (Input.GetAxisRaw("Opt2-2") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[1].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
else if (Input.GetAxisRaw("Opt3-2") == 1f) {
|
|
||||||
squadCamera.SetTarget(squads[2].gameObject.transform.position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 742e02efdaddce54e8bda108068bbb89
|
|
||||||
timeCreated: 1439572844
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
80
Assets/Scripts/PlayerController.cs
Normal file
80
Assets/Scripts/PlayerController.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class PlayerController : MonoBehaviour {
|
||||||
|
|
||||||
|
public enum Player { Player1 = 1, Player2 = 2 };
|
||||||
|
public Player player;
|
||||||
|
|
||||||
|
public SquadCamera squadCamera;
|
||||||
|
public Squad[] squads;
|
||||||
|
private int currentSquadIndex;
|
||||||
|
|
||||||
|
private float lastHorizontalAxis = 0f;
|
||||||
|
private float lastVerticalAxis = 0f;
|
||||||
|
|
||||||
|
MovementManager movementManager;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
currentSquadIndex = 0;
|
||||||
|
squadCamera.SetTarget(squads[currentSquadIndex].gameObject.transform.position);
|
||||||
|
|
||||||
|
movementManager = GetComponent<MovementManager>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
|
||||||
|
// switching between squads
|
||||||
|
if (Input.GetButtonDown("Opt1-" + (int)player)) {
|
||||||
|
currentSquadIndex = 0;
|
||||||
|
squadCamera.SetTarget(squads[0].gameObject.transform.position);
|
||||||
|
}
|
||||||
|
if (Input.GetButtonDown("Opt2-" + (int)player)) {
|
||||||
|
currentSquadIndex = 1;
|
||||||
|
squadCamera.SetTarget(squads[1].gameObject.transform.position);
|
||||||
|
}
|
||||||
|
if (Input.GetButtonDown("Opt3-" + (int)player)) {
|
||||||
|
currentSquadIndex = 2;
|
||||||
|
squadCamera.SetTarget(squads[2].gameObject.transform.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
// movements
|
||||||
|
|
||||||
|
float horizontalAxis = Input.GetAxisRaw("Horizontal" + (int)player);
|
||||||
|
if (horizontalAxis != 0 && horizontalAxis != lastHorizontalAxis) { // only enqueue a move when it is a new key press
|
||||||
|
|
||||||
|
if (horizontalAxis == 1f) {
|
||||||
|
movementManager.EnqueuMove(MovementManager.RIGHT);
|
||||||
|
}
|
||||||
|
else if (horizontalAxis == -1f) {
|
||||||
|
movementManager.EnqueuMove(MovementManager.LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
lastHorizontalAxis = horizontalAxis;
|
||||||
|
|
||||||
|
float verticalAxis = Input.GetAxisRaw("Vertical" + (int)player);
|
||||||
|
if (verticalAxis != 0 && verticalAxis != lastVerticalAxis) { // only enqueue a move when it is a new key press
|
||||||
|
|
||||||
|
if (verticalAxis == 1f) {
|
||||||
|
movementManager.EnqueuMove(MovementManager.UP);
|
||||||
|
}
|
||||||
|
else if (verticalAxis == -1f) {
|
||||||
|
movementManager.EnqueuMove(MovementManager.DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
lastVerticalAxis = verticalAxis;
|
||||||
|
|
||||||
|
|
||||||
|
//TODO add human interaction button (heal/retreat)
|
||||||
|
|
||||||
|
|
||||||
|
//TODO add squad mode button (transform/capture)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,17 +3,19 @@
|
|||||||
--- !u!129 &1
|
--- !u!129 &1
|
||||||
PlayerSettings:
|
PlayerSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 7
|
serializedVersion: 6
|
||||||
AndroidProfiler: 0
|
AndroidProfiler: 0
|
||||||
defaultScreenOrientation: 4
|
defaultScreenOrientation: 4
|
||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
|
targetGlesGraphics: -1
|
||||||
|
targetIOSGraphics: -1
|
||||||
targetResolution: 0
|
targetResolution: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: DefaultCompany
|
||||||
productName: VZ
|
productName: VZ
|
||||||
|
cloudProjectId:
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
m_ShowUnitySplashScreen: 1
|
|
||||||
defaultScreenWidth: 1024
|
defaultScreenWidth: 1024
|
||||||
defaultScreenHeight: 768
|
defaultScreenHeight: 768
|
||||||
defaultScreenWidthWeb: 960
|
defaultScreenWidthWeb: 960
|
||||||
@ -23,6 +25,7 @@ PlayerSettings:
|
|||||||
m_ActiveColorSpace: 0
|
m_ActiveColorSpace: 0
|
||||||
m_MTRendering: 1
|
m_MTRendering: 1
|
||||||
m_MobileMTRendering: 0
|
m_MobileMTRendering: 0
|
||||||
|
m_UseDX11: 1
|
||||||
m_Stereoscopic3D: 0
|
m_Stereoscopic3D: 0
|
||||||
iosShowActivityIndicatorOnLoading: -1
|
iosShowActivityIndicatorOnLoading: -1
|
||||||
androidShowActivityIndicatorOnLoading: -1
|
androidShowActivityIndicatorOnLoading: -1
|
||||||
@ -77,7 +80,6 @@ PlayerSettings:
|
|||||||
metroEnableIndependentInputSource: 0
|
metroEnableIndependentInputSource: 0
|
||||||
metroEnableLowLatencyPresentationAPI: 0
|
metroEnableLowLatencyPresentationAPI: 0
|
||||||
xboxOneDisableKinectGpuReservation: 0
|
xboxOneDisableKinectGpuReservation: 0
|
||||||
virtualRealitySupported: 0
|
|
||||||
productGUID: 54ead80470c104b4682c53a4f7f867b5
|
productGUID: 54ead80470c104b4682c53a4f7f867b5
|
||||||
AndroidBundleVersionCode: 1
|
AndroidBundleVersionCode: 1
|
||||||
AndroidMinSdkVersion: 9
|
AndroidMinSdkVersion: 9
|
||||||
@ -116,11 +118,9 @@ PlayerSettings:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 0
|
rgba: 0
|
||||||
iOSLaunchScreenFillPct: 1
|
iOSLaunchScreenFillPct: 1
|
||||||
iOSLaunchScreenSize: 100
|
|
||||||
iOSLaunchScreenCustomXibPath:
|
iOSLaunchScreenCustomXibPath:
|
||||||
AndroidTargetDevice: 0
|
AndroidTargetDevice: 0
|
||||||
AndroidSplashScreenScale: 0
|
AndroidSplashScreenScale: 0
|
||||||
androidSplashScreen: {fileID: 0}
|
|
||||||
AndroidKeystoreName:
|
AndroidKeystoreName:
|
||||||
AndroidKeyaliasName:
|
AndroidKeyaliasName:
|
||||||
AndroidTVCompatibility: 1
|
AndroidTVCompatibility: 1
|
||||||
@ -130,7 +130,6 @@ PlayerSettings:
|
|||||||
- width: 320
|
- width: 320
|
||||||
height: 180
|
height: 180
|
||||||
banner: {fileID: 0}
|
banner: {fileID: 0}
|
||||||
androidGamepadSupportLevel: 0
|
|
||||||
resolutionDialogBanner: {fileID: 0}
|
resolutionDialogBanner: {fileID: 0}
|
||||||
m_BuildTargetIcons:
|
m_BuildTargetIcons:
|
||||||
- m_BuildTarget:
|
- m_BuildTarget:
|
||||||
@ -138,7 +137,6 @@ PlayerSettings:
|
|||||||
- m_Icon: {fileID: 0}
|
- m_Icon: {fileID: 0}
|
||||||
m_Size: 128
|
m_Size: 128
|
||||||
m_BuildTargetBatching: []
|
m_BuildTargetBatching: []
|
||||||
m_BuildTargetGraphicsAPIs: []
|
|
||||||
webPlayerTemplate: APPLICATION:Default
|
webPlayerTemplate: APPLICATION:Default
|
||||||
m_TemplateCustomTags: {}
|
m_TemplateCustomTags: {}
|
||||||
actionOnDotNetUnhandledException: 1
|
actionOnDotNetUnhandledException: 1
|
||||||
@ -200,7 +198,6 @@ PlayerSettings:
|
|||||||
ps4ApplicationParam2: 0
|
ps4ApplicationParam2: 0
|
||||||
ps4ApplicationParam3: 0
|
ps4ApplicationParam3: 0
|
||||||
ps4ApplicationParam4: 0
|
ps4ApplicationParam4: 0
|
||||||
ps4GarlicHeapSize: 2048
|
|
||||||
ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ
|
ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ
|
||||||
ps4pnSessions: 1
|
ps4pnSessions: 1
|
||||||
ps4pnPresence: 1
|
ps4pnPresence: 1
|
||||||
@ -212,7 +209,6 @@ PlayerSettings:
|
|||||||
psp2NPTrophyPackPath:
|
psp2NPTrophyPackPath:
|
||||||
psp2NPSupportGBMorGJP: 0
|
psp2NPSupportGBMorGJP: 0
|
||||||
psp2NPAgeRating: 12
|
psp2NPAgeRating: 12
|
||||||
psp2NPTitleDatPath:
|
|
||||||
psp2NPCommsID:
|
psp2NPCommsID:
|
||||||
psp2NPCommunicationsID:
|
psp2NPCommunicationsID:
|
||||||
psp2NPCommsPassphrase:
|
psp2NPCommsPassphrase:
|
||||||
@ -227,7 +223,6 @@ PlayerSettings:
|
|||||||
psp2PatchOriginalPackage:
|
psp2PatchOriginalPackage:
|
||||||
psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui
|
psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui
|
||||||
psp2KeystoneFile:
|
psp2KeystoneFile:
|
||||||
psp2MemoryExpansionMode: 0
|
|
||||||
psp2DRMType: 0
|
psp2DRMType: 0
|
||||||
psp2StorageType: 0
|
psp2StorageType: 0
|
||||||
psp2MediaCapacity: 0
|
psp2MediaCapacity: 0
|
||||||
@ -343,7 +338,8 @@ PlayerSettings:
|
|||||||
blackberrySquareSplashScreen: {fileID: 0}
|
blackberrySquareSplashScreen: {fileID: 0}
|
||||||
tizenProductDescription:
|
tizenProductDescription:
|
||||||
tizenProductURL:
|
tizenProductURL:
|
||||||
tizenSigningProfileName:
|
tizenCertificatePath:
|
||||||
|
tizenCertificatePassword:
|
||||||
tizenGPSPermissions: 0
|
tizenGPSPermissions: 0
|
||||||
tizenMicrophonePermissions: 0
|
tizenMicrophonePermissions: 0
|
||||||
stvDeviceAddress:
|
stvDeviceAddress:
|
||||||
@ -362,7 +358,6 @@ PlayerSettings:
|
|||||||
XboxOnePackagingOverridePath:
|
XboxOnePackagingOverridePath:
|
||||||
XboxOneAppManifestOverridePath:
|
XboxOneAppManifestOverridePath:
|
||||||
XboxOnePackageEncryption: 0
|
XboxOnePackageEncryption: 0
|
||||||
XboxOnePackageUpdateGranularity: 2
|
|
||||||
XboxOneDescription:
|
XboxOneDescription:
|
||||||
XboxOneIsContentPackage: 0
|
XboxOneIsContentPackage: 0
|
||||||
XboxOneEnableGPUVariability: 0
|
XboxOneEnableGPUVariability: 0
|
||||||
@ -405,9 +400,4 @@ PlayerSettings:
|
|||||||
WebGL::emscriptenArgs:
|
WebGL::emscriptenArgs:
|
||||||
WebGL::template: APPLICATION:Default
|
WebGL::template: APPLICATION:Default
|
||||||
additionalIl2CppArgs::additionalIl2CppArgs:
|
additionalIl2CppArgs::additionalIl2CppArgs:
|
||||||
firstStreamedSceneWithResources: 0
|
firstStreamedLevelWithResources: 0
|
||||||
cloudProjectId:
|
|
||||||
projectId:
|
|
||||||
projectName:
|
|
||||||
organizationId:
|
|
||||||
cloudEnabled: 0
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user