diff --git a/Maquette/Assets/Scenes/Salle1.unity b/Maquette/Assets/Scenes/Salle1.unity index b536d2f0b56d7dc40ec3df2e6c3c5f0e321d83f7..b798a3805910d1ffda438085dfa233751d950e71 100644 --- a/Maquette/Assets/Scenes/Salle1.unity +++ b/Maquette/Assets/Scenes/Salle1.unity @@ -1161,7 +1161,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 11f0fe9a8b3a94bb896c1ff017052ba4, type: 3} m_Name: m_EditorClassIdentifier: - FirePointBobby: {fileID: 458278266} + FirePoint: {fileID: 458278266} cadence: 0 projectile: {fileID: 0} --- !u!1 &420897131 @@ -2313,7 +2313,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 11f0fe9a8b3a94bb896c1ff017052ba4, type: 3} m_Name: m_EditorClassIdentifier: - FirePointBobby: {fileID: 1528629699} + FirePoint: {fileID: 1528629699} cadence: 0 projectile: {fileID: 0} --- !u!1 &1353434756 diff --git a/Maquette/Assets/Scenes/Salle3.unity b/Maquette/Assets/Scenes/Salle3.unity index c7cb9cb9ef4db7933a89d01dfe8f8fc7aaa92100..7d9805f0ea6b8cdd1a132a4fe54b28c95e241fe8 100644 --- a/Maquette/Assets/Scenes/Salle3.unity +++ b/Maquette/Assets/Scenes/Salle3.unity @@ -556,7 +556,7 @@ PrefabInstance: - target: {fileID: 1999743495383100369, guid: 4a9ea4d464fe04784ba00d102d98db70, type: 3} propertyPath: m_RootOrder - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 1999743495383100369, guid: 4a9ea4d464fe04784ba00d102d98db70, type: 3} @@ -588,6 +588,11 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 6923119580283927733, guid: 4a9ea4d464fe04784ba00d102d98db70, + type: 3} + propertyPath: gunName + value: 4 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 4a9ea4d464fe04784ba00d102d98db70, type: 3} --- !u!1 &737834353 diff --git a/Maquette/Assets/Scripts/Pistol.cs b/Maquette/Assets/Scripts/Pistol.cs index 888ed6f880151b8d841991744d2e8273686397a3..0551aa22fcdd83cb4d5f4441007d631cb892f5f2 100644 --- a/Maquette/Assets/Scripts/Pistol.cs +++ b/Maquette/Assets/Scripts/Pistol.cs @@ -4,7 +4,7 @@ using UnityEngine; public class Pistol : MonoBehaviour { - public Transform FirePointBobby; + public Transform FirePoint; public int cadence; private bool cooldown; private int timer; @@ -16,9 +16,9 @@ public class Pistol : MonoBehaviour void Start() { cooldown = false; - FirePointVectorOrth.x = FirePointBobby.position.y; - FirePointVectorOrth.y = - FirePointBobby.position.x; - FirePointVectorOrth.z = FirePointBobby.position.z; + FirePointVectorOrth.x = FirePoint.position.y; + FirePointVectorOrth.y = - FirePoint.position.x; + FirePointVectorOrth.z = FirePoint.position.z; } // Update is called once per frame @@ -36,7 +36,7 @@ public class Pistol : MonoBehaviour } } else{ - Instantiate(projectile, FirePointBobby.position, FirePointBobby.transform.rotation); + Instantiate(projectile, FirePoint.position, FirePoint.transform.rotation); cooldown = true; timer = cadence; } @@ -50,13 +50,13 @@ public class Pistol : MonoBehaviour } } else{ - Instantiate(projectile, FirePointBobby.position , FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, -3)*FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, 3)*FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, -6)*FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, 6)*FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, -9)*FirePointBobby.transform.rotation); - Instantiate(projectile, FirePointBobby.position , Quaternion.Euler(0, 0, 9)*FirePointBobby.transform.rotation); + Instantiate(projectile, FirePoint.position , FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, -3)*FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, 3)*FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, -6)*FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, 6)*FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, -9)*FirePoint.transform.rotation); + Instantiate(projectile, FirePoint.position , Quaternion.Euler(0, 0, 9)*FirePoint.transform.rotation); cooldown = true; timer = cadence; } diff --git a/Maquette/Assets/Scripts/VillainShooter.cs b/Maquette/Assets/Scripts/VillainShooter.cs index 1014c26b8426f5d7e09ff13e8412556080361c7e..e4e9588f96f6acce58d5885f57a75965bc8740d9 100644 --- a/Maquette/Assets/Scripts/VillainShooter.cs +++ b/Maquette/Assets/Scripts/VillainShooter.cs @@ -9,11 +9,18 @@ public class VillainShooter : MonoBehaviour bool cooldown = false; int cooltime = 0; public GameObject Bullet; + public Gun.GunName gunName; + public WeaponData weapons; + private Pistol pistol; + public Transform roomCanvas; + private Gun currentGun; // Start is called before the first frame update void Start() { - + pistol = gameObject.GetComponentInChildren<Pistol>(); + SetWeapon(gunName); + roomCanvas = GameObject.FindWithTag("RoomCanvas").transform; } // Update is called once per frame @@ -23,7 +30,12 @@ public class VillainShooter : MonoBehaviour foreach (RaycastHit2D hit in hits) { if (hit.collider.tag == "Bobby" || hit.collider.tag == "Clyde") { if(!cooldown){ - Shoot(); + if(currentGun.name == Gun.GunName.shotgun){ + pistol.Scatter(); + } + else{ + pistol.Shoot(); + } cooldown = true; cooltime = 0; } @@ -42,4 +54,11 @@ public class VillainShooter : MonoBehaviour void Shoot(){ Instantiate(Bullet, FirePointVillain.position, FirePointVillain.rotation); } + + public void SetWeapon(Gun.GunName weapon){ + Gun newGun = weapons.GetGun(weapon); + currentGun = newGun; + pistol.cadence = newGun.cadence; + pistol.projectile = newGun.projectile; + } } diff --git a/Maquette/Assets/Villain.prefab b/Maquette/Assets/Villain.prefab index ad41d4387435a7530dc4133f7d43e91e1fa0550b..562e8f1b1033b507cdbc55794f78e742a7b0e700 100644 --- a/Maquette/Assets/Villain.prefab +++ b/Maquette/Assets/Villain.prefab @@ -177,6 +177,52 @@ MonoBehaviour: VillainPos: {fileID: 1999743495383100369} body: {fileID: 6923119579645949283} Players: [] +--- !u!1 &6134282395086340331 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5865532803041814002} + - component: {fileID: 2498653682707979798} + m_Layer: 0 + m_Name: Pistol + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5865532803041814002 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6134282395086340331} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 6923119580283927732} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2498653682707979798 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6134282395086340331} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 11f0fe9a8b3a94bb896c1ff017052ba4, type: 3} + m_Name: + m_EditorClassIdentifier: + FirePoint: {fileID: 6923119578298239390} + cadence: 0 + projectile: {fileID: 0} --- !u!1 &6923119578298239389 GameObject: m_ObjectHideFlags: 0 @@ -598,7 +644,8 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -1.2304579, y: 0.35945725, z: -2} m_LocalScale: {x: 0.6666667, y: 0.6666667, z: 1} - m_Children: [] + m_Children: + - {fileID: 5865532803041814002} m_Father: {fileID: 1999743495383100369} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -617,3 +664,6 @@ MonoBehaviour: FirePointVillain: {fileID: 6923119578298239390} Villain: {fileID: 6923119579645949283} Bullet: {fileID: 7163642854384020411, guid: b0c33b05543f0496396a571f77cad5eb, type: 3} + gunName: 0 + weapons: {fileID: 11400000, guid: 1919b5b27e7b84012a3f4bba54b04b0f, type: 2} + roomCanvas: {fileID: 0}