static public BattleVisionControl Instance() { if (instance == null) { instance = new BattleVisionControl(); } return(instance); }
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); }
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"); // }
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; } }
// 考虑共享视野 public bool IsCanSeeUnit(BLUnitBase enemy_unit) { HashSet <BLUnitBase> vision_enemy_units = BattleVisionControl.Instance().GetEnemys(team_id); return(vision_enemy_units.Contains(enemy_unit)); }