mirror of
https://github.com/ConjureETS/Labo_2_Equ_1_a15.git
synced 2026-03-25 10:30:59 +00:00
First part
This commit is contained in:
parent
1ec4de6231
commit
4a2a0fd111
Binary file not shown.
@ -4,13 +4,15 @@ public class Character{
|
|||||||
private int mass;
|
private int mass;
|
||||||
private int mouvementSpeed { get; set; }
|
private int mouvementSpeed { get; set; }
|
||||||
private int forceJump { get; set; }
|
private int forceJump { get; set; }
|
||||||
|
private bool touchingTheFloor;
|
||||||
|
|
||||||
|
|
||||||
public Character(int m, int mvtSpeed, int fJump)
|
public Character(int m, int mvtSpeed, int fJump, bool touchFloor)
|
||||||
{
|
{
|
||||||
this.mass = m;
|
this.mass = m;
|
||||||
this.mouvementSpeed = mvtSpeed;
|
this.mouvementSpeed = mvtSpeed;
|
||||||
this.forceJump = fJump;
|
this.forceJump = fJump;
|
||||||
|
this.touchingTheFloor = touchFloor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -23,5 +25,13 @@ public class Character{
|
|||||||
this.mass = m;
|
this.mass = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTouchingTheFloor(bool touchFloor){
|
||||||
|
this.touchingTheFloor = touchFloor;
|
||||||
|
}
|
||||||
|
public bool isTouchingTheFloor()
|
||||||
|
{
|
||||||
|
return touchingTheFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,9 +4,49 @@ using System.Collections;
|
|||||||
public class Gravity : MonoBehaviour {
|
public class Gravity : MonoBehaviour {
|
||||||
|
|
||||||
public Character player;
|
public Character player;
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
player = new Character(1, 10, 10, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
int test = player.getMass();
|
|
||||||
|
if (!player.isTouchingTheFloor())
|
||||||
|
{
|
||||||
|
this.gameObject.transform.Translate(0,-0.1f,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKey("p"))
|
||||||
|
{
|
||||||
|
player.setTouchingTheFloor(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnTriggerStay2D(Collider2D other)
|
||||||
|
{
|
||||||
|
if (other.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
player.setTouchingTheFloor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTriggerExit2D(Collider2D other)
|
||||||
|
{
|
||||||
|
if (other.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
|
||||||
|
player.setTouchingTheFloor(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTriggerEnter2D(Collider2D other)
|
||||||
|
{
|
||||||
|
if (other.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
player.setTouchingTheFloor(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user