Пример #1
0
        public override void Execute()
        {
            MYXZEntity entity = new MYXZEntity(Npc, 2);

            entity.RegisterObserver(AOIInfoModel.Update);

            entity.UpdatePosition();
            int mark = MYXZTimer.Instance.AddTimer(entity.UpdatePosition, Setting.AOI.UPDATE_RATE, -1);

            AOIInfoModel.AddEntityUpdateMark(entity, mark);
            MapModel.AddEntity(Npc.TargetGameObject, entity);
        }
Пример #2
0
 private void RefreshEntityInterests(MYXZEntity entity, EntityCollection <MYXZGrid> enumerable)
 {
     for (int x = entity.LocatedGridPosition.x - entity.InterstRadius;
          x < 2 * entity.InterstRadius; x++) //正方形的感兴趣范围
     {
         for (int y = entity.LocatedGridPosition.y - entity.InterstRadius;
              y < 2 * entity.InterstRadius; y++)
         {
             Vector2Int pos = new Vector2Int(x, y);
             if (AOIInfoModel.Contains(pos)) //如果这个pos在当前地图是合法的
             {
                 enumerable.Add(AOIInfoModel.AllGrids[pos]);
             }
         }
     }
 }