This commit is contained in:
Marc-Antoine Dumont 2015-11-09 23:02:14 -05:00
commit b860d7f90d
16 changed files with 144 additions and 87 deletions

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a078ad8c97314a34d9ecd3e37dae2156
timeCreated: 1446945210
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

View File

@ -4,8 +4,10 @@ using System.Collections;
public class Animations : MonoBehaviour { public class Animations : MonoBehaviour {
private Animator anim; private Animator anim;
private bool isShooting; private bool isShooting;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
@ -32,8 +34,12 @@ public class Animations : MonoBehaviour {
} // if } // if
anim.SetFloat("SpeedX", Mathf.Abs(mouvementX)); anim.SetFloat("SpeedX", Mathf.Abs(mouvementX));
anim.SetBool("isShooting", isShooting); anim.SetBool("isShooting", isShooting);
} }
} }

View File

@ -5,12 +5,17 @@ public class Control : MonoBehaviour {
public Transform thingsToMove; public Transform thingsToMove;
public int speed;
public float speed;
private int eulerAngle;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
} eulerAngle = 0;
}
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
@ -18,20 +23,11 @@ public class Control : MonoBehaviour {
float mouvement = Input.GetAxis ("Horizontal"); float mouvement = Input.GetAxis ("Horizontal");
/*
if ( mouvement!= 0)
{
thingsToMove.Translate(new Vector2(mouvement * speed, 0));
}
*/
// aller vers la gauche // aller vers la gauche
if (mouvement > 0.0) if (mouvement > 0.0)
{ {
thingsToMove.Translate(new Vector2(mouvement * speed, 0)); thingsToMove.Translate(new Vector2(mouvement * speed, 0)); // bouger le player
transform.eulerAngles = new Vector2(0, 0); eulerAngle = 0;
} // if } // if
@ -40,11 +36,11 @@ public class Control : MonoBehaviour {
if (mouvement < 0.0) if (mouvement < 0.0)
{ {
thingsToMove.Translate(new Vector2(-(mouvement * speed), 0)); thingsToMove.Translate(new Vector2(-(mouvement * speed), 0)); // bouger le player
transform.eulerAngles = new Vector2(0, 180); eulerAngle = 180;
} // if } // if
transform.eulerAngles = new Vector3(0, eulerAngle, 0); // gauche = sprite effet miroir, droite = sprite normal
} }
} }

View File

@ -4,6 +4,7 @@ using System.Collections;
public class Gravity : MonoBehaviour { public class Gravity : MonoBehaviour {
public Character player; public Character player;
void Start() void Start()
{ {
player = new Character(1, 10, 10, false); player = new Character(1, 10, 10, false);

View File

@ -3,34 +3,58 @@ using System.Collections;
public class Jump : MonoBehaviour { 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 // Use this for initialization
void Start () { void Start () {
isJumping = false; isOnGround = false;
timeJump = 0;
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
if (Input.GetButton("Fire1") && isJumping == false) if (Input.GetButton("Fire1") && isOnGround == true)
{ {
timeJump = 10; player.velocity = new Vector2(player.velocity.x, playerSpeedY);
isJumping = true;
}
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;
}
}
} }

View File

@ -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<Rigidbody2D>().position.x;
positionPlayerY = player.GetComponent<Rigidbody2D>().position.y;
// ajuster la camera selon la position du player
transform.position = new Vector3(positionPlayerX, positionPlayerY + 3.5F, -10);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c729e4edf3bf65d4fa14333e02f090e0
timeCreated: 1446932586
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 14370da66867eeb479e470bd4bb068f7 guid: 14370da66867eeb479e470bd4bb068f7
timeCreated: 1446690230 timeCreated: 1446945412
licenseType: Free licenseType: Free
TextureImporter: TextureImporter:
fileIDToRecycleName: fileIDToRecycleName:
@ -22,6 +22,7 @@ TextureImporter:
21300030: Jumping3 21300030: Jumping3
21300032: Jumping4 21300032: Jumping4
21300034: Shooting 21300034: Shooting
21300036: Jump3
serializedVersion: 2 serializedVersion: 2
mipmaps: mipmaps:
mipMapMode: 0 mipMapMode: 0
@ -148,56 +149,6 @@ TextureImporter:
alignment: 0 alignment: 0
pivot: {x: .5, y: .5} pivot: {x: .5, y: .5}
border: {x: 0, y: 0, z: 0, w: 0} 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 - name: Shooting
rect: rect:
serializedVersion: 2 serializedVersion: 2
@ -208,6 +159,36 @@ TextureImporter:
alignment: 0 alignment: 0
pivot: {x: .5, y: .5} pivot: {x: .5, y: .5}
border: {x: 0, y: 0, z: 0, w: 0} 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: spritePackingTag:
userData: userData:
assetBundleName: assetBundleName:

View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.2.1f1 m_EditorVersion: 5.2.2f1
m_StandardAssetsVersion: 0 m_StandardAssetsVersion: 0

Binary file not shown.