Ejemplo n.º 1
0
    public void SetInitInfo(Vector2 _dir, float _velocity, float _effectiveRange, E_BulletType _bulletType = E_BulletType.Independent, int _spreadNum = 1, float _spreadDegree = 0.0f, string _bulletName = "Bullet")
    {
        isActivated    = true;
        bulletType     = _bulletType;
        effectiveRange = _effectiveRange;
        dir            = _dir;
        velocity       = _velocity;
        spreadNum      = _spreadNum;
        spreadDegree   = _spreadDegree;

        if (bulletType == E_BulletType.Group)
        {
            bulletPrefab = Resources.Load("Prefabs/" + _bulletName) as GameObject;

            for (int i = 0; i < spreadNum; i++)
            {
                Quaternion rot       = Quaternion.Euler(0.0f, 0.0f, Random.Range(-spreadDegree / 2.0f, spreadDegree / 2.0f)); // 회전각
                Vector2    rottedDir = rot * dir;
                GameObject newObject = Instantiate(bulletPrefab);
                CS_Bullet  bullet    = newObject.GetComponent <CS_Bullet>();
                bullet.transform.position = transform.position;
                bullet.SetInitInfo(rottedDir, velocity, effectiveRange);
            }

            DestroyObject(this.gameObject);
        }
    }
Ejemplo n.º 2
0
        public virtual void Initialize(E_BulletType bulletType, BaseEntity target, float pDamage, float splashRange,
                                       bool pIsMine, bool pIsBottomPlayer, float effect)
        {
            obj_Bullet.SetActive(true);
            if (obj_EndEffect != null)
            {
                obj_EndEffect.SetActive(false);
            }

            _bulletType     = bulletType;
            _isTarget       = true;
            _damage         = pDamage;
            _splashRange    = splashRange;
            _isMine         = pIsMine;
            _isBottomPlayer = pIsBottomPlayer;
            _target         = target;
            _effect         = effect;

            if (_target)
            {
                SetColor();
                StartCoroutine(Move());
            }
            else
            {
                _poad.Deactive();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///刷新数据
 /// </summary>
 /// <param name="data"></param>
 public virtual void refreshData(BulletData data)
 {
     this.data = data;
     btype     = data.btype;
     onStart();
     this.enabled = true;
     dataInit     = true;
 }
Ejemplo n.º 4
0
    private void Awake()
    {
        E_BulletType type = _type;

        _type = type;

        _rb  = GetComponent <Rigidbody>();
        _col = GetComponent <Collider>();
    }
Ejemplo n.º 5
0
 public BulletComponent(int _HostID, E_BulletType _Type, int _Damage, float3 _Direction, float _Speed, LayerMask _TargetLayerMask)
 {
     HostID          = _HostID;
     BulletType      = _Type;
     Damage          = _Damage;
     Direction       = _Direction;
     Speed           = _Speed;
     TargetLayerMask = _TargetLayerMask;
 }
Ejemplo n.º 6
0
    public IFireable Create(E_BulletType type)
    {
        switch (type)
        {
        default:
        case E_BulletType.enemy: return(m_enemyBullets.Create());

        case E_BulletType.player: return(m_playerBullets.Create());;
        }
    }
Ejemplo n.º 7
0
 // Use this for initialization
 void Awake()
 {
     // 정보가 없다면 '평범한 총알'을 흉내낸 정보가 담긴다.
     bulletType     = E_BulletType.Independent;
     spreadNum      = 1;
     spreadDegree   = 0.0f;
     velocity       = 15.0f; // unit sec
     damage         = 2;
     travelDistance = 0.0f;
     isActivated    = false;
 }
Ejemplo n.º 8
0
    public void saveBullet(BaseBullet bb)
    {
        E_BulletType btype = bb.btype;

        if (!bulletPool.ContainsKey(btype))
        {
            bulletPool.Add(btype, new List <BaseBullet>());
        }
        bb.onDispose();
        bulletPool[btype].Add(bb);
        bb.CacheTrans.SetParent(PoolRoot);
        bb.CacheTrans.localPosition = Vector3.zero;
    }
Ejemplo n.º 9
0
    public T getBullet <T>(BulletData data) where T : BaseBullet
    {
        E_BulletType btype = data.btype;

        if (bulletPool.ContainsKey(btype) && bulletPool[btype].Count > 0)
        {
            BaseBullet bb = bulletPool[btype][0];
            bb.refreshData(data);
            bulletPool[btype].RemoveAt(0);
            bb.CacheTrans.SetParent(null);
            return(bb as T);
        }
        else
        {
            return(BulletFactory.create <T>(data));
        }
    }
Ejemplo n.º 10
0
    private void OnGUI()
    {
        _bulletId      = EditorGUILayout.TextField(_roleNameTitle, _bulletId);
        _animClipStart = EditorGUILayout.ObjectField("出生动画", _animClipStart, typeof(AnimationClip), true);
        _animClipRun   = EditorGUILayout.ObjectField("飞行动画", _animClipRun, typeof(AnimationClip), true);
        _animClipEnd   = EditorGUILayout.ObjectField("撞击动画", _animClipEnd, typeof(AnimationClip), true);
        type           = (E_BulletType)EditorGUILayout.EnumPopup("子弹类型", type);

        if (GUILayout.Button("创建"))
        {
            if (string.IsNullOrEmpty(_bulletId))
            {
                Debug.LogError("子弹Id不能为空!!!");
                return;
            }
            if (_animClipStart == null || _animClipRun == null || _animClipEnd == null)
            {
                Debug.LogError("动画不能为空!!!");
                return;
            }
            CreateBullet("Bullet_" + _bulletId);
        }
    }
Ejemplo n.º 11
0
    static public void CreateBullet(float3 _StartPosition, float _LifeTime, int _HostID, E_BulletType _Type, int _Damage, float3 _Direction, float _Speed, LayerMask _TargetLayerMask, int _TrailMeshCount = 10)
    {
        int meshcount = _TrailMeshCount;

        Entity entity = m_EntityManger.CreateEntity(m_BulletArchetype);

        m_EntityManger.SetComponentData(entity, new Translation()
        {
            Value = _StartPosition
        });
        m_EntityManger.SetComponentData(entity, new BulletComponent(_HostID, _Type, _Damage, Unity.Mathematics.math.normalize(_Direction), _Speed, _TargetLayerMask));
        m_EntityManger.SetComponentData(entity, new TrailComponent()
        {
            MeshCount = meshcount
        });
        m_EntityManger.SetComponentData(entity, new LifeTimerComponent(_LifeTime));
        DynamicBuffer <TrailBufferElement> buffer = m_EntityManger.GetBuffer <TrailBufferElement>(entity);
        DynamicBuffer <float3>             reinb  = buffer.Reinterpret <float3>();

        for (int i = 0; i < meshcount; ++i)
        {
            reinb.Add(_StartPosition);
        }
    }