Enemies half done
This commit is contained in:
parent
eaa8cdd462
commit
16507f4121
93 changed files with 31744 additions and 119 deletions
50
Assets/Scripts/Level 12/Bullet12.cs
Normal file
50
Assets/Scripts/Level 12/Bullet12.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Level12 {
|
||||
public class Bullet12 : BulletStats {
|
||||
int _currentBounces;
|
||||
|
||||
[SerializeField] Sprite red, yellow;
|
||||
|
||||
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) {
|
||||
++PlayerMovement12.instance.Bullets;
|
||||
GetComponent<Rigidbody2D>().velocity = Vector2.right * direction * bulletSpeed;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D other) {
|
||||
transform.DOPunchScale(transform.localScale * 1.5f, .1f);
|
||||
|
||||
DOTween.Sequence()
|
||||
.AppendCallback(() => {
|
||||
Sprite.sprite = yellow;
|
||||
}).AppendInterval(.1f)
|
||||
.AppendCallback(() => {
|
||||
Sprite.sprite = red;
|
||||
});
|
||||
|
||||
--_currentBounces;
|
||||
if (_currentBounces != 0 || other.gameObject.CompareTag("Enemy")) return;
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
--PlayerMovement12.instance.Bullets;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue