private List <Cube3D> GenerateCubes3D()
        {
            var cubes = RubiksCubeModel.GetCubies();

            var cubes3D = new List <Cube3D>();

            double d = 2.0 / 3.0;

            foreach (var c in cubes)
            {
                var cr = new Cube3D(new Point3D(d * ToInt(GetLayer(c.Layers, RotationDirection.X)), d * ToInt(GetLayer(c.Layers, RotationDirection.Y)), d * ToInt(GetLayer(c.Layers, RotationDirection.Z))), d / 2, c);
                if (cr.Positions.Contains(LayerType.Top))
                {
                    cr = cr.Rotate(RotationDirection.Y, LayerRotation[LayerType.Top], new Point3D(0, d, 0));
                }
                if (cr.Positions.Contains(LayerType.MiddleFromTop))
                {
                    cr = cr.Rotate(RotationDirection.Y, LayerRotation[LayerType.MiddleFromTop], new Point3D(0, 0, 0));
                }
                if (cr.Positions.Contains(LayerType.Bottom))
                {
                    cr = cr.Rotate(RotationDirection.Y, LayerRotation[LayerType.Bottom], new Point3D(0, -d, 0));
                }
                if (cr.Positions.Contains(LayerType.Front))
                {
                    cr = cr.Rotate(RotationDirection.Z, LayerRotation[LayerType.Front], new Point3D(0, 0, d));
                }
                if (cr.Positions.Contains(LayerType.MiddleFromFront))
                {
                    cr = cr.Rotate(RotationDirection.Z, LayerRotation[LayerType.MiddleFromFront], new Point3D(0, 0, 0));
                }
                if (cr.Positions.Contains(LayerType.Back))
                {
                    cr = cr.Rotate(RotationDirection.Z, LayerRotation[LayerType.Back], new Point3D(0, 0, -d));
                }
                if (cr.Positions.Contains(LayerType.Left))
                {
                    cr = cr.Rotate(RotationDirection.X, LayerRotation[LayerType.Left], new Point3D(-d, 0, 0));
                }
                if (cr.Positions.Contains(LayerType.MiddleFromLeft))
                {
                    cr = cr.Rotate(RotationDirection.X, LayerRotation[LayerType.MiddleFromLeft], new Point3D(0, 0, 0));
                }
                if (cr.Positions.Contains(LayerType.Right))
                {
                    cr = cr.Rotate(RotationDirection.X, LayerRotation[LayerType.Right], new Point3D(d, 0, 0));
                }

                cr = cr.Rotate(RotationDirection.Y, Rotation[1], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationDirection.Z, Rotation[2], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationDirection.X, Rotation[0], new Point3D(0, 0, 0));
                cubes3D.Add(cr);
            }
            return(cubes3D);
        }
Beispiel #2
0
        public void Id_Ok()
        {
            string referenceId = "a cube";
            int    vertices    = 0;
            string expected    = $"{referenceId}{vertices}";
            Cube3D cube        = new Cube3D {
                ReferenceId = referenceId
            };

            Assert.IsNotNull(cube);
            Assert.AreEqual(expected, cube.Id);
        }
Beispiel #3
0
 protected override void Initialize()
 {
     sman = new ScreenManager(this);
     Components.Add(sman);
     graphics.PreferMultiSampling = true;
     NameGenerator.init();
     Helpfile.init();
     FileEntry.init(Content);
     PatternDrawer.init(Content);
     ProgramList.init();
     Cube3D.Initilize(graphics.GraphicsDevice);
     base.Initialize();
 }
Beispiel #4
0
        public static void Task1()
        {
            Console.WriteLine("AOC2020_Day17_1");

            var cube = new Cube3D();

            cube.Load(6);
            for (int i = 0; i < 6; i++)
            {
                cube.Step();
            }
            Console.WriteLine("Sum : {0}", cube.GetActiveSum());
        }
Beispiel #5
0
 protected override void Initialize()
 {
     this.sman = new ScreenManager((Game)this);
     this.Components.Add((IGameComponent)this.sman);
     this.graphics.PreferMultiSampling = true;
     NameGenerator.init();
     PatternDrawer.init(this.Content);
     ProgramList.init();
     Cube3D.Initilize(this.graphics.GraphicsDevice);
     AlienwareFXManager.Init();
     this.graphics.GraphicsDevice.DeviceLost += new EventHandler <EventArgs>(this.GraphicsDevice_DeviceLost);
     base.Initialize();
 }
Beispiel #6
0
 public CubeSpace3D(int xSize, int ySize, int zSize)
 {
     _cubes = new Cube3D[xSize, ySize, zSize];
     for (int x = 0; x < xSize; x++)
     {
         for (int y = 0; y < ySize; y++)
         {
             for (int z = 0; z < zSize; z++)
             {
                 _cubes[x, y, z] = new Cube3D(this, x, y, z);
             }
         }
     }
 }
Beispiel #7
0
        private void HumanMenuItem_Click(object sender, RoutedEventArgs e)
        {
            HumanMenuItem.IsChecked = true;
            CubeMenuItem.IsChecked  = PiramideMenuItem.IsChecked = false;

            ClearLines();
            var body = new Cube3D(-40, -50, -25, 40, 70, 25);

            lines3D.AddRange(body.GetLines());

            var head = new Cube3D(-20, -50, -25, 20, -90, 25);

            lines3D.AddRange(head.GetLines());

            var leye = new Cube3D(-15, -80, -25, -2, -75, -25);

            lines3D.AddRange(leye.GetLines());

            var reye = new Cube3D(2, -80, -25, 15, -75, -25);

            lines3D.AddRange(reye.GetLines());

            var larm = new Cube3D(40, -50, -12, 60, 40, 12);

            lines3D.AddRange(larm.GetLines());

            var rarm = new Cube3D(-40, -50, -12, -60, 40, 12);

            lines3D.AddRange(rarm.GetLines());

            var lleg = new Cube3D(-30, 70, -14, -10, 170, 14);

            lines3D.AddRange(lleg.GetLines());

            var rleg = new Cube3D(10, 70, -14, 30, 170, 14);

            lines3D.AddRange(rleg.GetLines());

            AddLines();
        }
Beispiel #8
0
 public override void draw(Rectangle bounds, SpriteBatch sb)
 {
     base.draw(bounds, sb);
     try
     {
         int width  = bounds.Width;
         int height = bounds.Height;
         if (this.rendertarget == null || this.rendertarget.Width != width || this.rendertarget.Height != height)
         {
             if (this.rtSpritebatch == null)
             {
                 this.rtSpritebatch = new SpriteBatch(sb.GraphicsDevice);
             }
             if (this.rendertarget != null)
             {
                 this.rendertarget.Dispose();
             }
             this.rendertarget = new RenderTarget2D(sb.GraphicsDevice, width, height);
         }
         if (!this.PlayingHeartbreak)
         {
             TextItem.DrawShadow = false;
             TextItem.doFontLabel(new Vector2((float)(bounds.X + 6), (float)(bounds.Y + 2)), Utils.FlipRandomChars("PortHack.Heart", 0.003), GuiData.font, new Color?(Utils.AddativeWhite * 0.6f), (float)(bounds.Width - 10), 100f, false);
             TextItem.doFontLabel(new Vector2((float)(bounds.X + 6), (float)(bounds.Y + 2)), Utils.FlipRandomChars("PortHack.Heart", 0.1), GuiData.font, new Color?(Utils.AddativeWhite * 0.2f), (float)(bounds.Width - 10), 100f, false);
         }
         if (this.PlayingHeartbreak)
         {
             this.playTimeExpended += (float)this.os.lastGameTime.ElapsedGameTime.TotalSeconds;
         }
         this.UpdateForTime(bounds, sb);
         RenderTarget2D currentRenderTarget = Utils.GetCurrentRenderTarget();
         sb.GraphicsDevice.SetRenderTarget(this.rendertarget);
         sb.GraphicsDevice.Clear(Color.Transparent);
         this.rtSpritebatch.Begin();
         Rectangle dest      = new Rectangle(0, 0, bounds.Width, bounds.Height);
         Vector3   vector3_1 = new Vector3(MathHelper.ToRadians(35.4f), MathHelper.ToRadians(45f), MathHelper.ToRadians(0.0f));
         Vector3   vector3_2 = new Vector3(1f, 1f, 0.0f) * this.os.timer * 0.2f + new Vector3(this.os.timer * 0.1f, this.os.timer * -0.4f, 0.0f);
         float     num       = 2.5f;
         if (this.PlayingHeartbreak)
         {
             if ((double)this.playTimeExpended < (double)num)
             {
                 Cube3D.RenderWireframe(Vector3.Zero, 2.6f, Vector3.Lerp(Utils.NormalizeRotationVector(vector3_2), vector3_1, Utils.QuadraticOutCurve(this.playTimeExpended / num)), Color.White);
             }
             else
             {
                 this.pcs.DrawHeartSequence(dest, (float)this.os.lastGameTime.ElapsedGameTime.TotalSeconds, 30f);
             }
         }
         else
         {
             Cube3D.RenderWireframe(new Vector3(0.0f, 0.0f, 0.0f), 2.6f, vector3_2, Color.White);
         }
         this.rtSpritebatch.End();
         sb.GraphicsDevice.SetRenderTarget(currentRenderTarget);
         Rectangle rectangle = new Rectangle(bounds.X + (bounds.Width - width) / 2, bounds.Y + (bounds.Height - height) / 2, width, height);
         float     rarity    = Math.Min(1f, (float)((double)this.playTimeExpended / (double)num * 0.800000011920929 + 0.200000002980232));
         FlickeringTextEffect.DrawFlickeringSprite(sb, rectangle, (Texture2D)this.rendertarget, 4f, rarity, (object)this.os, Color.White);
         sb.Draw((Texture2D)this.rendertarget, rectangle, Utils.AddativeWhite * 0.7f);
     }
     catch (Exception ex)
     {
         Console.WriteLine(Utils.GenerateReportFromException(ex));
     }
 }
        public override void draw(Rectangle bounds, SpriteBatch sb)
        {
            base.draw(bounds, sb);
            var width  = bounds.Width;
            var height = bounds.Height;

            if (rendertarget == null || rendertarget.Width != width || rendertarget.Height != height)
            {
                if (rtSpritebatch == null)
                {
                    rtSpritebatch = new SpriteBatch(sb.GraphicsDevice);
                }
                if (rendertarget != null)
                {
                    rendertarget.Dispose();
                }
                rendertarget = new RenderTarget2D(sb.GraphicsDevice, width, height);
            }
            if (!PlayingHeartbreak)
            {
                TextItem.DrawShadow = false;
                TextItem.doFontLabel(new Vector2(bounds.X + 6, bounds.Y + 2),
                                     Utils.FlipRandomChars("PortHack.Heart", 0.003), GuiData.font, Utils.AddativeWhite * 0.6f,
                                     bounds.Width - 10, 100f);
                TextItem.doFontLabel(new Vector2(bounds.X + 6, bounds.Y + 2),
                                     Utils.FlipRandomChars("PortHack.Heart", 0.1), GuiData.font, Utils.AddativeWhite * 0.2f,
                                     bounds.Width - 10, 100f);
            }
            if (PlayingHeartbreak)
            {
                playTimeExpended += (float)os.lastGameTime.ElapsedGameTime.TotalSeconds;
            }
            UpdateForTime(bounds, sb);
            var currentRenderTarget = Utils.GetCurrentRenderTarget();

            sb.GraphicsDevice.SetRenderTarget(rendertarget);
            sb.GraphicsDevice.Clear(Color.Transparent);
            rtSpritebatch.Begin();
            var dest      = new Rectangle(0, 0, bounds.Width, bounds.Height);
            var vector3_1 = new Vector3(MathHelper.ToRadians(35.4f), MathHelper.ToRadians(45f),
                                        MathHelper.ToRadians(0.0f));
            var vector3_2 = new Vector3(1f, 1f, 0.0f) * os.timer * 0.2f + new Vector3(os.timer * 0.1f, os.timer * -0.4f, 0.0f);
            var num       = 2.5f;

            if (PlayingHeartbreak)
            {
                if (playTimeExpended < (double)num)
                {
                    Cube3D.RenderWireframe(Vector3.Zero, 2.6f,
                                           Vector3.Lerp(Utils.NormalizeRotationVector(vector3_2), vector3_1,
                                                        Utils.QuadraticOutCurve(playTimeExpended / num)), Color.White);
                }
                else
                {
                    pcs.DrawHeartSequence(dest, (float)os.lastGameTime.ElapsedGameTime.TotalSeconds, 30f);
                }
            }
            else
            {
                Cube3D.RenderWireframe(new Vector3(0.0f, 0.0f, 0.0f), 2.6f, vector3_2, Color.White);
            }
            rtSpritebatch.End();
            sb.GraphicsDevice.SetRenderTarget(currentRenderTarget);
            var rectangle = new Rectangle(bounds.X + (bounds.Width - width) / 2, bounds.Y + (bounds.Height - height) / 2,
                                          width, height);
            var rarity = Math.Min(1f, (float)(playTimeExpended / (double)num * 0.800000011920929 + 0.200000002980232));

            FlickeringTextEffect.DrawFlickeringSprite(sb, rectangle, rendertarget, 4f, rarity, os, Color.White);
            sb.Draw(rendertarget, rectangle, Utils.AddativeWhite * 0.7f);
        }