Exemplo n.º 1
0
        public void AddBloc(Bloc bloc, Point gridPosition)
        {
            //Test if the asked position is in the world's range
            if (gridPosition.X >= blocs.GetLength(0) || gridPosition.Y >= blocs.GetLength(1))
            {
                throw new Exception("The bloc to add does not fall in world's array of bloc range. World array of blocs [" + blocs.GetLength(0) + "][" + blocs.GetLength(1) + "]");
            }

            //Calculate the bloc position (from coordinate to pixels)
            bloc.CalculatePosition(gridPosition);

            //Add the bloc in the grid position
            blocs[gridPosition.X, gridPosition.Y] = bloc;

            //Add the bloc in the world's things
            AddThing(bloc);
        }