| 12345678910111213141516171819202122232425262728293031323334353637 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public abstract class EnemyBase : EntityBase {
- internal override void OnUpdate() {
- rb.mass = baseMass * (towardsRight ? 1.2f : 0.8f);
- // 反向
- if (towardsRight != (Mathf.Abs(rb.velocity.x) > filpSpeed ? rb.velocity.x > 0 : towardsRight)) {
- towardsRight = !towardsRight;
- transform.DOScaleX(towardsRight ? 1 : -1, 0.15f);
- }
- }
- public bool movingLeft = false;
- internal override void OnHitBorder() {
- // 死亡
- Modules.DestroyGameObject(gameObject);
- }
- public int hp; internal int currentHp = -10;
- internal override void OnHitBullet() {
- // 受伤动画
- sprite.DOColor(new Color(1f, 0.5f, 0.5f), 0.04f).SetLoops(2, LoopType.Yoyo);
- // 死亡判断
- if (currentHp == -10) currentHp = hp;
- currentHp--;
- if (currentHp <= 0) {
- AudioM.Play("enemy_die", 0.7f);
- Modules.DestroyGameObject(gameObject);
- if (hp > 3) { Camera.current.DOShakePosition(0.15f, 0.4f, 100).SetId("ScreenShake"); }
- }
- }
- }
|