Пример #1
0
 public UnitCamera(
     DrawUnit target,
     Vector2 keepBound,
     Vector2 followBound,
     Vector2 upperBound,
     Vector2 lowerBound,
     Vector2 resetBound,
     Vector3 offset)
     : base(Constants.TIME_TICKS_EVENT)
 {
     _target = target;
     _offset = offset;
     _keepBound = keepBound;
     _followBound = followBound;
     _upperBound = upperBound;
     _lowerBound = lowerBound;
     _resetBound = resetBound;
 }
        private void LoadTerrain()
        {
            var def = XmlHelper.LoadFromFile<TerrainDef>(@"Data\Terrain.xml");
            _terrain = _world.CreateTerrain(def);

            Root.Add(_terrain.Sprite);
        }
Пример #3
0
        public DrawUnit CreateUnit(DrawUnitDef def)
        {
            var bodydef = new BodyDef();
            bodydef.type = def.BodyType;
            bodydef.angle = def.RotateZ;
            bodydef.fixedRotation = def.FixedRotation;
            bodydef.position.X = B2Value(def.X);
            bodydef.position.Y = B2Value(def.Y);
            Body body = _world.CreateBody(bodydef);

            var tex = XNADevicesManager.Instance.ContentManager.Load<Texture2D>(def.TexName);
            Sprite sprite;
            if (def.RepeatX != 0.0f || def.RepeatY != 0.0f)
            {
                var rSprite = new RepeatSprite(tex);
                if (def.RepeatX != 0.0f)
                {
                    rSprite.RepeatX = def.RepeatX;
                }
                if (def.RepeatY != 0.0f)
                {
                    rSprite.RepeatY = def.RepeatY;
                }
                sprite = rSprite;
            }
            else
            {
                sprite = new Sprite(tex);
                sprite.DrawRectangle = def.DrawRectangle;
            }
            sprite.Alpha = def.Alpha;
            sprite.ScaleX = def.ScaleX;
            sprite.ScaleY = def.ScaleY;
            sprite.RotateX = def.RotateX;
            sprite.RotateY = def.RotateY;
            sprite.RotateZ = def.RotateZ;
            sprite.R = def.R;
            sprite.G = def.G;
            sprite.B = def.B;
            sprite.X = def.X;
            sprite.Y = def.Y;
            sprite.Z = def.Z;
            sprite.TransformOrigin = def.TransformOrigin;
            sprite.ZWriteEnable = def.ZWriteEnable;
            var unit = new DrawUnit(sprite, body, this);
            unit.Group = def.Group;
            body.SetUserData(unit);
            return unit;
        }