예제 #1
0
        public static void Update(GameTime GT)
        {
            Outil.RemoveDeadBodies(unites);
            gametime = GT;
            // Debug les unites qui attaquent des unites mortes
            foreach (Unite u in unites)
            {
                // affiche la barre des sorts des unités attaquant un champion
                if (u.uniteAttacked != null && u.uniteAttacked.isAChamp)
                {
                    u.Drawlife = true;
                }
                if (u.uniteAttacked != null && !unites.Contains((Unite)u.uniteAttacked))
                {
                    u.uniteAttacked = null;
                }
            }
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].InInventory)
                {
                    items.RemoveAt(i);
                }
            }

            // Dit si on a gagné , que toutes les vagues sont finies



            if (OnaWin && SceneHandler.level == "level4")
            {
                PackMap.joueurs[0].Interface.Win = true;
            }
            foreach (Joueur j in PackMap.joueurs)
            {
                if (j.champion.PositionTile == new Vector2(97, 8) || j.champion.PositionTile == new Vector2(97, 7) || j.champion.PositionTile == new Vector2(97, 9))
                {
                    if (SceneHandler.level == "level1")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(3, 20);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                        }
                        SceneHandler.ResetGameplay("level2");
                    }
                }
                if (j.champion.PositionTile == new Vector2(129, 11) || j.champion.PositionTile == new Vector2(129, 12) || j.champion.PositionTile == new Vector2(129, 13))
                {
                    if (SceneHandler.level == "level2")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(2, 17);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                        }
                        SceneHandler.ResetGameplay("level3");
                    }
                }

                if (j.champion.PositionTile == new Vector2(128, 29) || j.champion.PositionTile == new Vector2(128, 30) || j.champion.PositionTile == new Vector2(128, 31) || j.champion.PositionTile == new Vector2(128, 32))
                {
                    if (SceneHandler.level == "level3")
                    {
                        foreach (Joueur j2 in PackMap.joueurs)
                        {
                            j2.champion.PositionTile  = new Vector2(12, 15);
                            j2.champion.ObjectifListe = new List <Noeud> {
                            };
                            j2.camera.Position        = new Vector2(0, 200);
                            FondSonore.PlayBoss();
                        }
                        SceneHandler.ResetGameplay("level4");
                    }
                }
            }
        }
예제 #2
0
        public void Update(List <Unite> unites)
        {
            if (!champion.Mort)
            {
                Interface.mouse = Mouse.GetState();
                Interface.key   = Keyboard.GetState();
                // Pour cibler un point pour un sort
                if (Interface.mouse.LeftButton == ButtonState.Pressed && Interface.Oldmouse.LeftButton == ButtonState.Released && InWaitingPoint)
                {
                    champion.pointCible       = new Vector2((int)((camera.Position.X + Interface.mouse.X) / 32), (int)((camera.Position.Y + Interface.mouse.Y) / 32));
                    InWaitingPoint            = false;
                    Interface.DrawSelectPoint = false;
                    champion.Cast(spell, champion.pointCible, SelectedUnit);
                }
                // Pour cibler une unité pour un sort
                if (Interface.mouse.LeftButton == ButtonState.Pressed && Interface.Oldmouse.LeftButton == ButtonState.Released && InWaitingUnit)
                {
                    Vector2 point = new Vector2((int)((camera.Position.X + Interface.mouse.X) / 32), (int)((camera.Position.Y + Interface.mouse.Y) / 32));

                    foreach (Unite u in Map.unites)
                    {
                        if (u != champion && !u.isApnj && Outil.DistancePoints(point, u.PositionTile) <= 46)
                        {
                            SelectedUnit = u;
                        }
                    }

                    if (SelectedUnit != null)
                    {
                        champion.Cast(spell, champion.pointCible, SelectedUnit);
                    }

                    InWaitingUnit            = false;
                    Interface.DrawSelectUnit = false;
                }

                // Pour se déplacer
                if (Interface.mouse.RightButton == ButtonState.Pressed && !DonnerOrdreAttaquer() && (SourisHoverInventory() && !Interface.DrawSac || !SourisHoverInventory()) && (SourisHoverEquipement() && !Interface.DrawEquipement || !SourisHoverEquipement()))
                {
                    DonnerOrdreDeplacer();
                }

                if (!Interface.isWriting) // Si on écrit pas on peut utiliser les raccourcis clavier
                {
                    // Pour attaquer un point
                    if (Interface.key.IsKeyDown(Keys.A))
                    {
                        DonnerOrdreAttaquerPoint();
                    }
                    // Pour arreter les déplacements
                    if (Interface.key.IsKeyDown(Keys.S))
                    {
                        DonnerOrdreStop();
                    }
                    // Pour se teleporter!
                    if (Interface.key.IsKeyDown(Keys.T) && Interface.Oldkey.IsKeyUp(Keys.T) && CrystalGateGame.isTest)
                    {
                        if (SceneHandler.level == "level1")
                        {
                            FondSonore.PlayBoss();
                            SceneHandler.ResetGameplay("level4");
                        }
                        else
                        {
                            SceneHandler.ResetGameplay("level1");
                        }
                    }

                    // Pour afficher/cacher le sac
                    if (Interface.key.IsKeyDown(Keys.B) && Interface.Oldkey.IsKeyUp(Keys.B) || Interface.key.IsKeyDown(Keys.I) && Interface.Oldkey.IsKeyUp(Keys.I))
                    {
                        Interface.DrawSac = !Interface.DrawSac;
                    }
                    // Pour afficher/cacher le sac
                    if (Interface.key.IsKeyDown(Keys.C) && Interface.Oldkey.IsKeyUp(Keys.C))
                    {
                        Interface.DrawEquipement = !Interface.DrawEquipement;
                    }
                }

                // Pour lancer un sort
                if (Interface.key.IsKeyDown(Keys.D1) && Interface.Oldkey.IsKeyUp(Keys.D1) && champion.spells.Count > 0 || Interface.SourisClickSpellCheck(0) && champion.spells.Count > 0)
                {
                    spell = champion.spells[0];
                    if (champion.IsCastable(0))
                    {
                        if (champion.spells[0].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D2) && Interface.Oldkey.IsKeyUp(Keys.D2) && champion.spells.Count > 1 || Interface.SourisClickSpellCheck(1) && champion.spells.Count > 1)
                {
                    spell = champion.spells[1];
                    if (champion.IsCastable(1))
                    {
                        if (champion.spells[1].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D3) && Interface.Oldkey.IsKeyUp(Keys.D3) && champion.spells.Count > 2 || Interface.SourisClickSpellCheck(2) && champion.spells.Count > 2)
                {
                    spell = champion.spells[2];
                    if (champion.IsCastable(2))
                    {
                        if (champion.spells[2].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D4) && Interface.Oldkey.IsKeyUp(Keys.D4) && champion.spells.Count > 3 || Interface.SourisClickSpellCheck(3) && champion.spells.Count > 3)
                {
                    spell = champion.spells[3];
                    if (champion.IsCastable(3))
                    {
                        if (champion.spells[3].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D5) && Interface.Oldkey.IsKeyUp(Keys.D5) && champion.spells.Count > 4 || Interface.SourisClickSpellCheck(4) && champion.spells.Count > 4)
                {
                    spell = champion.spells[4];
                    if (champion.IsCastable(4))
                    {
                        if (champion.spells[4].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        if (champion.spells[4].NeedAUnit)
                        {
                            Interface.DrawSelectUnit = true;
                            InWaitingUnit            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
                if (Interface.key.IsKeyDown(Keys.D6) && Interface.Oldkey.IsKeyUp(Keys.D6) && champion.spells.Count > 5 || Interface.SourisClickSpellCheck(5) && champion.spells.Count > 5)
                {
                    spell = champion.spells[5];
                    if (champion.IsCastable(5))
                    {
                        if (champion.spells[5].NeedUnPoint)
                        {
                            Interface.DrawSelectPoint = true;
                            InWaitingPoint            = true;
                        }
                        if (champion.spells[5].NeedAUnit)
                        {
                            Interface.DrawSelectUnit = true;
                            InWaitingUnit            = true;
                        }
                        else
                        {
                            champion.Cast(spell, champion.pointCible, SelectedUnit);
                        }
                    }
                }
            }
            // Pour verifier si on parle a un pnj
            SpeakToPNJ();
            // Pour déplacer la caméra
            CameraUpdate();
            Interface.Update();
            UpdateReseau();
            CurseurCheck();
            Interface.Oldmouse = Interface.mouse;
            Interface.Oldkey   = Interface.key;
        }