示例#1
0
        // 攻击类型的判定unit1 能否打unit2
        public static bool IsCanAttackByAttackType(BLUnitBase unit1, BLUnitBase unit2)
        {
            // 暂时没有能攻击的建筑
            if (unit1.unit_type == UnitType.Building)
            {
                return(false);
            }
            else if (unit1.unit_type == UnitType.Hero)
            {
                if (unit2.unit_type == UnitType.Building)
                {
                    return(true);
                }
                else if (unit2.unit_type == UnitType.Hero)
                {
                    BLUnitHero cast_unit  = unit1 as BLUnitHero;
                    BLUnitHero enemy_unit = unit2 as BLUnitHero;

                    bool can_attack = false;

                    if ((enemy_unit.is_fly && cast_unit.can_attack_fly) || (!enemy_unit.is_fly) && cast_unit.can_attack_ground)
                    {
                        can_attack = true;
                    }

                    return(can_attack);
                }
            }

            return(false);
        }
示例#2
0
    public override void OnInit()
    {
        bl_unit_info = BL.BLUnitManager.Instance().GetUnit(unit_id) as BL.BLUnitHero;

        base.OnInit();

        attack_range_circle.gameObject.SetActive(false);
    }
示例#3
0
        public BLUnitHero CreateHeroUnit(int unit_id, string gds_name, BLIntVector3 pos, int team_id)
        {
            GDSKit.unit unit_gds = GDSKit.unit.GetInstance(gds_name);

            BLUnitHero hero_unit = new BLUnitHero();

            // 属性相关设置
            hero_unit.gds_name         = gds_name;
            hero_unit.unit_type        = UnitType.Hero;
            hero_unit.unit_id          = unit_id;
            hero_unit.revive_cool_down = unit_gds.revive_cd;
            hero_unit.move_speed       = unit_gds.move_speed;
            hero_unit.attack_range     = unit_gds.attack_range;
            hero_unit.vision           = unit_gds.attack_vision;
            hero_unit.attack_speed     = unit_gds.attack_speed;
            hero_unit.attack_power     = unit_gds.unit_attack;
            hero_unit.hp     = unit_gds.unit_hp;
            hero_unit.max_hp = unit_gds.unit_hp;

            hero_unit.is_move_attack    = unit_gds.is_move_attack;
            hero_unit.is_fly            = unit_gds.is_fly;
            hero_unit.can_attack_fly    = unit_gds.can_attack_fly;
            hero_unit.can_attack_ground = unit_gds.can_attack_ground;
            hero_unit.can_pursue        = unit_gds.can_pursue;
            hero_unit.aoe_radius        = unit_gds.aoe_radius;
            hero_unit.bullet_speed      = unit_gds.bullet_speed;

            hero_unit.position = pos;
            hero_unit.team_id  = team_id;

            if (all_unit_list.ContainsKey(hero_unit.unit_id))
            {
                Debug.LogError("相同名字的unit已经在管理器里了 id : " + hero_unit.unit_id);
                return(null);
            }

            all_unit_list.Add(hero_unit.unit_id, hero_unit);
            hero_unit_list.Add(hero_unit.unit_id, hero_unit);

            hero_unit.OnInit();

            // 表现层
            HeroUnit unit_renderer = UnitManager.Instance().CreateHeroUnit(hero_unit.gds_name, hero_unit.unit_id, hero_unit.position.Vector3Value());

            // 表现层需要显示迷雾,攻击范围,所以需要这些数据
            unit_renderer.attack_vision = hero_unit.vision * 0.001f;
            unit_renderer.team_id       = hero_unit.team_id;
            unit_renderer.attack_range  = (hero_unit.attack_range * 0.001f);

            unit_renderer.OnInit();

            return(hero_unit);
        }
示例#4
0
        static public BLUnitBase FindCanAttackTarget(BLUnitHero hero_unit)
        {
            // 找到视野范围内,第一个能攻击到的目标
            var enemys = BattleVisionControl.Instance().GetEnemys(hero_unit.team_id);

            if (enemys != null)
            {
                var enumerator = enemys.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    BLUnitBase enemy_unit = enumerator.Current;
                    if (hero_unit.IsCanAttack(enemy_unit))
                    {
                        return(enemy_unit);
                    }
                }
            }

            return(null);
        }
示例#5
0
        public override void OnInit()
        {
            base.OnInit();

            hero_unit = cast_unit as BLUnitHero;

            command_type = TickCommandType.Move;

            start_position = hero_unit.position;

            // 准备数据
            List <BLIntVector3> path_node = null;

            if (hero_unit.is_fly)
            {
                path_node = BattleField.battle_field.SearchFlyPath(start_position, dest_position);
            }
            else
            {
                path_node = BattleField.battle_field.SearchPath(start_position, dest_position);
            }


            frame_at_node.Clear();
            final_path_node.Clear();

            if (path_node != null && path_node.Count > 0)
            {
                BLIntVector3 pre_node = path_node[0];

                int frame = 0;
                frame_at_node.Add(frame);
                final_path_node.Add(pre_node);

                for (int i = 1; i < path_node.Count; ++i)
                {
                    BLIntVector3 current_node = path_node[i];

                    int magnitude  = (current_node - pre_node).Magnitude();
                    int need_frame = (int)(magnitude / hero_unit.move_speed / BLTimelineController.MS_PER_FRAME);

                    if (need_frame > 0)
                    {
                        frame += need_frame;

                        frame_at_node.Add(frame);

                        final_path_node.Add(path_node[i]);

                        //Debug.Log("frame at node i " + i + " frame " + frame);
                    }

                    pre_node = current_node;
                }
            }

            pre_node_index     = 0;
            current_node_index = 1;
            current_frame      = 0;


            hero_unit.pre_position = start_position;

            current_dir = (hero_unit.position - hero_unit.pre_position).Vector3Value();

            EventManager.Instance().PostEvent(EventConfig.EVENT_L2R_START_MOVE, new object[] { hero_unit.unit_id });
        }
示例#6
0
    public override void OnClear()
    {
        base.OnClear();

        bl_unit_info = null;
    }