void LoadLevel( MapCurve curve, int mapIndex ) { if( currentLevel != null ) currentLevel.Unload(); currentLevel = Level.Load( mapCurve.Levels[ mapIndex ] ); currentLevelIndex = mapIndex; }
protected void UpdateCamera() { base.OnRender(); //float outCurveTime; //Update camera orientation if (Map.Instance != null) { //moveTime = Time; Vec3 position; Vec3 forward; //Vec3 up; Degree fov; MapCamera mapCamera = GetMapCamera(); if (mapCamera == null) { return; } //iNCIN if (cameraCurves == null) { return; } //curve ///////////////////////////////////////////////////////////// MapCurve mapCurve = (MapCurve)Entities.Instance.GetByName("MM_Curve"); //insert curve name here if (moveTime >= mapCurve.GetCurveMaxTime()) { moveTime -= mapCurve.GetCurveMaxTime(); } mapCamera.Position = mapCurve.CalculateCurvePointByTime(moveTime); mapCamera.Rotation = mapCurve.CalculateCurveRotationByTime(moveTime); //real Camera///////////////////////////////////////////////////////////// position = mapCamera.Position; forward = mapCamera.Rotation * new Vec3(1, 0, 0); fov = mapCamera.Fov; if (fov == 0) { fov = Map.Instance.Fov; } Camera camera = RendererWorld.Instance.DefaultCamera; camera.NearClipDistance = Map.Instance.NearFarClipDistance.Minimum; camera.FarClipDistance = Map.Instance.NearFarClipDistance.Maximum; camera.FixedUp = Vec3.ZAxis; camera.Fov = fov; camera.Position = position; camera.Direction = forward; } }
protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); if (way == entity) { way = null; } }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary> protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); if (entity == mapCamera) mapCamera = null; if (entity == mapCurve) mapCurve = null; }
// protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); if (way == entity) way = null; if (activateRegion == entity) activateRegion = null; }
// protected override void OnRelatedEntityDelete( Entity entity ) { base.OnRelatedEntityDelete( entity ); if( way == entity ) way = null; if( activateRegion == entity ) activateRegion = null; }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnRelatedEntityDelete(Entity)"/></summary> protected override void OnRelatedEntityDelete( Entity entity ) { base.OnRelatedEntityDelete( entity ); if( entity == mapCamera ) mapCamera = null; if( entity == mapCurve ) mapCurve = null; }
void LoadLevel(MapCurve curve, int mapIndex) { if (currentLevel != null) { currentLevel.Unload(); } currentLevel = Level.Load(mapCurve.Levels[mapIndex]); currentLevelIndex = mapIndex; }
private void UpdateCameramain() { //Update camera orientation if (Map.Instance != null) { moveTime = Time; Vec3 position; Vec3 forward; Degree fov; MapCamera mapCamera = GetMapCamera(); if (mapCamera == null) { return; } //curve MapCurve mapCurve = (MapCurve)Entities.Instance.GetByName("MM_Curve"); //Insert curve name here if (moveTime >= mapCurve.GetCurveMaxTime()) { moveTime -= mapCurve.GetCurveMaxTime(); } if (moveTime < 0) { moveTime = 0; } mapCamera.Position = mapCurve.CalculateCurvePointByTime(moveTime); mapCamera.Rotation = mapCurve.CalculateCurveRotationByTime(moveTime); //real Camera///////////////////////////////////////////////////////////// position = mapCamera.Position; forward = mapCamera.Rotation * new Vec3(1, 0, 0); fov = mapCamera.Fov; if (fov == 0) { fov = Map.Instance.Fov; } // damn ///////////////////////////////////////////////////////////////// Camera camera = RendererWorld.Instance.DefaultCamera; camera.NearClipDistance = Map.Instance.NearFarClipDistance.Minimum; camera.FarClipDistance = Map.Instance.NearFarClipDistance.Maximum; camera.FixedUp = Vec3.ZAxis; camera.Fov = fov; camera.Position = position; camera.Direction = forward;// LookAt( position + forward * 100 ); } }
void Task(MapCurve way) { task_way = way; task_current_waypoint = null; if (task_way != null) { task_current_waypoint = task_way; } ResetTask(); }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnRelatedEntityDelete(Entity)"/></summary> protected override void OnRelatedEntityDelete(Entity entity) { base.OnRelatedEntityDelete(entity); if (entity == mapCamera) { mapCamera = null; } if (entity == mapCurve) { mapCurve = null; } }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary> protected override void OnDeleteSubscribedToDeletionEvent(Entity entity) { base.OnDeleteSubscribedToDeletionEvent(entity); if (entity == mapCamera) { mapCamera = null; } if (entity == mapCurve) { mapCurve = null; } }
// protected override void OnRelatedEntityDelete(Entity entity) { base.OnRelatedEntityDelete(entity); if (way == entity) { way = null; } if (activateRegion == entity) { activateRegion = null; } }
private void DoGeneralTask(MapCurve way) { TaskWay = way; CurrentWayPoint = null; if (TaskWay != null && CurrentWayPoint == null) { CurrentWayPoint = TaskWay; } if (CurrentWayPoint != null) { firstWay = false; } }
private void DoGeneralTask(GeneralTaskTypes type, MapCurve way) { generalTaskType = type; generalTaskWay = way; generalTaskCurrentWayPoint = null; if (generalTaskWay != null) { generalTaskCurrentWayPoint = generalTaskWay; } //if( generalTaskType == GeneralTaskTypes.None ) ResetMoveTask(); }
public void ActivateWayMovement() { MapCurve way = null; { EntityComponent_ForTankDemo component = (EntityComponent_ForTankDemo) ControlledObject.Component_GetFirstWithType(typeof(EntityComponent_ForTankDemo)); if (component != null) { way = component.Way; } } if (way != null) { DoGeneralTask(GeneralTaskTypes.WayMove, way); } }
public void ActivateWayMovement() { MapCurve way = null; { TankGameExtendedProperties extendedProperties = ControlledObject.ExtendedProperties as TankGameExtendedProperties; if (extendedProperties != null) { way = extendedProperties.Way; } } if (way != null) { DoGeneralTask(GeneralTaskTypes.WayMove, way); } }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary> protected override void OnPostCreate(bool loaded) { base.OnPostCreate(loaded); SubscribeToTickEvent(); MapCurve way = null; { EntityComponent_SSDC component = (EntityComponent_SSDC) ControlledObject.Component_GetFirstWithType(typeof(EntityComponent_SSDC)); if (component != null) { way = component.Way; } } if (way != null) { Task(way); } }
private void GetMapCameraCurvePoint(out MapCurvePoint point, float MapCameraCurvePointTime) { point = null; //MapCameraCurvePointTime = 0; MapCurve mapCurve = (MapCurve)Entities.Instance.GetByName("MM_Curve"); //MapCameraCurvePoint curvepoint; //for(int i = 0; i < mapCurve.Points.Count; i++) foreach (MapCurvePoint curvepoint in mapCurve.Points) { //curvepoint = mapCurve.Points. if (curvepoint.Time >= mapCurve.GetCurveTimeRange().Minimum&& curvepoint.Time >= mapCurve.GetCurveTimeRange().Maximum) { point = curvepoint; return; } } }
private void DoGeneralTask(GeneralTaskTypes type, MapCurve way) { generalTaskType = type; }
void DoGeneralTask( GeneralTaskTypes type, MapCurve way ) { generalTaskType = type; generalTaskWay = way; generalTaskCurrentWayPoint = null; if( generalTaskWay != null ) generalTaskCurrentWayPoint = generalTaskWay; //if( generalTaskType == GeneralTaskTypes.None ) ResetMoveTask(); }
private void DoGeneralTask(GeneralTaskTypes type, MapCurve way) { generalTaskType = type; }
private void DoGeneralTask(GeneralTaskTypes type, MapCurve way) { generalTaskType = type; generalTaskWay = way; generalTaskCurrentWayPoint = null; switch (generalTaskType) { case GeneralTaskTypes.Battle: case GeneralTaskTypes.EnemyFlag: case GeneralTaskTypes.Leave: case GeneralTaskTypes.None: case GeneralTaskTypes.Patrol: case GeneralTaskTypes.PrimaryTargets: case GeneralTaskTypes.SecondaryTargets: case GeneralTaskTypes.TeamFlag: case GeneralTaskTypes.WayMove: { if (generalTaskWay != null) generalTaskCurrentWayPoint = generalTaskWay; break; } } if (generalTaskType == GeneralTaskTypes.None) ResetMoveTask(); }
/// <summary> /// Finds the nearest point to a map curve. /// </summary> /// <param name="destPos">The point to which is searched the nearest.</param> /// <param name="mapCurve">The map curve.</param> /// <returns>The nearest point to a map curve.</returns> Vec3 GetNearestPointToMapCurve( Vec3 destPos, MapCurve mapCurve ) { //Calculate cached points if( observeCameraMapCurvePoints != mapCurve ) { observeCameraMapCurvePoints = mapCurve; observeCameraMapCurvePointsList.Clear(); float curveLength = 0; { ReadOnlyCollection<MapCurvePoint> points = mapCurve.Points; for( int n = 0; n < points.Count - 1; n++ ) curveLength += ( points[ n ].Position - points[ n + 1 ].Position ).LengthFast(); } float step = 1.0f / curveLength / 100; for( float c = 0; c < 1; c += step ) observeCameraMapCurvePointsList.Add( mapCurve.CalculateCurvePointByCoefficient( c ) ); } //calculate nearest point Vec3 nearestPoint = Vec3.Zero; float nearestDistanceSqr = float.MaxValue; foreach( Vec3 point in observeCameraMapCurvePointsList ) { float distanceSqr = ( point - destPos ).LengthSqr(); if( distanceSqr < nearestDistanceSqr ) { nearestPoint = point; nearestDistanceSqr = distanceSqr; } } return nearestPoint; }
private void DoGeneralTask(MapCurve way) { TaskWay = way; CurrentWayPoint = null; if (TaskWay != null && CurrentWayPoint == null) { CurrentWayPoint = TaskWay; } if (CurrentWayPoint != null) { firstWay = false; } }
private void GraphicPanel_OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (DrawMode.Checked) { createdCurve = new MapCurve(); createdCurve.AddPoint(e.Location); curves.Add(createdCurve); } else { if (LinkToFH.Checked) { if (EditTile.Checked || EditObj.Checked) { MapFootholds group = Map.Instance.layers[(int)Layer.Value].GetFootholdGroupAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (group != null) { foreach (MapItem s in selected) { s.Object.SetInt("zM", group.ID); if (s is ICached) (s as ICached).Cache(); } if (selectedGroup != null) { selectedGroup.Selected = false; } selectedGroup = group; selectedGroup.Selected = true; } } return; } else if (FootholdsCreator.Checked) { if (EditFH.Checked) { MapFootholdDesign fh = Map.Instance.layers[(int)Layer.Value].GetFootholdDesignAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (fh != null) { if (!FHCreating.Contains(fh)) { FHCreating.Add(fh); } } else { if (FHCreating.Count > 0) { CreateFootholds(FHCreating); FHCreating.Clear(); } } } else if (EditLR.Checked) { MapLRDesign lr = Map.Instance.layers[(int)Layer.Value].GetLRDesignAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (lr != null && !LRCreating.Contains(lr)) { if (LRCreating.Count > 0) { if (LRCreating[0].GetX() == lr.GetX() && LRCreating[0].ladder == lr.ladder) { LRCreating.Add(lr); CreateLRs(LRCreating); LRCreating.Clear(); } } else { LRCreating.Add(lr); } } else { LRCreating.Clear(); } } return; } //GraphicPanel.Focus(); if (EditMode.Checked && Map.Instance != null && !dragged) { if (EditTile.Checked || EditObj.Checked || EditLife.Checked || EditReactor.Checked || EditBack.Checked) { if (Map.Instance.layers[(int)Layer.Value].GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)) == null) { draggingSelection = true; selectingX = e.X; selectingY = e.Y; if (!CtrlPressed && !ShiftPressed) { Deselect(); } } else { if (CtrlPressed && selected.Count > 0) { MapItem at = Map.Instance.layers[(int)Layer.Value].GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (at != null) { if (selected.Contains(at)) { selected.Remove(at); at.Selected = false; if (selected.Count == 0) Deselect(); else if (selected.Count == 1 && EditObj.Checked) toolStripStatusLabel1.Text = "Z: " + selected[0].Object.GetInt("z"); } else { selected.Add(at); at.Selected = true; toolStripStatusLabel1.Text = ""; } } } else { if (EditTile.Checked && selected.Count == 1 && selected[0].IsPointInArea((int)(e.X / Zoom), (int)(e.Y / Zoom))) { dragged = true; selectedDragged = selected[0]; sX = e.X; sY = e.Y; } else { MapItem at = Map.Instance.layers[(int)Layer.Value].GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (selected.Count > 1 && at != null && (selected.Contains(at))) { dragged = true; selectedDragged = at; sX = e.X; sY = e.Y; } else { Deselect(); if (at != null) { selected.Add(at); at.Selected = true; if (EditObj.Checked) toolStripStatusLabel1.Text = "Z: " + at.Object.GetInt("z"); } } } } } if (EditTile.Checked) Map.Instance.layers[(int)Layer.Value].OrderTiles(); } else if (EditFH.Checked) { if (Map.Instance.layers[(int)Layer.Value].GetConnectionAt((int)(e.X / Zoom), (int)(e.Y / Zoom)).Count == 0) { draggingSelection = true; selectingX = e.X; selectingY = e.Y; if (!CtrlPressed && !ShiftPressed) { Deselect(); } } else { if (CtrlPressed && selected.Count > 0) { List<MapFootholdSide> list = Map.Instance.layers[(int)Layer.Value].GetConnectionAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (list.Count > 0) { if (selected.Contains(list[0])) { foreach (MapFootholdSide f in list) { selected.Remove(f); f.Selected = false; } if (selected.Count == 0) Deselect(); } else { foreach (MapFootholdSide f in list) { selected.Add(f); f.Selected = true; } } } } else { List<MapFootholdSide> list = Map.Instance.layers[(int)Layer.Value].GetConnectionAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (selected.Count > 2 && list.Count > 0 && selected.Contains(list[0])) { dragged = true; selectedDragged = list[0]; if (list.Count > 1) selectedDragged2 = list[1]; sX = e.X; sY = e.Y; } else { Deselect(); if (list.Count > 0) { foreach (MapFootholdSide f in list) { selected.Add(f); f.Selected = true; } } } } } } else if (EditLR.Checked) { MapLRSide lr = Map.Instance.layers[(int)Layer.Value].GetLRSideAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (lr != null && selected.Contains(lr)) { dragged = true; selectedDragged = lr; sX = e.X; sY = e.Y; } else { Deselect(); if (lr != null) { selected.Add(lr); lr.Selected = true; } } } else if (EditSeat.Checked || EditPortal.Checked || EditToolTip.Checked || EditClock.Checked) { MapItem item = null; item = Map.Instance.GetItemAt((int)(e.X / Zoom), (int)(e.Y / Zoom)); if (item != null && selected.Contains(item)) { dragged = true; selectedDragged = item; sX = e.X; sY = e.Y; } else { Deselect(); if (item != null) { selected.Add(item); item.Selected = true; } } } } if (selected.Count > 0) { bool clickedIn = false; foreach (MapItem s in selected) { if (s.IsPointInArea((int)(e.X / Zoom), (int)(e.Y / Zoom))) { clickedIn = true; } } if (clickedIn) { dragged = true; sX = e.X; sY = e.Y; lastX = e.X; lastY = e.Y; } } if (selected.Count == 1) { toolStripStatusLabel1.Text = selected[0].ToString(); } } if (scrolling) { scrolling = false; Cursor = Cursors.Default; } } else if (e.Button == MouseButtons.Middle) { wheelClicked = true; scrolling = true; scrollingDragged = false; scrollPosition = new Point(e.X - ShiftX, e.Y - ShiftY); if (vScrollBar1.Visible && hScrollBar1.Visible) { Cursor = Cursors.NoMove2D; } else if (vScrollBar1.Visible) { Cursor = Cursors.NoMoveVert; } else if (hScrollBar1.Visible) { Cursor = Cursors.NoMoveHoriz; } else { scrolling = false; } } }
private void GraphicPanel_OnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (DrawMode.Checked) { if (!createdCurve.Close()) curves.Remove(createdCurve); else { try { createdCurve.Simplify(); } catch { curves.Remove(createdCurve); } } createdCurve = null; } else { MagnetDisable(); if (draggingSelection) { if (selectingX != e.X && selectingY != e.Y) { int x1 = (int)(selectingX / Zoom), x2 = (int)(e.X / Zoom); int y1 = (int)(selectingY / Zoom), y2 = (int)(e.Y / Zoom); if (x1 > x2) { x1 = (int)(e.X / Zoom); x2 = (int)(selectingX / Zoom); } if (y1 > y2) { y1 = (int)(e.Y / Zoom); y2 = (int)(selectingY / Zoom); } List<MapItem> items; if (EditFH.Checked) { items = Map.Instance.layers[(int)Layer.Value].GetConnectionsAt(new Rectangle(x1, y1, x2 - x1, y2 - y1)); } else { items = Map.Instance.layers[(int)Layer.Value].GetItemsAt(new Rectangle(x1, y1, x2 - x1, y2 - y1)); } foreach (MapItem item in items) { if (selected.Contains(item) && CtrlPressed) { selected.Remove(item); item.Selected = false; } else if (!selected.Contains(item)) { selected.Add(item); item.Selected = true; } } if (selected.Count == 1 && EditObj.Checked) toolStripStatusLabel1.Text = "Z: " + selected[0].Object.GetInt("z"); } draggingSelection = false; TempChanged.Clear(); } else { if (dragged && (sX != e.X || sY != e.Y)) { undo.Push(new ActionMove(new List<MapItem>(selected), e.X - sX, e.Y - sY)); redo.Clear(); } dragged = false; if (selectedDragged != null) { if (e.X == sX && e.Y == sY) { Deselect(); selected.Add(selectedDragged); selectedDragged.Selected = true; if (selectedDragged2 != null) { selected.Add(selectedDragged2); selectedDragged2.Selected = true; } if (EditObj.Checked) toolStripStatusLabel1.Text = "Z: " + selectedDragged.Object.GetInt("z"); } selectedDragged = null; selectedDragged2 = null; } } if (EditTile.Checked) Map.Instance.layers[(int)Layer.Value].OrderTiles(); } } else if (e.Button == MouseButtons.Middle) { wheelClicked = false; if (scrollingDragged) { scrolling = false; Cursor = Cursors.Default; } } }