/// <summary> /// Rafraichi un calque /// </summary> /// <param name="layer"></param> /// <param name="main"></param> private void RefreshLayer(VO_Layer layer, bool main, bool moveOrAnimation) { //Decors foreach (VO_StageDecor item in layer.ListDecors) { Draw(SpriteManager.GetScreenSprite(item.Id)); } //Animations foreach (VO_StageAnimation item in layer.ListAnimations) { VO_AnimatedSprite anim = _Service.DrawAnimated(item); if (anim != null) { Draw(anim, _Service.GetRatioFromMatrix(new Point(item.Location.X, item.Location.Y), _ProjectData.Resolution.MatrixPrecision), moveOrAnimation); } if (moveOrAnimation && anim.CurrentSpriteIndex == 0 && anim.ReadyToExecScript) { _Service.ExecuteAnimationScript(item, Enums.TriggerExecutionType.BeginingAnimation); anim.ReadyToExecScript = false; } else if (moveOrAnimation && anim.CurrentSpriteIndex == anim.SpritesCount - 1 && anim.ReadyToExecScript) { _Service.ExecuteAnimationScript(item, Enums.TriggerExecutionType.EndingAnimation); anim.ReadyToExecScript = false; } } }
/// <summary> /// Charge les couleurs d'une matrice d'un calque /// </summary> /// <param name="pLayer">Calque</param> private void LoadNewMatrix(VO_Layer layer) { ColorMatrix opacity = new ColorMatrix(); opacity.Matrix33 = layer.ColorTransformations.Opacity / 255.0f; _Opacity.SetColorMatrix(opacity, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); }
/// <summary> /// Click sur delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDeleteLayer_Click(object sender, EventArgs e) { if (EditorHelper.Instance.GetCurrentStageInstance() != null && GrdLayers.SelectedRows.Count > 0) { Guid idLayer = new Guid(GrdLayers.SelectedRows[0].Cells[0].Value.ToString()); VO_Layer layer = EditorHelper.Instance.GetCurrentStageInstance().ListLayers.Find(p => p.Id == idLayer); if (!layer.MainLayer) { _Service.DeleteLayer(idLayer); GrdLayers.Rows.Remove(GrdLayers.SelectedRows[0]); //On force la sélection sur le premier élément. GrdLayers.ClearSelection(); GrdLayers.Rows[0].Selected = true; idLayer = new Guid(GrdLayers.Rows[0].Cells[0].Value.ToString()); EditorHelper.Instance.CurrentLayer = idLayer; GrdLayers_RowEnter(new DataGridViewCellEventArgs(0, 0)); this.LayerDeleted(this, new EventArgs()); } else { GrdLayers_RowEnter(new DataGridViewCellEventArgs(0, GrdLayers.SelectedRows[0].Index)); } } }
/// <summary> /// Rafraichi le ProjectPanel /// </summary> public void RefreshStageObjectsPanel() { if (EditorHelper.Instance.CurrentStage == Guid.Empty) { StageObjectsTreeView.Nodes.Clear(); return; } StageObjectsTreeView.Nodes.Clear(); VO_Layer currentLayer = EditorHelper.Instance.GetCurrentLayerInstance(); VO_Stage currentStage = EditorHelper.Instance.GetCurrentStageInstance(); switch (EditorHelper.Instance.CurrentStageState) { case Enums.StagePanelState.Decors: foreach (VO_StageDecor decor in currentLayer.ListDecors) { StageObjectsTreeView.Nodes.Add(decor.Id.ToString(), decor.Title, EditorConstants.STAGEOBJECTSPANEL_DECOR_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_DECOR_ACTIVE); } break; case Enums.StagePanelState.Objects: foreach (VO_StageAnimation anim in currentLayer.ListAnimations) { StageObjectsTreeView.Nodes.Add(anim.Id.ToString(), anim.Title, EditorConstants.STAGEOBJECTSPANEL_ANIMATION_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_ANIMATION_ACTIVE); } break; case Enums.StagePanelState.Characters: foreach (VO_StageCharacter character in currentStage.ListCharacters) { StageObjectsTreeView.Nodes.Add(character.Id.ToString(), character.Title, EditorConstants.STAGEOBJECTSPANEL_CHARACTER_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_CHARACTER_ACTIVE); } break; case Enums.StagePanelState.HotSpots: foreach (VO_StageHotSpot decor in currentStage.ListHotSpots) { StageObjectsTreeView.Nodes.Add(decor.Id.ToString(), decor.Title, EditorConstants.STAGEOBJECTSPANEL_HOTSPOT_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_HOTSPOT_ACTIVE); } break; case Enums.StagePanelState.WalkableAreas: foreach (VO_StageHotSpot decor in currentLayer.ListWalkableAreas) { StageObjectsTreeView.Nodes.Add(decor.Id.ToString(), decor.Title, EditorConstants.STAGEOBJECTSPANEL_WALK_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_WALK_ACTIVE); } break; case Enums.StagePanelState.Regions: foreach (VO_StageHotSpot decor in currentStage.ListRegions) { StageObjectsTreeView.Nodes.Add(decor.Id.ToString(), decor.Title, EditorConstants.STAGEOBJECTSPANEL_REGION_INACTIVE, EditorConstants.STAGEOBJECTSPANEL_REGION_ACTIVE); } break; } }
/// <summary> /// Supprime un calque /// </summary> /// <param name="pIdLayer">Id du calque à supprimer</param> public void DeleteLayer(Guid idLayer) { VO_Layer selectedLayer = null; List <VO_Layer> layers = EditorHelper.Instance.GetCurrentStageInstance().ListLayers; foreach (VO_Layer layer in layers) { if (!layer.MainLayer && layer.Id == idLayer) { selectedLayer = layer; } } selectedLayer.Delete(); }
public static VO_Layer CreateLayer(VO_Stage stage, string pTitle, int pLastOrdinal, bool pMain) { VO_Layer vLayer = new VO_Layer(); vLayer.Id = Guid.NewGuid(); vLayer.MainLayer = pMain; vLayer.Ordinal = pLastOrdinal; vLayer.ColorTransformations = new VO_ColorTransformation(); vLayer.ListAnimations = new List <VO_StageAnimation>(); vLayer.ListWalkableAreas = new List <VO_StageWalkable>(); vLayer.Title = pTitle; vLayer.ListDecors = new List <VO_StageDecor>(); vLayer.Stage = stage.Id; stage.ListLayers.Add(vLayer); return(vLayer); }
/// <summary> /// Survient lors d'une entrée dans la gridview /// </summary> /// <param name="e">Arguments contenant le numéro de ligne et colonne courant</param> private void GrdLayers_RowEnter(DataGridViewCellEventArgs e) { Guid idLayer = new Guid(GrdLayers.Rows[e.RowIndex].Cells[0].Value.ToString()); //Recherche et assignation du layer courant VO_Layer selectedLayer = EditorHelper.Instance.GetCurrentStageInstance().ListLayers.Find(p => p.Id == idLayer); if (selectedLayer.MainLayer) { BtnDeleteLayer.Enabled = false; } else { BtnDeleteLayer.Enabled = true; } }
public static VO_StageHotSpot CreateWalkableArea(VO_Layer layer, Point position) { if (layer.ListWalkableAreas.Count < GlobalConstants.PERF_MAX_WALK_PER_STAGE) { VO_StageWalkable newHotSpot = new VO_StageWalkable(); newHotSpot.Id = Guid.NewGuid(); newHotSpot.Title = GlobalConstants.WALK_NEW_ITEM; newHotSpot.ObjectType = Enums.StageObjectType.Walkables; newHotSpot.Stage = layer.Stage; newHotSpot.Points = new Point[1]; newHotSpot.Points[0] = position; newHotSpot.Layer = layer.Id; newHotSpot.Event = null; layer.ListWalkableAreas.Add(newHotSpot); return(newHotSpot); } MessageBox.Show(string.Format(Errors.STAGE_MAX_WALK, GlobalConstants.PERF_MAX_WALK_PER_STAGE), Errors.ERROR_BOX_TITLE); return(null); }
public static void CreateAnimation(VO_Layer layer, Point position, Guid animId) { if (layer.ListAnimations.Count < GlobalConstants.PERF_MAX_ANIMATION_PER_LAYERS) { VO_Animation animation = GameCore.Instance.GetAnimationById(animId); VO_StageAnimation newAnim = new VO_StageAnimation(); newAnim.Id = Guid.NewGuid(); newAnim.Title = animation.Title; newAnim.Location = position; newAnim.Size = new Size(animation.SpriteWidth, animation.SpriteHeight); newAnim.AnimationId = animId; newAnim.ObjectType = Enums.StageObjectType.Animations; newAnim.Stage = layer.Stage; newAnim.Layer = layer.Id; newAnim.Event = CreateEvent(Enums.EventType.Animation, animation.Id); layer.ListAnimations.Add(newAnim); } else { MessageBox.Show(string.Format(Errors.STAGE_MAX_ANIMATIONS, GlobalConstants.PERF_MAX_ANIMATION_PER_LAYERS), Errors.ERROR_BOX_TITLE); } }
/// <summary> /// Inverse les ordinaux de deux calques. /// </summary> /// <param name="pFirstLayer">Id du premier calque</param> /// <param name="pSecondLayer">Id du second calque</param> public void SwitchOrdinalBetweenLayers(Guid firstLayer, Guid secondLayer) { List <VO_Layer> layers = EditorHelper.Instance.GetCurrentStageInstance().ListLayers; VO_Layer voFirstLayer = null; VO_Layer voSecondLayer = null; int switchValue = 0; foreach (VO_Layer layer in layers) { if (layer.Id == firstLayer) { voFirstLayer = layer; } else if (layer.Id == secondLayer) { voSecondLayer = layer; } } switchValue = voFirstLayer.Ordinal; voFirstLayer.Ordinal = voSecondLayer.Ordinal; voSecondLayer.Ordinal = switchValue; }
/// <summary> /// Charge le panneau avec les données du calque /// </summary> public void LoadPanel() { List <VO_Layer> layers = EditorHelper.Instance.GetCurrentStageInstance().ListLayers; foreach (VO_Layer layer in layers) { if (layer.Id == EditorHelper.Instance.CurrentLayer) { CurrentLayer = layer; OriginalColorTransformations = new VO_ColorTransformation(); OriginalColorTransformations.Red = layer.ColorTransformations.Red; OriginalColorTransformations.Blue = layer.ColorTransformations.Blue; OriginalColorTransformations.Green = layer.ColorTransformations.Green; OriginalColorTransformations.Grey = layer.ColorTransformations.Grey; OriginalColorTransformations.Opacity = layer.ColorTransformations.Opacity; tbRed.Value = Convert.ToInt32(layer.ColorTransformations.Red); tbGreen.Value = Convert.ToInt32(layer.ColorTransformations.Green); tbBlue.Value = Convert.ToInt32(layer.ColorTransformations.Blue); tbGrey.Value = Convert.ToInt32(layer.ColorTransformations.Grey); tbOpacity.Value = Convert.ToInt32(layer.ColorTransformations.Opacity); } } }
public static void CreateDecor(VO_Layer layer, Point position, string file) { if (layer.ListDecors.Count < GlobalConstants.PERF_MAX_DECORS_PER_LAYERS) { //Récupérer la taille de l'image Size picSize = ImageManager.GetImageStageDecor(GameCore.Instance.Game.Project.RootPath + GlobalConstants.PROJECT_DIR_RESOURCES + file).Size; VO_StageDecor newDecor = new VO_StageDecor(); newDecor.Id = Guid.NewGuid(); newDecor.Title = Path.GetFileNameWithoutExtension(file); newDecor.Location = position; newDecor.Size = picSize; newDecor.Filename = file; newDecor.ObjectType = Enums.StageObjectType.Decors; newDecor.Stage = layer.Stage; newDecor.Layer = layer.Id; layer.ListDecors.Add(newDecor); } else { MessageBox.Show(string.Format(Errors.STAGE_MAX_DECORS, GlobalConstants.PERF_MAX_DECORS_PER_LAYERS), Errors.ERROR_BOX_TITLE); } }