/// <summary> /// Code ajouté lors de la création d'un item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListCharacters_ItemToCreate(object sender, EventArgs e) { VO_PlayableCharacter newChar = _Service.CreatePlayer(); ListPlayers.AddItem(newChar.Id, newChar.Title); LoadCharacter(newChar.Id); }
private void ChangePlayerAnimation(object sender, EventArgs e) { VO_Base SelectedAnim = null; cmbTypeAnimation.Items.Clear(); if (characterButton1.CharacterGuid != Guid.Empty) { VO_PlayableCharacter playableCharacter = GameCore.Instance.GetPlayableCharacterById(characterButton1.CharacterGuid); List <VO_Base> AnimationList = GameCore.Instance.GetCharAnimations(playableCharacter.CharacterId); cmbTypeAnimation.DisplayMember = "Title"; cmbTypeAnimation.ValueMember = "Id"; foreach (VO_Base CurrentAnimation in AnimationList) { cmbTypeAnimation.Items.Add(CurrentAnimation); cmbTypeAnimation.SelectedIndex = 0; if (CurrentAnimation.Id == CharacterAnimationType) { SelectedAnim = CurrentAnimation; } } if (SelectedAnim != null) { cmbTypeAnimation.SelectedItem = SelectedAnim; } } }
public VO_Player(VO_PlayableCharacter playableCharacter) { //Perso associé VO_Character character = GameCore.Instance.GetCharacterById(playableCharacter.CharacterId); //Bindings _playableCharacter = playableCharacter; _characterSprite = new VO_CharacterSprite(character, playableCharacter.StartPosition, playableCharacter.CoordsCharacter); this.Id = _playableCharacter.Id; this.Actions = new List <Guid>(); foreach (Guid action in playableCharacter.Actions) { AddAction(action); } this.ActivateLife = playableCharacter.ActivateLife; this.PvAtStart = playableCharacter.PvAtStart; this.PvMax = playableCharacter.PvMax; //Inventaire CreateInventory(GameCore.Instance.Game.Menu.GridWidth, GameCore.Instance.Game.Menu.GridHeight); foreach (Guid item in playableCharacter.Items) { AddItem(item); } }
/// <summary> /// Récupère une nouvelle instance d'un objet /// </summary> /// <param name="pId">ID du character</param> /// <returns>VO_PlayableCharacter</returns> public VO_PlayableCharacter GetPlayableCharacterById(Guid id) { VO_PlayableCharacter character = Game.PlayableCharacters.Find(p => p.Id == id); if (character != null) { return(character); } return((VO_PlayableCharacter)ValidationTools.CreateEmptyRessource(new VO_PlayableCharacter())); }
/// <summary> /// Crée un character /// </summary> /// <returns>VO_Character</returns> public VO_PlayableCharacter CreatePlayer() { VO_PlayableCharacter character = null; RunServiceTask(delegate { character = _Business.CreatePlayer(); }, Errors.ERROR_CHARACTER_STR_CREATE); return(character); }
/// <summary> /// Insère un character /// </summary> /// <returns>VO_PlayableCharacter</returns> public static VO_PlayableCharacter CreatePlayableCharacter() { //Création de l'objet int i = 1; string title = string.Empty; while (true) { if (GameCore.Instance.Game.PlayableCharacters.Find(p => p.Title == string.Format(GlobalConstants.PLAYABLECHARACTERS_NEW_ITEM, i)) != null) { i++; continue; } else { title = string.Format(GlobalConstants.PLAYABLECHARACTERS_NEW_ITEM, i); break; } } VO_PlayableCharacter character = new VO_PlayableCharacter(Guid.NewGuid()) { Title = title, PvMax = 100, PvAtStart = 100, StartPosition = Enums.Movement.Down, CoordsCharacter = new VO_Coords(new Point(), Guid.Empty) }; //Insertion de l'objet GameCore.Instance.Game.PlayableCharacters.Add(character); //Attachement de l'action "Aller" character.Actions = new List <Guid>(); foreach (VO_Action action in GameCore.Instance.Game.Actions) { if (action.GoAction) { character.Actions.Add(action.Id); } else if (action.UseAction) { character.Actions.Add(action.Id); } } character.Items = new List <Guid>(); return(character); }
/// <summary> /// Survient lorsque le formulaire devient visible /// </summary> public void InitializeDBPlayers() { CurrentCharacter = null; ProvisionList(); if (ListPlayers.DataSource.Count > 0) { Guid firstAnimation = ListPlayers.DataSource[0].Id; ListPlayers.SelectItem(firstAnimation); LoadCharacter(firstAnimation); } else { ListCharacters_ListIsEmpty(this, new EventArgs()); } }
/// <summary> /// Méthode qui charge l'animation courante /// </summary> public void LoadCharacter(Guid guid) { Cursor.Current = Cursors.WaitCursor; //Suppression des eventhandler this.chkLife.CheckedChanged -= new System.EventHandler(this.chkLife_CheckedChanged); this.ddpPVStarting.ValueChanged -= new System.EventHandler(this.ddpPV_ValueChanged); this.ddpPVMax.ValueChanged -= new System.EventHandler(this.ddpPV_ValueChanged); this.txtName.LostFocus -= new System.EventHandler(this.txtName_TextChanged); this.crdStartingPosition.ValueChanged -= new EventHandler(crdStartingPosition_ValueChanged); //Code de chargement CurrentCharacter = GameCore.Instance.GetPlayableCharacterById(guid); _characterTemplate = GameCore.Instance.GetCharacterById(CurrentCharacter.CharacterId); txtName.Text = CurrentCharacter.Title; ddpPVMax.Value = CurrentCharacter.PvMax; ddpPVStarting.Value = CurrentCharacter.PvAtStart; chkLife.Checked = CurrentCharacter.ActivateLife; chkLife_CheckedChanged(this, new EventArgs()); crdStartingPosition.FullCoords = CurrentCharacter.CoordsCharacter; AnimCharacter.ParentCharacter = _characterTemplate.Id; LoadLists(); if (_characterTemplate.StandingAnim != new Guid()) { AnimCharacter.UseCustomRow = true; AnimCharacter.Row = (int)CurrentCharacter.StartPosition; AnimCharacter.LoadAnimation(_characterTemplate.StandingAnim); AnimCharacter.Start(); } else { AnimCharacter.LoadAnimation(new Guid()); } //Chargement des actions ListSelectedActions.Items.Clear(); ListSelectedActions.DisplayMember = "Title"; ListSelectedActions.ValueMember = "Id"; ListAvailableActions.Items.Clear(); ListAvailableActions.DisplayMember = "Title"; ListAvailableActions.ValueMember = "Id"; foreach (VO_Base action in GameCore.Instance.Game.Actions) { if (CurrentCharacter.Actions.Contains(action.Id)) { ListSelectedActions.Items.Add(action); } else { ListAvailableActions.Items.Add(action); } } //Chargement des items ListSelectedItems.Items.Clear(); ListSelectedItems.DisplayMember = "Title"; ListSelectedItems.ValueMember = "Id"; ListAvailableItems.Items.Clear(); ListAvailableItems.DisplayMember = "Title"; ListAvailableItems.ValueMember = "Id"; foreach (VO_Base item in GameCore.Instance.Game.Items) { if (CurrentCharacter.Items.Contains(item.Id)) { ListSelectedItems.Items.Add(item); } else { ListAvailableItems.Items.Add(item); } } this.chkLife.CheckedChanged += new System.EventHandler(this.chkLife_CheckedChanged); this.ddpPVStarting.ValueChanged += new System.EventHandler(this.ddpPV_ValueChanged); this.ddpPVMax.ValueChanged += new System.EventHandler(this.ddpPV_ValueChanged); this.txtName.LostFocus += new System.EventHandler(this.txtName_TextChanged); this.crdStartingPosition.ValueChanged += new EventHandler(crdStartingPosition_ValueChanged); grpAnimations.Visible = true; grpInteractions.Visible = true; grpInformations.Visible = true; grpLife.Visible = true; Cursor.Current = DefaultCursor; }
/// <summary> /// Code ajouté lors de la suppression d'un item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListCharacters_ItemToDelete(object sender, EventArgs e) { CurrentCharacter.Delete(); CurrentCharacter = null; }
public static bool CheckCurrentProjectIntegrity() { #region Check Event Stage Integrity ProjectValid = true; ErrorList = new List <string>(); #region Verification des nécessités de démarrage VO_Project project = GameCore.Instance.Game.Project; VO_PlayableCharacter character = GameCore.Instance.GetPlayableCharacterById(project.StartingCharacter); if (character == null) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STARTING_CHARACTER_NEEDED); ErrorList.Add(FormatedResult); } else { VO_Stage stage = GameCore.Instance.GetStageById(character.CoordsCharacter.Map); if (stage == null) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STARTING_STAGE_NEEDED); ErrorList.Add(FormatedResult); } } if (string.IsNullOrEmpty(project.GuiResource)) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.GUI_SYSTEM_NEEDED); ErrorList.Add(FormatedResult); } #endregion #region Verification des GlobalEvents ErrorList.Add(Culture.Language.ProjectIntegrity.INTEGRITY_DATABASEZONE + "\r\n\r\n"); foreach (VO_GlobalEvent CurrentEvent in GameCore.Instance.Game.GlobalEvents) { #region Verification des pages if (CurrentEvent.Script != null) { if (EventScriptIntegrity(CurrentEvent.Script) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_GLOBALEVENT, CurrentEvent.Title); ErrorList.Add(FormatedResult); } } #endregion } #endregion #region Verification de GameOver VO_Script GameOverScript = project.GameOver; if (EventScriptIntegrity(GameOverScript) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_GAMEOVER); ErrorList.Add(FormatedResult); } #endregion #region Verification des Items foreach (VO_Item CurrentItem in GameCore.Instance.Game.Items) { #region Verification des Action sur Item if (CurrentItem.Scripts != null) { foreach (VO_ActionOnItemScript CurrentItemScript in CurrentItem.Scripts) { if (EventScriptIntegrity(CurrentItemScript.Script) == false) { VO_Action CurrentAction = GameCore.Instance.GetActionById(CurrentItemScript.Id); ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ITEM, CurrentItem.Title, CurrentAction.Title); ErrorList.Add(FormatedResult); } } } #endregion } #endregion #region Verification des ItemsInteraction foreach (VO_Script CurrentItemInteraction in GameCore.Instance.Game.InteractionScripts) { #region Verification de l'ItemInteraction if (CurrentItemInteraction != null) { if (EventScriptIntegrity(CurrentItemInteraction) == false) { ProjectValid = false; int FoundItem = 0; List <VO_Item> AssociatedItems = new List <VO_Item>(); foreach (VO_Item CurrentItem in GameCore.Instance.Game.Items) { if (CurrentItem.ItemInteraction.Find(p => p.Script == CurrentItemInteraction.Id) != null) { AssociatedItems.Add(CurrentItem); if (FoundItem == 2) { break; } else { FoundItem = FoundItem + 1; } } } string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ITEMINTERACTION, AssociatedItems[0].Title, AssociatedItems[1].Title); ErrorList.Add(FormatedResult); } } #endregion } #endregion #region Verification des Personnages de la Database List <VO_PlayableCharacter> PlayableCharacterList = GameCore.Instance.Game.PlayableCharacters; foreach (VO_PlayableCharacter CurrentPlayableCharacter in PlayableCharacterList) { if (ValidationTools.CheckMapExistence(CurrentPlayableCharacter.CoordsCharacter) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.CHECK_PLAYABLECHARACTER_MAP, CurrentPlayableCharacter.Title); ErrorList.Add(FormatedResult); } } #endregion ErrorList.Add("\r\n\r\n" + Culture.Language.ProjectIntegrity.INTEGRITY_STAGE + "\r\n\r\n"); List <VO_Base> StageList = GameCore.Instance.GetStages(); foreach (VO_Stage CurrentStage in StageList) { #region Verification du Script de démarrage (Premiere fois) if (EventScriptIntegrity(CurrentStage.StartingFirstScript) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_START_FIRST, CurrentStage.Title); ErrorList.Add(FormatedResult); } #endregion #region Verification du Script de démarrage if (EventScriptIntegrity(CurrentStage.StartingScript) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_START, CurrentStage.Title); ErrorList.Add(FormatedResult); } #endregion #region Verification du Script de fin (Premiere fois) if (EventScriptIntegrity(CurrentStage.EndingFirstScript) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_END_FIRST, CurrentStage.Title); ErrorList.Add(FormatedResult); } #endregion #region Verification du Script de fin if (EventScriptIntegrity(CurrentStage.EndingScript) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_END, CurrentStage.Title); ErrorList.Add(FormatedResult); } #endregion #region Verification des Hotspot foreach (VO_StageHotSpot CurrentHotSpot in CurrentStage.ListHotSpots) { #region Verification des pages if (CurrentHotSpot.Event != null) { foreach (VO_Page CurrentPage in CurrentHotSpot.Event.PageList) { #region Verification du Script Courant if (EventScriptIntegrity(CurrentPage.Script) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_HOTSPOT, CurrentStage.Title, CurrentHotSpot.Title, CurrentPage.PageNumber + 1); ErrorList.Add(FormatedResult); } #endregion } } #endregion } #endregion #region Verification des Personnages foreach (VO_StageCharacter CurrentCharacter in CurrentStage.ListCharacters) { #region Verification des pages if (CurrentCharacter.Event != null) { foreach (VO_Page CurrentPage in CurrentCharacter.Event.PageList) { #region Verification du Script Courant if (EventScriptIntegrity(CurrentPage.Script) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.STAGE_SCRIPT_CHARACTER, CurrentStage.Title, CurrentCharacter.Title, CurrentPage.PageNumber + 1); ErrorList.Add(FormatedResult); } #endregion } } #endregion } #endregion #region Verification des Animation foreach (VO_Layer CurrentLayer in CurrentStage.ListLayers) { #region Verification des pages List <VO_StageAnimation> StageAnimationList = CurrentLayer.ListAnimations; if (StageAnimationList != null) { foreach (VO_StageAnimation CurrentStageAnimation in StageAnimationList) { foreach (VO_Page CurrentPage in CurrentStageAnimation.Event.PageList) { #region Verification du Script Courant if (EventScriptIntegrity(CurrentPage.Script) == false) { ProjectValid = false; string FormatedResult = System.String.Format(Culture.Language.ProjectIntegrity.SCRIPT_ANIMATION, CurrentStage.Title, CurrentLayer.Title, CurrentStageAnimation.Title, CurrentPage.PageNumber); ErrorList.Add(FormatedResult); } #endregion } } } #endregion } #endregion } #endregion return(ProjectValid); }