示例#1
0
        public void Update(ObstacleList obs)
        {
            for (int x = 0; x < rows; x++)
            {
                for (int y = 0; y < columns; y++)
                {
                    foreach (Obstacle ob1 in obstacles[x, y])
                    {
                        ob1.Update();
                    }
                    foreach (Obstacle ob2 in obstacles[x, y])
                    {
                        if (ob2.Moving)
                        {
                            movingObstacles.Add(ob2);
                        }
                    }
                    obstacles[x, y].RemoveAll(ob => ob.Dead);
                    obstacles[x, y].RemoveAll(ob => ob.Moving);
                }
            }
            foreach (Obstacle ob in movingObstacles)
            {
                if (!ob.Moving)
                {
                    int x = (int)ob.Position.X / sectionSize;
                    int y = (int)ob.Position.Y / sectionSize;
                    obstacles[x, y].Add(ob);
                }
            }
            movingObstacles.RemoveAll(ob => !ob.Moving);


            movingObstacles.RemoveAll(ob => !ob.Moving);
        }
示例#2
0
 public CollisionObjectsList(Vector2 pos, int w, int h)
 {
     obstacles = new ObstacleList(pos, w, h);
     npcs      = new NPCList();
 }