コード例 #1
0
    private void HandleAOIEvent()
    {
        AOIEventMap enter_map = this.aoi.GetEnterMap();
        AOIEventMap leave_map = this.aoi.GetLeaveMap();

        foreach (KeyValuePair <int, List <int> > pair in enter_map)
        {
            Entity entity = this.GetEntityById(pair.Key);
            if (entity != null)
            {
                //进入Entity的视野
                foreach (int target_entity_id in pair.Value)
                {
                    Entity target_entity = this.GetEntityById(target_entity_id);
                    if (target_entity != null)
                    {
                        entity.EnterVision(target_entity);
                    }
                }
            }
        }

        foreach (KeyValuePair <int, List <int> > pair in leave_map)
        {
            Entity entity = this.GetEntityById(pair.Key);
            if (entity != null)
            {
                //离开Entity的视野
                foreach (int target_entity_id in pair.Value)
                {
                    Entity target_entity = this.GetEntityById(target_entity_id);
                    if (target_entity != null)
                    {
                        entity.LeaveVision(target_entity);
                    }
                }
            }
        }

        this.aoi.ClearEvent();
    }
コード例 #2
0
ファイル: AOI.cs プロジェクト: a3562351/FightForMoney
 public void ClearEvent()
 {
     this.enter_map = new AOIEventMap();
     this.leave_map = new AOIEventMap();
 }