public override void Init() { camera = new Libraries.Camera(TurkeySmashGame.manager); #region player1 model = new Joueur(PlayerIndex.One, MathHelper.ToRadians(-90), MathHelper.ToRadians(180)); model.Load("Models\\dude", TurkeySmashGame.content); walk = new AnimatedModel(); walk.Load("Models\\dude-walk", TurkeySmashGame.content); AnimationClip clip = walk.Clips[0]; AnimationPlayer player = model.PlayClip(clip); player.Looping = true; model.Size = new Vector2(50, 350); elements.Add(model); #endregion if (SelectionNiveau.niveauSelect == "spacefarm") level = new Level("Jeu\\space", "Models\\farm", elements, TurkeySmashGame.content); else level = new Level("Jeu\\citybackground", "Models\\MapCity2", elements, TurkeySmashGame.content); hud.Load(elements); camera.Initialize(); sonInstance.Volume = 0.5f; sonInstance.IsLooped = true; sonInstance.Resume(); }
public Level(string backgroundName, string levelName, AnimatedModel[] elements, ContentManager content) { this.elements = elements; Position = Vector3.Zero; spawnPoints[0] = new Vector3(1200, 0, 0); spawnPoints[1] = new Vector3(-1300, 0, 0); spawnPoints[2] = new Vector3(700, 0, 0); spawnPoints[3] = new Vector3(700, 0, 0); Init(); if (backgroundName == "Jeu\\space") { GlobalHitBoxesList[0] = new Rectangle(-1825, -150, 3650, 150); GlobalHitBoxesList[1] =new Rectangle(-750, 0, 850, 250); GlobalHitBoxesList[2] = new Rectangle(400, 450, 725, 50); } else { GlobalHitBoxesList[0] = new Rectangle(-1500, -50, 2800, 50); GlobalHitBoxesList[1] = new Rectangle(1530, 75, 780, 15); GlobalHitBoxesList[2] = new Rectangle(-550, 570, 1000, 30); } background = new Sprite(); background.Load(content, backgroundName); Load(content, levelName); }
public void Update(AnimatedModel[] players) { int i = 0; foreach (Personnage player in players) { if (player != null) { pourcentages[i].Texte = Convert.ToString(player.Percent) + " %"; i++; } } }
public void Load(AnimatedModel[] players) { int i = 0; foreach (Personnage player in players) { if (player != null) { pourcentages[i] = new Font((i + 1) * (TurkeySmashGame.manager.PreferredBackBufferWidth / 4), (3.5f * TurkeySmashGame.manager.PreferredBackBufferHeight / 4)); pourcentages[i].NameFont = "Pourcent"; pourcentages[i].Load(TurkeySmashGame.content); pourcentages[i].SizeText = 1.0f; playersCount++; i++; } } pourcentages[0].Color = Color.Red; }
/// <summary> /// Constructor for the animation player. It makes the /// association between a clip and a model and sets up for playing /// </summary> /// <param name="clip"></param> public AnimationPlayer(AnimationClip clip, AnimatedModel model) { this.clip = clip; this.model = model; // Create the bone information classes boneCnt = clip.Bones.Count; boneInfos = new BoneInfo[boneCnt]; for(int b=0; b<boneInfos.Length; b++) { // Create it boneInfos[b] = new BoneInfo(clip.Bones[b]); // Assign it to a model bone boneInfos[b].SetModel(model); } Rewind(); }
public static void CheckHitBoxe(Rectangle[] GlobalHitBoxesList, AnimatedModel objet) { foreach (Rectangle rect in GlobalHitBoxesList) { if (rect != null) { Console.WriteLine(rect.Intersects(objet.HitBox())); if (rect.Intersects(objet.HitBox())) { // Bottom et Top sont inversés : Top est l'arret inférieur, // car la Hitbox est crée en fonction de la position du model qui est à la base du model // et le dessin du rectangle pose de gros probleme avec l'utilisation de valeur négative // Intersect c'est de la GROSSE MERDE if (rect.Bottom > objet.HitBox().Top && rect.Bottom < objet.HitBox().Bottom) { objet.velocityY = 0; objet.YPos = rect.Bottom + (objet.YSize / 2); } if (rect.Top < objet.HitBox().Bottom && rect.Top > objet.HitBox().Top) { objet.velocityY = 0; objet.YPos = rect.Top - objet.YSize; } if (rect.Left < objet.HitBox().Right && rect.Left > objet.HitBox().Left) { objet.velocityX = 0; objet.XPos = rect.Left - (objet.XSize / 2); } if (rect.Right > objet.HitBox().Left && rect.Right < objet.HitBox().Right) { objet.velocityX = 0; objet.XPos = rect.Right + (objet.XSize / 2); } } } } }
/// <summary> /// Assign this bone to the correct bone in the model /// </summary> /// <param name="model"></param> public void SetModel(AnimatedModel model) { // Find this bone assignedBone = model.FindBone(ClipBone.Name); }
/// <summary> /// Retourne vrai si la partie est terminée /// </summary> public bool Partieterminee(AnimatedModel[] models) { int i = 0; // compte de nombre de mort int j = 0; // compte de nombre de personnage foreach (Personnage player in models) { if (player != null) { j++; if (player.Mort) i++; } } return i > j - 2; // si le nombre de mort est supérieur ou egal a 1 vivant }
public bool IsOutScreen(AnimatedModel objet) { return objet.XPos < cadreDecor.Left || objet.XPos > cadreDecor.Right || objet.YPos < cadreDecor.Bottom || objet.YPos > cadreDecor.Top; }