update samples
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2673676235c2ebf4790768011d015d1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Pooling;
|
||||
|
||||
public class EntityAsteroid : MonoBehaviour
|
||||
{
|
||||
public float MoveSpeed = -5f;
|
||||
public float Tumble = 5f;
|
||||
|
||||
private SpawnHandle _handle;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public void InitEntity(SpawnHandle handle)
|
||||
{
|
||||
_handle = handle;
|
||||
|
||||
_rigidbody.velocity = this.transform.forward * MoveSpeed;
|
||||
_rigidbody.angularVelocity = Random.insideUnitSphere * Tumble;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_rigidbody = this.transform.GetComponent<Rigidbody>();
|
||||
}
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("PlayerBullet"))
|
||||
{
|
||||
BattleEventDefine.AsteroidExplosion.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Boundary"))
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffef5a382eef32d46b1d6175c85f644e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Pooling;
|
||||
|
||||
public class EntityBullet : MonoBehaviour
|
||||
{
|
||||
public float MoveSpeed = 20f;
|
||||
public float DelayDestroyTime = 5f;
|
||||
|
||||
private SpawnHandle _handle;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public void InitEntity(SpawnHandle handle)
|
||||
{
|
||||
_handle = handle;
|
||||
_rigidbody.velocity = this.transform.forward * MoveSpeed;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_rigidbody = this.transform.GetComponent<Rigidbody>();
|
||||
}
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Boundary"))
|
||||
return;
|
||||
|
||||
if (this.gameObject.CompareTag("EnemyBullet"))
|
||||
{
|
||||
if (other.CompareTag("Enemy") == false)
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.gameObject.CompareTag("PlayerBullet"))
|
||||
{
|
||||
if (other.CompareTag("Player") == false)
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Boundary"))
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a9d4ddd3c4e60245b6bc4f9f1435291
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Pooling;
|
||||
|
||||
public class EntityEffect : MonoBehaviour
|
||||
{
|
||||
public float DelayDestroyTime = 1f;
|
||||
|
||||
private SpawnHandle _handle;
|
||||
|
||||
public void InitEntity(SpawnHandle handle)
|
||||
{
|
||||
_handle = handle;
|
||||
|
||||
Invoke(nameof(DelayDestroy), DelayDestroyTime);
|
||||
}
|
||||
private void DelayDestroy()
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 014c1f9b87e247446bd7d558f8bf143e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Pooling;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EntityEnemy : MonoBehaviour
|
||||
{
|
||||
private const float Dodge = 5f;
|
||||
private const float Smoothing = 7.5f;
|
||||
|
||||
public RoomBoundary Boundary;
|
||||
public float MoveSpeed = 20f;
|
||||
public float FireInterval = 2f;
|
||||
|
||||
public Vector2 StartWait = new Vector2(0.5f, 1f);
|
||||
public Vector2 ManeuverTime = new Vector2(1, 2);
|
||||
public Vector2 ManeuverWait = new Vector2(1, 2);
|
||||
|
||||
private SpawnHandle _handle;
|
||||
private Transform _shotSpawn;
|
||||
private Rigidbody _rigidbody;
|
||||
private AudioSource _audioSource;
|
||||
private float _lastFireTime = 0f;
|
||||
private float _currentSpeed;
|
||||
private float _targetManeuver;
|
||||
|
||||
|
||||
public void InitEntity(SpawnHandle handle)
|
||||
{
|
||||
_handle = handle;
|
||||
|
||||
_rigidbody.velocity = this.transform.forward * -5f;
|
||||
_lastFireTime = Time.time;
|
||||
_currentSpeed = _rigidbody.velocity.z;
|
||||
_targetManeuver = 0f;
|
||||
StartCoroutine(Evade());
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_rigidbody = this.gameObject.GetComponent<Rigidbody>();
|
||||
_audioSource = this.gameObject.GetComponent<AudioSource>();
|
||||
_shotSpawn = this.transform.Find("shot_spawn");
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (Time.time - _lastFireTime >= FireInterval)
|
||||
{
|
||||
_lastFireTime = Time.time;
|
||||
_audioSource.Play();
|
||||
BattleEventDefine.EnemyFireBullet.SendEventMessage(_shotSpawn.position, _shotSpawn.rotation);
|
||||
}
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
float newManeuver = Mathf.MoveTowards(_rigidbody.velocity.x, _targetManeuver, Smoothing * Time.deltaTime);
|
||||
_rigidbody.velocity = new Vector3(newManeuver, 0.0f, _currentSpeed);
|
||||
_rigidbody.position = new Vector3
|
||||
(
|
||||
Mathf.Clamp(_rigidbody.position.x, Boundary.xMin, Boundary.xMax),
|
||||
0.0f,
|
||||
Mathf.Clamp(_rigidbody.position.z, Boundary.zMin, Boundary.zMax)
|
||||
);
|
||||
|
||||
float tilt = 10f;
|
||||
_rigidbody.rotation = Quaternion.Euler(0, 0, _rigidbody.velocity.x * -tilt);
|
||||
}
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("PlayerBullet"))
|
||||
{
|
||||
BattleEventDefine.EnemyDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Boundary"))
|
||||
{
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Evade()
|
||||
{
|
||||
yield return new WaitForSeconds(Random.Range(StartWait.x, StartWait.y));
|
||||
while (true)
|
||||
{
|
||||
_targetManeuver = Random.Range(1, Dodge) * -Mathf.Sign(transform.position.x);
|
||||
yield return new WaitForSeconds(Random.Range(ManeuverTime.x, ManeuverTime.y));
|
||||
_targetManeuver = 0;
|
||||
yield return new WaitForSeconds(Random.Range(ManeuverWait.x, ManeuverWait.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a613426c4968b3149b8bf9bf88fe41c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Pooling;
|
||||
|
||||
public class EntityPlayer : MonoBehaviour
|
||||
{
|
||||
public RoomBoundary Boundary;
|
||||
public float MoveSpeed = 10f;
|
||||
public float FireRate = 0.25f;
|
||||
|
||||
private SpawnHandle _handle;
|
||||
private float _nextFireTime = 0f;
|
||||
private Transform _shotSpawn;
|
||||
private Rigidbody _rigidbody;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
public void InitEntity(SpawnHandle handle)
|
||||
{
|
||||
_handle = handle;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_rigidbody = this.gameObject.GetComponent<Rigidbody>();
|
||||
_audioSource = this.gameObject.GetComponent<AudioSource>();
|
||||
_shotSpawn = this.transform.Find("shot_spawn");
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetButton("Fire1") && Time.time > _nextFireTime)
|
||||
{
|
||||
_nextFireTime = Time.time + FireRate;
|
||||
_audioSource.Play();
|
||||
BattleEventDefine.PlayerFireBullet.SendEventMessage(_shotSpawn.position, _shotSpawn.rotation);
|
||||
}
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
float moveHorizontal = Input.GetAxis("Horizontal");
|
||||
float moveVertical = Input.GetAxis("Vertical");
|
||||
|
||||
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
|
||||
_rigidbody.velocity = movement * MoveSpeed;
|
||||
_rigidbody.position = new Vector3
|
||||
(
|
||||
Mathf.Clamp(GetComponent<Rigidbody>().position.x, Boundary.xMin, Boundary.xMax),
|
||||
0.0f,
|
||||
Mathf.Clamp(GetComponent<Rigidbody>().position.z, Boundary.zMin, Boundary.zMax)
|
||||
);
|
||||
|
||||
float tilt = 5f;
|
||||
_rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, _rigidbody.velocity.x * -tilt);
|
||||
}
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Enemy") || other.CompareTag("EnemyBullet") || other.CompareTag("Asteroid"))
|
||||
{
|
||||
BattleEventDefine.PlayerDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||
_handle.Restore();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3933af4e188ec44683e3c52784eadb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
@@ -31,6 +31,7 @@ internal class FsmSceneHome : IStateNode
|
||||
|
||||
private IEnumerator Prepare()
|
||||
{
|
||||
Debug.LogWarning("LoadScene Home");
|
||||
yield return YooAssets.LoadSceneAsync("scene_home");
|
||||
yield return UniWindow.OpenWindowAsync<UIHomeWindow>("UIHome");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7866629ff257c6d4d84cd9dab5d0b000
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-257
@@ -1,257 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Window;
|
||||
using UniFramework.Pooling;
|
||||
using UniFramework.Event;
|
||||
using UniFramework.Utility;
|
||||
using YooAsset;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
[Serializable]
|
||||
public class RoomBoundary
|
||||
{
|
||||
public float xMin, xMax, zMin, zMax;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗房间
|
||||
/// </summary>
|
||||
public class BattleRoom
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
Ready,
|
||||
Spawn,
|
||||
WaitSpawn,
|
||||
WaitWave,
|
||||
GameOver,
|
||||
}
|
||||
|
||||
private EventGroup _eventGroup = new EventGroup();
|
||||
private Spawner _entitySpawner;
|
||||
private GameObject _roomRoot;
|
||||
private AssetOperationHandle _musicHandle;
|
||||
|
||||
// 关卡参数
|
||||
private const int EnemyCount = 10;
|
||||
private const int EnemyScore = 10;
|
||||
private const int AsteroidScore = 1;
|
||||
private readonly Vector3 _spawnValues = new Vector3(6, 0, 20);
|
||||
private readonly string[] _entityLocations = new string[]
|
||||
{
|
||||
"asteroid01", "asteroid02", "asteroid03", "enemy_ship"
|
||||
};
|
||||
|
||||
private ESteps _steps = ESteps.None;
|
||||
private int _totalScore = 0;
|
||||
private int _waveSpawnCount = 0;
|
||||
|
||||
private UniTimer _startWaitTimer = UniTimer.CreateOnceTimer(1f);
|
||||
private UniTimer _spawnWaitTimer = UniTimer.CreateOnceTimer(0.75f);
|
||||
private UniTimer _waveWaitTimer = UniTimer.CreateOnceTimer(4f);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 销毁房间
|
||||
/// </summary>
|
||||
public void DestroyRoom()
|
||||
{
|
||||
if (_musicHandle != null)
|
||||
_musicHandle.Release();
|
||||
|
||||
if (_eventGroup != null)
|
||||
_eventGroup.RemoveAllListener();
|
||||
|
||||
if (_entitySpawner != null)
|
||||
_entitySpawner.DestroyAll(true);
|
||||
|
||||
if (_roomRoot != null)
|
||||
GameObject.Destroy(_roomRoot);
|
||||
|
||||
UniWindow.CloseWindow<UIBattleWindow>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新房间
|
||||
/// </summary>
|
||||
public void UpdateRoom()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.GameOver)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.Ready)
|
||||
{
|
||||
if (_startWaitTimer.Update(Time.deltaTime))
|
||||
{
|
||||
_steps = ESteps.Spawn;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.Spawn)
|
||||
{
|
||||
var enemyLocation = _entityLocations[Random.Range(0, 4)];
|
||||
Vector3 spawnPosition = new Vector3(Random.Range(-_spawnValues.x, _spawnValues.x), _spawnValues.y, _spawnValues.z);
|
||||
Quaternion spawnRotation = Quaternion.identity;
|
||||
|
||||
if (enemyLocation == "enemy_ship")
|
||||
{
|
||||
// 生成敌人实体
|
||||
var handle = _entitySpawner.SpawnSync(enemyLocation, _roomRoot.transform, spawnPosition, spawnRotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityEnemy>();
|
||||
entity.InitEntity(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 生成小行星实体
|
||||
var handle = _entitySpawner.SpawnSync(enemyLocation, _roomRoot.transform, spawnPosition, spawnRotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityAsteroid>();
|
||||
entity.InitEntity(handle);
|
||||
}
|
||||
|
||||
_waveSpawnCount++;
|
||||
if (_waveSpawnCount >= EnemyCount)
|
||||
{
|
||||
_steps = ESteps.WaitWave;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.WaitSpawn;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.WaitSpawn)
|
||||
{
|
||||
if (_spawnWaitTimer.Update(Time.deltaTime))
|
||||
{
|
||||
_spawnWaitTimer.Reset();
|
||||
_steps = ESteps.Spawn;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.WaitWave)
|
||||
{
|
||||
if (_waveWaitTimer.Update(Time.deltaTime))
|
||||
{
|
||||
_waveWaitTimer.Reset();
|
||||
_waveSpawnCount = 0;
|
||||
_steps = ESteps.Spawn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载房间
|
||||
/// </summary>
|
||||
public IEnumerator LoadRoom()
|
||||
{
|
||||
// 创建房间根对象
|
||||
_roomRoot = new GameObject("BattleRoom");
|
||||
|
||||
// 加载背景音乐
|
||||
_musicHandle = YooAssets.LoadAssetAsync<AudioClip>("music_background");
|
||||
yield return _musicHandle;
|
||||
|
||||
// 播放背景音乐
|
||||
var audioSource = _roomRoot.AddComponent<AudioSource>();
|
||||
audioSource.loop = true;
|
||||
audioSource.clip = _musicHandle.AssetObject as AudioClip;
|
||||
audioSource.Play();
|
||||
|
||||
// 创建游戏对象发生器
|
||||
_entitySpawner = UniPooling.CreateSpawner("DefaultPackage");
|
||||
|
||||
// 创建游戏对象池
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("player_ship");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("player_bullet");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("enemy_ship");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("enemy_bullet");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("asteroid01");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("asteroid02");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("asteroid03");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("explosion_asteroid");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("explosion_enemy");
|
||||
yield return _entitySpawner.CreateGameObjectPoolAsync("explosion_player");
|
||||
|
||||
// 创建玩家实体对象
|
||||
var handle = _entitySpawner.SpawnSync("player_ship");
|
||||
var entity = handle.GameObj.GetComponent<EntityPlayer>();
|
||||
entity.InitEntity(handle);
|
||||
|
||||
// 显示战斗界面
|
||||
yield return UniWindow.OpenWindowAsync<UIBattleWindow>("UIBattle");
|
||||
|
||||
// 监听游戏事件
|
||||
_eventGroup.AddListener<BattleEventDefine.PlayerDead>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<BattleEventDefine.EnemyDead>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<BattleEventDefine.AsteroidExplosion>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<BattleEventDefine.PlayerFireBullet>(OnHandleEventMessage);
|
||||
_eventGroup.AddListener<BattleEventDefine.EnemyFireBullet>(OnHandleEventMessage);
|
||||
|
||||
_steps = ESteps.Ready;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收事件
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private void OnHandleEventMessage(IEventMessage message)
|
||||
{
|
||||
if (message is BattleEventDefine.PlayerDead)
|
||||
{
|
||||
var msg = message as BattleEventDefine.PlayerDead;
|
||||
|
||||
// 创建爆炸效果
|
||||
var handle = _entitySpawner.SpawnSync("explosion_player", _roomRoot.transform, msg.Position, msg.Rotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityEffect>();
|
||||
entity.InitEntity(handle);
|
||||
|
||||
_steps = ESteps.GameOver;
|
||||
BattleEventDefine.GameOver.SendEventMessage();
|
||||
}
|
||||
else if (message is BattleEventDefine.EnemyDead)
|
||||
{
|
||||
var msg = message as BattleEventDefine.EnemyDead;
|
||||
|
||||
// 创建爆炸效果
|
||||
var handle = _entitySpawner.SpawnSync("explosion_enemy", _roomRoot.transform, msg.Position, msg.Rotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityEffect>();
|
||||
entity.InitEntity(handle);
|
||||
|
||||
_totalScore += EnemyScore;
|
||||
BattleEventDefine.ScoreChange.SendEventMessage(_totalScore);
|
||||
}
|
||||
else if (message is BattleEventDefine.AsteroidExplosion)
|
||||
{
|
||||
var msg = message as BattleEventDefine.AsteroidExplosion;
|
||||
|
||||
// 创建爆炸效果
|
||||
var handle = _entitySpawner.SpawnSync("explosion_asteroid", _roomRoot.transform, msg.Position, msg.Rotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityEffect>();
|
||||
entity.InitEntity(handle);
|
||||
|
||||
_totalScore += AsteroidScore;
|
||||
BattleEventDefine.ScoreChange.SendEventMessage(_totalScore);
|
||||
}
|
||||
else if (message is BattleEventDefine.PlayerFireBullet)
|
||||
{
|
||||
var msg = message as BattleEventDefine.PlayerFireBullet;
|
||||
|
||||
// 创建子弹实体
|
||||
var handle = _entitySpawner.SpawnSync("player_bullet", _roomRoot.transform, msg.Position, msg.Rotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityBullet>();
|
||||
entity.InitEntity(handle);
|
||||
}
|
||||
else if (message is BattleEventDefine.EnemyFireBullet)
|
||||
{
|
||||
var msg = message as BattleEventDefine.EnemyFireBullet;
|
||||
|
||||
// 创建子弹实体
|
||||
var handle = _entitySpawner.SpawnSync("enemy_bullet", _roomRoot.transform, msg.Position, msg.Rotation);
|
||||
var entity = handle.GameObj.GetComponent<EntityBullet>();
|
||||
entity.InitEntity(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4dfc5f1cace4e8469e496d83b254ac7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user