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; }
public void Cast(Spell s, Vector2 point, Unite unit, bool fromOnline = false) { // Cast ou initialise le sort s.Point = point; s.UniteCible = unit; if(SceneHandler.gameplayScene.isCoopPlay && !fromOnline) isCasting = true; else { spellsUpdate.Add(s); spellsUpdate[spellsUpdate.Count - 1].Begin(point, unit); } }