mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Lib roll
This commit is contained in:
		
							parent
							
								
									af65800aa0
								
							
						
					
					
						commit
						e6bb2ba216
					
				
					 2 changed files with 39 additions and 27 deletions
				
			
		|  | @ -90,6 +90,7 @@ | ||||||
|     <PackageReference Include="Markdig" Version="0.17.1" /> |     <PackageReference Include="Markdig" Version="0.17.1" /> | ||||||
|     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" /> |     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" /> | ||||||
|     <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> |     <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> | ||||||
|  |     <PackageReference Include="OnePlat.DiceNotation" Version="2.0.2" /> | ||||||
|     <PackageReference Include="Rg.Plugins.Popup" Version="1.1.5.188" /> |     <PackageReference Include="Rg.Plugins.Popup" Version="1.1.5.188" /> | ||||||
|     <PackageReference Include="SkiaSharp.Svg" Version="1.60.0" /> |     <PackageReference Include="SkiaSharp.Svg" Version="1.60.0" /> | ||||||
|     <PackageReference Include="SkiaSharp.Views" Version="1.68.0" /> |     <PackageReference Include="SkiaSharp.Views" Version="1.68.0" /> | ||||||
|  |  | ||||||
|  | @ -1,4 +1,6 @@ | ||||||
| using System; | using OnePlat.DiceNotation; | ||||||
|  | using OnePlat.DiceNotation.DieRoller; | ||||||
|  | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
| using System.Globalization; | using System.Globalization; | ||||||
|  | @ -71,31 +73,34 @@ namespace AideDeJeu.Views | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|             var diceRoller = new ViewModels.DiceRollerViewModel(); |             //var diceRoller = new ViewModels.DiceRollerViewModel(); | ||||||
|             var diceRolls = diceRoller.DicesValues(6, 3); |             //var diceRolls = diceRoller.DicesValues(6, 3); | ||||||
|             float sumx = diceRolls.Sum(kv => kv.Value); |             //float sumx = diceRolls.Sum(kv => kv.Value); | ||||||
| 
 | 
 | ||||||
|             int sizei = 6; |             int sizei = 3; | ||||||
|             int sizej = 3; |             int sizej = 2; | ||||||
|             baseNode.Scale = new Vector3(sizei * 1.5f, 1, sizej * 1.5f); |             baseNode.Scale = new Vector3(sizei * 1.5f, 1, sizej * 1.5f); | ||||||
|             bars = new List<Bar>(sizei * sizej); |             bars = new List<Bar>(sizei * sizej); | ||||||
| 
 | 
 | ||||||
|             DrawRolls(diceRolls, sumx, 0, 1); |             //DrawRolls(diceRolls, sumx, 0, 1); | ||||||
|             //int idice = 0; |             int idice = 0; | ||||||
|             //for (var i = 0f; i < sizei * 1.5f; i += 1.5f) |             for (var i = 0f; i < sizei * 1.5f; i += 1.5f) | ||||||
|             //{ |             { | ||||||
|             //    for (var j = 0f; j < sizej * 1.5f; j += 1.5f) |                 for (var j = 0f; j < sizej * 1.5f; j += 1.5f) | ||||||
|             //    { |                 { | ||||||
|             //        var boxNode = plotNode.CreateChild(); |                     var boxNode = plotNode.CreateChild(); | ||||||
|             //        boxNode.Position = new Vector3(sizei / 2f - i, 0, sizej / 2f - j); |                     boxNode.Position = new Vector3(sizei / 2f - i, 0, sizej / 2f - j); | ||||||
|             //        var bar = new Bar(new Color(RandomHelper.NextRandom(), RandomHelper.NextRandom(), RandomHelper.NextRandom(), 0.9f)); |                     var bar = new Bar(new Color(RandomHelper.NextRandom(), RandomHelper.NextRandom(), RandomHelper.NextRandom(), 0.9f)); | ||||||
|             //        boxNode.AddComponent(bar); |                     boxNode.AddComponent(bar); | ||||||
|             //        //bar.SetValueWithAnimation((Math.Abs(i) + Math.Abs(j) + 1) / 2f); |                     //bar.SetValueWithAnimation((Math.Abs(i) + Math.Abs(j) + 1) / 2f); | ||||||
|  |                     IDice dice = new Dice(); | ||||||
|  |                     var diceResult = dice.Roll("3d6", new RandomDieRoller()); | ||||||
|  |                     bar.SetValueWithAnimation(diceResult.Value); | ||||||
|                     //bar.SetValueWithAnimation(diceRolls[idice + 3] / 10); |                     //bar.SetValueWithAnimation(diceRolls[idice + 3] / 10); | ||||||
|             //        bars.Add(bar); |                     bars.Add(bar); | ||||||
|             //    } |                 } | ||||||
|             //    idice++; |                 idice++; | ||||||
|             //} |             } | ||||||
| 
 | 
 | ||||||
|             SelectedBar = bars.First(); |             SelectedBar = bars.First(); | ||||||
|             SelectedBar.Select(); |             SelectedBar.Select(); | ||||||
|  | @ -180,7 +185,13 @@ namespace AideDeJeu.Views | ||||||
|             set { barNode.Scale = new Vector3(1, value < 0.3f ? 0.3f : value, 1); } |             set { barNode.Scale = new Vector3(1, value < 0.3f ? 0.3f : value, 1); } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public void SetValueWithAnimation(float value) => barNode.RunActionsAsync(new EaseBackOut(new ScaleTo(3f, 1, value, 1))); |         private float finalValue { get; set; } | ||||||
|  | 
 | ||||||
|  |         public void SetValueWithAnimation(float value) | ||||||
|  |         { | ||||||
|  |             finalValue = value; | ||||||
|  |             barNode.RunActionsAsync(new EaseBackOut(new ScaleTo(3f, 1, value, 1))); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         public Bar(Color color) |         public Bar(Color color) | ||||||
|         { |         { | ||||||
|  | @ -211,10 +222,10 @@ namespace AideDeJeu.Views | ||||||
|             var scale = barNode.Scale; |             var scale = barNode.Scale; | ||||||
|             barNode.Position = new Vector3(pos.X, scale.Y / 2f, pos.Z); |             barNode.Position = new Vector3(pos.X, scale.Y / 2f, pos.Z); | ||||||
|             textNode.Position = new Vector3(0.5f, scale.Y + 0.2f, 0); |             textNode.Position = new Vector3(0.5f, scale.Y + 0.2f, 0); | ||||||
|             var newValue = (float)Math.Round(scale.Y, 1); |             //var newValue = (float)Math.Round(scale.Y, 1); | ||||||
|             if (lastUpdateValue != newValue) |             //if (lastUpdateValue != newValue) | ||||||
|                 text3D.Text = newValue.ToString("F01", CultureInfo.InvariantCulture); |                 text3D.Text = finalValue.ToString();// newValue.ToString("F01", CultureInfo.InvariantCulture); | ||||||
|             lastUpdateValue = newValue; |             //lastUpdateValue = newValue; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public void Deselect() |         public void Deselect() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez