예제 #1
0
        public Triangle(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius)
        {
            _engine      = engine;
            Transform.X  = x;
            Transform.Y  = y;
            base.Paint  += OnPaint;
            base.Update += OnUpdate;
            MaxMinHeight = Transform.Y - _engine.Surface.Height / 4;
            Radius       = radius;
            A            = new Vec2(-Radius, Radius);
            B            = new Vec2(Radius, Radius);
            C            = new Vec2(0, -Radius);
            VelacityX    = 0;
            VelacityY    = 0;

            Paint = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                Color       = new SKColor(150, 150, 150)
            };

            Path = new SKPath();
            Path.MoveTo(A.X, A.Y);
            Path.LineTo(B.X, B.Y);
            Path.LineTo(C.X, C.Y);
            Path.Close();
        }
예제 #2
0
        public ITransmission Build(HipsterEngine.Core.HipsterEngine engine, IPlanet planet, float x, float y, float angle, float size)
        {
            _engine = engine;
            Planet  = planet;
            Radius  = size;

            RigidBody = (RigidBodyCircle)_engine.Physics.FactoryBody
                        .CreateRigidCircle()
                        .CreateCircleDef(0.2f, 0.8f, 50, Radius)
                        .CreateBodyDef(x, y, angle, true, false)
                        .Build(1f);

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new[] { 10.0f, 10.0f }, 10),
                StrokeWidth = 5,
                Color       = new SKColor(100, 70, 30)
            };

            Paint1 = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                IsAntialias = true,
                Color       = new SKColor(150, 100, 50)
            };

            return(this);
        }
예제 #3
0
        public LevelPlatform(HipsterEngine.Core.HipsterEngine engine, float x, float y, float width, float height) : base(engine)
        {
            X      = x;
            Y      = y;
            Width  = width;
            Height = height;

            RigidBody = (RigidBodyVertex)_engine.Physics.FactoryBody
                        .CreateRigidVertex()
                        .CreateBox(0.3f, 0.8f, Width, Height, 0.0f)
                        .CreateBodyDef(X, Y, 0, true, false)
                        .Build(0);

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new[] { 10.0f, 10.0f }, 10),

                Color = new SKColor(210, 80, 0, 150)
                        //   Shader = SKShader.CreateRadialGradient(new SKPoint(X, Y), Radius, new SKColor[]
                        //   {
                        //       new SKColor(50, 50, 50),
                        //       new SKColor(0, 140, 210, 100),
                        //   }, new float[] { 0.5f, Radius }, SKShaderTileMode.Repeat),
                        //   Color = new SKColor(210, 170, 0, 100)
            };
        }
예제 #4
0
        public Rope(HipsterEngine.Core.HipsterEngine engine, float x, float y, float length) : base(engine)
        {
            Length = length;
            Nodes  = new List <RigidBody>();

            Generate(x, y);
        }
예제 #5
0
        public Tree(HipsterEngine.Core.HipsterEngine engine, float x, float y, float angle, int layers, float size) : base(engine)
        {
            X      = x;
            Y      = y;
            _angle = angle / 180.0f * (float)Math.PI;

            Leaves = new List <RigidBody>();
            Nodes  = new List <Node>();

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 2,
                Color       = new SKColor(100, 100, 100)
            };

            Theta = (float)(Math.PI / 2) / 3;

            float width = 7;

            Root = new Branch(engine, X, Y, width, true, 0.1f);

            var next = (Branch)Root.AddNode(new Branch(engine, X, Y - size, width, true, 0.1f));

            Root.RigidBody.JointRevolute(next.RigidBody, 0, 0, false, -0, 0, 0);

            Generate(next, 6, 0, layers, -30, size, new Vec2(0, -70));
            Generate(next, 6, 0, layers, 30, size, new Vec2(0, -70));
        }
예제 #6
0
        public static bool SaveProfile(HipsterEngine.Core.HipsterEngine engine, Profile profile)
        {
            var fileName = Path.Combine(StoragePath, PathToProfile);
            var result   = engine.Files.Serialize(profile, fileName);

            return(result);
        }
예제 #7
0
        public PlanetStart(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius) : base(engine, x, y, radius, -1)
        {
            PaintText = new SKPaint
            {
                IsAntialias = true,
                Color       = new SKColor(150, 150, 150),
                TextAlign   = SKTextAlign.Center,
                TextSize    = 80
            };

            Text = "1";

            Paint1 = new SKPaint
            {
                IsAntialias = true,
                Color       = new SKColor(150, 150, 150),
                StrokeWidth = 3,
                Style       = SKPaintStyle.Stroke
            };
            Paint2 = new SKPaint
            {
                IsAntialias = true,
                Color       = new SKColor(150, 150, 150),
                PathEffect  = SKPathEffect.CreateDash(new[] { 20.0f, 20.0f }, 10),
                StrokeWidth = 10,
                Style       = SKPaintStyle.Stroke
            };
        }
예제 #8
0
        public static Profile GetProfile(HipsterEngine.Core.HipsterEngine engine)
        {
            var fileName = Path.Combine(StoragePath, PathToProfile);
            var profile  = engine.Files.Deserialize <Profile>(fileName);

            return(profile);
        }
예제 #9
0
        public IBody Build(HipsterEngine.Core.HipsterEngine engine, float x, float y, float angle, float size)
        {
            _engine      = engine;
            Width        = size * 2;
            Height       = size * 2;
            PointsJoints = new Vec2[]
            {
                new Vec2(size, 0),
            };

            RigidBody = (RigidBodyVertex)_engine.Physics.FactoryBody
                        .CreateRigidVertex()
                        .CreateBox(0.2f, 0.8f, Width, Height, 0.2f)
                        .CreateBodyDef(x, y - size * 2, angle, true, false)
                        .Build(1f);

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new[] { 10.0f, 10.0f }, 10),
                StrokeWidth = 5,
                Color       = new SKColor(100, 70, 30)
            };

            Paint1 = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                IsAntialias = true,
                Color       = new SKColor(150, 100, 50)
            };

            return(this);
        }
예제 #10
0
        public ParallaxBackground(HipsterEngine.Core.HipsterEngine engine, Triangle triangle)
        {
            _engine   = engine;
            _triangle = triangle;

            Update += OnUpdate;
            Paint  += OnPaint;

            Stars      = new List <Vec3>();
            PaintStars = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                Color       = new SKColor(250, 250, 250, 100)
            };

            _random = new Random();

            for (var i = 0; i < 50; i++)
            {
                Stars.Add(new Vec3(_random.Next(0, (int)_engine.Surface.Width), _random.Next(0, (int)_engine.Surface.Height * 4), _random.Next(5, 10)));
            }

            _clearColor = new SKColor((byte)_random.Next(20, 50), (byte)_random.Next(20, 50), (byte)_random.Next(20, 50));
        }
예제 #11
0
        public PlanetEarth(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius) : base(engine)
        {
            X      = x;
            Y      = y;
            Radius = radius;

            RigidBody = (RigidBodyCircle)_engine.Physics.FactoryBody
                        .CreateRigidCircle()
                        .CreateCircleDef(0.3f, 0.8f, 0.0f, Radius)
                        .CreateBodyDef(X, Y, 0, true, false)
                        .Build(0);

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new[] { 10.0f, 10.0f }, 10),

                Color = new SKColor(210, 170, 0, 100)
                        //   Shader = SKShader.CreateRadialGradient(new SKPoint(X, Y), Radius, new SKColor[]
                        //   {
                        //       new SKColor(50, 50, 50),
                        //       new SKColor(0, 140, 210, 100),
                        //   }, new float[] { 0.5f, Radius }, SKShaderTileMode.Repeat),
                        //   Color = new SKColor(210, 170, 0, 100)
            };

            PaintEarth = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 5,
                Color       = new SKColor(100, 100, 100, 100)
            };

            PaintPlanet = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                IsAntialias = true,
                StrokeWidth = 3,
                Color       = new SKColor(80, 40, 0, 150)
            };

            PaintCore = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                IsAntialias = true,
                StrokeWidth = 3,
                Color       = new SKColor(50, 50, 50)
            };

            PaintCoreBorder = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 3,
                Color       = new SKColor(50, 100, 170, 100)
            };
        }
예제 #12
0
 public ButtonScroll(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius, float angle = 0)
 {
     _engine = engine;
     X       = x;
     Y       = y;
     Radius  = radius;
     Angle   = angle;
 }
예제 #13
0
 public Label(HipsterEngine.Core.HipsterEngine engine, float x, float y, string text, SKPaint style, float scale = 1)
 {
     X       = x;
     Y       = y;
     Scale   = scale;
     Text    = text;
     Style   = style;
     _engine = engine;
 }
예제 #14
0
        public GunBullet(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius)
        {
            Radius = radius;

            RigidBody = (RigidBodyCircle)engine.Physics.FactoryBody
                        .CreateRigidCircle()
                        .CreateCircleDef(0.2f, 0.2f, 0.2f, Radius)
                        .CreateBodyDef(x, y, 0, true, true)
                        .Build(1);
        }
예제 #15
0
        public Button(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius)
        {
            _engine = engine;

            X      = x;
            Y      = y;
            Radius = radius;

            _rect = SKRect.Create(-Radius, -Radius, Radius * 2, Radius * 2);

            OnLoad();
        }
예제 #16
0
        public ITransmission Build(HipsterEngine.Core.HipsterEngine engine, IPlanet planet, float x, float y, float angle, float size)
        {
            _engine = engine;
            Wheel1  = (Wheel) new Wheel().Build(_engine, planet, x - size - 10, y, angle, size);
            Wheel2  = (Wheel) new Wheel().Build(_engine, planet, x + size + 10, y, angle, size);

            var distance = Vec2.Distance(Wheel1.RigidBody.GetBody().GetPosition(),
                                         Wheel2.RigidBody.GetBody().GetPosition());

            Wheel1.RigidBody.JointDistance(Wheel2.RigidBody, 0, 0, 0, 0, false, 1, distance);

            return(this);
        }
예제 #17
0
            public LayoutHorizontal(HipsterEngine.Core.HipsterEngine engine, float x, int section)
            {
                _engine = engine;

                X = x;

                var radius = 50.0f;
                var bX     = 150;
                var y      = _engine.Surface.Height / section;

                ButtonRight = new ButtonScroll(_engine, _engine.Surface.Width - bX + X, y, radius);
                ButtonLeft  = new ButtonScroll(_engine, bX + X, y, radius, 180);
            }
예제 #18
0
        public HorizontalListBox(HipsterEngine.Core.HipsterEngine engine, float x, float y, float width, float height, int countMax)
        {
            X      = x;
            Y      = y;
            Width  = width;
            Height = height;

            layouts = new List <LayoutHorizontal>();

            _engine = engine;
            _engine.Surface.Canvas.Camera.SetTarget(_engine.Surface.Width + _engine.Surface.Width / 2, _engine.Surface.Height / 2);

            layouts.Add(new LayoutHorizontal(_engine, 0, 2));
        }
예제 #19
0
        public Model(HipsterEngine.Core.HipsterEngine engine)
        {
            _engine = engine;
            _canvas = _engine.Surface.Canvas;
            Timer   = new TimeWatch();
            Rand    = new Random();

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 2,
                Color       = new SKColor(100, 100, 100)
            };
        }
예제 #20
0
 public MapPlanets(HipsterEngine.Core.HipsterEngine engine, Triangle triangle)
 {
     _engine  = engine;
     _random  = new Random();
     Planets  = new List <Planet>();
     Triangle = triangle;
     Balls    = 1;
     Triangle.IncrementBalls += (sender, args) => { Balls++; };
     IsEndGame         = false;
     PaintFinishedLine = new SKPaint
     {
         Style       = SKPaintStyle.Stroke,
         IsAntialias = true,
         Color       = new SKColor(150, 150, 150)
     };
 }
예제 #21
0
        public void Build(HipsterEngine.Core.HipsterEngine engine, IPlanet planet, IBody body)
        {
            _planet = planet;
            _engine = engine;
            _body   = body;
            Width   = 10;
            Height  = 40;
            Bullets = new List <GunBullet>();

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                IsAntialias = true,
                Color       = new SKColor(30, 30, 30)
            };
            SetAngleRad(180);
        }
예제 #22
0
        public Planet(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius, int textureId, float angle = 0,
                      float angularVelocity = 0)
        {
            _engine         = engine;
            Transform.X     = x;
            Transform.Y     = y;
            Radius          = radius;
            Transform.Angle = angle;
            VelacityX       = 0;
            VelacityY       = 0;
            AngularVelocity = angularVelocity;
            CorrectAngle    = 0;
            TextureId       = textureId;

            _rect = SKRect.Create(-Radius, -Radius, Radius * 2, Radius * 2);

            Update += OnUpdate;
            Paint  += OnPaint;
        }
예제 #23
0
        public Branch(HipsterEngine.Core.HipsterEngine engine, float x, float y, float strokeWidth,
                      bool isPhysics = true, float mass = 1, bool isSensor = false, short gIndex = 1) : base(x, y)
        {
            _engine = engine;

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = strokeWidth,
                Color       = new SKColor(100, 100, 100)
            };

            if (isPhysics)
            {
                RigidBody = (RigidBodyCircle)_engine.Physics.FactoryBody
                            .CreateRigidCircle()
                            .CreateCircleDef(0.2f, 0.2f, 0.2f, 5, gIndex)
                            .CreateBodyDef(X, Y, 0, true, isSensor)
                            .Build(mass);
            }
        }
예제 #24
0
        public LayoutRecord(HipsterEngine.Core.HipsterEngine engine)
        {
            _engine = engine;
            canvas  = _engine.Surface.Canvas;

            Radius     = _engine.Surface.Width / 5;
            Y          = _engine.Surface.Height - _engine.Surface.Height / 4;
            _x1Line1   = 0;
            _y1Line1   = Y;
            _x2Line1   = _engine.Surface.Width / 2 - Radius;
            _y2Line1   = Y;
            _x1Line2   = _engine.Surface.Width / 2 + Radius;
            _y1Line2   = Y;
            _x2Line2   = _engine.Surface.Width;
            _y2Line2   = Y;
            _circleX   = _engine.Surface.Width / 2;
            _circleY   = Y;
            _textX     = _engine.Surface.Width / 2 - 1;
            _textY     = Y + 16;
            TextRecord = "0";

            Paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                StrokeWidth = 2,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new[] { 10.0f, 10.0f }, 10),
                Color       = new SKColor(150, 150, 150)
            };

            PaintText = new SKPaint
            {
                IsAntialias = true,
                Color       = new SKColor(150, 150, 150),
                TextAlign   = SKTextAlign.Center,
                Typeface    = Assets.Typeface,
                TextSize    = 50
            };
        }
예제 #25
0
        public LayoutTop(HipsterEngine.Core.HipsterEngine engine)
        {
            _engine    = engine;
            LabelBalls = new Label(_engine, _engine.Surface.Width - 40, -15, "1", new SKPaint
            {
                IsAntialias = true,
                TextAlign   = SKTextAlign.Center,
                TextSize    = 20,
                Color       = new SKColor(150, 150, 150)
            });
            Balls       = 1;
            Timer       = new TimeWatch();
            Timer.Tick += TimerOnTick;
            Timer.Start(1, 40);

            BtnPause        = new ButtonPause(_engine, 30, -15, 15);
            BtnPause.Click += (element, state) =>
            {
                if (BtnPause.TextureId == 0)
                {
                    BtnPause.TextureId = 1;

                    _engine.Screens.CurrentScreen.OnPaused();
                }
                else if (BtnPause.TextureId == 1)
                {
                    BtnPause.TextureId = 0;

                    _engine.Screens.CurrentScreen.OnResume();
                }
            };

            _engine.Screens.CurrentScreen.MouseDown += (element, state) => BtnPause.OnMouseAction(state);
            _engine.Screens.CurrentScreen.MouseMove += (element, state) => BtnPause.OnMouseAction(state);
            _engine.Screens.CurrentScreen.MouseUp   += (element, state) => BtnPause.OnMouseAction(state);
        }
예제 #26
0
 public ButtonPause(HipsterEngine.Core.HipsterEngine engine, float x, float y, float radius) : base(engine, x,
                                                                                                    y, radius)
 {
 }
예제 #27
0
 public Robot(HipsterEngine.Core.HipsterEngine engine, IPlanet planet)
 {
     _engine = engine;
     _planet = planet;
 }
 public TriangleParticlesController(HipsterEngine.Core.HipsterEngine engine, Triangle triangle) : base(engine)
 {
     Random    = new Random();
     _triangle = triangle;
 }
예제 #29
0
 public LevelModel(HipsterEngine.Core.HipsterEngine engine) : base(engine)
 {
 }