123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 Jiang Yin. All rights reserved.
- // Homepage: https://gameframework.cn/
- // Feedback: mailto:ellan@gameframework.cn
- //------------------------------------------------------------
- using UnityEngine;
- using UnityGameFramework.Runtime;
- namespace MetaClient
- {
- /// <summary>
- /// 子弹类。
- /// </summary>
- public class Bullet : Entity
- {
- [SerializeField]
- private BulletData m_BulletData = null;
- public ImpactData GetImpactData()
- {
- return new ImpactData(m_BulletData.OwnerCamp, 0, m_BulletData.Attack, 0);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnInit(object userData)
- #else
- protected internal override void OnInit(object userData)
- #endif
- {
- base.OnInit(userData);
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnShow(object userData)
- #else
- protected internal override void OnShow(object userData)
- #endif
- {
- base.OnShow(userData);
- m_BulletData = userData as BulletData;
- if (m_BulletData == null)
- {
- Log.Error("Bullet data is invalid.");
- return;
- }
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- #else
- protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
- #endif
- {
- base.OnUpdate(elapseSeconds, realElapseSeconds);
- CachedTransform.Translate(Vector3.forward * m_BulletData.Speed * elapseSeconds, Space.World);
- }
- }
- }
|