|
|
@ -9,6 +9,7 @@ using System.IO;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Reflection;
|
|
|
|
using SkiaSharp.Views.Forms;
|
|
|
|
using SkiaSharp.Views.Forms;
|
|
|
|
using TouchTracking;
|
|
|
|
using TouchTracking;
|
|
|
|
|
|
|
|
using Xamarin.Essentials;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TheGameExtreme.view
|
|
|
|
namespace TheGameExtreme.view
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -20,7 +21,7 @@ namespace TheGameExtreme.view
|
|
|
|
private bool isFirst = true;
|
|
|
|
private bool isFirst = true;
|
|
|
|
private Main viewmodel;
|
|
|
|
private Main viewmodel;
|
|
|
|
private List<SKRect> stacks = new List<SKRect>();
|
|
|
|
private List<SKRect> stacks = new List<SKRect>();
|
|
|
|
Button button = new Button();
|
|
|
|
Button button;
|
|
|
|
List<string> playersNames;
|
|
|
|
List<string> playersNames;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +30,7 @@ namespace TheGameExtreme.view
|
|
|
|
Dictionary<long, TouchManipulationBitmap> bitmapDictionary = new Dictionary<long, TouchManipulationBitmap>();
|
|
|
|
Dictionary<long, TouchManipulationBitmap> bitmapDictionary = new Dictionary<long, TouchManipulationBitmap>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainPage(List<string> playersNames)
|
|
|
|
public MainPage(List<string> playersNames)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.playersNames = playersNames;
|
|
|
|
this.playersNames = playersNames;
|
|
|
@ -36,29 +38,26 @@ namespace TheGameExtreme.view
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
|
|
|
|
|
|
|
|
Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
//Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
|
|
|
|
|
|
|
|
string[] resourceIDs = assembly.GetManifestResourceNames();
|
|
|
|
////string[] resourceIDs = assembly.GetManifestResourceNames();
|
|
|
|
|
|
|
|
//string resourceID = "TheGameExtreme.Media.thegame.jpg";
|
|
|
|
|
|
|
|
|
|
|
|
SKPoint position = new SKPoint();
|
|
|
|
//SKPoint position = new SKPoint(100, (float)(DeviceDisplay.MainDisplayInfo.Height - 0.2 * DeviceDisplay.MainDisplayInfo.Height));
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string resourceID in resourceIDs)
|
|
|
|
//for (int i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
if (resourceID.EndsWith(".png") ||
|
|
|
|
// using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
resourceID.EndsWith(".jpg"))
|
|
|
|
// {
|
|
|
|
{
|
|
|
|
// SKBitmap bitmap = SKBitmap.Decode(stream).Resize(new SKImageInfo(225, 225), SKFilterQuality.High);
|
|
|
|
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
|
|
|
|
{
|
|
|
|
// bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
SKBitmap bitmap = SKBitmap.Decode(stream);
|
|
|
|
// {
|
|
|
|
bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
// Matrix = SKMatrix.MakeTranslation(position.X, position.Y - bitmap.Height),
|
|
|
|
{
|
|
|
|
// });
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
|
|
|
|
// position.X += bitmap.Width + 50;
|
|
|
|
});
|
|
|
|
// }
|
|
|
|
position.X += 100;
|
|
|
|
//}
|
|
|
|
position.Y += 100;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stacks.Add(checkbox0);
|
|
|
|
//stacks.Add(checkbox0);
|
|
|
@ -74,15 +73,26 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
|
|
//viewmodel.PlayerChanged += OnPlayerChanged;
|
|
|
|
//viewmodel.PlayerChanged += OnPlayerChanged;
|
|
|
|
|
|
|
|
|
|
|
|
//Alert.SetBinding(Label.TextProperty, new Binding("Alert", source: viewmodel));
|
|
|
|
viewmodel.AlertChanged += OnAlertChanged;
|
|
|
|
|
|
|
|
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
|
|
|
|
|
|
|
|
inflateHand();
|
|
|
|
inflateHand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnAlertChanged(object sender, EventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (viewmodel.Alert != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DisplayAlert("", viewmodel.Alert, "OK");
|
|
|
|
|
|
|
|
viewmodel.Alert = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) // Faire plusieurs canvas
|
|
|
|
public void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) // Faire plusieurs canvas
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
SKCanvas canvas = args.Surface.Canvas;
|
|
|
|
SKCanvas canvas = args.Surface.Canvas;
|
|
|
@ -94,7 +104,7 @@ namespace TheGameExtreme.view
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnTouchEffectAction(object sender, TouchActionEventArgs args)
|
|
|
|
public void OnTouchEffectAction(object sender, TouchActionEventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Convert Xamarin.Forms point to pixels
|
|
|
|
// Convert Xamarin.Forms point to pixels
|
|
|
|
TouchTrackingPoint pt = args.Location;
|
|
|
|
TouchTrackingPoint pt = args.Location;
|
|
|
@ -146,7 +156,7 @@ namespace TheGameExtreme.view
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args)
|
|
|
|
public void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (bitmap != null)
|
|
|
|
if (bitmap != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -163,10 +173,10 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPlayerChanged(object sender, PlayerChangedEventArgs args)
|
|
|
|
//private void OnPlayerChanged(object sender, PlayerChangedEventArgs args)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
inflateHand();
|
|
|
|
// inflateHand();
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
private void inflateHand()
|
|
|
|
private void inflateHand()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -179,58 +189,78 @@ namespace TheGameExtreme.view
|
|
|
|
// Hand.Children.Add(card);
|
|
|
|
// Hand.Children.Add(card);
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < playersNames.Count; i++)
|
|
|
|
|
|
|
|
|
|
|
|
bitmapCollection.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string resourceID = "TheGameExtreme.Media.thegame.jpg";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SKPoint position = new SKPoint(100, (float)(DeviceDisplay.MainDisplayInfo.Height - 0.2 * DeviceDisplay.MainDisplayInfo.Height));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SKBitmap bitmap = SKBitmap.Decode(stream).Resize(new SKImageInfo(225, 225), SKFilterQuality.High);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y - bitmap.Height),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
position.X += bitmap.Width + 50;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
private void OnBindingChanged(object sender, TopRangeChangedEventArgs args)
|
|
|
|
private void OnBindingChanged(object sender, TopRangeChangedEventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (args.NumStackChanged)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
pile0.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
pile1.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
pile2.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
pile3.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Hand.Children.Count; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Button b = Hand.Children[i] as Button;
|
|
|
|
|
|
|
|
if (String.Equals(b.Text,args.NewTopRangeCard.Value.ToString()))
|
|
|
|
|
|
|
|
{
|
|
|
|
//switch (args.NumStackChanged)
|
|
|
|
Hand.Children.RemoveAt(i);
|
|
|
|
//{
|
|
|
|
break;
|
|
|
|
// case 0:
|
|
|
|
}
|
|
|
|
// pile0.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
}
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// case 1:
|
|
|
|
|
|
|
|
// pile1.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// case 2:
|
|
|
|
|
|
|
|
// pile2.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// case 3:
|
|
|
|
|
|
|
|
// pile3.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < Hand.Children.Count; i++)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// Button b = Hand.Children[i] as Button;
|
|
|
|
|
|
|
|
// if (String.Equals(b.Text,args.NewTopRangeCard.Value.ToString()))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Hand.Children.RemoveAt(i);
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void played(object sender, EventArgs args)
|
|
|
|
private void played(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
viewmodel.Alert = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int numStack = 0;
|
|
|
|
int numStack = 0;
|
|
|
|
bool hasFind = false;
|
|
|
|
bool hasFind = false;
|
|
|
|
stacks.ForEach(checkbox =>
|
|
|
|
stacks.ForEach(checkbox =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (checkbox.IsChecked)
|
|
|
|
//if (checkbox.IsChecked)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
hasFind = true;
|
|
|
|
// hasFind = true;
|
|
|
|
if (viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text)))
|
|
|
|
// if (viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text)))
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
botPanel.Children.Add(button);
|
|
|
|
// botPanel.Children.Add(button);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
numStack += 1;
|
|
|
|
numStack += 1;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -241,23 +271,23 @@ namespace TheGameExtreme.view
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void radioButton(object sender, EventArgs args)
|
|
|
|
//private void radioButton(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
if (isFirst)
|
|
|
|
// if (isFirst)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
isFirst = false;
|
|
|
|
// isFirst = false;
|
|
|
|
|
|
|
|
|
|
|
|
stacks.ForEach(checkbox =>
|
|
|
|
// stacks.ForEach(checkbox =>
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
if (!checkbox.Equals(sender))
|
|
|
|
// if (!checkbox.Equals(sender))
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
checkbox.IsChecked = false;
|
|
|
|
// checkbox.IsChecked = false;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
isFirst = true;
|
|
|
|
// isFirst = true;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
private void retry(object sender, EventArgs args)
|
|
|
|
private void retry(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -265,36 +295,35 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
|
|
viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
|
|
|
|
|
|
|
|
Alert.SetBinding(Label.TextProperty, new Binding("Alert", source: viewmodel));
|
|
|
|
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
|
|
|
|
|
|
|
|
inflateHand();
|
|
|
|
inflateHand();
|
|
|
|
|
|
|
|
|
|
|
|
pile0.Text = "1";
|
|
|
|
//pile0.Text = "1";
|
|
|
|
pile1.Text = "1";
|
|
|
|
//pile1.Text = "1";
|
|
|
|
pile2.Text = "100";
|
|
|
|
//pile2.Text = "100";
|
|
|
|
pile3.Text = "100";
|
|
|
|
//pile3.Text = "100";
|
|
|
|
|
|
|
|
|
|
|
|
botPanel.Children.Remove(button);
|
|
|
|
gameOption.Children.Clear();
|
|
|
|
|
|
|
|
gameOption.Children.Add(button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void endTurn(object sender, EventArgs args)
|
|
|
|
private void EndTurn(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
viewmodel.Alert = "";
|
|
|
|
|
|
|
|
if (viewmodel.endTurn())
|
|
|
|
if (viewmodel.endTurn())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
botPanel.Children.Add(button);
|
|
|
|
button = (Button)gameOption.Children[0];
|
|
|
|
|
|
|
|
gameOption.Children.Clear();
|
|
|
|
|
|
|
|
Button retryButton = new Button();
|
|
|
|
|
|
|
|
retryButton.Text = "Retry";
|
|
|
|
|
|
|
|
retryButton.Clicked += retry;
|
|
|
|
|
|
|
|
gameOption.Children.Add(retryButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inflateHand();
|
|
|
|
inflateHand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*private async void Back(object sender, EventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await Navigation.PopToRootAsync();
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void PlayToHome(object sender, EventArgs args)
|
|
|
|
private async void PlayToHome(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|