diff --git a/Assets/Animations/Jump0.anim b/Assets/Animations/Jump0.anim new file mode 100644 index 0000000..7c479fe Binary files /dev/null and b/Assets/Animations/Jump0.anim differ diff --git a/Assets/Animations/Jump0.anim.meta b/Assets/Animations/Jump0.anim.meta new file mode 100644 index 0000000..12e486b --- /dev/null +++ b/Assets/Animations/Jump0.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a078ad8c97314a34d9ecd3e37dae2156 +timeCreated: 1446945210 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Shooting.anim b/Assets/Animations/Shooting.anim similarity index 100% rename from Assets/Sprites/Shooting.anim rename to Assets/Animations/Shooting.anim diff --git a/Assets/Sprites/Shooting.anim.meta b/Assets/Animations/Shooting.anim.meta similarity index 100% rename from Assets/Sprites/Shooting.anim.meta rename to Assets/Animations/Shooting.anim.meta diff --git a/Assets/Animations/megaman.controller b/Assets/Animations/megaman.controller index 4769ef1..effaa31 100644 Binary files a/Assets/Animations/megaman.controller and b/Assets/Animations/megaman.controller differ diff --git a/Assets/Scenes/XavierScene.unity b/Assets/Scenes/XavierScene.unity index 974c028..8633347 100644 Binary files a/Assets/Scenes/XavierScene.unity and b/Assets/Scenes/XavierScene.unity differ diff --git a/Assets/Scripts/Animations.cs b/Assets/Scripts/Animations.cs index a7b1a34..850c74a 100644 --- a/Assets/Scripts/Animations.cs +++ b/Assets/Scripts/Animations.cs @@ -4,8 +4,10 @@ using System.Collections; public class Animations : MonoBehaviour { private Animator anim; + private bool isShooting; + // Use this for initialization void Start () { @@ -31,10 +33,13 @@ public class Animations : MonoBehaviour { isShooting = false; } // if - + + anim.SetFloat("SpeedX", Mathf.Abs(mouvementX)); anim.SetBool("isShooting", isShooting); + } + } diff --git a/Assets/Scripts/Control.cs b/Assets/Scripts/Control.cs index 429cf28..26bf857 100644 --- a/Assets/Scripts/Control.cs +++ b/Assets/Scripts/Control.cs @@ -5,12 +5,17 @@ public class Control : MonoBehaviour { public Transform thingsToMove; - public int speed; + + public float speed; + + private int eulerAngle; // Use this for initialization void Start () { - - } + + eulerAngle = 0; + + } // Update is called once per frame void Update () { @@ -18,20 +23,11 @@ public class Control : MonoBehaviour { float mouvement = Input.GetAxis ("Horizontal"); - - /* - if ( mouvement!= 0) - { - thingsToMove.Translate(new Vector2(mouvement * speed, 0)); - } - */ - - // aller vers la gauche if (mouvement > 0.0) { - thingsToMove.Translate(new Vector2(mouvement * speed, 0)); - transform.eulerAngles = new Vector2(0, 0); + thingsToMove.Translate(new Vector2(mouvement * speed, 0)); // bouger le player + eulerAngle = 0; } // if @@ -40,11 +36,11 @@ public class Control : MonoBehaviour { if (mouvement < 0.0) { - thingsToMove.Translate(new Vector2(-(mouvement * speed), 0)); - transform.eulerAngles = new Vector2(0, 180); + thingsToMove.Translate(new Vector2(-(mouvement * speed), 0)); // bouger le player + eulerAngle = 180; } // if - + transform.eulerAngles = new Vector3(0, eulerAngle, 0); // gauche = sprite effet miroir, droite = sprite normal } } diff --git a/Assets/Scripts/Gravity.cs b/Assets/Scripts/Gravity.cs index 3d73f18..c96c1db 100644 --- a/Assets/Scripts/Gravity.cs +++ b/Assets/Scripts/Gravity.cs @@ -4,6 +4,7 @@ using System.Collections; public class Gravity : MonoBehaviour { public Character player; + void Start() { player = new Character(1, 10, 10, false); diff --git a/Assets/Scripts/Jump.cs b/Assets/Scripts/Jump.cs index 617a8f5..0b6b140 100644 --- a/Assets/Scripts/Jump.cs +++ b/Assets/Scripts/Jump.cs @@ -3,34 +3,58 @@ using System.Collections; public class Jump : MonoBehaviour { - public int timeJump; + public Rigidbody2D player; // le player + + public float playerSpeedY; // la vitesse de saut + + private bool isOnGround; // somme nous sur le sol? - public Transform player; - private bool isJumping; // Use this for initialization void Start () { - isJumping = false; - timeJump = 0; + isOnGround = false; } // Update is called once per frame void Update () { - if (Input.GetButton("Fire1") && isJumping == false) + if (Input.GetButton("Fire1") && isOnGround == true) { - timeJump = 10; - isJumping = true; + player.velocity = new Vector2(player.velocity.x, playerSpeedY); } - if (timeJump > 0) { - player.Translate(0, 0.4f, 0); - timeJump--; - } - else - { - isJumping = false; - } - } + + + void OnTriggerStay2D(Collider2D other) + { + if (other.gameObject.tag == "Floor") + { + isOnGround = true; + } + + } + + + void OnTriggerEnter2D(Collider2D other) + { + if (other.gameObject.tag == "Floor") + { + isOnGround = true; + } + } + + + void OnTriggerExit2D(Collider2D other) + { + if (other.gameObject.tag == "Floor") + { + + isOnGround = false; + } + + } + + + } diff --git a/Assets/Scripts/MainCamera.cs b/Assets/Scripts/MainCamera.cs new file mode 100644 index 0000000..072bf89 --- /dev/null +++ b/Assets/Scripts/MainCamera.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using System.Collections; + +public class MainCamera : MonoBehaviour { + + // le player + public Rigidbody2D player; + + private float positionPlayerX; // position du player en X + private float positionPlayerY; // // position du player en Y + + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + // definir la position du player + positionPlayerX = player.GetComponent().position.x; + positionPlayerY = player.GetComponent().position.y; + + // ajuster la camera selon la position du player + transform.position = new Vector3(positionPlayerX, positionPlayerY + 3.5F, -10); + + } +} diff --git a/Assets/Scripts/MainCamera.cs.meta b/Assets/Scripts/MainCamera.cs.meta new file mode 100644 index 0000000..784dd5e --- /dev/null +++ b/Assets/Scripts/MainCamera.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c729e4edf3bf65d4fa14333e02f090e0 +timeCreated: 1446932586 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/mm.png.meta b/Assets/Sprites/mm.png.meta index d08f2e5..c7b9908 100644 --- a/Assets/Sprites/mm.png.meta +++ b/Assets/Sprites/mm.png.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 14370da66867eeb479e470bd4bb068f7 -timeCreated: 1446690230 +timeCreated: 1446945412 licenseType: Free TextureImporter: fileIDToRecycleName: @@ -22,6 +22,7 @@ TextureImporter: 21300030: Jumping3 21300032: Jumping4 21300034: Shooting + 21300036: Jump3 serializedVersion: 2 mipmaps: mipMapMode: 0 @@ -148,56 +149,6 @@ TextureImporter: alignment: 0 pivot: {x: .5, y: .5} border: {x: 0, y: 0, z: 0, w: 0} - - name: Jumping0 - rect: - serializedVersion: 2 - x: 261 - y: 13 - width: 16 - height: 24 - alignment: 0 - pivot: {x: .5, y: .5} - border: {x: 0, y: 0, z: 0, w: 0} - - name: Jumping1 - rect: - serializedVersion: 2 - x: 313 - y: 13 - width: 12 - height: 24 - alignment: 0 - pivot: {x: .5, y: .5} - border: {x: 0, y: 0, z: 0, w: 0} - - name: Jumping2 - rect: - serializedVersion: 2 - x: 361 - y: 13 - width: 17 - height: 24 - alignment: 0 - pivot: {x: .5, y: .5} - border: {x: 0, y: 0, z: 0, w: 0} - - name: Jumping3 - rect: - serializedVersion: 2 - x: 408 - y: 13 - width: 21 - height: 24 - alignment: 0 - pivot: {x: .5, y: .5} - border: {x: 0, y: 0, z: 0, w: 0} - - name: Jumping4 - rect: - serializedVersion: 2 - x: 458 - y: 13 - width: 21 - height: 24 - alignment: 0 - pivot: {x: .5, y: .5} - border: {x: 0, y: 0, z: 0, w: 0} - name: Shooting rect: serializedVersion: 2 @@ -208,6 +159,36 @@ TextureImporter: alignment: 0 pivot: {x: .5, y: .5} border: {x: 0, y: 0, z: 0, w: 0} + - name: Jump0 + rect: + serializedVersion: 2 + x: 357 + y: 107 + width: 25 + height: 30 + alignment: 0 + pivot: {x: .5, y: .5} + border: {x: 0, y: 0, z: 0, w: 0} + - name: Jump1 + rect: + serializedVersion: 2 + x: 412 + y: 123 + width: 16 + height: 17 + alignment: 0 + pivot: {x: .5, y: .5} + border: {x: 0, y: 0, z: 0, w: 0} + - name: Jump3 + rect: + serializedVersion: 2 + x: 461 + y: 112 + width: 16 + height: 22 + alignment: 0 + pivot: {x: .5, y: .5} + border: {x: 0, y: 0, z: 0, w: 0} spritePackingTag: userData: assetBundleName: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 071b29b..10ae0c1 100644 Binary files a/ProjectSettings/TagManager.asset and b/ProjectSettings/TagManager.asset differ