예제 #1
0
 private void CreateGFX(AssetCreator assets)
 {
     _face           = new Sprite(assets.CircleTexture(1f, MaterialType.Squares, Color.Gray, 1f, 24f));
     _torso          = new Sprite(assets.TextureFromVertices(PolygonTools.CreateRectangle(2f, 4f), MaterialType.Squares, Color.LightSlateGray, 0.8f, 24f));
     _leftJetEngine  = new Sprite(assets.CircleTexture(1f, MaterialType.Waves, Color.Gray, 1f, 24f));
     _rightJetEngine = new Sprite(assets.CircleTexture(1f, MaterialType.Waves, Color.Gray, 1f, 24f));
 }
예제 #2
0
        private void CreateGFX(AssetCreator assets)
        {
            int counterAlpha = (int)Math.Floor(255f / 10f);

            _sprite = new Sprite(assets.CircleTexture(1f, MaterialType.Waves, Color.Gray, 1f, 24f));
            _mainCharPairsSpriteHP = new Dictionary <int, Sprite>();
            for (int i = 0; i <= 10; i += 1)
            {
                _mainCharPairsSpriteHP[i] = new Sprite(assets.CircleTexture(1f, MaterialType.Waves, new Color(255, 0, 0, 255 - counterAlpha * i), 1f, 24f));
            }
        }
예제 #3
0
        public Spider(World world, PhysicsGameScreen screen, Vector2 position)
        {
            //Load bodies
            _circle          = BodyFactory.CreateCircle(world, SpiderBodyRadius, 0.1f, position);
            _circle.BodyType = BodyType.Dynamic;

            //Left upper leg
            _leftUpper = BodyFactory.CreateRectangle(world, _upperLegSize.X, _upperLegSize.Y, 0.1f,
                                                     _circle.Position - new Vector2(SpiderBodyRadius, 0f) -
                                                     new Vector2(_upperLegSize.X / 2f, 0f));
            _leftUpper.BodyType = BodyType.Dynamic;

            //Left lower leg
            _leftLower = BodyFactory.CreateRectangle(world, _lowerLegSize.X, _lowerLegSize.Y, 0.1f,
                                                     _circle.Position - new Vector2(SpiderBodyRadius, 0f) -
                                                     new Vector2(_upperLegSize.X, 0f) -
                                                     new Vector2(_lowerLegSize.X / 2f, 0f));
            _leftLower.BodyType = BodyType.Dynamic;

            //Right upper leg
            _rightUpper = BodyFactory.CreateRectangle(world, _upperLegSize.X, _upperLegSize.Y, 0.1f,
                                                      _circle.Position + new Vector2(SpiderBodyRadius, 0f) +
                                                      new Vector2(_upperLegSize.X / 2f, 0f));
            _rightUpper.BodyType = BodyType.Dynamic;

            //Right lower leg
            _rightLower = BodyFactory.CreateRectangle(world, _lowerLegSize.X, _lowerLegSize.Y, 0.1f,
                                                      _circle.Position + new Vector2(SpiderBodyRadius, 0f) +
                                                      new Vector2(_upperLegSize.X, 0f) +
                                                      new Vector2(_lowerLegSize.X / 2f, 0f));
            _rightLower.BodyType = BodyType.Dynamic;

            //Create joints
            JointFactory.CreateRevoluteJoint(world, _circle, _leftUpper, new Vector2(_upperLegSize.X / 2f, 0f));
            _leftShoulderAngleJoint            = JointFactory.CreateAngleJoint(world, _circle, _leftUpper);
            _leftShoulderAngleJoint.MaxImpulse = 3f;

            JointFactory.CreateRevoluteJoint(world, _circle, _rightUpper, new Vector2(-_upperLegSize.X / 2f, 0f));
            _rightShoulderAngleJoint            = JointFactory.CreateAngleJoint(world, _circle, _rightUpper);
            _rightShoulderAngleJoint.MaxImpulse = 3f;

            JointFactory.CreateRevoluteJoint(world, _leftUpper, _leftLower, new Vector2(_lowerLegSize.X / 2f, 0f));
            _leftKneeAngleJoint            = JointFactory.CreateAngleJoint(world, _leftUpper, _leftLower);
            _leftKneeAngleJoint.MaxImpulse = 3f;

            JointFactory.CreateRevoluteJoint(world, _rightUpper, _rightLower, new Vector2(-_lowerLegSize.X / 2f, 0f));
            _rightKneeAngleJoint            = JointFactory.CreateAngleJoint(world, _rightUpper, _rightLower);
            _rightKneeAngleJoint.MaxImpulse = 3;

            _screen = screen;

            //GFX
            AssetCreator creator = _screen.ScreenManager.Assets;

            _torso    = new Sprite(creator.CircleTexture(SpiderBodyRadius, MaterialType.Waves, Color.Gray, 1f));
            _upperLeg = new Sprite(creator.TextureFromShape(_leftUpper.FixtureList[0].Shape,
                                                            MaterialType.Blank, Color.DimGray, 1f));
            _lowerLeg = new Sprite(creator.TextureFromShape(_leftLower.FixtureList[0].Shape,
                                                            MaterialType.Blank, Color.DarkSlateGray, 1f));
        }
예제 #4
0
 private void CreateGFX(AssetCreator assets, ScreenManager screenManager)
 {
     //ColorTEST = Color.White;
     _circle   = new Sprite(assets.CircleTexture(1f, MaterialType.Waves, Color.Red, 1f, 24f));
     _circle2  = new Sprite(screenManager.Game.Content.Load <Texture2D>("virus1"));
     scaleKoef = _circle2.Size / _circle.Size;
 }
예제 #5
0
        private void CreateGFX(AssetCreator assets)
        {
            _face  = new Sprite(assets.CircleTexture(0.9f, MaterialType.Squares, Color.Gray, 1f, 24f));
            _torso = new Sprite(assets.TextureFromVertices(PolygonTools.CreateRoundedRectangle(2f, 4f, 0.5f, 0.7f, 2), MaterialType.Squares, Color.LightSlateGray, 0.8f, 24f));

            _upperArm = new Sprite(assets.TextureFromVertices(PolygonTools.CreateCapsule(1.9f, 0.45f, 16), MaterialType.Squares, Color.DimGray, 0.8f, 24f));
            _lowerArm = new Sprite(assets.TextureFromVertices(PolygonTools.CreateCapsule(1.9f, 0.45f, 16), MaterialType.Squares, Color.DarkSlateGray, 0.8f, 24f));

            _upperLeg = new Sprite(assets.TextureFromVertices(PolygonTools.CreateCapsule(2f, 0.5f, 16), MaterialType.Squares, Color.DimGray, 0.8f, 24f));
            _lowerLeg = new Sprite(assets.TextureFromVertices(PolygonTools.CreateCapsule(2f, 0.5f, 16), MaterialType.Squares, Color.DarkSlateGray, 0.8f, 24f));
        }
예제 #6
0
        public Agent(World world, PhysicsGameScreen screen, Vector2 position)
        {
            _collidesWith        = Category.All;
            _collisionCategories = Category.All;

            _agentBody          = BodyFactory.CreateBody(world, position);
            _agentBody.BodyType = BodyType.Dynamic;

            //Center
            FixtureFactory.AttachCircle(0.5f, 0.5f, _agentBody);

            //Left arm
            FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(-1f, 0f), _agentBody);
            FixtureFactory.AttachCircle(0.5f, 0.5f, _agentBody, new Vector2(-2f, 0f));

            //Right arm
            FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(1f, 0f), _agentBody);
            FixtureFactory.AttachCircle(0.5f, 0.5f, _agentBody, new Vector2(2f, 0f));

            //Top arm
            FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, 1f), _agentBody);
            FixtureFactory.AttachCircle(0.5f, 0.5f, _agentBody, new Vector2(0f, 2f));

            //Bottom arm
            FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, -1f), _agentBody);
            FixtureFactory.AttachCircle(0.5f, 0.5f, _agentBody, new Vector2(0f, -2f));

            _screen = screen;

            //GFX
            AssetCreator creator = _screen.ScreenManager.Assets;

            _box = new Sprite(creator.TextureFromVertices(PolygonTools.CreateRectangle(1.75f, 0.2f),
                                                          MaterialType.Blank, Color.White, 1f));
            _knob   = new Sprite(creator.CircleTexture(0.5f, MaterialType.Blank, Color.Orange, 1f));
            _offset = ConvertUnits.ToDisplayUnits(2f);
        }
예제 #7
0
        public Objects(World world, ScreenManager screenManager, Vector2 startPosition, Vector2 endPosition, int count, float radius, ObjectType type, float toothHeight = 1f)
        {
            _batch      = screenManager.SpriteBatch;
            _bodyRadius = radius;
            BodyList    = new List <Body>(count);


            for (int i = 0; i < count; i++)
            {
                switch (type)
                {
                case ObjectType.Circle:
                    BodyList.Add(world.CreateCircle(radius, 1f));
                    break;

                case ObjectType.Rectangle:
                    BodyList.Add(world.CreateRectangle(radius, radius, 1f));
                    _bodyRadius = radius / 2f;
                    break;

                case ObjectType.Star:
                    BodyList.Add(world.CreateGear(radius, 10, 0f, toothHeight, 1f));
                    _bodyRadius = radius * 2.7f;
                    break;

                case ObjectType.Gear:
                    BodyList.Add(world.CreateGear(radius, 10, 100f, toothHeight, 1f));
                    _bodyRadius = radius * 2.7f;
                    break;
                }
            }

            for (int i = 0; i < BodyList.Count; i++)
            {
                Body body = BodyList[i];
                body.BodyType = BodyType.Dynamic;
                body.Position = Vector2.Lerp(startPosition, endPosition, i / (float)(count - 1));
                foreach (Fixture fixture in body.FixtureList)
                {
                    fixture.Restitution         = 0.7f;
                    fixture.Friction            = 0.2f;
                    fixture.CollisionCategories = Category.All;
                    fixture.CollidesWith        = Category.All;
                }
            }

            //GFX
            AssetCreator creator = screenManager.Assets;

            switch (type)
            {
            case ObjectType.Circle:
                _object = new Sprite(creator.CircleTexture(radius, MaterialType.Dots, Color.DarkRed, 0.8f, 24f));
                break;

            case ObjectType.Rectangle:
                _object = new Sprite(creator.TextureFromVertices(PolygonTools.CreateRectangle(radius / 2f, radius / 2f), MaterialType.Dots, Color.Blue, 0.8f, 24f));
                break;

            case ObjectType.Star:
                _object = new Sprite(creator.TextureFromVertices(PolygonTools.CreateGear(radius, 10, 0f, toothHeight), MaterialType.Dots, Color.Yellow, 0.8f, 24f));
                break;

            case ObjectType.Gear:
                _object = new Sprite(creator.TextureFromVertices(PolygonTools.CreateGear(radius, 10, 100f, toothHeight), MaterialType.Dots, Color.DarkGreen, 0.8f, 24f));
                break;
            }
        }
예제 #8
0
        public Objects(World world, PhysicsGameScreen screen, Vector2 startPosition, Vector2 endPosition, int count,
                       float radius, ObjectType type)
        {
            _bodies             = new List <Body>(count);
            CollidesWith        = Category.All;
            CollisionCategories = Category.All;

            for (int i = 0; i < count; ++i)
            {
                switch (type)
                {
                case ObjectType.Circle:
                    _bodies.Add(BodyFactory.CreateCircle(world, radius, 1f));
                    break;

                case ObjectType.Rectangle:
                    _bodies.Add(BodyFactory.CreateRectangle(world, radius, radius, 1f));
                    break;

                case ObjectType.Star:
                    _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 0f, 1f, 1f));
                    break;

                case ObjectType.Gear:
                    _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 100f, 1f, 1f));
                    break;
                }
            }

            for (int i = 0; i < _bodies.Count; ++i)
            {
                Body body = _bodies[i];
                body.BodyType            = BodyType.Dynamic;
                body.Position            = Vector2.Lerp(startPosition, endPosition, i / (float)(count - 1));
                body.Restitution         = .7f;
                body.Friction            = .2f;
                body.CollisionCategories = CollisionCategories;
                body.CollidesWith        = CollidesWith;
            }

            _screen = screen;

            //GFX
            AssetCreator creator = _screen.ScreenManager.Assets;

            switch (type)
            {
            case ObjectType.Circle:
                _object = new Sprite(creator.CircleTexture(radius, MaterialType.Dots, Color.DarkRed, 0.8f));
                break;

            case ObjectType.Rectangle:
                _object =
                    new Sprite(creator.TextureFromVertices(PolygonTools.CreateRectangle(radius / 2f, radius / 2f),
                                                           MaterialType.Dots, Color.Blue, 0.8f));
                break;

            case ObjectType.Star:
                _object = new Sprite(creator.TextureFromVertices(PolygonTools.CreateGear(radius, 10, 0f, 1f),
                                                                 MaterialType.Dots, Color.Yellow, 0.8f));
                break;

            case ObjectType.Gear:
                _object = new Sprite(creator.TextureFromVertices(PolygonTools.CreateGear(radius, 10, 100f, 1f),
                                                                 MaterialType.Dots, Color.DarkGreen, 0.8f));
                break;
            }
        }