Esempio n. 1
0
        public override void UpdateSort()
        {
            Positions.Clear();
            if (TickCurrent == 0)
            {
                rayon = 1;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            rayon += 0.1f;
            // On ajoute les explosions
            for (double i = 0; i < 2 * Math.PI; i += 0.25f)
            {
                Positions.Add(Point / 32 + new Vector2((float)Math.Cos(i), (float)Math.Sin(i)) * rayon);
            }
            // On verifie les degats sur les unités de la map
            foreach (Vector2 v in Positions)
            {
                foreach (Unite u in Map.unites)
                {
                    float distance = Outil.DistancePoints(v, u.PositionTile);
                    if (u != unite && !u.isAChamp && distance <= Portée)
                    {
                        u.Vie -= (int)(unite.Puissance * ratio + 3 - u.DefenseMagique);
                        //u.color = Color.Red;
                    }

                    /*else
                     *  u.color = Color.White;*/
                }
            }
            //sonSort.Play();
        }
Esempio n. 2
0
 public override void UpdateSort()
 {
     foreach (Unite u in Map.unites)
     {
         float distance = Outil.DistancePoints(this.Point, u.PositionTile);
         if (u != unite && !u.isAChamp && distance <= Portée)
         {
             u.Vie -= (int)(unite.Puissance * ratio - u.DefenseMagique);
             //u.color = Color.Red;
         }
     }
 }
Esempio n. 3
0
 public void Update(List <Unite> unites) // Appelé quand l'objet est sur la Map
 {
     foreach (Unite u in unites)
     {
         if (u.isAChamp && Outil.DistancePoints(Position, u.PositionTile) <= 32 && !InInventory)
         {
             if (u.Inventory.Count + 1 <= u.InventoryCapacity)
             {
                 unite = u;
                 u.Inventory.Add(this);
                 InInventory = true; // retire l'objet de la carte et l'ajoute a l'inventaire de l'unité proche
                 Effet(u);
             }
         }
     }
 }
Esempio n. 4
0
        public bool SpeakToPNJ() // Renvoie si on parle a un PNJ, et modifie l'UI si c'est le cas
        {
            // Stoque les PNJ pres du joueurs dans une liste
            List <Unite> result = Map.unites.Where(i => Outil.DistanceUnites(i, champion) <= 64 && i.isApnj).ToList();

            PNJSelected = (result.Count > 0) ? result[0] : null; // prend le premier et le met dans la variable PNJSelected

            if (PNJSelected != null)                             // Si on est assez proche du PNJ, on draw le dialogue
            {
                Interface.DrawDialogue = Outil.DistancePoints(champion.PositionTile, PNJSelected.PositionTile) <= 46;
            }
            else
            {
                Interface.DrawDialogue = false;
            }
            return(Interface.DrawDialogue);
        }
Esempio n. 5
0
        public bool CurseurCheck() // Renvoie vrai si le curseur est sur un méchant :p
        {
            Vector2 ObjectifPoint = new Vector2(camera.Position.X + Interface.mouse.X, camera.Position.Y + Interface.mouse.Y) / Map.TailleTiles;

            ObjectifPoint = new Vector2((int)ObjectifPoint.X, (int)ObjectifPoint.Y);

            foreach (Unite u in Map.unites)
            {
                if (!u.isAChamp && Outil.DistancePoints(ObjectifPoint, u.PositionTile) <= 32)
                {
                    Interface.CurseurOffensif = true;
                    return(true);
                }
            }

            Interface.CurseurOffensif = false;
            return(false);
        }
Esempio n. 6
0
        public override void UpdateSort()
        {
            if (TickCurrent == 0)
            {
                rayon = 0.1f;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            rayon += 0.0001f;
            // On ajoute les explosions
            if (TickCurrent > 0 && TickCurrent % 3 == 0)
            {
                Positions.Add(Point / 32);
            }
            // Update de la position
            for (int i = 0; i < Positions.Count; i++)
            {
                Positions[i] += new Vector2((float)Math.Cos(i + 1) * rayon, (float)Math.Sin(i + 1) * rayon);
            }

            if (TickCurrent == Ticks - 1)
            {
                rayon = 0.1f;
                Point = ConvertUnits.ToDisplayUnits(unite.body.Position);
            }
            // On verifie les degats sur les unités de la map
            foreach (Vector2 v in Positions)
            {
                foreach (Unite u in Map.unites)
                {
                    float distance = Outil.DistancePoints(v, u.PositionTile);
                    if (u != unite && distance <= Portée)
                    {
                        u.Vie  -= (int)(unite.Puissance * ratio + 1 - u.DefenseMagique);
                        u.color = Color.Red;
                    }
                    else
                    {
                        u.color = Color.White;
                    }
                }
            }
            sonSort.Play();
        }
Esempio n. 7
0
        public bool DonnerOrdreAttaquer()
        {
            Vector2 ObjectifPoint = new Vector2(camera.Position.X + Interface.mouse.X, camera.Position.Y + Interface.mouse.Y) / Map.TailleTiles;

            ObjectifPoint = new Vector2((int)ObjectifPoint.X, (int)ObjectifPoint.Y);
            foreach (Unite u in Map.unites)
            {
                if (!u.isAChamp && !u.isApnj && Outil.DistancePoints(ObjectifPoint, u.PositionTile) <= 60)
                {
                    champion.uniteAttacked = u;
                    List <Noeud> chemin = PathFinding.TrouverChemin(champion.PositionTile, ObjectifPoint, Map.Taille, new List <Unite> {
                    }, Map.unitesStatic, false);
                    if (chemin != null)
                    {
                        champion.ObjectifListe = chemin;
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 8
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;
        }