Esempio n. 1
0
        internal void checkPosInMapBound()
        {
            double radioFix = radius_ * simulator.getMapBoundFix();

            if (position_.x - radioFix < simulator.mapBounds.xMin)
            {
                double fix = (simulator.mapBounds.xMin - (position_.x - radioFix)) / simulator.mapBounds.width;

                position_ = new Vector2(simulator.mapBounds.xMin + radioFix - fix, position_.y);
            }
            else if (position_.x + radioFix > simulator.mapBounds.xMax)
            {
                double fix = (position_.x + radioFix - simulator.mapBounds.xMax) / simulator.mapBounds.width;

                position_ = new Vector2(simulator.mapBounds.xMax - radioFix + fix, position_.y);
            }

            if (position_.y - radioFix < simulator.mapBounds.yMin)
            {
                double fix = (simulator.mapBounds.yMin - (position_.y - radioFix)) / simulator.mapBounds.height;

                position_ = new Vector2(position_.x, simulator.mapBounds.yMin + radioFix - fix);
            }
            else if (position_.y + radioFix > simulator.mapBounds.yMax)
            {
                double fix = (position_.y + radioFix - simulator.mapBounds.yMax) / simulator.mapBounds.height;

                position_ = new Vector2(position_.x, simulator.mapBounds.yMax - radioFix + fix);
            }
        }