Exemplo n.º 1
0
        public void Init(int player_id_, int team_id_)
        {
            team_id   = team_id_;
            player_id = player_id_;

            for (int i = 0; i < hero_config.Length; ++i)
            {
                int hero_index             = i;
                BLPlayerHeroData hero_data = new BLPlayerHeroData();

                hero_data.hero_gds_name = hero_config[hero_index];
                hero_data.build_site_id = BLUnitManager.Instance().GetBaseID(player_id);

                BLUnitBase unit = BLUnitManager.Instance().GetUnit(hero_data.build_site_id);

                if (unit != null)
                {
                    Debug.Assert(unit.unit_type == UnitType.Building);
                    BLUnitBuilding build_unit = unit as BLUnitBuilding;

                    int unit_id = BLUnitManager.Instance().GetHeroUnitID(player_id, hero_index);
                    build_unit.AddReviveUnit(hero_data.hero_gds_name, unit_id, 0);
                }

                all_hero_data.Add(hero_data);
            }
        }
Exemplo n.º 2
0
        public BLUnitBuilding FindNeareatReviveBuilding()
        {
            var building_list = BLUnitManager.Instance().GetBuildingList();

            float distance = float.MaxValue;

            BLUnitBuilding revive_building = null;

            var enumerator = building_list.GetEnumerator();

            while (enumerator.MoveNext())
            {
                BLUnitBuilding building_unit = enumerator.Current.Value;

                if (building_unit.team_id == team_id && building_unit.can_revive_hero)
                {
                    float temp = (building_unit.position - position).SqrMagnitude();

                    if (temp < distance)
                    {
                        revive_building = building_unit;
                    }
                }
            }

            return(revive_building);
        }
Exemplo n.º 3
0
        public override void DoCommand()
        {
            base.DoCommand();

            //Debug.Log("放置英雄在第: " + BLTimelineController.Instance().current_logic_frame + " 帧.");

            // 暂时用team id 代替player id,在房间内是不重复的
            BLPlayerData player_data = BLPlayerDataManager.Instance().GetPlayerData(player_id);

            // 检查是否为可放置的状态
            if (player_data.IsCanPutHero(hero_index))
            {
                BLPlayerHeroData hero_data    = player_data.GetHeroData(hero_index);
                BL.BLIntVector3  born_point   = BattleField.battle_field.born_point[player_id];
                int             unit_id       = BL.BLUnitManager.Instance().GetHeroUnitID(player_id, hero_index);
                string          unit_gds_name = hero_data.hero_gds_name;
                BL.BLIntVector3 born_pos      = BL.BLUnitManager.Instance().GetRandomPosition(born_point);

                BL.BLUnitManager.Instance().CreateHeroUnit(unit_id, unit_gds_name, born_pos, team_id);

                // 建筑上移除
                BLUnitBase unit = BLUnitManager.Instance().GetUnit(hero_data.build_site_id);
                Debug.Assert(unit.unit_type == UnitType.Building);
                BLUnitBuilding build_unit = unit as BLUnitBuilding;

                build_unit.RemoveUnit(unit_id);
            }
        }
Exemplo n.º 4
0
        static public BLUnitManager Instance()
        {
            if (instance == null)
            {
                instance = new BLUnitManager();
            }

            return(instance);
        }
Exemplo n.º 5
0
        public override void DoCommand()
        {
            cast_unit = BLUnitManager.Instance().GetUnit(cast_unit_id);

            if (cast_unit != null)
            {
                cast_unit.DoCommand(this);
            }
        }
Exemplo n.º 6
0
        public bool IsCanPutHero(int hero_index)
        {
            if (IsHeroAlreadyPut(hero_index))
            {
                // 已经放置了这个将军
                return(false);
            }

            BLPlayerHeroData hero_data = GetHeroData(hero_index);
            int unit_id = BLUnitManager.Instance().GetHeroUnitID(player_id, hero_index);

            // 检查资源

            // 检查复活状态
            BLUnitBase unit = BLUnitManager.Instance().GetUnit(hero_data.build_site_id);

            Debug.Assert(unit.unit_type == UnitType.Building);
            BLUnitBuilding build_unit = unit as BLUnitBuilding;

            return(build_unit.IsUnitCanRevive(unit_id));
        }
Exemplo n.º 7
0
        public void DoMainLogic(int elapsed_frame)
        {
            while (elapsed_frame > 0)
            {
                --elapsed_frame;

                //pre_logic_frame_time_stamp = current_logic_frame * MS_PER_FRAME * 0.001f;
                pre_logic_frame_time_stamp     = current_logic_frame_time_stamp;
                current_logic_frame_time_stamp = total_time_elapsed;

                BattleVisionControl.Instance().Tick();

                // 有指令的话,分发指令
                BLCommandManager.Instance().Tick(current_logic_frame);

                BLUnitManager.Instance().Tick();

                BLBulletManager.Instance().Tick();

                ++current_logic_frame;

                //current_logic_frame_time_stamp = current_logic_frame * MS_PER_FRAME * 0.001f;
            }
        }
Exemplo n.º 8
0
        // 每帧更新能看到的单位,
        // 所有的单位共享视野
        public void Tick()
        {
            vision_enemy_units.Clear();

            // 最多8支队伍
            for (int i = 0; i < BattleField.MAX_PLAYER; ++i)
            {
                vision_enemy_units.Add(i + 1, new HashSet <BLUnitBase>());
            }

            var unit_list1 = BLUnitManager.Instance().GetAllUnitList();
            var unit_list2 = BLUnitManager.Instance().GetAllUnitList();

            var enumerator1 = unit_list1.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                var enumerator2 = unit_list2.GetEnumerator();

                while (enumerator2.MoveNext())
                {
                    BLUnitBase unit1 = enumerator1.Current.Value;
                    BLUnitBase unit2 = enumerator2.Current.Value;

                    if (unit1.team_id != unit2.team_id &&
                        unit1.IsAlive() && unit2.IsAlive() &&
                        unit1.IsCanSeeUnitCheckOnlyMyself(unit2))
                    {
                        if (!vision_enemy_units[unit1.team_id].Contains(unit2))
                        {
                            vision_enemy_units[unit1.team_id].Add(unit2);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public bool IsHeroAlreadyPut(int hero_index)
        {
            int unit_id = BLUnitManager.Instance().GetHeroUnitID(player_id, hero_index);

            return(BLUnitManager.Instance().GetUnit(unit_id) != null);
        }