Base mechanics done

This commit is contained in:
Gerard Gascón 2023-08-20 17:27:37 +02:00
parent e4cc23e7f0
commit eaa8cdd462
67 changed files with 21667 additions and 330 deletions

View file

@ -1,16 +1,22 @@
using UnityEngine;
namespace Level8 {
public class Bullet8 : MonoBehaviour {
[SerializeField] float speed;
public class Bullet8 : BulletStats {
void FixedUpdate() {
if (Rb.velocity.y <= maxYSpeed) return;
Vector2 velocity = Rb.velocity;
velocity.y = maxYSpeed;
Rb.velocity = velocity;
}
public void AddForce(int direction) {
Rigidbody2D rb = GetComponent<Rigidbody2D>();
rb.velocity = Vector2.right * direction * speed;
GetComponent<Rigidbody2D>().velocity = Vector2.right * direction * bulletSpeed;
}
void OnCollisionEnter2D(Collision2D other) {
Destroy(gameObject);
if (other.gameObject.CompareTag("Enemy")) {
Destroy(gameObject);
}
}
}
}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 07abba302fe75e04c8485e7a5ae40dcb
guid: e8589b066efc2a44782262ccea1a924e
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8f8ff3b239fcea04b91b8c49085c0cdb
guid: a59820a761d4477468f1cc9da75eca3d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -1,3 +1,3 @@
fileFormatVersion: 2
guid: 07622b149a150ff4c9470ed89e7347c8
guid: 3c59ba55a285218468f7cb423b1aa267
timeCreated: 1691603524

View file

@ -1,16 +0,0 @@
using UnityEngine;
namespace Level8 {
public class PlayerFollower8 : MonoBehaviour {
public void SetPosition(Vector3 position, bool grounded) {
if (grounded) {
transform.position = position;
return;
}
Vector3 pos = transform.position;
pos.x = position.x;
transform.position = pos;
}
}
}

View file

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: fa9b72934e014867b4b865e119ad0f0b
timeCreated: 1692381164

View file

@ -3,9 +3,7 @@ using UnityEngine.InputSystem;
namespace Level8 {
public class PlayerMovement8 : PlayerStats {
[SerializeField] PlayerFollower8 playerFollower8;
[Header("Shooting")]
[SerializeField] Bullet8 bullet;
[SerializeField] Transform shootingPos;
@ -88,8 +86,6 @@ namespace Level8 {
_currentCoyoteTime -= Time.deltaTime;
_currentBufferTime -= Time.deltaTime;
playerFollower8.SetPosition(transform.position, _grounded);
}
void FixedUpdate() {

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cd40848ae407e14418cf25c22f6f4be5
guid: 51ca43f5f9e97404da11f9669675fdee
MonoImporter:
externalObjects: {}
serializedVersion: 2