Base mechanics done
This commit is contained in:
parent
e4cc23e7f0
commit
eaa8cdd462
67 changed files with 21667 additions and 330 deletions
32
Assets/Scripts/Level 9/Bullet9.cs
Normal file
32
Assets/Scripts/Level 9/Bullet9.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Level9 {
|
||||
public class Bullet9 : 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) {
|
||||
GetComponent<Rigidbody2D>().velocity = Vector2.right * direction * bulletSpeed;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D other) {
|
||||
--_currentBounces;
|
||||
if (_currentBounces != 0 && !other.gameObject.CompareTag("Enemy")) return;
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue