Merge branch 'master' of gitlab.iut-clermont.uca.fr:cldupland/thegameextreme

master
Baptiste ARNAUD 5 years ago
commit d6ff7f9692

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.uca.thegameextreme" android:installLocation="auto"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="3.0" package="com.uca.thegameextreme" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" /> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="TheGameExtreme.Android" android:icon="@drawable/TrierImageB"></application> <application android:label="TheGameExtreme.Android" android:icon="@drawable/TrierImageB"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

@ -1,11 +1,11 @@
#pragma warning disable 1591 #pragma warning disable 1591
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Ce code a été généré par un outil. // This code was generated by a tool.
// Version du runtime :4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si // Changes to this file may cause incorrect behavior and will be lost if
// le code est régénéré. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -42,7 +42,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<MandroidI18n /> <MandroidI18n />
<AndroidSupportedAbis /> <AndroidSupportedAbis />

@ -36,6 +36,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch> <MtouchArch>x86_64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

@ -8,9 +8,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme.iOS", "TheGa
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}" Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProjectGame", "UnitTestProjectGame\UnitTestProjectGame.csproj", "{4092C852-D253-42F7-A800-E618C99C349E}" Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "UnitTestProjectGame", "UnitTestProjectGame\UnitTestProjectGame.csproj", "{AAEDA45E-5C40-47DA-AD1F-735DFE845904}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -59,30 +59,30 @@ Global
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.Build.0 = Release|Any CPU {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.Build.0 = Release|Any CPU
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.Build.0 = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhone.ActiveCfg = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhone.Build.0 = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|iPhone.Build.0 = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.Build.0 = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|Any CPU.Build.0 = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.ActiveCfg = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|iPhone.ActiveCfg = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.Build.0 = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|iPhone.Build.0 = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {783EEFEF-AD6C-48B9-89AA-D81B2E7906E0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|Any CPU.Build.0 = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhone.ActiveCfg = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhone.Build.0 = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|iPhone.Build.0 = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|Any CPU.ActiveCfg = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|Any CPU.Build.0 = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|Any CPU.Build.0 = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhone.ActiveCfg = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|iPhone.ActiveCfg = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhone.Build.0 = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|iPhone.Build.0 = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {AAEDA45E-5C40-47DA-AD1F-735DFE845904}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -188,7 +188,10 @@
<value>Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;)</value> <value>Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;)</value>
</data> </data>
<data name="StrWin" xml:space="preserve"> <data name="StrWin" xml:space="preserve">
<value>Le jeu est terminé!\n Bravo vous avez gagné!</value> <value>
Le jeu est terminé!
Bravo vous avez gagné!
</value>
</data> </data>
<data name="StrWrongStack" xml:space="preserve"> <data name="StrWrongStack" xml:space="preserve">
<value>La carte ne rentre pas dans la pile sectionnée!</value> <value>La carte ne rentre pas dans la pile sectionnée!</value>

@ -3,10 +3,8 @@ using System.ComponentModel;
namespace TheGameExtreme.model.card namespace TheGameExtreme.model.card
{ {
public abstract class Card // : INotifyPropertyChanged public abstract class Card
{ {
//public event PropertyChangedEventHandler PropertyChanged;
private decimal value; private decimal value;
public decimal Value public decimal Value
{ {
@ -14,20 +12,19 @@ namespace TheGameExtreme.model.card
set set
{ {
this.value = value; this.value = value;
//OnPropertyChange("Value");
} }
} }
//private void OnPropertyChange(string v)
//{
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(v));
//}
public Card(decimal value) public Card(decimal value)
{ {
Value = value; Value = value;
} }
public override string ToString()
{
return Value.ToString();
}
public abstract String getName(); public abstract String getName();
public abstract bool rapidEffect(); public abstract bool rapidEffect();

@ -0,0 +1,30 @@
using System;
namespace TheGameExtreme.model.card.cardType
{
public class FractionCard : Card
{
public static readonly String CARD_FRACTION = "FractionCard";
private Fraction fraction;
public FractionCard(Fraction value) : base(value.Result())
{
fraction = value;
}
public override bool rapidEffect()
{
return false;
}
override public String getName()
{
return CARD_FRACTION;
}
public override string ToString()
{
return fraction.ToString();
}
}
}

@ -0,0 +1,61 @@

using System;
namespace TheGameExtreme.model
{
public class Fraction
{
public int Numerateur;
public int Denominateur;
public Fraction(int numerateur, int denominateur)
{
Numerateur = numerateur;
Denominateur = denominateur;
}
//public int CompareTo(Fraction fraction)
//{
// decimal d = (Numerateur / Denominateur) - (fraction.Numerateur / fraction.Denominateur);
// if (d > 0)
// {
// return 1;
// }
// else if (d < 0)
// {
// return -1;
// }
// else
// {
// return 0;
// }
//}
public bool testDiviseurCommun(Fraction fraction)
{
if (PGCD(Numerateur, fraction.Numerateur) == Numerateur || PGCD(Denominateur, fraction.Denominateur) == Denominateur)
{
return true;
}
return false;
}
private int PGCD(int a, int b)
{
int temp = a % b;
if (temp == 0)
return b;
return PGCD(b, temp);
}
public decimal Result()
{
decimal result = (decimal)Numerateur / (decimal)Denominateur;
return result;
}
override public string ToString()
{
return Numerateur.ToString() + "/" + Denominateur.ToString();
}
}
}

@ -0,0 +1,37 @@
using System;
using TheGameExtreme.model.card.cardType;
namespace TheGameExtreme.model.deck
{
public class FractionDeck : Deck
{
public FractionDeck()
{
Random random = new Random();
for (int i = 1; i < 100; i ++)
{
int entier = random.Next(0, 100);
int deci = random.Next(0,100);
decimal d = (decimal)entier + (decimal)deci * 0.001m;
int numerateur = (int)(d * 1000m);
int denominateur = 1000;
int pgcd = PGCD(numerateur, denominateur);
while (pgcd != 1)
{
numerateur = numerateur / pgcd;
denominateur = denominateur / pgcd;
pgcd = PGCD(numerateur, denominateur);
}
deck.Add(new FractionCard(new Fraction(numerateur, denominateur)));
}
}
private int PGCD(int a, int b)
{
int temp = a % b;
if (temp == 0)
return b;
return PGCD(b, temp);
}
}
}

@ -0,0 +1,23 @@
using System;
using TheGameExtreme.model.card.cardType;
namespace TheGameExtreme.model.piles
{
public class FractionPiles : Piles
{
public FractionPiles(int nbPile) : base(nbPile)
{
for (int i = 0; i < nbPile; i++)
{
if (i < (nbPile * 0.5))
{
ListOrderedStacks[i].Push(new ClassicCard(0));
}
else
{
ListOrderedStacks[i].Push(new ClassicCard(100));
}
}
}
}
}

@ -8,7 +8,7 @@ namespace TheGameExtreme.view
public partial class GamePreparationPage : ContentPage public partial class GamePreparationPage : ContentPage
{ {
public List<int> listNbPlayer = new List<int> { 1, 2, 3, 4, 5 }; public List<int> listNbPlayer = new List<int> { 1, 2, 3, 4, 5 };
public List<string> listGameMode = new List<string> { "entières", "relatives", "décimales", "dizaines", "centaines", "millièmes" }; // , "fractionnées" public List<string> listGameMode = new List<string> { "entières", "relatives", "décimales", "dizaines", "centaines", "millièmes", "fractionnées" };
public List<int> listNbStack = new List<int> { 4, 6, 8 }; public List<int> listNbStack = new List<int> { 4, 6, 8 };

@ -68,10 +68,6 @@
HeightRequest="45" HeightRequest="45"
BackgroundColor="{DynamicResource BlackColor}" BackgroundColor="{DynamicResource BlackColor}"
Clicked="PlayToHome"/> Clicked="PlayToHome"/>
<Label Text="↑" TextColor="White"
FontSize="64"
Grid.Column="0" Grid.Row="1" Margin="120,0,0,10"/>
</StackLayout> </StackLayout>
@ -88,9 +84,6 @@
BackgroundColor="{DynamicResource SkyBlueColor}" BackgroundColor="{DynamicResource SkyBlueColor}"
HeightRequest="35" HeightRequest="35"
Clicked="EndTurn"/> Clicked="EndTurn"/>
<Label Text="↓" TextColor="White"
FontSize="64" Grid.Column="2" Grid.Row="1" Margin="0,0,120,10"/>
</StackLayout> </StackLayout>

@ -122,6 +122,8 @@ namespace TheGameExtreme.view
if (textDictionary.ContainsKey(args.Id)) if (textDictionary.ContainsKey(args.Id))
{ {
TouchManipulationBitmap bitmap = textDictionary[args.Id]; TouchManipulationBitmap bitmap = textDictionary[args.Id];
point.Y -= 120;
point.X -= 50;
bitmap.ProcessTouchEvent(args.Id, args.Type, point); bitmap.ProcessTouchEvent(args.Id, args.Type, point);
canvasView.InvalidateSurface(); canvasView.InvalidateSurface();
} }
@ -137,10 +139,11 @@ namespace TheGameExtreme.view
bool find = false; bool find = false;
foreach (TouchManipulationBitmap stack in stackCollection) foreach (TouchManipulationBitmap stack in stackCollection)
{ {
if (stack.HitTest(point)) SKPoint pointVisuCard = new SKPoint(point.X, point.Y - 120);
if (stack.HitTest(point) || stack.HitTest(pointVisuCard))
{ {
int indexPile = stackCollection.IndexOf(stack); int indexPile = stackCollection.IndexOf(stack);
if (played(indexPile, decimal.Parse(bitmap.Value))) if (played(indexPile, bitmap.Value.Value))
{ {
bitmap.ProcessTouchEvent(args.Id, TouchActionType.Moved, stack.InitialPoint); bitmap.ProcessTouchEvent(args.Id, TouchActionType.Moved, stack.InitialPoint);
bitmap.InitialPoint = stackCollection[stackCollection.IndexOf(stack)].InitialPoint; bitmap.InitialPoint = stackCollection[stackCollection.IndexOf(stack)].InitialPoint;
@ -180,16 +183,17 @@ namespace TheGameExtreme.view
SKPaint textPaint = new SKPaint(); SKPaint textPaint = new SKPaint();
float textWidth = textPaint.MeasureText("001"); float textWidth = textPaint.MeasureText("001");
float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth; float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.getListOrderedStacks().Count * 2)) - textPaint.MeasureText("01"), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01 + 2 * textSize)); SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.getListOrderedStacks().Count * 2)) - textPaint.MeasureText("01") * 0.5f, (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01 + 2 * textSize));
for (int i = 0; i < viewmodel.getListOrderedStacks().Count; i++) for (int i = 0; i < viewmodel.getListOrderedStacks().Count; i++)
{ {
textPaint = new SKPaint(); textPaint = new SKPaint();
textPaint.TextSize = textSize; textPaint.TextSize = textSize;
stackCollection.Add(new TouchManipulationBitmap(textPaint, viewmodel.getListOrderedStacks()[i].Peek().Value) stackCollection.Add(new TouchManipulationBitmap(textPaint, viewmodel.getListOrderedStacks()[i].Peek())
{ {
Matrix = SKMatrix.MakeTranslation(position.X, position.Y), Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialMatrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialPoint = position InitialPoint = position
}); });
@ -202,7 +206,7 @@ namespace TheGameExtreme.view
SKPaint textPaint = new SKPaint(); SKPaint textPaint = new SKPaint();
float textWidth = textPaint.MeasureText("001"); float textWidth = textPaint.MeasureText("001");
float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth; float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.CurrentHand.Count * 2)) - textPaint.MeasureText("01"), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.2 - textSize)); SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.CurrentHand.Count * 2)) - textPaint.MeasureText("01") * 0.5f + (float)(DeviceDisplay.MainDisplayInfo.Width * 0.01), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.1 - 2 * textSize));
for (int i = 0; i < viewmodel.CurrentHand.Count; i++) for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
{ {
@ -210,9 +214,10 @@ namespace TheGameExtreme.view
textPaint.TextSize = textSize; textPaint.TextSize = textSize;
position.X -= (float)(textWidth * 0.5); position.X -= (float)(textWidth * 0.5);
textCollection.Add(new TouchManipulationBitmap(textPaint, viewmodel.CurrentHand[i].Value) textCollection.Add(new TouchManipulationBitmap(textPaint, viewmodel.CurrentHand[i])
{ {
Matrix = SKMatrix.MakeTranslation(position.X, position.Y), Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialMatrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialPoint = position InitialPoint = position
}); });

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using SkiaSharp; using SkiaSharp;
using TheGameExtreme.viewmodel;
using TouchTracking; using TouchTracking;
using Xamarin.Essentials;
namespace TheGameExtreme.view namespace TheGameExtreme.view
{ {
@ -10,37 +12,40 @@ namespace TheGameExtreme.view
public SKPoint InitialPoint { get; set; } public SKPoint InitialPoint { get; set; }
SKPaint textPaint; SKPaint textPaint;
Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>(); Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>();
public string Value; public CardVM Value;
public string display;
private float width = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width;
private float height = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width * 3f;
public TouchManipulationBitmap(SKPaint textPaint, decimal value) public TouchManipulationBitmap(SKPaint textPaint, CardVM value)
{ {
this.textPaint = textPaint; this.textPaint = textPaint;
Value = value.ToString(); Value = value;
if (value < 0 && value > -10) display = Value.ToString();
if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/"))
{ {
Value = "-0" + Math.Abs(value).ToString(); if (decimal.Parse(display) < 0 && decimal.Parse(display) > -10)
}
else if (value >= 0 && value < 10 && !(value > 0 && value < 1))
{ {
Value = "0" + value.ToString(); display = "-0" + Math.Abs(decimal.Parse(display)).ToString();
} }
else else if (decimal.Parse(display) >= 0 && decimal.Parse(display) < 10)
{ {
Value = value.ToString(); display = "0" + display;
}
} }
Matrix = SKMatrix.MakeIdentity(); Matrix = SKMatrix.MakeIdentity();
TouchManager = new TouchManipulationManager Mode = TouchManipulationMode.PanOnly;
{
Mode = TouchManipulationMode.PanOnly
};
} }
public TouchManipulationManager TouchManager { set; get; } public TouchManipulationMode Mode { set; get; }
public SKMatrix Matrix { set; get; } public SKMatrix Matrix { set; get; }
public SKMatrix InitialMatrix { set; get; }
public void Paint(SKCanvas canvas, SKColor color) public void Paint(SKCanvas canvas, SKColor color)
{ {
canvas.Save(); canvas.Save();
@ -53,14 +58,13 @@ namespace TheGameExtreme.view
textPaint.Style = SKPaintStyle.Stroke; textPaint.Style = SKPaintStyle.Stroke;
SKRect textBounds = new SKRect(); SKRect textBounds = new SKRect();
textPaint.MeasureText(Value, ref textBounds); textPaint.MeasureText(display, ref textBounds);
SKRoundRect card = new SKRoundRect(textBounds, 1f, 1f); SKRoundRect card = new SKRoundRect(textBounds, 1f, 1f);
card.Inflate(35, 55); card.Inflate(width, height);
canvas.DrawRoundRect(card, textPaint); canvas.DrawRoundRect(card, textPaint);
canvas.DrawText(Value, 0, 0, textPaint); canvas.DrawText(display, 0, 0, textPaint);
canvas.Restore(); canvas.Restore();
@ -82,7 +86,7 @@ namespace TheGameExtreme.view
SKPoint transformedPoint = inverseMatrix.MapPoint(location); SKPoint transformedPoint = inverseMatrix.MapPoint(location);
// Check if it's in the untransformed bitmap rectangle // Check if it's in the untransformed bitmap rectangle
SKRect rect = new SKRect(-70, -110, textPaint.MeasureText(Value) + 35, textPaint.TextSize); SKRect rect = new SKRect(-70, -110, textPaint.MeasureText(display) + 35, textPaint.TextSize);
return rect.Contains(transformedPoint); return rect.Contains(transformedPoint);
} }
return false; return false;
@ -119,29 +123,11 @@ namespace TheGameExtreme.view
{ {
TouchManipulationInfo[] infos = new TouchManipulationInfo[touchDictionary.Count]; TouchManipulationInfo[] infos = new TouchManipulationInfo[touchDictionary.Count];
touchDictionary.Values.CopyTo(infos, 0); touchDictionary.Values.CopyTo(infos, 0);
SKMatrix touchMatrix = SKMatrix.MakeIdentity();
if (infos.Length == 1) if (Mode == TouchManipulationMode.PanOnly)
{ {
SKPoint prevPoint = infos[0].PreviousPoint; Matrix = SKMatrix.MakeTranslation(infos[0].NewPoint.X, infos[0].NewPoint.Y);
SKPoint newPoint = infos[0].NewPoint;
SKPoint pivotPoint = Matrix.MapPoint(textPaint.MeasureText(Value) / 2, textPaint.TextSize / 2);
touchMatrix = TouchManager.OneFingerManipulate(prevPoint, newPoint, pivotPoint);
} }
//else if (infos.Length >= 2)
//{
// int pivotIndex = infos[0].NewPoint == infos[0].PreviousPoint ? 0 : 1;
// SKPoint pivotPoint = infos[pivotIndex].NewPoint;
// SKPoint newPoint = infos[1 - pivotIndex].NewPoint;
// SKPoint prevPoint = infos[1 - pivotIndex].PreviousPoint;
// touchMatrix = TouchManager.TwoFingerManipulate(prevPoint, newPoint, pivotPoint);
//}
SKMatrix matrix = Matrix;
SKMatrix.PostConcat(ref matrix, touchMatrix);
Matrix = matrix;
} }
} }
} }

@ -1,107 +1,107 @@
using System; //using System;
using SkiaSharp; //using SkiaSharp;
namespace TheGameExtreme.view //namespace TheGameExtreme.view
{ //{
public class TouchManipulationManager // public class TouchManipulationManager
{
public TouchManipulationMode Mode { set; get; }
//float Magnitude(SKPoint point)
// { // {
// return (float)Math.Sqrt(Math.Pow(point.X, 2) + Math.Pow(point.Y, 2));
//}
public SKMatrix OneFingerManipulate(SKPoint prevPoint, SKPoint newPoint, SKPoint pivotPoint) // public TouchManipulationMode Mode { set; get; }
{
if (Mode == TouchManipulationMode.None)
{
return SKMatrix.MakeIdentity();
}
SKMatrix touchMatrix = SKMatrix.MakeIdentity(); // //float Magnitude(SKPoint point)
SKPoint delta = newPoint - prevPoint; // //{
// // return (float)Math.Sqrt(Math.Pow(point.X, 2) + Math.Pow(point.Y, 2));
// //}
//if (Mode == TouchManipulationMode.ScaleDualRotate) // One-finger rotation // public SKMatrix OneFingerManipulate(SKPoint prevPoint, SKPoint newPoint, SKPoint pivotPoint)
// { // {
// SKPoint oldVector = prevPoint - pivotPoint; // if (Mode == TouchManipulationMode.None)
// SKPoint newVector = newPoint - pivotPoint;
// // Avoid rotation if fingers are too close to center
// if (Magnitude(newVector) > 25 && Magnitude(oldVector) > 25)
// { // {
// float prevAngle = (float)Math.Atan2(oldVector.Y, oldVector.X); // return SKMatrix.MakeIdentity();
// float newAngle = (float)Math.Atan2(newVector.Y, newVector.X); // }
// // Calculate rotation matrix // SKMatrix touchMatrix = SKMatrix.MakeIdentity();
// float angle = newAngle - prevAngle; // SKPoint delta = newPoint - prevPoint;
// touchMatrix = SKMatrix.MakeRotation(angle, pivotPoint.X, pivotPoint.Y);
// // Effectively rotate the old vector // //if (Mode == TouchManipulationMode.ScaleDualRotate) // One-finger rotation
// float magnitudeRatio = Magnitude(oldVector) / Magnitude(newVector); // //{
// oldVector.X = magnitudeRatio * newVector.X; // // SKPoint oldVector = prevPoint - pivotPoint;
// oldVector.Y = magnitudeRatio * newVector.Y; // // SKPoint newVector = newPoint - pivotPoint;
// // Recalculate delta // // // Avoid rotation if fingers are too close to center
// delta = newVector - oldVector; // // if (Magnitude(newVector) > 25 && Magnitude(oldVector) > 25)
// } // // {
//} // // float prevAngle = (float)Math.Atan2(oldVector.Y, oldVector.X);
// // float newAngle = (float)Math.Atan2(newVector.Y, newVector.X);
// Multiply the rotation matrix by a translation matrix // // // Calculate rotation matrix
SKMatrix.PostConcat(ref touchMatrix, SKMatrix.MakeTranslation(delta.X, delta.Y)); // // float angle = newAngle - prevAngle;
// // touchMatrix = SKMatrix.MakeRotation(angle, pivotPoint.X, pivotPoint.Y);
return touchMatrix; // // // Effectively rotate the old vector
} // // float magnitudeRatio = Magnitude(oldVector) / Magnitude(newVector);
// // oldVector.X = magnitudeRatio * newVector.X;
// // oldVector.Y = magnitudeRatio * newVector.Y;
public SKMatrix TwoFingerManipulate(SKPoint prevPoint, SKPoint newPoint, SKPoint pivotPoint) // // // Recalculate delta
{ // // delta = newVector - oldVector;
SKMatrix touchMatrix = SKMatrix.MakeIdentity(); // // }
//SKPoint oldVector = prevPoint - pivotPoint; // //}
//SKPoint newVector = newPoint - pivotPoint;
//if (Mode == TouchManipulationMode.ScaleRotate || // // Multiply the rotation matrix by a translation matrix
// Mode == TouchManipulationMode.ScaleDualRotate) // SKMatrix.PostConcat(ref touchMatrix, SKMatrix.MakeTranslation(delta.X, delta.Y));
//{
// // Find angles from pivot point to touch points
// float oldAngle = (float)Math.Atan2(oldVector.Y, oldVector.X);
// float newAngle = (float)Math.Atan2(newVector.Y, newVector.X);
// // Calculate rotation matrix
// float angle = newAngle - oldAngle;
// touchMatrix = SKMatrix.MakeRotation(angle, pivotPoint.X, pivotPoint.Y);
// // Effectively rotate the old vector
// float magnitudeRatio = Magnitude(oldVector) / Magnitude(newVector);
// oldVector.X = magnitudeRatio * newVector.X;
// oldVector.Y = magnitudeRatio * newVector.Y;
//}
float scaleX = 1; // return touchMatrix;
float scaleY = 1; // }
//if (Mode == TouchManipulationMode.AnisotropicScale) // public SKMatrix TwoFingerManipulate(SKPoint prevPoint, SKPoint newPoint, SKPoint pivotPoint)
// { // {
// scaleX = newVector.X / oldVector.X; // SKMatrix touchMatrix = SKMatrix.MakeIdentity();
// scaleY = newVector.Y / oldVector.Y; // //SKPoint oldVector = prevPoint - pivotPoint;
// //SKPoint newVector = newPoint - pivotPoint;
//}
//else if (Mode == TouchManipulationMode.IsotropicScale || // //if (Mode == TouchManipulationMode.ScaleRotate ||
// Mode == TouchManipulationMode.ScaleRotate || // // Mode == TouchManipulationMode.ScaleDualRotate)
// Mode == TouchManipulationMode.ScaleDualRotate) // //{
// // // Find angles from pivot point to touch points
// // float oldAngle = (float)Math.Atan2(oldVector.Y, oldVector.X);
// // float newAngle = (float)Math.Atan2(newVector.Y, newVector.X);
// // // Calculate rotation matrix
// // float angle = newAngle - oldAngle;
// // touchMatrix = SKMatrix.MakeRotation(angle, pivotPoint.X, pivotPoint.Y);
// // // Effectively rotate the old vector
// // float magnitudeRatio = Magnitude(oldVector) / Magnitude(newVector);
// // oldVector.X = magnitudeRatio * newVector.X;
// // oldVector.Y = magnitudeRatio * newVector.Y;
// //}
// float scaleX = 1;
// float scaleY = 1;
// //if (Mode == TouchManipulationMode.AnisotropicScale)
// //{
// // scaleX = newVector.X / oldVector.X;
// // scaleY = newVector.Y / oldVector.Y;
// //}
// //else if (Mode == TouchManipulationMode.IsotropicScale ||
// // Mode == TouchManipulationMode.ScaleRotate ||
// // Mode == TouchManipulationMode.ScaleDualRotate)
// //{
// // scaleX = scaleY = Magnitude(newVector) / Magnitude(oldVector);
// //}
// if (!float.IsNaN(scaleX) && !float.IsInfinity(scaleX) &&
// !float.IsNaN(scaleY) && !float.IsInfinity(scaleY))
// { // {
// scaleX = scaleY = Magnitude(newVector) / Magnitude(oldVector); // SKMatrix.PostConcat(ref touchMatrix,
// SKMatrix.MakeScale(scaleX, scaleY, pivotPoint.X, pivotPoint.Y));
// } // }
if (!float.IsNaN(scaleX) && !float.IsInfinity(scaleX) && // return touchMatrix;
!float.IsNaN(scaleY) && !float.IsInfinity(scaleY)) // }
{
SKMatrix.PostConcat(ref touchMatrix,
SKMatrix.MakeScale(scaleX, scaleY, pivotPoint.X, pivotPoint.Y));
}
return touchMatrix;
}
} // }
} //}

@ -36,7 +36,9 @@ namespace TheGameExtreme.viewmodel
Value = view.Value; Value = view.Value;
} }
public override string ToString()
{
return View.ToString();
}
} }
} }

@ -76,9 +76,9 @@ namespace TheGameExtreme.viewmodel
case 5: case 5:
gameMode = new GameMode(new PilesMoins5To5(nbPile), new MilliemeDeck()); gameMode = new GameMode(new PilesMoins5To5(nbPile), new MilliemeDeck());
break; break;
//case 6: case 6:
// // Fraction gameMode = new GameMode(new FractionPiles(nbPile), new FractionDeck());
// break; break;
default: default:
gameMode = new GameMode(new ClassicPiles(nbPile), new ClassicDeck()); gameMode = new GameMode(new ClassicPiles(nbPile), new ClassicDeck());
break; break;

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save