Base mechanics done
This commit is contained in:
parent
e4cc23e7f0
commit
eaa8cdd462
67 changed files with 21667 additions and 330 deletions
34
Assets/Scripts/Level 10/Bullet10.cs
Normal file
34
Assets/Scripts/Level 10/Bullet10.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Level10 {
|
||||
public class Bullet10 : BulletStats {
|
||||
int _currentBounces;
|
||||
|
||||
protected override void Start() {
|
||||
base.Start();
|
||||
|
||||
_currentBounces = maxBounces;
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if (Rb.velocity.y <= maxYSpeed) return;
|
||||
Vector2 velocity = Rb.velocity;
|
||||
velocity.y = maxYSpeed;
|
||||
Rb.velocity = velocity;
|
||||
}
|
||||
|
||||
public void AddForce(int direction) {
|
||||
++PlayerMovement10.instance.Bullets;
|
||||
GetComponent<Rigidbody2D>().velocity = Vector2.right * direction * bulletSpeed;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D other) {
|
||||
--_currentBounces;
|
||||
if (_currentBounces != 0 && !other.gameObject.CompareTag("Enemy")) return;
|
||||
|
||||
--PlayerMovement10.instance.Bullets;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue