Exemplo n.º 1
0
        public BulletComponent CreateBullet()
        {
            BulletComponent bullet = new BulletComponent();

            bullet.bullet_id = UnitManager.GetUniqueID();

            all_bullets.Add(bullet);

            bullet_id_map[bullet.bullet_id] = bullet;

            return(bullet);
        }
Exemplo n.º 2
0
        public void Tick()
        {
            for (int i = all_bullets.Count - 1; i >= 0; --i)
            {
                BulletComponent bullet_com = all_bullets[i];

                if (bullet_com.Tick())
                {
                    bullet_id_map.Remove(bullet_com.bullet_id);
                    all_bullets.RemoveAt(i);
                }
            }
        }
Exemplo n.º 3
0
        // 实际攻击逻辑
        public override void DoAttack(BLUnitBase attack_target_unit)
        {
            if (attack_cool_down <= 0)
            {
                my_unit.DoAttack(attack_target_unit, false);


                BulletComponent bullet = BLBulletManager.Instance().CreateBullet();
                bullet.bullet_speed = my_unit.bullet_speed;
                bullet.Start(my_unit.position, attack_target_unit.position, HitCallBack);

                // 换算成攻击间隔是多少帧
                attack_cool_down = (int)(my_unit.attack_speed / BLTimelineController.MS_PER_FRAME);
            }
        }
Exemplo n.º 4
0
    public void CreateBulletGameObject(int bullet_id)
    {
        BL.BulletComponent bullet_com = BL.BLBulletManager.Instance().GetBullet(bullet_id);
        if (bullet_com != null)
        {
            BulletGameObject obj = new BulletGameObject();
            obj.bullet_id  = bullet_id;
            obj.bullet_obj = ObjectPoolManager.Instance().GetObject("Missil_01");
            obj.bullet_obj.transform.SetParent(UnitManager.Instance().cache_root_effect_node, false);

            Vector3 start_pos  = bullet_com.start_postion.Vector3Value();
            Vector3 end_pos    = bullet_com.end_position.Vector3Value();
            Vector3 bullet_dir = (end_pos - start_pos).normalized;

            obj.bullet_obj.transform.position = start_pos;
            obj.bullet_obj.transform.rotation = Quaternion.LookRotation(bullet_dir);

            all_bullet_gameobj[bullet_id] = obj;
        }
    }
Exemplo n.º 5
0
        public void HitCallBack(BulletComponent bullet_componet)
        {
            // 结算伤害
            var all_enemys = BattleVisionControl.Instance().GetEnemys(my_unit.team_id);

            int hit_radius_sqr = my_unit.aoe_radius * my_unit.aoe_radius;

            var enumerator = all_enemys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                BLUnitBase unit = enumerator.Current;

                if (unit.IsAlive() && (unit.position - bullet_componet.end_position).SqrMagnitude() <= hit_radius_sqr)
                {
                    unit.OnDamage(my_unit.attack_power);
                }
            }

//			my_unit.AddEffect(bullet_componet.end_position, "hit_effect3");
//
        }
Exemplo n.º 6
0
    public void                     Tick(float delta_time)
    {
        BL.BulletComponent bullet_com = BL.BLBulletManager.Instance().GetBullet(bullet_id);

        if (bullet_com != null)
        {
            float current_time_span = (BL.BLTimelineController.Instance().current_logic_frame_time_stamp - BL.BLTimelineController.Instance().pre_logic_frame_time_stamp);

            if (current_time_span == 0)
            {
                return;
            }

            float current_elapsed = BL.BLTimelineController.Instance().time_elapsed_from_pre_frame;

            Vector3 pre_position  = bullet_com.pre_position.Vector3Value();
            Vector3 next_position = bullet_com.now_position.Vector3Value();

            Vector3 now_position = Vector3.Lerp(pre_position, next_position, current_elapsed / current_time_span);

            bullet_obj.transform.position = now_position;
        }
    }