diff --git a/Assets/Prefabs/Player1.prefab b/Assets/Prefabs/Player1.prefab index f430481..45d82a8 100644 --- a/Assets/Prefabs/Player1.prefab +++ b/Assets/Prefabs/Player1.prefab @@ -9,6 +9,7 @@ GameObject: m_Component: - 4: {fileID: 464164} - 114: {fileID: 11428944} + - 114: {fileID: 11410490} m_Layer: 0 m_Name: Player1 m_TagString: Untagged @@ -28,6 +29,17 @@ Transform: m_Children: [] m_Father: {fileID: 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 MonoBehaviour: m_ObjectHideFlags: 1 @@ -39,6 +51,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ab440c57173b5b343b5201cc8f701ff2, type: 3} m_Name: m_EditorClassIdentifier: + player: 1 squadCamera: {fileID: 0} squads: - {fileID: 0} diff --git a/Assets/Prefabs/Player2.prefab b/Assets/Prefabs/Player2.prefab index 90eae82..105303c 100644 --- a/Assets/Prefabs/Player2.prefab +++ b/Assets/Prefabs/Player2.prefab @@ -9,6 +9,7 @@ GameObject: m_Component: - 4: {fileID: 455296} - 114: {fileID: 11486914} + - 114: {fileID: 11410742} m_Layer: 0 m_Name: Player2 m_TagString: Untagged @@ -28,6 +29,17 @@ Transform: m_Children: [] m_Father: {fileID: 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 MonoBehaviour: m_ObjectHideFlags: 1 @@ -36,9 +48,10 @@ MonoBehaviour: m_GameObject: {fileID: 101062} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 742e02efdaddce54e8bda108068bbb89, type: 3} + m_Script: {fileID: 11500000, guid: ab440c57173b5b343b5201cc8f701ff2, type: 3} m_Name: m_EditorClassIdentifier: + player: 2 squadCamera: {fileID: 0} squads: - {fileID: 0} diff --git a/Assets/Scenes/jp.unity b/Assets/Scenes/jp.unity index 8666903..06e5ed8 100644 --- a/Assets/Scenes/jp.unity +++ b/Assets/Scenes/jp.unity @@ -219,64 +219,6 @@ MonoBehaviour: type: 2} m_PrefabInternal: {fileID: 1421464866} 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 MonoBehaviour: m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9, @@ -778,6 +720,64 @@ MonoBehaviour: type: 2} m_PrefabInternal: {fileID: 2086876520} 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 MonoBehaviour: m_PrefabParentObject: {fileID: 11458372, guid: 8d6d640df84c10549b99d9ccf6b349d9, diff --git a/Assets/Scripts/MovementManager.cs b/Assets/Scripts/MovementManager.cs index 00208e1..d679e8f 100644 --- a/Assets/Scripts/MovementManager.cs +++ b/Assets/Scripts/MovementManager.cs @@ -12,83 +12,91 @@ using System; public class MovementManager : MonoBehaviour { - public Queue p1MovBuffer = new Queue(4); // Buffer de mouvement pour le player 1 - //public Queue p2MovBuffer = new Queue(4); //Buffer de mouvement pour le player 2 + public Queue moveBuffer = new Queue(4); // Buffer de mouvement + + + public const string UP = "Up"; + public const string DOWN = "Down"; + public const string LEFT = "Left"; + public const string RIGHT = "Right"; + + // Use this for initialization void Awake() { + //test + moveBuffer.Enqueue("Up"); - p1MovBuffer.Enqueue("Up"); - // p2MovBuffer.Enqueue("Up"); - - p1MovBuffer.Enqueue("Right"); - // p2MovBuffer.Enqueue("Right"); - - p1MovBuffer.Enqueue("Down"); - // p2MovBuffer.Enqueue("Down"); - + moveBuffer.Enqueue("Right"); + moveBuffer.Enqueue("Down"); } 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() { - ReadMovement(); + //ReadMovement(); - Debug.Log(p1MovBuffer.Peek()); + //Debug.Log(moveBuffer.Peek()); - Debug.Log(Input.GetAxisRaw("Vertical1")); + //Debug.Log(Input.GetAxisRaw("Vertical1")); } void ReadMovement() { if (Input.GetKeyDown(KeyCode.W)) { - p1MovBuffer.Enqueue("Up"); + moveBuffer.Enqueue("Up"); } if (Input.GetKeyDown(KeyCode.A)) { - p1MovBuffer.Enqueue("Left"); + moveBuffer.Enqueue("Left"); } if (Input.GetKeyDown(KeyCode.S)) { - p1MovBuffer.Enqueue("Down"); + moveBuffer.Enqueue("Down"); } if (Input.GetKeyDown(KeyCode.D)) { - p1MovBuffer.Enqueue("Right"); + moveBuffer.Enqueue("Right"); } if (Input.GetKeyDown(KeyCode.I)) { - p1MovBuffer.Enqueue("Up"); + moveBuffer.Enqueue("Up"); } if (Input.GetKeyDown(KeyCode.J)) { - p1MovBuffer.Enqueue("Left"); + moveBuffer.Enqueue("Left"); } if (Input.GetKeyDown(KeyCode.K)) { - p1MovBuffer.Enqueue("Down"); + moveBuffer.Enqueue("Down"); } if (Input.GetKeyDown(KeyCode.L)) { - p1MovBuffer.Enqueue("Right"); + moveBuffer.Enqueue("Right"); } // Debug.Log(p1MovBuffer.First.ToString() + " " + p2MovBuffer.First.ToString()); } + public void EnqueuMove(string move){ + + moveBuffer.Enqueue(move); + } + + public string[] TransferBuffer(int playerId) { /* switch (playerId) @@ -104,8 +112,8 @@ public class MovementManager : MonoBehaviour }*/ - fillBuffWithEmpty(1, 4 - p1MovBuffer.Count); - return p1MovBuffer.ToArray(); + fillBuffWithEmpty(1, 4 - moveBuffer.Count); + return moveBuffer.ToArray(); } void fillBuffWithEmpty(int id, int num) @@ -113,7 +121,7 @@ public class MovementManager : MonoBehaviour for (int u = 0; u < num; u++) { if(id == 1){ - p1MovBuffer.Enqueue("Stop"); + moveBuffer.Enqueue("Stop"); } /* else if(id ==2){ p2MovBuffer.Enqueue("Stop"); @@ -124,6 +132,6 @@ public class MovementManager : MonoBehaviour void ResetBuffer() { - p1MovBuffer = new Queue(4); + moveBuffer = new Queue(4); } } diff --git a/Assets/Scripts/Player1Controller.cs b/Assets/Scripts/Player1Controller.cs deleted file mode 100644 index 68ad251..0000000 --- a/Assets/Scripts/Player1Controller.cs +++ /dev/null @@ -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); - } - - - } -} diff --git a/Assets/Scripts/Player2Controller.cs b/Assets/Scripts/Player2Controller.cs deleted file mode 100644 index 1b3321a..0000000 --- a/Assets/Scripts/Player2Controller.cs +++ /dev/null @@ -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); - } - } -} diff --git a/Assets/Scripts/Player2Controller.cs.meta b/Assets/Scripts/Player2Controller.cs.meta deleted file mode 100644 index 36b9747..0000000 --- a/Assets/Scripts/Player2Controller.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 742e02efdaddce54e8bda108068bbb89 -timeCreated: 1439572844 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs new file mode 100644 index 0000000..81fa14b --- /dev/null +++ b/Assets/Scripts/PlayerController.cs @@ -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(); + + } + + // 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) + + + } +} diff --git a/Assets/Scripts/Player1Controller.cs.meta b/Assets/Scripts/PlayerController.cs.meta similarity index 100% rename from Assets/Scripts/Player1Controller.cs.meta rename to Assets/Scripts/PlayerController.cs.meta diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 1110906..59334a4 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,17 +3,19 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 7 + serializedVersion: 6 AndroidProfiler: 0 defaultScreenOrientation: 4 targetDevice: 2 + targetGlesGraphics: -1 + targetIOSGraphics: -1 targetResolution: 0 accelerometerFrequency: 60 companyName: DefaultCompany productName: VZ + cloudProjectId: defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} - m_ShowUnitySplashScreen: 1 defaultScreenWidth: 1024 defaultScreenHeight: 768 defaultScreenWidthWeb: 960 @@ -23,6 +25,7 @@ PlayerSettings: m_ActiveColorSpace: 0 m_MTRendering: 1 m_MobileMTRendering: 0 + m_UseDX11: 1 m_Stereoscopic3D: 0 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 @@ -77,7 +80,6 @@ PlayerSettings: metroEnableIndependentInputSource: 0 metroEnableLowLatencyPresentationAPI: 0 xboxOneDisableKinectGpuReservation: 0 - virtualRealitySupported: 0 productGUID: 54ead80470c104b4682c53a4f7f867b5 AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 9 @@ -116,11 +118,9 @@ PlayerSettings: serializedVersion: 2 rgba: 0 iOSLaunchScreenFillPct: 1 - iOSLaunchScreenSize: 100 iOSLaunchScreenCustomXibPath: AndroidTargetDevice: 0 AndroidSplashScreenScale: 0 - androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: AndroidTVCompatibility: 1 @@ -130,7 +130,6 @@ PlayerSettings: - width: 320 height: 180 banner: {fileID: 0} - androidGamepadSupportLevel: 0 resolutionDialogBanner: {fileID: 0} m_BuildTargetIcons: - m_BuildTarget: @@ -138,7 +137,6 @@ PlayerSettings: - m_Icon: {fileID: 0} m_Size: 128 m_BuildTargetBatching: [] - m_BuildTargetGraphicsAPIs: [] webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} actionOnDotNetUnhandledException: 1 @@ -200,7 +198,6 @@ PlayerSettings: ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 ps4ApplicationParam4: 0 - ps4GarlicHeapSize: 2048 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 ps4pnPresence: 1 @@ -212,7 +209,6 @@ PlayerSettings: psp2NPTrophyPackPath: psp2NPSupportGBMorGJP: 0 psp2NPAgeRating: 12 - psp2NPTitleDatPath: psp2NPCommsID: psp2NPCommunicationsID: psp2NPCommsPassphrase: @@ -227,7 +223,6 @@ PlayerSettings: psp2PatchOriginalPackage: psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui psp2KeystoneFile: - psp2MemoryExpansionMode: 0 psp2DRMType: 0 psp2StorageType: 0 psp2MediaCapacity: 0 @@ -343,7 +338,8 @@ PlayerSettings: blackberrySquareSplashScreen: {fileID: 0} tizenProductDescription: tizenProductURL: - tizenSigningProfileName: + tizenCertificatePath: + tizenCertificatePassword: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 stvDeviceAddress: @@ -362,7 +358,6 @@ PlayerSettings: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: XboxOnePackageEncryption: 0 - XboxOnePackageUpdateGranularity: 2 XboxOneDescription: XboxOneIsContentPackage: 0 XboxOneEnableGPUVariability: 0 @@ -405,9 +400,4 @@ PlayerSettings: WebGL::emscriptenArgs: WebGL::template: APPLICATION:Default additionalIl2CppArgs::additionalIl2CppArgs: - firstStreamedSceneWithResources: 0 - cloudProjectId: - projectId: - projectName: - organizationId: - cloudEnabled: 0 + firstStreamedLevelWithResources: 0