/** * Constructor. * * @param sceneDataControl * Parent scene controller * @param activeArea * Exit of the data control structure */ public NodeDataControl(SceneDataControl sceneDataControl, Trajectory.Node node, Trajectory trajectory) { this.sceneDataControl = sceneDataControl; this.node = node; this.trajectory = trajectory; initial = false; }
public void Init(DialogReceiverInterface e, SceneDataControl scene, int exitIndex) { sceneRef = scene; calledExitIndexRef = exitIndex; string backgroundPath = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex].getPreviewBackground(); backgroundPreviewTex = AssetsController.getImage(backgroundPath).texture; activeAreaTex = (Texture2D)Resources.Load("Editor/ActiveArea", typeof(Texture2D)); exitTex = (Texture2D)Resources.Load("Editor/ExitArea", typeof(Texture2D)); selectedExitTex = (Texture2D)Resources.Load("Editor/SelectedArea", typeof(Texture2D)); imageBackgroundRect = new Rect(0f, 0f, backgroundPreviewTex.width, backgroundPreviewTex.height); x = sceneRef.getExitsList().getExitsList()[exitIndex].getX(); y = sceneRef.getExitsList().getExitsList()[exitIndex].getY(); width = sceneRef.getExitsList().getExitsList()[exitIndex].getWidth(); heigth = sceneRef.getExitsList().getExitsList()[exitIndex].getHeight(); HALF_WIDTH = (int)(0.5f * sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getWidth()); HALF_HEIGHT = (int)(0.5f * sceneRef.getExitsList().getExitsList()[calledExitIndexRef].getHeight()); base.Init(e, backgroundPreviewTex.width, backgroundPreviewTex.height); }
protected override void DrawInspector() { workingScene = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex]; GUILayout.Space(20); EditorGUI.BeginChangeCheck(); var playerMode = GetScenePlayerMode(workingScene); var playerModeTexts = new string[] { TC.get("Scene.NoPlayer"), TC.get("Scene.UseInitialPosition"), TC.get("Scene.UseTrajectory") }; playerMode = (PlayerMode)GUILayout.Toolbar((int)playerMode, playerModeTexts); if (EditorGUI.EndChangeCheck()) { OnPlayerModeChange(playerMode); } switch (playerMode) { case PlayerMode.NoPlayer: // No Player break; case PlayerMode.InitialPosition: // No trajectory break; case PlayerMode.Trajectory: // Trajectory { trajectoryComponent.Action = GUILayout.Toolbar(action, tools .Select(t => t.image ? new GUIContent(t.image, t.tooltip.Traslate()) : new GUIContent(t.text.Traslate())).ToArray()); } break; } }
public ChangeForcePlayerInSceneTool(bool isAllow, /*ScenePreviewEditionPanel scenePreviewEditionPanel,*/ SceneDataControl scene) { controller = Controller.getInstance(); this.isAllow = isAllow; //this.scenePreviewEditionPanel = scenePreviewEditionPanel; this.scene = scene; }
public override void OnSceneSelected(SceneDataControl scene) { base.OnSceneSelected(scene); exitsList.SetData(scene.getExitsList(), (dc) => (dc as ExitsListDataControl).getExits().Cast <DataControl>().ToList()); }
public void Init(DialogReceiverInterface e, SceneDataControl scene, int areaIndex) { sceneRef = scene; calledItemIndexRef = areaIndex; string backgroundPath = Controller.getInstance().getSelectedChapterDataControl().getScenesList() .getScenes()[GameRources.GetInstance().selectedSceneIndex].getPreviewBackground(); backgroundPreviewTex = AssetsController.getImage(backgroundPath).texture; selectedObjectTex = (Texture2D)Resources.Load("Editor/SelectedArea", typeof(Texture2D)); imageBackgroundRect = new Rect(0f, 0f, backgroundPreviewTex.width, backgroundPreviewTex.height); objectsTex = new List <Sprite>(); foreach ( ElementContainer element in Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex].getReferencesList().getAllReferencesDataControl()) { Debug.Log(element.getImage()); objectsTex.Add(element.getImage()); } base.Init(e, backgroundPreviewTex.width, backgroundPreviewTex.height); }
public ScenesWindowElementReference(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, aOptions) { clearImg = (Texture2D)Resources.Load("EAdventureData/img/icons/deleteContent", typeof(Texture2D)); addTexture = (Texture2D)Resources.Load("EAdventureData/img/icons/addNode", typeof(Texture2D)); moveUp = (Texture2D)Resources.Load("EAdventureData/img/icons/moveNodeUp", typeof(Texture2D)); moveDown = (Texture2D)Resources.Load("EAdventureData/img/icons/moveNodeDown", typeof(Texture2D)); if (GameRources.GetInstance().selectedSceneIndex >= 0) { currentIndex = GameRources.GetInstance().selectedSceneIndex; currentScene = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[currentIndex]; backgroundPath = currentScene.getPreviewBackground(); } if (backgroundPath != null && !backgroundPath.Equals("")) { backgroundPreviewTex = AssetsController.getImage(backgroundPath).texture; } conditionTex = (Texture2D)Resources.Load("EAdventureData/img/icons/no-conditions-24x24", typeof(Texture2D)); selectedElementSkin = (GUISkin)Resources.Load("Editor/EditorLeftMenuItemSkinConcreteOptions", typeof(GUISkin)); noBackgroundSkin = (GUISkin)Resources.Load("Editor/EditorNoBackgroundSkin", typeof(GUISkin)); selectedElement = null; addMenu = new AddItemActionMenu(); }
public override void OnSceneSelected(SceneDataControl scene) { base.OnSceneSelected(scene); if (scene != null) { referenceList.ReferencesListDataControl = scene.getReferencesList(); } }
public AddTrajectorySideTool(NodeDataControl startNode, NodeDataControl endNode, Trajectory trajectory, TrajectoryDataControl trajectoryDataControl, SceneDataControl sceneDataControl) { this.startNode = startNode; this.endNode = endNode; this.trajectory = trajectory; this.trajectoryDataControl = trajectoryDataControl; this.sceneDataControl = sceneDataControl; }
public AddTrajectoryNodeTool(Trajectory trajectory, TrajectoryDataControl trajectoryDataControl, int x, int y, SceneDataControl sceneDataControl) { this.trajectory = trajectory; this.trajectoryDataControl = trajectoryDataControl; this.x = x; this.y = y; this.sceneDataControl = sceneDataControl; this.wasInitial = false; }
public override void OnSceneSelected(SceneDataControl scene) { base.OnSceneSelected(scene); if (scene == null) { return; } barriersList.SetData(scene.getBarriersList(), (dc) => (dc as BarriersListDataControl).getBarriers().Cast <DataControl>().ToList()); }
// AUX FUNCTIONS private void DrawScene(SceneDataControl scene) { var rect = AdaptToViewport(GetSceneRect(scene), space); switch (Event.current.type) { case EventType.Repaint: GUI.DrawTexture(rect, images[scene.getPreviewBackground()] ?? noBackground); if (sceneList.index != -1 && Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[sceneList.index] == scene) { HandleUtil.DrawPolyLine(rect.ToPoints().ToArray(), true, Color.red); } break; } EditorGUI.DropShadowLabel(new Rect(rect.position - new Vector2(20, 0), rect.size), scene.getId()); var prevHot = GUIUtility.hotControl; EditorGUI.BeginChangeCheck(); rect = HandleUtil.HandleRectMovement(scene.GetHashCode(), rect); if (EditorGUI.EndChangeCheck()) { rect = RevertFromViewport(rect, space); if (settings != null) { var canvasRect = new Rect(0, 0, SPACE_WIDTH, SPACE_HEIGHT); sceneToNode[scene].BoundingBox = ToGraphRect(rect, canvasRect, graph.BoundingBox); UpdatePositions(); /*var bounds = * new Microsoft.Msagl.Core.Geometry.Rectangle(100, 100, 100 + rect.width, * 100 + rect.height); * * if (!sceneLockPositions.ContainsKey(scene)) * { * sceneLockPositions[scene] = settings.CreateLock(sceneToNode[scene], bounds); * } * * sceneLockPositions[scene].Bounds = bounds;*/ } else { positions[scene.getId()] = rect.position; } } if (GUIUtility.hotControl != prevHot) { sceneList.index = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes().IndexOf(scene); if (Event.current.clickCount == 2 && OnSelectElement != null) { OnSelectElement(scene); } } }
/** * Constructor. * * @param sceneDataControl * Parent scene controller * @param activeArea * Exit of the data control structure */ public ActiveAreaDataControl(SceneDataControl sceneDataControl, ActiveArea activeArea) { this.sceneDataControl = sceneDataControl; this.activeArea = activeArea; conditionsController = new ConditionsController(new Conditions()); this.influenceAreaDataControl = new InfluenceAreaDataControl(sceneDataControl, activeArea.getInfluenceArea(), this); descriptionsController = new DescriptionsController(activeArea.getDescriptions()); // Create subcontrollers actionsListDataControl = new ActionsListDataControl(activeArea.getActions(), this); }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param activeAreasList * List of activeAreas */ public ActiveAreasListDataControl(SceneDataControl sceneDataControl, List <ActiveArea> activeAreasList) { this.sceneDataControl = sceneDataControl; this.activeAreasList = activeAreasList; // Create subcontrollers activeAreasDataControlList = new List <ActiveAreaDataControl>(); foreach (ActiveArea activeArea in activeAreasList) { activeAreasDataControlList.Add(new ActiveAreaDataControl(sceneDataControl, activeArea)); } }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param exitsList * List of exits */ public ExitsListDataControl(SceneDataControl sceneDataControl, List <Exit> exitsList) { this.sceneDataControl = sceneDataControl; this.exitsList = exitsList; // Create subcontrollers exitsDataControlList = new List <ExitDataControl>(); foreach (Exit exit in exitsList) { exitsDataControlList.Add(new ExitDataControl(sceneDataControl, exit)); } }
public static PlayerMode GetScenePlayerMode(SceneDataControl scene) { if (!scene.isAllowPlayer()) { return(PlayerMode.NoPlayer); } else { var hasTrajectory = scene.getTrajectory().hasTrajectory(); return(hasTrajectory ? PlayerMode.Trajectory : PlayerMode.InitialPosition); } }
/** * Constructor. * * @param sceneDataControl * Parent scene controller * @param exit * Exit of the data control structure */ public ExitDataControl(SceneDataControl sceneDataControl, Exit exit) { this.sceneDataControl = sceneDataControl; this.exit = exit; this.influenceAreaDataControl = new InfluenceAreaDataControl(sceneDataControl, exit.getInfluenceArea(), this); effectsController = new EffectsController(exit.getEffects()); postEffectsController = new EffectsController(exit.getPostEffects()); notEffectsController = new EffectsController(exit.getNotEffects()); conditionsController = new ConditionsController(new Conditions()); exitLookDataControl = new ExitLookDataControl(exit); }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param itemReferencesList * List of item references */ public ReferencesListDataControl(string playerImagePath, SceneDataControl sceneDataControl, List <ElementReference> itemReferencesList, List <ElementReference> atrezzoReferencesList, List <ElementReference> npcReferencesList) { this.playerImagePath = playerImagePath; this.sceneDataControl = sceneDataControl; this.itemReferencesList = itemReferencesList; this.atrezzoReferencesList = atrezzoReferencesList; this.npcReferencesList = npcReferencesList; this.allReferencesDataControl = new List <ElementContainer>(); this.lastElementContainer = null; this.playerPositionInAllReferences = NO_PLAYER; this.imagePathHasChanged = false; // Check if one of references has layer -1: if it is true, it means that element references has no layer. // Create subcontrollers bool hasLayerV = hasLayer(); foreach (ElementReference itemReference in itemReferencesList) { int counter = count(itemReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, itemReference, Controller.ITEM_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } foreach (ElementReference atrezzoReference in atrezzoReferencesList) { int counter = count(atrezzoReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, atrezzoReference, Controller.ATREZZO_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } foreach (ElementReference npcReference in npcReferencesList) { int counter = count(npcReference); ElementReferenceDataControl erdc = new ElementReferenceDataControl(sceneDataControl, npcReference, Controller.NPC_REFERENCE, counter); insertInOrder(new ElementContainer(erdc, -1, null), hasLayerV); } // insert player // by default, if player don´t have layer, we give it to him. if (playerImagePath != null && (!Controller.getInstance().isPlayTransparent()) && sceneDataControl.isForcedPlayerLayer()) { int layer; if (sceneDataControl.getPlayerLayer() == Scene.PLAYER_WITHOUT_LAYER) { layer = 0; } else { layer = sceneDataControl.getPlayerLayer(); } reassignLayerAllReferencesDataControl(insertInOrder(new ElementContainer(null, layer, AssetsController.getImage(this.playerImagePath)), true)); } }
private Rect GetSceneRect(SceneDataControl scene) { if (!this.positions.ContainsKey(scene.getId())) { string id = GetScenePropertyId(Controller.Instance.SelectedChapterDataControl, scene); string X = ProjectConfigData.getProperty(id + ".X"); string Y = ProjectConfigData.getProperty(id + ".Y"); positions.Add(scene.getId(), new Vector2(ExParsers.ParseDefault(X, 0), ExParsers.ParseDefault(Y, 0))); } var background = scene.getPreviewBackground(); if (!sizes.ContainsKey(background)) { Texture2D scenePreview = null; Vector2 previewSize = new Vector2(800, 600); if (!images.ContainsKey(background)) { scenePreview = Controller.ResourceManager.getImage(background) ?? Controller.ResourceManager.getImage(SpecialAssetPaths.ASSET_EMPTY_IMAGE); images[background] = scenePreview; } else { scenePreview = images[background]; } if (scenePreview) { previewSize = new Vector2(scenePreview.width, scenePreview.height); } sizes.Add(background, previewSize); Color color; try { var pixel = scenePreview.GetPixel(scenePreview.width / 2, scenePreview.height / 2); var colorAsVector = ToHSV(new Color(1f - pixel.r, 1f - pixel.g, 1f - pixel.b)); colorAsVector.y *= 2f; colorAsVector.z *= 1.5f; color = FromHSV(colorAsVector); } catch { // Error getting the pixel color = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 0.5f, 1f, 1f, 1f); } sceneColors[background] = color; } return(new Rect(positions[scene.getId()], sizes[background] * SceneScaling)); }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param barriersList * List of activeAreas */ public BarriersListDataControl(SceneDataControl sceneDataControl, List <Barrier> barriersList) { this.sceneDataControl = sceneDataControl; this.barriersList = barriersList; // Create subcontrollers barriersDataControlList = new List <BarrierDataControl>(); foreach (Barrier barrier in barriersList) { barriersDataControlList.Add(new BarrierDataControl(sceneDataControl, barrier)); } id = barriersList.Count + 1; }
/** * Constructor. * * @param sceneDataControl * Link to the parent scene controller * @param itemReferencesList * List of item references */ public ReferencesListDataControl(string playerImagePath, SceneDataControl sceneDataControl) { this.playerImagePath = playerImagePath; this.sceneDataControl = sceneDataControl; this.typeReferenceList = new Dictionary <Type, List <ElementReference> >(); var content = sceneDataControl.getContent() as Scene; typeReferenceList.Add(typeof(Item), content.getItemReferences()); typeReferenceList.Add(typeof(Atrezzo), content.getAtrezzoReferences()); typeReferenceList.Add(typeof(NPC), content.getCharacterReferences()); this.allReferencesDataControl = new List <ElementContainer>(); this.lastElementContainer = null; this.playerPositionInAllReferences = NO_PLAYER; // Check if one of references has layer -1: if it is true, it means that element references has no layer. // Create subcontrollers bool hasLayerV = false; foreach (var itemReference in getReferencesList(typeof(Item))) { hasLayerV |= InsertReference(itemReference, Controller.ITEM_REFERENCE); } foreach (var atrezzoReference in getReferencesList(typeof(Atrezzo))) { hasLayerV |= InsertReference(atrezzoReference, Controller.ATREZZO_REFERENCE); } foreach (var npcReference in getReferencesList(typeof(NPC))) { hasLayerV |= InsertReference(npcReference, Controller.NPC_REFERENCE); } // insert player // by default, if player don´t have layer, we give it to him. if (playerImagePath != null && (!Controller.Instance.PlayTransparent) && sceneDataControl.isForcedPlayerLayer()) { int layer; if (sceneDataControl.getPlayerLayer() == Scene.PLAYER_WITHOUT_LAYER) { layer = 0; } else { layer = sceneDataControl.getPlayerLayer(); } reassignLayerAllReferencesDataControl(insertInOrder(new ElementContainer(null, layer, Controller.ResourceManager.getSprite(this.playerImagePath)), true)); } }
private Rect GetSceneRect(SceneDataControl scene, bool layoutCall) { var background = scene.getPreviewBackground(); if (!sizes.ContainsKey(background)) { Texture2D scenePreview = null; Vector2 previewSize = new Vector2(800, 600); if (!images.ContainsKey(background)) { scenePreview = Controller.ResourceManager.getImage(background) ?? Controller.ResourceManager.getImage(SpecialAssetPaths.ASSET_EMPTY_IMAGE); images[background] = scenePreview; } else { scenePreview = images[background]; } if (scenePreview) { previewSize = new Vector2(scenePreview.width, scenePreview.height); } sizes.Add(background, previewSize); Color color; try { var pixel = scenePreview.GetPixel(scenePreview.width / 2, scenePreview.height / 2); var colorAsVector = ToHSV(new Color(1f - pixel.r, 1f - pixel.g, 1f - pixel.b)); colorAsVector.y *= 2f; colorAsVector.z *= 1.5f; color = FromHSV(colorAsVector); } catch { // Error getting the pixel color = UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 0.5f, 1f, 1f, 1f); } sceneColors[scene.getId()] = color; } /*if (!layoutCall && positions[scene.getId()] == Vector2.zero) * { * Layout(false); * }*/ return(new Rect(positions[scene.getId()], sizes[background] * SCENE_SCALING)); }
protected override void DrawInspector() { workingScene = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[GameRources.GetInstance().selectedSceneIndex]; // Appearance table appearanceEditor.Data = workingScene; appearanceEditor.OnInspectorGUI(); GUILayout.Space(10); EditorGUI.BeginChangeCheck(); background.Path = workingScene.getPreviewBackground(); background.DoLayout(); if (EditorGUI.EndChangeCheck()) { workingScene.setPreviewBackground(background.Path); componentBasedEditor.RefreshSceneResources(workingScene); } EditorGUI.BeginChangeCheck(); foreground.Path = workingScene.getPreviewForeground(); foreground.DoLayout(); if (EditorGUI.EndChangeCheck()) { workingScene.setPreviewForeground(foreground.Path); componentBasedEditor.RefreshSceneResources(workingScene); } EditorGUI.BeginChangeCheck(); music.Path = workingScene.getPreviewMusic(); music.DoLayout(); if (EditorGUI.EndChangeCheck()) { workingScene.setPreviewMusic(music.Path); } GUILayout.Space(10); EditorGUI.BeginChangeCheck(); var newHideInventory = EditorGUILayout.Toggle("Scene.HideInventory".Traslate(), workingScene.HideInventory); if (EditorGUI.EndChangeCheck()) { workingScene.HideInventory = newHideInventory; } }
public void Init(DialogReceiverInterface e, SceneDataControl scene) { sceneRef = scene; string backgroundPath = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex].getPreviewBackground(); backgroundPreviewTex = (Texture2D)Resources.Load(backgroundPath.Substring(0, backgroundPath.LastIndexOf(".")), typeof(Texture2D)); string playerPath = Controller.getInstance().getSelectedChapterDataControl().getPlayer().getPreviewImage(); playerTex = (Texture2D)Resources.Load(playerPath.Substring(0, playerPath.LastIndexOf(".")), typeof(Texture2D)); selectedPlayerTex = (Texture2D)Resources.Load("Editor/SelectedArea", typeof(Texture2D)); editNodeTex = (Texture2D)Resources.Load("EAdventureData/img/icons/nodeEdit", typeof(Texture2D)); editSideTex = (Texture2D)Resources.Load("EAdventureData/img/icons/sideEdit", typeof(Texture2D)); setInitialNodeTex = (Texture2D)Resources.Load("EAdventureData/img/icons/selectStartNode", typeof(Texture2D)); deleteTex = (Texture2D)Resources.Load("EAdventureData/img/icons/deleteTool", typeof(Texture2D)); deleteTex = (Texture2D)Resources.Load("EAdventureData/img/icons/ScaleArea", typeof(Texture2D)); initialNodeTex = (Texture2D)Resources.Load("EAdventureData/img/icons/selectStartNode", typeof(Texture2D)); lineTex = (Texture2D)Resources.Load("Editor/LineTex", typeof(Texture2D)); selectedAreaSkin = (GUISkin)Resources.Load("Editor/ButtonSelected", typeof(GUISkin)); imageBackgroundRect = new Rect(0f, 0f, backgroundPreviewTex.width, backgroundPreviewTex.height); playerRect = new Rect(0f, 0f, playerTex.width, playerTex.height); useTrajectory = sceneRef.getTrajectory().hasTrajectory(); useInitialPosition = useInitialPositionLast = !useTrajectory; trajectory = sceneRef.getTrajectory().GetTrajectory(); x = sceneRef.getDefaultInitialPositionX(); y = sceneRef.getDefaultInitialPositionY(); playerRect = new Rect(x, y, playerTex.width, playerTex.height); base.Init(e, backgroundPreviewTex.width, backgroundPreviewTex.height); }
private void DrawExit(SceneDataControl scene, ExitDataControl exit) { var scenes = Controller.Instance.SelectedChapterDataControl.getScenesList(); var index = scenes.getSceneIndexByID(exit.getNextSceneId()); // If the exit points to a cutscene it normally is out of the array if (index < 0 || index > scenes.getScenes().Count) { return; } var polygon = AdaptToViewport(GetExitArea(scene, exit), space); if (polygon == null || polygon.Length == 0) { // If the exit is empty use the scene center itself to prevent errors polygon = new [] { AdaptToViewport(GetSceneRect(scene), space).center }; } var c = sceneColors[scene.getId()]; c = new Color(c.r, c.g, c.b, 0.8f); HandleUtil.DrawPolygon(polygon, c); var nextScene = scenes.getScenes()[index]; var sceneRect = AdaptToViewport(GetSceneRect(nextScene), space); Vector2 origin = polygon.Center(), destination; if (exit.hasDestinyPosition()) { destination = new Vector2(exit.getDestinyPositionX(), exit.getDestinyPositionY()); destination.x = sceneRect.x + (destination.x / sizes[nextScene.getPreviewBackground()].x) * sceneRect.width; destination.y = sceneRect.y + (destination.y / sizes[nextScene.getPreviewBackground()].y) * sceneRect.height; } else { destination = sceneRect.ToPoints().Center(); } HandleUtil.DrawPolyLine(new [] { origin, destination }, false, sceneColors[scene.getId()], 4); DrawArrowCap(destination, (destination - origin), 15f); }
public override bool moveElementDown(DataControl dataControl) { bool elementMoved = false; int elementIndex = scenesList.IndexOf((Scene)dataControl.getContent()); if (elementIndex < scenesList.Count - 1) { Scene s = scenesList[elementIndex]; SceneDataControl c = scenesDataControlList[elementIndex]; scenesList.RemoveAt(elementIndex); scenesDataControlList.RemoveAt(elementIndex); scenesList.Insert(elementIndex + 1, s); scenesDataControlList.Insert(elementIndex + 1, c); controller.DataModified(); elementMoved = true; } return(elementMoved); }
/** * Contructor. * * @param sceneDataControl * Parent scene controller * @param elementReference * Element reference of the data control structure */ public ElementReferenceDataControl(SceneDataControl sceneDataControl, ElementReference elementReference, int type, int referenceNumber) { this.sceneDataControl = sceneDataControl; this.elementReference = elementReference; this.type = type; this.visible = true; if (type == Controller.ITEM_REFERENCE || type == Controller.NPC_REFERENCE) { this.influenceAreaDataControl = new InfluenceAreaDataControl(sceneDataControl, elementReference.getInfluenceArea(), this); } // Create subcontrollers Dictionary <string, ConditionsController.ConditionContextProperty> context1 = new Dictionary <string, ConditionsController.ConditionContextProperty>(); ConditionsController.ConditionOwner parent = new ConditionsController.ConditionOwner(Controller.SCENE, sceneDataControl.getId()); ConditionsController.ConditionOwner owner = new ConditionsController.ConditionOwner(type, elementReference.getTargetId(), parent); context1.Add(ConditionsController.CONDITION_OWNER, owner); conditionsController = new ConditionsController(elementReference.getConditions(), context1); }
/** * Constructor. * * @param sceneDataControl * Parent scene controller * @param activeArea * Exit of the data control structure */ public BarrierDataControl(SceneDataControl sceneDataControl, Barrier barrier) { this.sceneDataControl = sceneDataControl; this.barrier = barrier; // Create subcontrollers Dictionary <string, ConditionsController.ConditionContextProperty> context1 = new Dictionary <string, ConditionsController.ConditionContextProperty>(); ConditionsController.ConditionOwner parent = new ConditionsController.ConditionOwner(Controller.SCENE, sceneDataControl.getId()); ConditionsController.ConditionOwner owner = new ConditionsController.ConditionOwner(Controller.BARRIER, barrier.getId(), parent); context1.Add(ConditionsController.CONDITION_OWNER, owner); conditionsController = new ConditionsController(barrier.getConditions(), context1); descriptionController = new DescriptionsController(barrier.getDescriptions()); //Barriers can only have name, and only one description, so we set selectedDEscription to 0 descriptionController.setSelectedDescription(0); }
private Vector2[] GetExitArea(SceneDataControl scene, ExitDataControl exit, bool layoutCall) { var holder = GetSceneRect(scene, layoutCall); var xRatio = holder.width / images[scene.getPreviewBackground()].width; var yRatio = holder.height / images[scene.getPreviewBackground()].height; Vector2[] polygon = null; var rectangle = exit.getRectangle(); if (rectangle.isRectangular()) { polygon = new Rect(rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight()).ToPoints(); } else { polygon = rectangle.getPoints().ToArray(); } return(polygon.ToList().ConvertAll(p => (new Vector2(p.x * xRatio, p.y * yRatio) + holder.position)).ToArray()); }
// AUX FUNCTIONS private void DrawScene(SceneDataControl scene) { var rect = AdaptToViewport(GetSceneRect(scene), space); switch (Event.current.type) { case EventType.Repaint: GUI.DrawTexture(rect, images[scene.getPreviewBackground()] ?? noBackground); if (sceneList.index != -1 && Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[sceneList.index] == scene) { HandleUtil.DrawPolyLine(rect.ToPoints().ToArray(), true, Color.red); } break; } EditorGUI.DropShadowLabel(new Rect(rect.position - new Vector2(20, 0), rect.size), scene.getId()); var prevHot = GUIUtility.hotControl; EditorGUI.BeginChangeCheck(); rect = HandleUtil.HandleRectMovement(scene.GetHashCode(), rect); if (EditorGUI.EndChangeCheck()) { rect = RevertFromViewport(rect, space); positions[scene.getId()] = rect.position; // Update in the project data var id = GetScenePropertyId(Controller.Instance.SelectedChapterDataControl, scene); ProjectConfigData.setProperty(id + ".X", ((int)positions[scene.getId()].x).ToString()); ProjectConfigData.setProperty(id + ".Y", ((int)positions[scene.getId()].y).ToString()); } if (GUIUtility.hotControl != prevHot) { sceneList.index = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes().IndexOf(scene); if (Event.current.clickCount == 2) { OnSelectElement(scene); } } }