/// <summary> /// Click sur un item pour le sélectionner dans le stage /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StageObjectsTreeView_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { TreeNode selectedNode = StageObjectsTreeView.GetNodeAt(e.X, e.Y); if (selectedNode != null) { VO_StageObject stageObject = GetStageObjectFromNode(selectedNode); if (stageObject != null) { EditorHelper.Instance.SelectedObjects = new List <VO_StageObject>(); EditorHelper.Instance.SelectedObjects.Add(stageObject); if (stageObject.ObjectType == Enums.StageObjectType.HotSpots || stageObject.ObjectType == Enums.StageObjectType.Walkables || stageObject.ObjectType == Enums.StageObjectType.Regions) { EditorHelper.Instance.SelectedHotSpot = (VO_StageHotSpot)stageObject; EditorHelper.Instance.SelectedHotSpotPoint = -1; EditorHelper.Instance.HotSpotEditionMode = true; } this.StageNeedsToBeRefreshed(this, new EventArgs()); ReloadItemChosen(); } } else { DesactivateButtons(); } } }
/// <summary> /// Valide si l'utilisateur est dans le bon mode pour effectuer des actions. /// </summary> private bool ValidateObjectAction() { if (EditorHelper.Instance.SelectedObjects.Count == 1) { VO_StageObject objectStage = EditorHelper.Instance.SelectedObjects[0]; if (objectStage.ObjectType == Enums.StageObjectType.Animations && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.Objects) { return(false); } if (objectStage.ObjectType == Enums.StageObjectType.Characters && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.Characters) { return(false); } if (objectStage.ObjectType == Enums.StageObjectType.Decors && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.Decors) { return(false); } if (objectStage.ObjectType == Enums.StageObjectType.HotSpots && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.HotSpots) { return(false); } if (objectStage.ObjectType == Enums.StageObjectType.Walkables && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.WalkableAreas) { return(false); } if (objectStage.ObjectType == Enums.StageObjectType.Regions && EditorHelper.Instance.CurrentStageState != Enums.StagePanelState.Regions) { return(false); } return(true); } return(false); }
// EVENT PREVU POUR CHARACTERS & EVENTS, les Anim ne sont pas supposées être cliquables public bool ExecuteClickedEvent(Point point, int matrixPrecision) { VO_StageObject hotSpot = null; #region Récupère le script //Gestion des characters foreach (VO_StageCharacter character in _CurrentStage.ListCharacters) { VO_CharacterSprite characterSprite = GetCharacterSprite(character.Id); if (characterSprite.PointIsInCharacter(point)) { //Activer l'event foreach (VO_Page page in character.Event.PageList) { if (IsActivePage(page)) { return(TestScript(character, Enums.TriggerEventConditionType.ClickEvent)); } } } } //Gestion des events int eventIndex = MatrixManager.CurrentStage.EventsMatrix[point.X / matrixPrecision, point.Y / matrixPrecision] - 1; //Récupérer l'event associé if (eventIndex > -1) { hotSpot = _CurrentStage.ListHotSpots[eventIndex]; return(TestScript(hotSpot, Enums.TriggerEventConditionType.ClickEvent)); } #endregion return(false); }
/// <summary> /// Récupère un objet de scène depuis une node /// </summary> /// <param name="node">Node</param> /// <returns>StageObject</returns> private VO_StageObject GetStageObjectFromNode(TreeNode node) { Guid id = new Guid(((TreeNode)node).Name); VO_StageObject stageObject = null; DesactivateButtons(); btnDelete.Enabled = true; switch (EditorHelper.Instance.CurrentStageState) { case Enums.StagePanelState.Objects: stageObject = EditorHelper.Instance.GetCurrentLayerInstance().ListAnimations.Find(p => p.Id == id); btnEvent.Enabled = true; break; case Enums.StagePanelState.Decors: stageObject = EditorHelper.Instance.GetCurrentLayerInstance().ListDecors.Find(p => p.Id == id); break; case Enums.StagePanelState.Characters: stageObject = EditorHelper.Instance.GetCurrentStageInstance().ListCharacters.Find(p => p.Id == id); btnEvent.Enabled = true; break; case Enums.StagePanelState.HotSpots: if (EditorHelper.Instance.CurrentDrawingTool == Enums.DrawingTools.Pointer) { stageObject = EditorHelper.Instance.GetCurrentStageInstance().ListHotSpots.Find(p => p.Id == id); btnEvent.Enabled = true; } break; case Enums.StagePanelState.WalkableAreas: if (EditorHelper.Instance.CurrentDrawingTool == Enums.DrawingTools.Pointer) { stageObject = EditorHelper.Instance.GetCurrentLayerInstance().ListWalkableAreas.Find(p => p.Id == id); btnEvent.Enabled = false; } break; case Enums.StagePanelState.Regions: if (EditorHelper.Instance.CurrentDrawingTool == Enums.DrawingTools.Pointer) { stageObject = EditorHelper.Instance.GetCurrentStageInstance().ListRegions.Find(p => p.Id == id); btnEvent.Enabled = false; } break; } return(stageObject); }
/// <summary> /// Script par contact /// </summary> /// <param name="matrixPrecision"></param> private void CheckContactScript(int matrixPrecision) { VO_StageObject hotSpot = null; Point point = PlayableCharactersManager.CurrentPlayerCharacter.CharacterSprite.Location; #region Récupère le script int eventIndex = MatrixManager.CurrentStage.EventsMatrix[point.X / matrixPrecision, point.Y / matrixPrecision] - 1; //Récupérer l'event associé if (eventIndex > -1) { hotSpot = _CurrentStage.ListHotSpots[eventIndex]; TestScript(hotSpot, Enums.TriggerEventConditionType.ContactEvent); } #endregion }
/// <summary> /// Test et gère les scripts /// </summary> /// <param name="stageObject"></param> /// <param name="IsProcess"></param> /// <returns></returns> public bool TestScript(VO_StageObject stageObject, Enums.TriggerEventConditionType type) { VO_Event eventSpot = stageObject.Event; VO_Page _page = null; //Activer l'event foreach (VO_Page page in eventSpot.PageList) { if (page.TriggerCondition == type && IsActivePage(page) && IsExecutablePage(page)) { _page = page; break; } } //Bad Interactions if (type == Enums.TriggerEventConditionType.ClickEvent) { if (_page == null && eventSpot != null && stageObject.ClassId != Guid.Empty) { VO_Dialog dialog = FindBadInteraction(eventSpot, stageObject.ClassId); if (dialog != null) { VO_Script dynamicScript = new VO_Script(Guid.NewGuid()); dynamicScript.Lines = new List <VO_Line>(); VO_Script_Message scriptMessage = new VO_Script_Message(); scriptMessage.Id = Guid.NewGuid(); scriptMessage.Dialog = dialog; dynamicScript.Lines.Add(scriptMessage); LaunchScript(stageObject, dynamicScript, type); return(true); } } } if (_page == null) { return(false); } #region Execute le script LaunchScript(stageObject, _page.Script, type); return(true); #endregion }
/// <summary> /// Double click pour ouvrir l'event manager /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StageObjectsTreeView_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { TreeNode selectedNode = StageObjectsTreeView.GetNodeAt(e.X, e.Y); if (selectedNode != null && selectedNode.Parent != null) { VO_StageObject stageObject = GetStageObjectFromNode(selectedNode); if (stageObject != null) { if (btnEvent.Enabled) { LoadEventManager(); } } } } }
/// <summary> /// Lance un script /// </summary> /// <param name="hotSpot"></param> /// <param name="script"></param> private void LaunchScript(VO_StageObject hotSpot, VO_Script script, Enums.TriggerEventConditionType type) { if (type == Enums.TriggerEventConditionType.ClickEvent && hotSpot.PlayerMustMove) { VO_RunningScript newScript = new VO_RunningScript(); newScript.Id = Guid.NewGuid(); newScript.Lines = new List <VO_Line>(); newScript.ScriptType = Enums.ScriptType.Dynamic; VO_Script_MovePlayer moveScript = new VO_Script_MovePlayer(); moveScript.Id = Guid.NewGuid(); moveScript.Coords = hotSpot.PlayerPositionPoint; newScript.Lines.Add(moveScript); VO_Script_ChangePlayerDirection playerDirection = new VO_Script_ChangePlayerDirection(); playerDirection.Id = Guid.NewGuid(); playerDirection.Direction = hotSpot.PlayerMoveEndDirection; newScript.Lines.Add(playerDirection); VO_Script_CallScript callScript = new VO_Script_CallScript(); callScript.Id = Guid.NewGuid(); callScript.Script = script; newScript.Lines.Add(callScript); ScriptManager.AddParallelScript(newScript); } else { VO_RunningScript runningScript = new VO_RunningScript(); runningScript.Id = script.Id; runningScript.Lines = script.Lines; switch (type) { case Enums.TriggerEventConditionType.Automatic: case Enums.TriggerEventConditionType.ClickEvent: case Enums.TriggerEventConditionType.ContactEvent: if (ScriptManager.CurrentScript == null) { ScriptManager.CurrentScript = runningScript; } break; case Enums.TriggerEventConditionType.ParallelProcess: ScriptManager.AddParallelScript(runningScript); break; } } }
/// <summary> /// Déplace un objet sur la scène /// </summary> /// <param name="pX">Position en X</param> /// <param name="pY">Position en Y</param> public void MoveObject(int x, int y) { if (EditorHelper.Instance.SelectedObjects.Count == 1 && ValidateObjectAction()) { VO_StageObject objectStage = EditorHelper.Instance.SelectedObjects[0]; Rectangle oldPosition = new Rectangle(objectStage.Location, objectStage.Size); objectStage.Location = new Point(EditorHelper.Instance.SelectedObjects[0].Location.X + x, EditorHelper.Instance.SelectedObjects[0].Location.Y + y); objectStage.Size = EditorHelper.Instance.SelectedObjects[0].Size; //Mouvement spécial hotspots if (objectStage.ObjectType == Enums.StageObjectType.HotSpots || objectStage.ObjectType == Enums.StageObjectType.Walkables || objectStage.ObjectType == Enums.StageObjectType.Regions) { int movX = objectStage.Location.X - oldPosition.X; int movY = objectStage.Location.Y - oldPosition.Y; VO_StageHotSpot hotspot = (VO_StageHotSpot)objectStage; MovePoints(hotspot.Points, movX, movY); } _KeyUp = true; this.StageNeedsToRefreshSelection(this, new EventArgs()); } ReloadItemChosen(); }