public void SetClickMode(EasyFlow easyflow, CLICK_MODE clickMode) { if (this.clickMode != clickMode) { this.clickMode = clickMode; // Remove previous ClickCover ClickCover cc = GetComponent <ClickCover>(); if (cc != null) { cc.OnBeforeDestroy(); DestroyImmediate(cc); } if (clickMode != CLICK_MODE.None) { // Add new ClickCover if (this is Cover_NGUI) { cc = gameObject.AddComponent <ClickCover_NGUI>(); } if (this is Cover_Quad) { cc = gameObject.AddComponent <ClickCover_Quad>(); } if (this is Cover_UGUI) { cc = gameObject.AddComponent <ClickCover_UGUI>(); } // Initalize cc.OnAfterCreated(easyflow, this); } } }
private CLICK_MODE DrawClickModeGrid(CLICK_MODE clickMode, int index, int count, bool isMini) { CLICK_MODE newMode = clickMode; EditorGUILayout.BeginHorizontal(); { for (int i = index; i < index + count; ++i) { if (clickMode == (CLICK_MODE)i) { GUILayout.Button(clickModeStrs[i], isMini ? onMiniStyle : onStyle); } else { if (GUILayout.Button(clickModeStrs[i], isMini ? offMiniStyle : offStyle)) { newMode = (CLICK_MODE)i; } } } } EditorGUILayout.EndHorizontal(); return(newMode); }
private void move() { if (xy.ClickMode != CLICK_MODE.MOVE && xy.ClickMode != CLICK_MODE.RESIZE) { lastClickMode = xy.ClickMode; } xy.ClickMode = CLICK_MODE.MOVE; xz.ClickMode = CLICK_MODE.MOVE; yz.ClickMode = CLICK_MODE.MOVE; }
void add() { if (xy.ClickMode == CLICK_MODE.NEW_CUBE || lastClickMode == CLICK_MODE.NEW_CUBE) { addCube(); } else if (xy.ClickMode == CLICK_MODE.NEW_SPHERE || lastClickMode == CLICK_MODE.NEW_SPHERE) { addSphere(); } lastClickMode = CLICK_MODE.SELECT_AREA; resetList(); removeRectangles(); setLines(); }
private void Init() { #region Cover coverCount = 0; coverCountLimit = 100; coverSize = new Vector2(120.0f, 90.0f); coverSizeLimit = new Vector2(200.0f, 200.0f); coverAngle = 0.0f; coverDistanceF = 100.0f; coverDistanceLimit = 200.0f; distanceRange = 0.0f; coverDistanceZ = 0.0f; coverDistanceZLimit = 200.0f; coverDistanceZMode = COVER_DISTANCE_Z_MODE.Disable; #endregion Cover #region Click clickMode = CLICK_MODE.None; #endregion Click #region Texture textureList = new List <Texture>(); textureMode = TEXTURE_MODE.Loop; #endregion Texture #region Drag dragPower = 1.0f; dragPowerLimit = 3.0f; dragMode = DRAG_MODE.OnScreen; dragRect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); isInverseDrag = BOOL.No; isDragOnAxis = BOOL.Yes; #endregion Drag #region Effect After Drag isEffectAfterDrag = BOOL.Yes; isMoveToNearCover = BOOL.Yes; effectAfterDragTime = 1.0f; effectAfterDragTimeLimit = 3.0f; effectAfterDragCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0.0f, 0.0f, 0.0f, 3.0f), new Keyframe(1.0f, 1.0f, 0.0f, 0.0f) }); #endregion Effect After Drag #region Position positionRate = 1.0f; positionRateLimit = 10.0f; positionInfluenceRange = 200.0f; positionInfluenceRangeLimit = 1000.0f; positionCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0.0f, 0.0f, 0.0f, 3.0f), new Keyframe(1.0f, 1.0f, 0.0f, 0.0f) }); #endregion Position #region Rotate isLookatCenter = BOOL.Yes; isRotateOnAxis = BOOL.Yes; rotateRate = 60.0f; rotateRateLimit = 120.0f; rotateInfluenceRange = 100.0f; rotateInfluenceRangeLimit = 200.0f; rotateCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0.0f, 0.0f, 0.0f, 3.0f), new Keyframe(1.0f, 1.0f, 0.0f, 0.0f) }); #endregion Rotate #region Scale scaleRate = 0.5f; scaleRateLimit = new Vector2(-1.0f, 2.0f); scaleInfluenceRange = 100.0f; scaleInfluenceRangeLimit = 200.0f; scaleCurve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f); #endregion Scale #region Alpha alphaRate = 1.0f; alphaRateLimit = 2.0f; alphaInfluenceRange = 300.0f; alphaInfluenceRangeLimit = 600.0f; alphaCurve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f); #endregion Alpha #region Depth panelDepth = 0.0f; panelDepthLimit = new Vector2(0.0f, 100.0f); coverDepth = new Vector2(0.0f, 1000.0f); coverDepthLimit = new Vector2(-1000.0f, 1000.0f); depthInfluenceRange = 500.0f; depthInfluenceRangeLimit = 1000.0f; depthCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0.0f, 0.0f, 0.0f, 3.0f), new Keyframe(1.0f, 1.0f, 0.0f, 0.0f) }); #endregion Depth #region Other isPanelMove = BOOL.No; beginFlowIndex = 0.0f; coverMode = COVER_MODE.Disabled; #endregion Other }
private void comboBoxRightClickMode_SelectedIndexChanged(object sender, EventArgs e) { modeRight = (CLICK_MODE)comboBoxRightClickMode.SelectedIndex; }
private void levelPanel_MouseMove(object sender, MouseEventArgs e) { if (selected != -1) { oldMouse = new System.Drawing.Point(newMouse.X, newMouse.Y); newMouse = levelPanel.PointToClient(Cursor.Position); newMouse.X += levelPanel.HorizontalScroll.Value; newMouse.Y += levelPanel.VerticalScroll.Value; level.solids[selected].position += new Vector2(newMouse.X - oldMouse.X, newMouse.Y - oldMouse.Y); level.solids[selected].position = snap(level.solids[selected].position); } else { newMouse = levelPanel.PointToClient(Cursor.Position); newMouse.X += levelPanel.HorizontalScroll.Value; newMouse.Y += levelPanel.VerticalScroll.Value; oldMouse = new System.Drawing.Point(newMouse.X, newMouse.Y); if (checkBoxSnap.Checked && (Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed || Mouse.GetState().RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)) { CLICK_MODE clickMode = modeRight; if (Mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { clickMode = modeLeft; } bool canDragPlace = true; for (int i = 0; i < level.solids.Length && canDragPlace; i++) { SolidData solid = level.solids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { canDragPlace = false; } } for (int i2 = 0; i2 < level.zombieSpawners.Length && canDragPlace; i2++) { Vector2 spawner = level.zombieSpawners[i2]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= spawner.X) && (mouse.Y >= spawner.Y) && (mouse.X <= spawner.X + textures[2].Image.Width) && (mouse.Y <= spawner.Y + textures[2].Image.Height)) { canDragPlace = false; } } for (int i = 0; i < level.backSolids.Length && canDragPlace && comboBoxLeftClickMode.SelectedIndex == 5; i++) { SolidData solid = level.backSolids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { canDragPlace = false; } } for (int i = 0; i < level.foreSolids.Length && canDragPlace && comboBoxLeftClickMode.SelectedIndex == 6; i++) { SolidData solid = level.foreSolids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { canDragPlace = false; } } if (clickMode == CLICK_MODE.DELETE) { canDragPlace = true; } if (canDragPlace) { alterLevelElement(newMouse, clickMode); } } } }
private void alterLevelElement(System.Drawing.Point levelPanelScrollPos, CLICK_MODE clickMode) { updateScrollPos(); if (clickMode == CLICK_MODE.PLACE) { if (selectedSolidTexture) { SolidData[] newSolids = new SolidData[level.solids.Length + 1]; for (int i = 0; i < level.solids.Length; i++) { newSolids[i] = level.solids[i]; } System.Drawing.Point point = levelPanel.PointToClient(Cursor.Position); point.X += levelPanel.HorizontalScroll.Value; point.Y += levelPanel.VerticalScroll.Value; point.X -= textures[comboBoxSolidTexture.SelectedIndex].Image.Width / 2; point.Y -= textures[comboBoxSolidTexture.SelectedIndex].Image.Height / 2; point = snap(point); newSolids[level.solids.Length] = new SolidData(new Vector2(point.X, point.Y), comboBoxSolidTexture.SelectedIndex, Microsoft.Xna.Framework.Color.White); level.solids = newSolids; PutPicturesInPanel(); } } if (clickMode == CLICK_MODE.DELETE) { bool deletedSomething = false; for (int i = 0; i < level.solids.Length; i++) { SolidData solid = level.solids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { int newLength = level.solids.Length - 1; SolidData[] newSolids = new SolidData[newLength]; bool foundDeleted = false; for (int i2 = 0; i2 < level.solids.Length; i2++) { if (foundDeleted) { newSolids[i2 - 1] = level.solids[i2]; } else { if (i == i2) { foundDeleted = true; } else { newSolids[i2] = level.solids[i2]; } } } level.solids = newSolids; deletedSomething = true; break; } } if (!deletedSomething) { for (int i = 0; i < level.foreSolids.Length; i++) { SolidData solid = level.foreSolids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { int newLength = level.foreSolids.Length - 1; SolidData[] newSolids = new SolidData[newLength]; bool foundDeleted = false; for (int i2 = 0; i2 < level.foreSolids.Length; i2++) { if (foundDeleted) { newSolids[i2 - 1] = level.foreSolids[i2]; } else { if (i == i2) { foundDeleted = true; } else { newSolids[i2] = level.foreSolids[i2]; } } } level.foreSolids = newSolids; deletedSomething = true; break; } } } if (!deletedSomething) { for (int i2 = 0; i2 < level.zombieSpawners.Length; i2++) { Vector2 spawner = level.zombieSpawners[i2]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= spawner.X) && (mouse.Y >= spawner.Y) && (mouse.X <= spawner.X + textures[2].Image.Width) && (mouse.Y <= spawner.Y + textures[2].Image.Height)) { int newLength = level.zombieSpawners.Length - 1; Vector2[] newSpawners = new Vector2[newLength]; bool foundDeleted = false; for (int i3 = 0; i3 < level.zombieSpawners.Length; i3++) { if (foundDeleted) { newSpawners[i3 - 1] = level.zombieSpawners[i3]; } else { if (i2 == i3) { foundDeleted = true; } else { newSpawners[i3] = level.zombieSpawners[i3]; } } } level.zombieSpawners = newSpawners; break; } } } if (!deletedSomething) { for (int i = 0; i < level.backSolids.Length; i++) { SolidData solid = level.backSolids[i]; System.Drawing.Point mouse = levelPanel.PointToClient(Cursor.Position); mouse.X += levelPanel.HorizontalScroll.Value; mouse.Y += levelPanel.VerticalScroll.Value; if ((mouse.X >= solid.position.X) && (mouse.Y >= solid.position.Y) && (mouse.X <= solid.position.X + textures[solid.textureNo].Image.Width) && (mouse.Y <= solid.position.Y + textures[solid.textureNo].Image.Height)) { int newLength = level.backSolids.Length - 1; SolidData[] newSolids = new SolidData[newLength]; bool foundDeleted = false; for (int i2 = 0; i2 < level.backSolids.Length; i2++) { if (foundDeleted) { newSolids[i2 - 1] = level.backSolids[i2]; } else { if (i == i2) { foundDeleted = true; } else { newSolids[i2] = level.backSolids[i2]; } } } level.backSolids = newSolids; deletedSomething = true; break; } } } PutPicturesInPanel(); } if (clickMode == CLICK_MODE.PLAYER) { System.Drawing.Point point = levelPanel.PointToClient(Cursor.Position); //System.Drawing.Point point = new System.Drawing.Point(levelPanel.PointToClient(Cursor.Position).X - textures[2].Image.Width / 2, // levelPanel.PointToClient(Cursor.Position).Y - textures[2].Image.Height / 2); point.X -= textures[2].Image.Width / 2; point.Y -= textures[2].Image.Height / 2; point = snap(point); level.playerSpawn.X = point.X + levelPanel.HorizontalScroll.Value; level.playerSpawn.Y = point.Y + levelPanel.VerticalScroll.Value; PutPicturesInPanel(); } if (clickMode == CLICK_MODE.ZOMBIE) { Vector2[] newSpawns = new Vector2[level.zombieSpawners.Length + 1]; for (int i = 0; i < level.zombieSpawners.Length; i++) { newSpawns[i] = level.zombieSpawners[i]; } System.Drawing.Point point = levelPanel.PointToClient(Cursor.Position); point.X += levelPanel.HorizontalScroll.Value; point.Y += levelPanel.VerticalScroll.Value; point.X -= textures[2].Image.Width / 2; point.Y -= textures[2].Image.Height / 2; point = snap(point); newSpawns[level.zombieSpawners.Length] = new Vector2(point.X, point.Y); level.zombieSpawners = newSpawns; PutPicturesInPanel(); } if (clickMode == CLICK_MODE.POINTER) { //not implemented } if (clickMode == CLICK_MODE.BACKGROUND) { if (selectedSolidTexture) { SolidData[] newSolids = new SolidData[level.backSolids.Length + 1]; for (int i = 0; i < level.backSolids.Length; i++) { newSolids[i] = level.backSolids[i]; } System.Drawing.Point point = levelPanel.PointToClient(Cursor.Position); point.X += levelPanel.HorizontalScroll.Value; point.Y += levelPanel.VerticalScroll.Value; point.X -= textures[comboBoxSolidTexture.SelectedIndex].Image.Width / 2; point.Y -= textures[comboBoxSolidTexture.SelectedIndex].Image.Height / 2; point = snap(point); newSolids[level.backSolids.Length] = new SolidData(new Vector2(point.X, point.Y), comboBoxSolidTexture.SelectedIndex, Microsoft.Xna.Framework.Color.White); level.backSolids = newSolids; PutPicturesInPanel(); } } if (clickMode == CLICK_MODE.FOREGROUND) { if (selectedSolidTexture) { SolidData[] newSolids = new SolidData[level.foreSolids.Length + 1]; for (int i = 0; i < level.foreSolids.Length; i++) { newSolids[i] = level.foreSolids[i]; } System.Drawing.Point point = levelPanel.PointToClient(Cursor.Position); point.X += levelPanel.HorizontalScroll.Value; point.Y += levelPanel.VerticalScroll.Value; point.X -= textures[comboBoxSolidTexture.SelectedIndex].Image.Width / 2; point.Y -= textures[comboBoxSolidTexture.SelectedIndex].Image.Height / 2; point = snap(point); newSolids[level.foreSolids.Length] = new SolidData(new Vector2(point.X, point.Y), comboBoxSolidTexture.SelectedIndex, Microsoft.Xna.Framework.Color.White); level.foreSolids = newSolids; PutPicturesInPanel(); } } }
private void GUIClickMode() { CLICK_MODE newMode = selectedEasyflow.saveData.clickMode; EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Select - Click Mode", new GUIStyle("BoldLabel"), GUILayout.ExpandWidth(true)); newMode = DrawClickModeGrid(selectedEasyflow.saveData.clickMode, 0, 3, false); newMode = DrawClickModeGrid(newMode, 4, 3, false); } if (EditorGUI.EndChangeCheck()) { if (newMode != selectedEasyflow.saveData.clickMode) { selectedEasyflow.saveData.clickMode = newMode; if (selectedEasyflow.saveData.clickMode != CLICK_MODE.Custom) { foreach (var v in selectedEasyflow.coverList) { v.SetClickMode(selectedEasyflow, selectedEasyflow.saveData.clickMode); } } } } if (selectedEasyflow.saveData.clickMode == CLICK_MODE.Custom) { GUILayout.Space(spaceInMenu); clickScrollViewPos = GUILayout.BeginScrollView(clickScrollViewPos, GUILayout.Height(200.0f)); { foreach (var v in selectedEasyflow.coverList) { GUILayout.BeginHorizontal(); { GUILayout.Label(v.name, nameStyle, GUILayout.Width(76.0f)); GUILayout.BeginVertical(); { newMode = DrawClickModeGrid(v.clickMode, 0, 3, true); newMode = DrawClickModeGrid(newMode, 4, 2, true); if (newMode != v.clickMode) { v.SetClickMode(selectedEasyflow, newMode); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(1.0f); } } GUILayout.EndScrollView(); } GUILayout.Space(spaceInMenu); if (selectedEasyflow.saveData.clickMode != CLICK_MODE.None) { EditorGUILayout.LabelField("Callback - OnClick", new GUIStyle("BoldLabel"), GUILayout.ExpandWidth(true)); if (selectedEasyflow != null) { float height = 18.0f * selectedEasyflow.callbackList.Count + 2.0f; if (height > 100.0f) { height = 100.0f; } callbackScrollViewPos = EditorGUILayout.BeginScrollView(callbackScrollViewPos, GUILayout.Height(height)); { foreach (var v in selectedEasyflow.callbackList) { Undo.RecordObject(selectedEasyflow, "NAsoft - Click Callback"); EditorGUILayout.BeginHorizontal(GUILayout.Height(16.0f)); { EditorGUI.BeginChangeCheck(); { v.DrawTargetField(true, GUILayout.Height(16.0f)); v.DrawMemberField(); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(selectedEasyflow); } if (GUILayout.Button("X", GUILayout.Width(16.0f), GUILayout.Height(14.0f))) { selectedEasyflow.callbackList.Remove(v); EditorGUILayout.EndHorizontal(); break; } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); } if (GUILayout.Button("Add new callback")) { selectedEasyflow.callbackList.Add(new Connector(typeof(Cover), typeof(int), typeof(string))); } } }