// Affiche le nom du joueur qui doit faire effectuer son tour ainsi que ses objectifs public void Tour() { validationObj(); Obj2.Hide(); Obj3.Hide(); Obj1.Hide(); Obj4.Hide(); Obj5.Hide(); nbreobjok.Text = listeJoueur[jEnCours].nbreObjOk.ToString(); act = Action.Indefinie; MessageBox.Show("C'est à " + listeJoueur[jEnCours].nom + " de jouer."); if (listeJoueur[jEnCours].main.Count() >= 1) { Obj1.Text = listeJoueur[jEnCours].main[0].objectif; Obj1.Show(); } if (listeJoueur[jEnCours].main.Count() >= 2) { Obj2.Text = listeJoueur[jEnCours].main[1].objectif; Obj2.Show(); } if (listeJoueur[jEnCours].main.Count() >= 3) { Obj3.Text = listeJoueur[jEnCours].main[2].objectif; Obj3.Show(); } if (listeJoueur[jEnCours].main.Count() >= 4) { Obj4.Text = listeJoueur[jEnCours].main[3].objectif; Obj4.Show(); } if (listeJoueur[jEnCours].main.Count() >= 5) { Obj5.Text = listeJoueur[jEnCours].main[4].objectif; Obj5.Show(); } estomacJaune.Text = listeJoueur[jEnCours].nbreBambouJaune.ToString(); estomacRose.Text = listeJoueur[jEnCours].nbreBambouRose.ToString(); estomacVert.Text = listeJoueur[jEnCours].nbreBambouVert.ToString(); }
public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { byte[] reds; byte[] greens; byte[] blues; double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; SKColor cl; N = Palette.Length; reds = new byte[N]; greens = new byte[N]; blues = new byte[N]; for (x = 0; x < N; x++) { cl = Palette[x]; reds[x] = cl.Red; greens[x] = cl.Green; blues[x] = cl.Blue; } Variables v = new Variables(); Variables.CopyTo(v); string ParameterName; if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } if (!(fPrim is IDifferentiable Differentiable2) || !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis)) { throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; Complex[] Row4; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2, Obj3; double Mod; Complex z, z2, z3; Complex R2 = R * 2; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Obj3 = fBis.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; Row4 = Obj3.AssociatedObjectValue as Complex[]; if (Row2 == null || Row3 == null || Row4 == null) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName, Node); } else if (Row2.Length != c || Row3.Length != c) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Length returned: " + Row2.Length.ToString() + ", " + Row3.Length.ToString() + " and " + Row4.Length.ToString() + ". Expected: " + c.ToString(), Node); } for (x = x2 = 0; x < c; x++) { j = Offset[x]; z = Row2[x]; z2 = Row3[x]; z3 = Row4[x]; z = R2 * z * z2 / (2 * z2 * z2 - z * z3); Row[x] -= z; Mod = z.Magnitude; if (Mod > Conv && Mod < Div) { if (x != x2) { Offset[x2] = j; } x2++; } else { if (n >= N) { rgb[j++] = 0; rgb[j++] = 0; rgb[j++] = 0; } else { rgb[j++] = blues[n]; rgb[j++] = greens[n]; rgb[j++] = reds[n]; } rgb[j++] = 255; } } if (x2 < x) { Array.Resize <Complex>(ref Row, x2); Array.Resize <int>(ref Offset, x2); c = x2; } } } using (SKData Data = SKData.Create(new MemoryStream(rgb))) { SKImage Bitmap = SKImage.FromPixelData(new SKImageInfo(Width, Height, SKColorType.Bgra8888), Data, Width * 4); return(new FractalGraph(Bitmap, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State)); } }
public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; N = Palette.Length; Variables v = new Variables(); Variables.CopyTo(v); string ParameterName; if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } if (!(fPrim is IDifferentiable Differentiable2) || !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis)) { throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node); } int size = Width * Height; double[] ColorIndex = new double[size]; double Conv = 1e-10; double Div = 1e10; Complex[] Row; Complex[] Row2; Complex[] Row3; Complex[] Row4; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2, Obj3; double Mod; Complex z, z2, z3; Complex R2 = R * 2; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Obj3 = fBis.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; Row4 = Obj3.AssociatedObjectValue as Complex[]; if (Row2 == null || Row3 == null || Row4 == null) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName, Node); } else if (Row2.Length != c || Row3.Length != c) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Length returned: " + Row2.Length.ToString() + ", " + Row3.Length.ToString() + " and " + Row4.Length.ToString() + ". Expected: " + c.ToString(), Node); } for (x = x2 = 0; x < c; x++) { j = Offset[x]; z = Row2[x]; z2 = Row3[x]; z3 = Row4[x]; z = R2 * z * z2 / (2 * z2 * z2 - z * z3); Row[x] -= z; Mod = z.Magnitude; if (Mod > Conv && Mod < Div) { if (x != x2) { Offset[x2] = j; } x2++; } else { if (n >= N) { ColorIndex[j++] = N; } else { ColorIndex[j++] = n; } } } if (x2 < x) { Array.Resize <Complex>(ref Row, x2); Array.Resize <int>(ref Offset, x2); c = x2; } } } Node.Expression.Preview(new GraphBitmap(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette))); double[] Boundary = FractalGraph.FindBoundaries(ColorIndex, Width, Height); FractalGraph.Smooth(ColorIndex, Boundary, Width, Height, N, Palette, Node, Variables); return(new FractalGraph(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette), r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State)); }
public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { byte[] reds; byte[] greens; byte[] blues; double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; SKColor cl; N = Palette.Length; reds = new byte[N]; greens = new byte[N]; blues = new byte[N]; for (x = 0; x < N; x++) { cl = Palette[x]; reds[x] = cl.Red; greens[x] = cl.Green; blues[x] = cl.Blue; } Variables v = new Variables(); Variables.CopyTo(v); string ParameterName; if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } if (!(fPrim is IDifferentiable Differentiable2) || !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis)) { throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; Complex[] Row4; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2, Obj3; double Mod; Complex z, z2, z3; Complex R2 = R * 2; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Obj3 = fBis.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; Row4 = Obj3.AssociatedObjectValue as Complex[]; if (Row2 is null || Row3 is null || Row4 is null) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName, Node); }
public Bambouseraie(ArrayList joueurs, int nbrej) { InitializeComponent(); baseDessin = zoneJardin.CreateGraphics(); #region Initialisation du tableau contenant les parcelles nbreParcelle = zoneJardin.Height / tailleParcelle; tableauParcelle = new Parcelle[nbreParcelle, nbreParcelle]; int xParcelle = 0; int yParcelle = 0; int ligne = 0; int colonne = 0; for (xParcelle = 0; xParcelle < zoneJardin.Height; xParcelle += (tailleParcelle + 1)) { for (yParcelle = 0; yParcelle < zoneJardin.Height; yParcelle += (tailleParcelle + 1)) { tableauParcelle[ligne, colonne] = new Parcelle(ligne, colonne, xParcelle, yParcelle, tailleParcelle); ligne++; } ligne = 0; colonne++; } #endregion #region Initialisation affichage objectif Obj1.Hide(); Obj2.Hide(); Obj3.Hide(); Obj4.Hide(); Obj5.Hide(); #endregion #region Intialisation de la pioche int maxPioche = nbrej * 6 + 10; piocheP = new List <Carte>(); Random rand = new Random(); for (int i = 0; i < maxPioche; i++) { pioche.Add(new Carte(rand.Next(1, 4))); } #endregion #region Initialisation du tableau des joueurs nbrejoueur = nbrej; listeJoueur = (Joueur[])joueurs.ToArray(typeof(Joueur)); #endregion #region Définition de l'étang tableauParcelle[4, 4].etang = true; tableauParcelle[4, 4].irriguee = true; tableauParcelle[4, 4].jardinier = true; tableauParcelle[4, 4].panda = true; tableauParcelle[4, 4].choixCouleur(Color.Blue); #endregion #region Initialisation des pinceaux contour = new Pen(Color.Black); police = new Font("Arial", 20); formatTexte = new StringFormat(); formatTexte.Alignment = StringAlignment.Center; formatTexte.LineAlignment = StringAlignment.Center; #endregion #region Définition des images string dossierimg = "C:/Users/Alice/Documents/Visual Studio 2013/Projects/Takenoko/TakenokoVisuel/img/"; jardinier = new Acteur(dossierimg + "jardinier.png", tableauParcelle[4, 4].dimension.X, tableauParcelle[4, 4].dimension.Y, tableauParcelle[4, 4], tailleInformation); int xpanda = tableauParcelle[4, 4].dimension.X + tailleParcelle - tailleInformation; panda = new Acteur(dossierimg + "panda.png", xpanda, tableauParcelle[4, 4].dimension.Y, tableauParcelle[4, 4], tailleInformation); #endregion }
public void InicializarCofre() { Random.seed = (int)System.DateTime.Now.Ticks; do { numero1 = Random.value; } while (numero1 < 0.00 || numero1 > 0.47); numero1 *= 100; numero1 = (int)numero1; do { numero2 = Random.value; } while (numero2 < 0.00 || numero2 > 0.47); numero2 *= 100; numero2 = (int)numero2; do { numero3 = Random.value; } while (numero3 < 0.00 || numero3 > 0.47); numero3 *= 100; numero3 = (int)numero3; Debug.Log(numero1 + " " + numero2 + " " + numero3); Obj1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero1.ToString()); Obj1.GetComponent <ObjetoId>().id = (int)numero1; switch (PersonajeIdPorObjeto((int)numero1)) { case 1: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } Obj2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero2.ToString()); Obj2.GetComponent <ObjetoId>().id = (int)numero2; switch (PersonajeIdPorObjeto((int)numero2)) { case 1: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } Obj3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero3.ToString()); Obj3.GetComponent <ObjetoId>().id = (int)numero3; switch (PersonajeIdPorObjeto((int)numero3)) { case 1: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } }