diff --git a/TheGameExtreme.Android/Resources/Resource.designer.cs b/TheGameExtreme.Android/Resources/Resource.designer.cs index 884c56f..455e66d 100644 --- a/TheGameExtreme.Android/Resources/Resource.designer.cs +++ b/TheGameExtreme.Android/Resources/Resource.designer.cs @@ -1,11 +1,11 @@ #pragma warning disable 1591 //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ diff --git a/TheGameExtreme/AppRessource.Designer.cs b/TheGameExtreme/AppRessource.Designer.cs index 32c99d9..9e97191 100644 --- a/TheGameExtreme/AppRessource.Designer.cs +++ b/TheGameExtreme/AppRessource.Designer.cs @@ -1,44 +1,57 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ namespace TheGameExtreme { using System; - using System.Reflection; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + /// + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class AppRessource { - private static System.Resources.ResourceManager resourceMan; + private static global::System.Resources.ResourceManager resourceMan; - private static System.Globalization.CultureInfo resourceCulture; + private static global::System.Globalization.CultureInfo resourceCulture; - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal AppRessource() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager { + /// + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { get { - if (object.Equals(null, resourceMan)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.AppRessource", typeof(AppRessource).Assembly); + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TheGameExtreme.AppRessource", typeof(AppRessource).Assembly); resourceMan = temp; } return resourceMan; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture { + /// + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -47,66 +60,99 @@ namespace TheGameExtreme { } } + /// + /// Recherche une chaîne localisée semblable à Pile ascendante. + /// internal static string StrAcendingStack { get { return ResourceManager.GetString("StrAcendingStack", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à La pile choisie n'existe pas!. + /// internal static string StrCantGetStack { get { return ResourceManager.GetString("StrCantGetStack", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Vous n'avez pas joué assez de carte! essaye encore. + /// internal static string StrCardPlayedLessThanTwo { get { return ResourceManager.GetString("StrCardPlayedLessThanTwo", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Veuillez selectionner une carte à placer sur une pile. + /// internal static string StrChooseCardToPlay { get { return ResourceManager.GetString("StrChooseCardToPlay", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Selectionner la pile sur laquelle vous souhaitez poser la carte. + /// internal static string StrChooseStack { get { return ResourceManager.GetString("StrChooseStack", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Pile Descendante. + /// internal static string StrDownStack { get { return ResourceManager.GetString("StrDownStack", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Le jeu est fini! Veuillez lancer une nouvelle partie!. + /// internal static string StrEndOfGame { get { return ResourceManager.GetString("StrEndOfGame", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Fin de tour. + /// internal static string StrEndTurn { get { return ResourceManager.GetString("StrEndTurn", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Le jeu est terminé! Désolé, vous avez perdu... Essayez encore!. + /// internal static string StrLose { get { return ResourceManager.GetString("StrLose", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Le jeu est terminé! Désolé, vous avez perdu... Vous deviez jouer trois cartes à cause de l'effet \"Trois cartes joué\" hors votre jeu ne permet pas d'en jouer autant! Essayez encore!. + /// internal static string StrLose3CardEffect { get { return ResourceManager.GetString("StrLose3CardEffect", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à Le joueur n'a plus de carte dans sa main. + /// internal static string StrNoMoreCardOnHand { get { return ResourceManager.GetString("StrNoMoreCardOnHand", resourceCulture); @@ -114,17 +160,28 @@ namespace TheGameExtreme { } /// - /// Recherche une chaîne localisée semblable à -L'objectif est de battre le jeu ! + /// Recherche une chaîne localisée semblable à Veuillez choisir un nombre de joueur et leur(s) nom(s). + /// + internal static string StrPlayerSelection { + get { + return ResourceManager.GetString("StrPlayerSelection", resourceCulture); + } + } + + /// + /// Recherche une chaîne localisée semblable à -L'objectif est de battre le jeu ! Seul ou à plusieurs ! /// - ///-99 cartes numérotés de 2 à 99. + ///-98 cartes numérotés de 2 à 99. /// ///-4 piles sont à votre disposition, deux ascendantes et deux descendantes. /// ///-L'objectif est de pourvoir poser toute les cartes de la pioches sur les différentes piles à votre disposition. /// - ///-Si vous arrivé a vider toute la pioche et de poser tout les cartes sur les piles, vous gagné, sinon vous perdez. + ///-Si vous arrivez à vider toute la pioche et de poser tout les cartes sur les piles, vous gagnez, sinon vous perdez. /// - ///-Quelques suprise pourrait aussi vous surprendre.. + ///-Chaque joueur doit jouer au minimum deux cartes par tour. + /// + ///-Sur une pile ascendante, il est possible de [le reste de la chaîne a été tronqué]";. /// internal static string StrRules { get { @@ -141,22 +198,22 @@ namespace TheGameExtreme { } } + /// + /// Recherche une chaîne localisée semblable à Le jeu est terminé!\n Bravo vous avez gagné!. + /// internal static string StrWin { get { return ResourceManager.GetString("StrWin", resourceCulture); } } + /// + /// Recherche une chaîne localisée semblable à La carte ne rentre pas dans la pile sectionnée!. + /// internal static string StrWrongStack { get { return ResourceManager.GetString("StrWrongStack", resourceCulture); } } - - internal static string StrPlayerSelection { - get { - return ResourceManager.GetString("StrPlayerSelection", resourceCulture); - } - } } } diff --git a/TheGameExtreme/AppRessource.resx b/TheGameExtreme/AppRessource.resx index 662a6a5..4eb7186 100644 --- a/TheGameExtreme/AppRessource.resx +++ b/TheGameExtreme/AppRessource.resx @@ -156,17 +156,23 @@ Le joueur n'a plus de carte dans sa main - -L'objectif est de battre le jeu ! + -L'objectif est de battre le jeu ! Seul ou à plusieurs ! --99 cartes numérotés de 2 à 99. +-98 cartes numérotés de 2 à 99. -4 piles sont à votre disposition, deux ascendantes et deux descendantes. -L'objectif est de pourvoir poser toute les cartes de la pioches sur les différentes piles à votre disposition. --Si vous arrivé a vider toute la pioche et de poser tout les cartes sur les piles, vous gagné, sinon vous perdez. +-Si vous arrivez à vider toute la pioche et de poser tout les cartes sur les piles, vous gagnez, sinon vous perdez. --Quelques suprise pourrait aussi vous surprendre. +-Chaque joueur doit jouer au minimum deux cartes par tour. + +-Sur une pile ascendante, il est possible de reculer de 10 (ex : 73 est joué -> possibilité de jouer au dessus de 73 ou bien 63). + +-Sur une pile descendante, il est possible de reculer de 10 (ex : 73 est joué -> possibilité de jouer en dessous de 73 ou bien 83). + +-La cohésion et la stratégie seront deux amis important pour venir à bout de The Game. Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;) diff --git a/TheGameExtreme/TheGameExtreme.csproj b/TheGameExtreme/TheGameExtreme.csproj index b46f374..48cc94d 100644 --- a/TheGameExtreme/TheGameExtreme.csproj +++ b/TheGameExtreme/TheGameExtreme.csproj @@ -6,6 +6,7 @@ + diff --git a/TheGameExtreme/view/App.xaml b/TheGameExtreme/view/App.xaml index 2dea446..3d463ec 100644 --- a/TheGameExtreme/view/App.xaml +++ b/TheGameExtreme/view/App.xaml @@ -5,7 +5,7 @@ black white - SkyBlue + SkyBlue diff --git a/TheGameExtreme/view/GamePreparationPage.xaml.cs b/TheGameExtreme/view/GamePreparationPage.xaml.cs index 7235f22..f2c4ed1 100644 --- a/TheGameExtreme/view/GamePreparationPage.xaml.cs +++ b/TheGameExtreme/view/GamePreparationPage.xaml.cs @@ -45,7 +45,7 @@ namespace TheGameExtreme.view playersNames.Add(((Entry)NameList.Children[i]).Text); if (string.IsNullOrWhiteSpace(playersNames[playersNames.Count - 1])) { - DisplayAlert("Erreur Pseudo", "Veuillez remplir tous les pseudos", "OK"); + await DisplayAlert("Erreur Pseudo", "Veuillez remplir tous les pseudos", "OK"); return; } } diff --git a/TheGameExtreme/view/MainPage.xaml.cs b/TheGameExtreme/view/MainPage.xaml.cs index 7ad3bac..7d8af20 100644 --- a/TheGameExtreme/view/MainPage.xaml.cs +++ b/TheGameExtreme/view/MainPage.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using Xamarin.Forms; @@ -77,7 +77,7 @@ namespace TheGameExtreme.view pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel)); - inflateHand(); + InflateHand(); } @@ -101,6 +101,8 @@ namespace TheGameExtreme.view foreach (TouchManipulationBitmap bitmap in bitmapCollection) { bitmap.Paint(canvas); + + } } @@ -162,6 +164,7 @@ namespace TheGameExtreme.view { Picker picker = (Picker)sender; bitmap.TouchManager.Mode = (TouchManipulationMode)picker.SelectedItem; + } } @@ -178,7 +181,7 @@ namespace TheGameExtreme.view // inflateHand(); //} - private void inflateHand() + private void InflateHand() { //Hand.Children.Clear(); //for (int i = 0; i < viewmodel.CurrentHand.Count; i++) diff --git a/TheGameExtreme/view/MainPage.xaml.cs.orig b/TheGameExtreme/view/MainPage.xaml.cs.orig new file mode 100644 index 0000000..e2deb12 --- /dev/null +++ b/TheGameExtreme/view/MainPage.xaml.cs.orig @@ -0,0 +1,343 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Xamarin.Forms; +using TheGameExtreme.model.@event; +using TheGameExtreme.viewmodel; +using SkiaSharp; +using System.IO; +using System.Reflection; +using SkiaSharp.Views.Forms; +using TouchTracking; +using Xamarin.Essentials; + +namespace TheGameExtreme.view +{ + // Learn more about making custom code visible in the Xamarin.Forms previewer + // by visiting https://aka.ms/xamarinforms-previewer + [DesignTimeVisible(false)] + public partial class MainPage : ContentPage + { + private bool isFirst = true; + private Main viewmodel; + private List stacks = new List(); + Button button; + List playersNames; + + + TouchManipulationBitmap bitmap; + List bitmapCollection = new List(); + Dictionary bitmapDictionary = new Dictionary(); + + + + public MainPage(List playersNames) + { + this.playersNames = playersNames; + + InitializeComponent(); + NavigationPage.SetHasNavigationBar(this, false); + + //Assembly assembly = GetType().GetTypeInfo().Assembly; + + ////string[] resourceIDs = assembly.GetManifestResourceNames(); + //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 < 8; 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; + // } + //} + + + //stacks.Add(checkbox0); + //stacks.Add(checkbox1); + //stacks.Add(checkbox2); + //stacks.Add(checkbox3); + //button.Text = "Retry"; + //button.Clicked += retry; + + viewmodel = new Main(playersNames); + + //viewmodel.BindingChanged += OnBindingChanged; + + //viewmodel.PlayerChanged += OnPlayerChanged; + + viewmodel.AlertChanged += OnAlertChanged; + + pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel)); + + InflateHand(); + } + + + private void OnAlertChanged(object sender, EventArgs args) + { + if (viewmodel.Alert != null) + { + DisplayAlert("", viewmodel.Alert, "OK"); + viewmodel.Alert = null; + } + } + + + + public void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) // Faire plusieurs canvas + { + + SKCanvas canvas = args.Surface.Canvas; + canvas.Clear(); + + foreach (TouchManipulationBitmap bitmap in bitmapCollection) + { + bitmap.Paint(canvas); + + + } + } + + public void OnTouchEffectAction(object sender, TouchActionEventArgs args) + { + // Convert Xamarin.Forms point to pixels + TouchTrackingPoint pt = args.Location; + SKPoint point = + new SKPoint((float)(canvasView.CanvasSize.Width * pt.X / canvasView.Width), + (float)(canvasView.CanvasSize.Height * pt.Y / canvasView.Height)); + + switch (args.Type) + { + case TouchActionType.Pressed: + for (int i = bitmapCollection.Count - 1; i >= 0; i--) + { + TouchManipulationBitmap bitmap = bitmapCollection[i]; + + if (bitmap.HitTest(point)) + { + // Move bitmap to end of collection + bitmapCollection.Remove(bitmap); + bitmapCollection.Add(bitmap); + + // Do the touch processing + bitmapDictionary.Add(args.Id, bitmap); + bitmap.ProcessTouchEvent(args.Id, args.Type, point); + canvasView.InvalidateSurface(); + break; + } + } + break; + + case TouchActionType.Moved: + if (bitmapDictionary.ContainsKey(args.Id)) + { + TouchManipulationBitmap bitmap = bitmapDictionary[args.Id]; + bitmap.ProcessTouchEvent(args.Id, args.Type, point); + canvasView.InvalidateSurface(); + } + break; + + case TouchActionType.Released: + case TouchActionType.Cancelled: + if (bitmapDictionary.ContainsKey(args.Id)) + { + TouchManipulationBitmap bitmap = bitmapDictionary[args.Id]; + bitmap.ProcessTouchEvent(args.Id, args.Type, point); + bitmapDictionary.Remove(args.Id); + canvasView.InvalidateSurface(); + } + break; + } + } + + public void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args) + { + if (bitmap != null) + { + Picker picker = (Picker)sender; + bitmap.TouchManager.Mode = (TouchManipulationMode)picker.SelectedItem; + + } + } + + + + + + + + + +<<<<<<< HEAD + //private void OnPlayerChanged(object sender, PlayerChangedEventArgs args) + //{ + // inflateHand(); + //} +======= + private void OnPlayerChanged(object sender, PlayerChangedEventArgs args) + { + InflateHand(); + } +>>>>>>> 63f000719bc49139482f85661607797f88afe093 + + private void InflateHand() + { + //Hand.Children.Clear(); + //for (int i = 0; i < viewmodel.CurrentHand.Count; i++) + //{ + // Button card = new Button(); + // card.Text = viewmodel.CurrentHand[i].Value.ToString(); + // card.Clicked += played; + // Hand.Children.Add(card); + //} + + + 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) + { + + + + + + //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())) + // { + // Hand.Children.RemoveAt(i); + // break; + // } + //} + } + + private void played(object sender, EventArgs args) + { + int numStack = 0; + bool hasFind = false; + stacks.ForEach(checkbox => + { + //if (checkbox.IsChecked) + //{ + // hasFind = true; + // if (viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text))) + // { + // botPanel.Children.Add(button); + // } + //} + numStack += 1; + }); + + if (!hasFind) + { + viewmodel.Alert = "Aucune pile selectionné! Veuillez séléctionner une pile."; + return; + } + } + + //private void radioButton(object sender, EventArgs args) + //{ + // if (isFirst) + // { + // isFirst = false; + + // stacks.ForEach(checkbox => + // { + // if (!checkbox.Equals(sender)) + // { + // checkbox.IsChecked = false; + // } + // }); + + // isFirst = true; + // } + //} + + private void retry(object sender, EventArgs args) + { + viewmodel = new Main(playersNames); + + viewmodel.BindingChanged += OnBindingChanged; + + pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel)); + + inflateHand(); + + //pile0.Text = "1"; + //pile1.Text = "1"; + //pile2.Text = "100"; + //pile3.Text = "100"; + + gameOption.Children.Clear(); + gameOption.Children.Add(button); + } + + private void EndTurn(object sender, EventArgs args) + { + if (viewmodel.endTurn()) + { + button = (Button)gameOption.Children[0]; + gameOption.Children.Clear(); + Button retryButton = new Button(); + retryButton.Text = "Retry"; + retryButton.Clicked += retry; + gameOption.Children.Add(retryButton); + } + else + { + inflateHand(); + } + } + + private async void PlayToHome(object sender, EventArgs args) + { + await Navigation.PopToRootAsync(); + } + } +} diff --git a/TheGameExtreme/viewmodel/CardVM.cs b/TheGameExtreme/viewmodel/CardVM.cs index a18952d..9f4adac 100644 --- a/TheGameExtreme/viewmodel/CardVM.cs +++ b/TheGameExtreme/viewmodel/CardVM.cs @@ -1,6 +1,9 @@ using System; using System.ComponentModel; using TheGameExtreme.model.card; +using SkiaSharp; +using System.Drawing; +using System.Drawing.Drawing2D; namespace TheGameExtreme.viewmodel { @@ -10,6 +13,7 @@ namespace TheGameExtreme.viewmodel public event PropertyChangedEventHandler PropertyChanged; public Card View { get; set; } protected string image; + public string Image { get { return image; } @@ -20,6 +24,8 @@ namespace TheGameExtreme.viewmodel } } protected int value; + private Image bmp; + public int Value { get { return value; } set @@ -33,11 +39,30 @@ namespace TheGameExtreme.viewmodel PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info)); } + + public CardVM(Card view) { View = view; - Value = view.Value; + + /*SKBitmap bit = new SKBitmap(); + RectangleF rectangle = new RectangleF(50, 90, 90, 50); + + Graphics g = Graphics.FromImage(bmp); + + g.SmoothingMode = SmoothingMode.AntiAlias; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + g.DrawString("yourText", new Font("Tahoma", 8), Brushes.Black, rectangle); + + g.Flush();*/ + + + } + + + } }