public override void Start() { base.Start(); Debug.WriteLine("Paused"); Engine.TimeModifier = 0f; var background = new RectangleObject(Engine.Width, Engine.Height) { Color = Color.FromArgb(125, 0, 0, 0), Fill = true, Order = 10, IgnoreCamera = true }; Engine.SpawnObject("pause_background", background); var pauseText = new TextObject(1.33f, Color.White) { Text = "PAUSE", IgnoreCamera = true }; //DarkGreen var pauseTextSize = pauseText.Measure(); pauseText.X = Engine.Width / 2f - pauseTextSize.X / 2; pauseText.Y = Engine.Height / 2f - pauseTextSize.Y / 2; pauseText.Order = 11; Engine.SpawnObject("pause_text", pauseText); AudioSource.Pause(); Hud.Instance.SpawnStats(); }
//Sets up the inner rectangles based on their rotation orientation public void InitialSetupInnerRectangles(RotateEnum rotate) { switch (rotate) { case RotateEnum.DoNotRotate: upperRectangle = new RectangleObject(rectangle.X, rectangle.Y, upperRectangleColor, new Size(rectangle.Width, upperRectangleHeigt)); lowerRectangle = new RectangleObject(rectangle.X, rectangle.Y + upperRectangleHeigt, lowerRectangleColor, new Size(rectangle.Width, lowerRectangleHeight)); break; case RotateEnum.Rotate90: upperRectangle = new RectangleObject(rectangle.X, rectangle.Y, upperRectangleColor, new Size(upperRectangleHeigt, rectangle.Width)); lowerRectangle = new RectangleObject(rectangle.X + upperRectangleHeigt, rectangle.Y, lowerRectangleColor, new Size(lowerRectangleHeight, rectangle.Width)); //base.Rotate(); break; case RotateEnum.Rotate180: upperRectangle = new RectangleObject(rectangle.X, rectangle.Y + lowerRectangleHeight, upperRectangleColor, new Size(rectangle.Width, upperRectangleHeigt)); lowerRectangle = new RectangleObject(rectangle.X, rectangle.Y, lowerRectangleColor, new Size(rectangle.Width, lowerRectangleHeight)); break; case RotateEnum.Rotate270: upperRectangle = new RectangleObject(rectangle.X + lowerRectangleHeight, rectangle.Y, upperRectangleColor, new Size(upperRectangleHeigt, rectangle.Width)); lowerRectangle = new RectangleObject(rectangle.X, rectangle.Y, lowerRectangleColor, new Size(lowerRectangleHeight, rectangle.Width)); //base.Rotate(); break; } }
private void StartGameOver() { Engine.TimeModifier = 0f; AudioSource.Pause(); MainWindow = "gameover"; var background = new RectangleObject(Engine.Width, Engine.Height) { Color = Color.FromArgb(125, 0, 0, 0), Fill = true, Order = 10, IgnoreCamera = true }; Engine.SpawnObject("gameover_background", background); var gameOver = new TextObject(1.33f, Color.White)//Color.Red) { Text = "GAMEOVER", Order = 11, IgnoreCamera = true }; // replace with alignment.center or use TextObject.Measure var gameOverSize = gameOver.Measure(); gameOver.X = Engine.Width / 2f - gameOverSize.X / 2; gameOver.Y = Engine.Height / 2f - gameOverSize.Y / 2; Engine.SpawnObject("gameover_text", gameOver); Timer.Set("gameOverTimer", GameOverDelay, ignoreTimeModifier: true); }
private RectangleObject CreateRectangleObject(XmlNode node) { var rectangleObject = new RectangleObject(); SetObjectProperties(rectangleObject, node); return(rectangleObject); }
void Start() { this.EntitiesOnTile = new List <Entity>(); RectangleObject tileObject = GetComponent <RectangleObject>(); Vector2Int tileMapPosition = Vector2Int.FloorToInt(tileObject.TmxPosition / tileObject.TmxSize); Map.Tiles[tileMapPosition] = this; }
public override void MouseDown(SchetsControl s, Point p) { base.MouseDown(s, p); mDrawingObject = new RectangleObject() { Color = s.PenColor, Filled = false, Position = p, Size = new Size(0, 0), LineWidth = s.PenSize }; s.Schets.BeginAddObject(mDrawingObject); }
/// <summary> /// 마우스 업 이벤트 /// DrawObject 의 추가, 선택, 이동, 사이즈 변경 등 후에 마우스 클릭을 놓으면 이벤트가 마무리 된다. /// </summary> private void DrawBox_MouseUp(object sender, MouseEventArgs e) { //마우스 왼쪽 버튼이 클릭된 상태였고, DrawObjectType 이 선택하기가 아닐 때, if (e.Button == MouseButtons.Left && !(MainController.Instance.DrawObjectType == DrawObjectType.Select)) { //DrawBox 의 상태를 아무것도 지정하지 않는다. MainController.Instance.SelectMode = SelectMode.None; //새롭게 추가되어 그려진 DrawObject 를 최종 상태로 설정한다. MainController.Instance.GraphicModel.GrapList[0].Normalize(); //Pencil 변수를 null 로 초기화 한다. this.mNewPencil = null; MainController.Instance.Notify(ObserverAction.Select); } else { ////DrawBox 의 상태가 영역으로 선택하기 일 때 if (MainController.Instance.SelectMode == SelectMode.NetSelection) { ControlPaint.DrawReversibleFrame(this.RectangleToScreen(RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mLastPoint)), Color.Black, FrameStyle.Dashed); //모든 DrawObject 의 선택을 해제한다. this.UnSelectAll(); //마우스의 처음과 마지막 위치 만큼의 Rectangle 을 생성한다. Rectangle rec = RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mLastPoint); //rec 의 영역에 DrawObject 가 포함된다면 선택된걸로 설정한다. foreach (DrawObject o in MainController.Instance.GraphicModel.GrapList) { if (o.IntersectsWith(rec)) { o.Selected = true; } } //DrawBox 의 상태를 아무것도 지정하지 않는다. MainController.Instance.SelectMode = SelectMode.None; } //DrawObjec 의 사이즈 변경 변수가 Null 이 아니라면 변경된 된 크기만큼 최종적으로 설정해준다. if (this.mResizedObject != null) { this.mResizedObject.Normalize(); this.mResizedObject = null; } //DrawBox 의 Paint 이벤트를 호출한다. this.Invalidate(false); } //마우스 캡쳐를 해제한다. this.Capture = false; }
private void AddRectangleObjectComponentsTo(GameObject gameObject, XElement goXml) { var xml = goXml.Element("RectangleObjectComponent"); if (xml != null) { RectangleObject tmxRectangle = gameObject.AddComponent <Tiled2Unity.RectangleObject>(); FillBaseTmxObjectProperties(tmxRectangle, xml); } }
private void CreateRectangleObject() { @interface.RemoveLayerObject(CurrentObject); CurrentObject = new GroupSelectable(); RectangleObject obj = new RectangleObject(); obj.X = (int)_mouseMoving.FirstCorner.X; obj.Y = (int)_mouseMoving.FirstCorner.Y; obj.ObjectCategory = @interface.FocusedObjectCategory; obj.Size = Size.Empty; CurrentObject.AddObject(obj); @interface.AddLayerObject(CurrentObject); @interface.AddGameObject(obj); }
public static void SpritesGameDemo() { Velotage3DGameEngine.AudioSource.AudioSource.MODPlayer("lintro.xm"); Game mygame = new Game("VeloTage 3D - Demo"); mygame.BackgroundColor = Color.White; TriangleObject mytritobj = new TriangleObject(Color.Cyan); RectangleObject myrectobj = new RectangleObject(Color.Purple); SpriteObject mysprite = new SpriteObject(Color.Chocolate); mygame.AddObject(myrectobj); mygame.AddObject(mytritobj); mygame.AddObject(mysprite); mygame.Run(mygame.game); }
//Generates four smaller rectanlges based on the space's rectangle. public void GenerateQuadrants() { quadrants = new RectangleObject[4]; int spaceWidth = GetWidth(); int spaceHeight = GetHeight(); int quadrantWidth = spaceWidth / 2; int quadrantHeight = spaceHeight / 2; int spaceBeginX = GetX(); int spaceBeginY = GetY(); quadrants[0] = new RectangleObject(spaceBeginX, spaceBeginY, new Size(quadrantWidth, quadrantHeight)); quadrants[1] = new RectangleObject(spaceBeginX + quadrantWidth, spaceBeginY, new Size(quadrantWidth, quadrantHeight)); quadrants[2] = new RectangleObject(spaceBeginX, spaceBeginY + quadrantHeight, new Size(quadrantWidth, quadrantHeight)); quadrants[3] = new RectangleObject(spaceBeginX + quadrantWidth, spaceBeginY + quadrantHeight, new Size(quadrantWidth, quadrantHeight)); }
private void ProcessRectangleObject(Quadtree <GameObject> hash, RectangleObject obj, Action <GameObject, BaseObject> func) { var entity = new GameObject(); var bounds = CCollisionBound.Rectangle(new Vector2(obj.Width, obj.Height)); var position = new CPosition(new Vector2(obj.X, obj.Y)); entity.Components.Add(bounds); entity.Components.Add(position); func(entity, obj); hash.Add(entity, new RectangleF( position.Position.X, position.Position.Y, bounds.Bounds.Width, bounds.Bounds.Height )); }
/// <summary> /// 重载鼠标移动事件 /// </summary> /// <param name="e"></param> protected override void OnViewMouseMove(System.Windows.Forms.MouseEventArgs e) { LastMessageTick = System.Environment.TickCount; if (bolCaptureMouse == false) { this.SetCursor(System.Windows.Forms.Cursors.IBeam); } // 进行坐标转换 System.Drawing.Point myPoint = new System.Drawing.Point(e.X, e.Y); if (e.Button == System.Windows.Forms.MouseButtons.Left && this.AllowDrop) { RectangleObject myRect = new RectangleObject(); myRect.SetRect(intStartCaptureX, intStartCaptureY, myPoint.X, myPoint.Y); if (myRect.Width > System.Windows.Forms.SystemInformation.DragSize.Width || myRect.Height > System.Windows.Forms.SystemInformation.DragSize.Height) { // 开始进行拖拽处理 if (OnStartDrag(myPoint.X, myPoint.Y)) { return; } } } // 计算移动步长 intLastMouseDX = myPoint.X - intLastMouseX; intLastMouseDY = myPoint.Y - intLastMouseY; if (myDocument != null) { if (myDocument.ViewMouseMove(myPoint.X, myPoint.Y, e.Button)) { intLastMouseX = myPoint.X; intLastMouseY = myPoint.Y; return; } } intLastMouseX = myPoint.X; intLastMouseY = myPoint.Y; base.OnViewMouseMove(e); }
private void StartEvent(object sender) { CurrentSprite = (SpriteAsset)Engine.GetAsset("player_animated_2_0"); //var fWidth = Width; //var fHeight = Height; SpellManager.Mask = (GameObject enemy) => enemy is Enemy; X = Engine.Width / 2 - Width / 2; Y = Engine.Height / 2 - Height / 2; Order = 9; redWindow = new RectangleObject(Engine.Width, Engine.Height) { Name = "redWindow", Color = Color.FromArgb(155, 255, 0, 0), X = 0, Y = 0, Fill = true, Order = Order + 1, IgnoreCamera = true }; redWindow.Box.scale = Vector2.Zero; Engine.SpawnObject("redWindow", redWindow); // Load animations var idleName = GetMovingStateString(MovingState.Idle); var movingLeftName = GetMovingStateString(MovingState.MovingLeft); var movingRightName = GetMovingStateString(MovingState.MovingRight); var movingDownName = GetMovingStateString(MovingState.MovingDown); var movingUpName = GetMovingStateString(MovingState.MovingUp); var baseSpriteName = "player_animated"; AddAnimation(idleName, Utils.GetAssetName(baseSpriteName, 1, 0), 5).Loop = false; AddAnimation(movingRightName, Utils.GetAssetName(baseSpriteName, 0, 2, 3), 5); AddAnimation(movingLeftName, Utils.GetAssetName(baseSpriteName, 0, 1, 3), 5); AddAnimation(movingUpName, Utils.GetAssetName(baseSpriteName, 0, 3, 3), 5); AddAnimation(movingDownName, Utils.GetAssetName(baseSpriteName, 0, 0, 3), 5); //CalculateAnimationHitBoxes(); }
public override void Start() { base.Start(); Name = "map_borders"; BlocksWithHitBox = false; BlockW = 32; //(blockAsset).sprite.Width; BlockH = 32; //(blockAsset).sprite.Height; base.Start(); BlockObject = () => { var rectangleBlock = new RectangleObject(BlockW, BlockH) { Color = Color.SandyBrown, Fill = true, Order = 10, IgnoreCamera = true }; return(rectangleBlock); }; SpawnBorders(); var roomWidth = (Engine.Width - BlockW * 2) / Game.Game.Instance.CurrentFloor.MapWidth; var roomHeight = (Engine.Height - BlockH * 2) / Game.Game.Instance.CurrentFloor.MapHeight; if (Game.Game.Instance.CurrentFloor.MapWidth >= Game.Game.Instance.CurrentFloor.MapHeight) { roomHeight = (int)(roomWidth / 1.77); } else if (Game.Game.Instance.CurrentFloor.MapHeight > Game.Game.Instance.CurrentFloor.MapWidth) { roomWidth = (int)(roomHeight * 1.77); } var paddingX = (Engine.Width - roomWidth * Game.Game.Instance.CurrentFloor.MapWidth - BlockW * 2) / 2 + BlockW; var paddingY = (Engine.Height - roomHeight * Game.Game.Instance.CurrentFloor.MapHeight - BlockH * 2) / 2 + BlockH; for (var bx = 0; bx < Game.Game.Instance.CurrentFloor.MapWidth; bx++) { for (var by = 0; by < Game.Game.Instance.CurrentFloor.MapHeight; by++) { if (Game.Game.Instance.CurrentFloor.Rooms[bx, by] != null) { //Room room = Game.Instance.currentFloor.rooms [x, y]; var mapObj = new RectangleObject(roomWidth - roomWidth / 5, roomHeight - roomHeight / 5) { Color = Game.Game.Instance.CurrentFloor.Rooms[bx, by] == Game.Game.Instance.CurrentFloor.CurrentRoom ? Color.Green : (Game.Game.Instance.CurrentFloor.Rooms[bx, by].Enemies.Count > 0 ? Color.SaddleBrown : Color.Wheat), Fill = true, X = paddingX + roomWidth * bx + roomHeight / 10, Y = paddingY + roomHeight * by + roomWidth / 10, Order = 10, IgnoreCamera = true }; Debug.WriteLine("Spawning map block at: {0}.{1}", mapObj.X, mapObj.Y); Engine.SpawnObject($"map_border_{bx}_{by}", mapObj); } } } }
//Reads text file and generates board spaces. //Creates 40 spaces public void LoadBoardFromFile() { //Determines the dimensions of the spaces and the starting //locations for the four board lanes. double sizeMultiplier = FormatManager.GetSizeMultiplier(); int SpaceSize = (int)((size.Width / 11) * sizeMultiplier); int LaneOneY = SpaceSize * 9 + SpaceSize; int LaneTwoX = 0; int LaneThreeY = 0; int LaneFourX = SpaceSize * 9 + SpaceSize; //Variables for reading the text file int i = 1; int x = 0; int id; String spaceType; String line; String[] lineSplit; char token = ','; reader = new StreamReader(fileLocation); //Add the four constant spaces and the inner board (rectangle within board). innerBoard = new RectangleObject(LaneTwoX + SpaceSize, LaneThreeY + SpaceSize, new Size(SpaceSize * 9, SpaceSize * 9)); boardSpaces.Add(new JailSpace(JAIL_SPACE_ID, LaneOneY, LaneOneY, Color.White, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); boardSpaces.Add(new FreeParkingSpace(FREE_PARKING_SPACE_ID, LaneTwoX, LaneOneY, Color.White, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); boardSpaces.Add(new GoToJailSpace(GO_TO_JAIL_SPACE_ID, LaneTwoX, LaneThreeY, Color.White, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); boardSpaces.Add(new GoSpace(GO_SPACE_ID, LaneFourX, LaneThreeY, Color.White, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); //Reads the whole file and generates a board space for each line while (!reader.EndOfStream) { line = reader.ReadLine(); lineSplit = line.Split(token); spaceType = lineSplit[0]; //Moves to next lane once the lane is filled if (i == 10) { i = 1; x++; } //Keeps the id consistent across lanes id = (i + (x * 10)); //Used to determine what kind of board space to create //Each case is a space type and each if is a lane switch (spaceType) { case "Property": Property property = new Property(lineSplit[1], int.Parse(lineSplit[2]), 0, Color.FromName(lineSplit[3].Trim())); if (x == 0) { boardSpaces.Add(new PropertySpace(id, LaneFourX, (i * SpaceSize) + (SpaceSize - SpaceSize), property, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); } else if (x == 1) { boardSpaces.Add(new PropertySpace(id, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), LaneOneY, property, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); } else if (x == 2) { boardSpaces.Add(new PropertySpace(id, LaneTwoX, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), property, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); } else { boardSpaces.Add(new PropertySpace(id, (i * SpaceSize) + (SpaceSize - SpaceSize), LaneThreeY, property, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); } break; case "Railroad": Railroad railroad = new Railroad(lineSplit[1], int.Parse(lineSplit[2])); if (x == 0) { boardSpaces.Add(new RailroadSpace(id, LaneFourX, (i * SpaceSize) + (SpaceSize - SpaceSize), railroad, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); } else if (x == 1) { boardSpaces.Add(new RailroadSpace(id, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), LaneOneY, railroad, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); } else if (x == 2) { boardSpaces.Add(new RailroadSpace(id, LaneTwoX, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), railroad, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); } else { boardSpaces.Add(new RailroadSpace(id, (i * SpaceSize) + (SpaceSize - SpaceSize), LaneThreeY, railroad, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); } break; case "CommunityChest": if (x == 0) { boardSpaces.Add(new CommunityChestSpace(id, LaneFourX, (i * SpaceSize) + (SpaceSize - SpaceSize), new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); } else if (x == 1) { boardSpaces.Add(new CommunityChestSpace(id, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), LaneOneY, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); } else if (x == 0) { boardSpaces.Add(new CommunityChestSpace(id, LaneTwoX, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); } else { boardSpaces.Add(new CommunityChestSpace(id, (i * SpaceSize) + (SpaceSize - SpaceSize), LaneThreeY, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); } break; case "Chance": if (x == 0) { boardSpaces.Add(new ChanceSpace(id, LaneFourX, (i * SpaceSize) + (SpaceSize - SpaceSize), new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); } else if (x == 1) { boardSpaces.Add(new ChanceSpace(id, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), LaneOneY, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); } else if (x == 2) { boardSpaces.Add(new ChanceSpace(id, LaneTwoX, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); } else { boardSpaces.Add(new ChanceSpace(id, (i * SpaceSize) + (SpaceSize - SpaceSize), LaneThreeY, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); } break; case "Utility": Utility utility = new Utility(lineSplit[1], 100); if (x == 0) { boardSpaces.Add(new UtilitySpace(id, LaneFourX, (i * SpaceSize) + (SpaceSize - SpaceSize), utility, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate90)); } else if (x == 1) { boardSpaces.Add(new UtilitySpace(id, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), LaneOneY, utility, new Size(SpaceSize, SpaceSize), RotateEnum.DoNotRotate)); } else if (x == 2) { boardSpaces.Add(new UtilitySpace(id, LaneTwoX, ((10 - i) * SpaceSize) + (SpaceSize - SpaceSize), utility, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate270)); } else { boardSpaces.Add(new UtilitySpace(id, (i * SpaceSize) + (SpaceSize - SpaceSize), LaneThreeY, utility, new Size(SpaceSize, SpaceSize), RotateEnum.Rotate180)); } break; } i++; } reader.Close(); }
public IEnumerator<bool> Execute() { DX.SetDrawMode(DX.DX_DRAWMODE_BILINEAR); info = new AccountInformation(Kbtter.Instance.Setting.Accounts.ToArray()); //The Kbtter Project var kbp = new Sprite() { Image = CommonObjects.ImageKbtterProject, HomeX = 256, HomeY = 32, X = 320, Y = 240 }; Manager.Add(kbp, 0); for (int i = 0; i < 120; i++) { kbp.ScaleX = kbp.ScaleY = Easing.OutBounce(i, 120, 4, -3); kbp.Alpha = Easing.OutSine(i, 120, 0, 1); yield return true; } kbp.ScaleX = kbp.ScaleY = 1; kbp.Alpha = 1; for (int i = 0; i < 120; i++) yield return true; for (int i = 0; i < 60; i++) { kbp.Alpha = Easing.OutSine(i, 60, 1, -1); yield return true; } kbp.IsDead = true; //タイトル画面 var back = new RectangleObject() { Width = 640, Height = 480, Color = CommonObjects.Colors.White, AllowFill = true }; Manager.Add(back, 0); for (int i = 0; i < 60; i++) { back.Alpha = Easing.OutSine(i, 60, 0, 1); yield return true; } back.Alpha = 1; var logo = new Sprite() { Image = CommonObjects.ImageLogo, HomeX = 240, HomeY = 80, X = 320 }; Manager.Add(logo, 1); for (int i = 0; i < 60; i++) { logo.Y = Easing.OutBounce(i, 60, -160, 320); yield return true; } //Press Z var pz = new StringSprite(CommonObjects.FontSystemBig, CommonObjects.Colors.Black) { Value = "Press Button", X = 320, Y = 400, HomeX = 160 }; var pzdx = DX.GetDrawStringWidthToHandle("Press Button", 12, CommonObjects.FontSystemBig); pz.HomeX = pzdx / 2; Manager.Add(pz, 1); do { for (int i = 0; i < 30 && !tstate.Buttons.Any(p => p); i++) { pz.Alpha = Easing.Linear(i, 30, 0, 1); yield return true; } for (int i = 0; i < 30 && !tstate.Buttons.Any(p => p); i++) { pz.Alpha = Easing.Linear(i, 30, 1, -1); yield return true; } } while (!tstate.Buttons.Any(p => p)); CommonObjects.SoundMenuOK.Play(); var st = pz.Alpha; for (int i = 0; i < 30; i++) { pz.Alpha = Easing.Linear(i, 30, st, -st); yield return true; } pz.IsDead = true; //menu menu = new[] { new AdditionalCoroutineSprite(){HomeX=160,HomeY=64,Image=CommonObjects.ImageTitleMenuStart,Y=720}, new AdditionalCoroutineSprite(){HomeX=160,HomeY=64,Image=CommonObjects.ImageTitleMenuQuick,Y=720}, new AdditionalCoroutineSprite(){HomeX=160,HomeY=64,Image=CommonObjects.ImageTitleMenuOption,Y=720}, new AdditionalCoroutineSprite(){HomeX=160,HomeY=64,Image=CommonObjects.ImageTitleMenuRanking,Y=720}, }; Manager.AddRangeTo(menu, 1); for (int i = 0; i < menu.Length; i++) { menu[i].X = 320 + 256 * i; if (i != selmenu) { menu[i].Alpha = 0.5; menu[i].ScaleX = menu[i].ScaleY = 0.8; } menu[i].ApplySpecialOperation(SpritePatterns.MenuIntro(i * 15, 60, 400)); } lrc = new[] { new MultiAdditionalCoroutineSprite(){HomeX=64,HomeY=64,ScaleX=0.5,ScaleY=0.8,Image=CommonObjects.ImageCursor128[0],X=120,Y=400}, new MultiAdditionalCoroutineSprite(){HomeX=64,HomeY=64,ScaleX=0.5,ScaleY=0.8,Image=CommonObjects.ImageCursor128[1],X=520,Y=400}, }; Manager.AddRangeTo(lrc, 2); foreach (var i in lrc) i.AddSubOperation(SpritePatterns.Blink(30, 0.8, Easing.Linear)); while (true) { switch (modestate) { case 0: //メニュー選択 while (!menu.All(p => p.SpecialOperation == null)) yield return true; while (true) { if ((tstate.Direction & GamepadDirection.Left) != 0) { selmenu = (selmenu + menu.Length - 1) % menu.Length; RefreshMenuPosition(); CommonObjects.SoundMenuSelect.Play(); } if ((tstate.Direction & GamepadDirection.Right) != 0) { selmenu = (selmenu + 1) % menu.Length; RefreshMenuPosition(); CommonObjects.SoundMenuSelect.Play(); } if (tstate.Buttons[0]) { //救済措置 if (selmenu == 0) { CommonObjects.SoundMenuOK.Play(); for (int i = 0; i < menu.Length; i++) { menu[i].ApplySpecialOperation(SpritePatterns.MenuIntro(0, 60, 600)); } foreach (var i in lrc) i.AddSubOperation(SpritePatterns.MenuOutro(0, 60, 600)); break; } } yield return true; } switch (selmenu) { case 0: //Start Children.AddChildScene(new TitleChildSceneAccountSelect(info)); break; case 1: //Quick break; case 2: //Option break; case 3: //Ranking break; } modestate = 1; break; case 1: //サブタスク動作 yield return true; break; case 2: for (int i = 0; i < 60; i++) { Manager.Alpha -= 1.0 / 60.0; yield return true; } Manager.Alpha = 0; goto EXIT; } } EXIT: Kbtter5.CurrentScene = new SceneGame(info.Accounts[selac], new UserInformation(info.Users[selac]), optinfo); }
/// <summary> /// 마우스 이동 이벤트, DrawObejct 를 그리거나, 이동하거, 사이즈를 조절할 때 사용된다. /// </summary> private void DrawBox_MouseMove(object sender, MouseEventArgs e) { this.mOldPoint = this.mLastPoint; //마우스 왼쪽 클릭이고, DrawObjectType 이 선택하기가 아닐 때 if (e.Button == MouseButtons.Left && MainController.Instance.DrawObjectType != DrawObjectType.Select) { //Pencil 그리기 일때 if (MainController.Instance.DrawObjectType == DrawObjectType.Pencil && this.mNewPencil != null) { Point point = new Point(e.X, e.Y); int distance = (e.X - this.mLastX) * (e.X - this.mLastX) + (e.Y - this.mLastY) * (e.Y - this.mLastY); //연결점 사이의 거리가 최소 거리보다 적을 때 if (distance < mMinDistance) { //Pencil의 라인을 연장해서 그린다 this.mNewPencil.MoveHandleTo(point, this.mNewPencil.HandleCount); } else //연결점 사이의 거리가 최소 거리보다 멀 때 { //새로운 연결점 추가 this.mNewPencil.AddPoint(e.Location); this.mLastX = e.X; this.mLastY = e.Y; } } else { //Pencil 이 DrawObject 를 그려준다. MainController.Instance.GraphicModel.GrapList[0].MoveHandleTo(e.Location, 5); } //DrawBox 의 Paint 이벤트를 호출해서 새롭게 그린다. this.Invalidate(false); return; } //마우스 왼쪽 클릭이고, DrawObjectType 이 선택하기 일때 else if (e.Button == MouseButtons.Left && MainController.Instance.DrawObjectType == DrawObjectType.Select) { //마우스의 현재 위치에서 마지막 위치를 뺀 값을 저장한다. int distanceX = e.X - mLastPoint.X; int distanceY = e.Y - mLastPoint.Y; //마우스의 현재 위치를 마지막 값으로 저장한다. this.mLastPoint = e.Location; //DrawBox 의 현재 상태가 사이즈 변경 모드일때 if (MainController.Instance.SelectMode == SelectMode.Size) { if (this.mResizedObject != null) { //DrawObject 의 사이즈를 변경한다. this.mResizedObject.MoveHandleTo(e.Location, this.mResizedObjectHandle); //DrawBox의 Paint 이벤트를 호출한다. this.Invalidate(false); return; } } //DrawBox 의 현재 상태가 이동 모드일때 if (MainController.Instance.SelectMode == SelectMode.Move) { //선택된 모든 DrawObject의 위치를 이동한다. foreach (DrawObject o in MainController.Instance.GraphicModel.GrapList) { if (o.Selected) { o.Move(distanceX, distanceY); } } //마우스 커서를 변경한다. this.Cursor = Cursors.SizeAll; //DrawBox 의 Paint 이벤트를 호출한다. this.Invalidate(false); return; } //DrawBox 의 현재 상태가 영역으로 선택 모드일때 if (MainController.Instance.SelectMode == SelectMode.NetSelection) { //마우스로 이동된 만큼 영역을 그려준다. ControlPaint.DrawReversibleFrame(this.RectangleToScreen(RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mOldPoint)), Color.Black, FrameStyle.Dashed); ControlPaint.DrawReversibleFrame(this.RectangleToScreen(RectangleObject.GetNormalizedRectangle(this.mStartPoint, e.Location)), Color.Black, FrameStyle.Dashed); return; } } //마우스가 클릭이 된 것이 없고, DrawObjectType 이 선택하기 일때 else if (e.Button == System.Windows.Forms.MouseButtons.None && MainController.Instance.DrawObjectType == DrawObjectType.Select) { //핸들의 위치에 맞게 마우스 커서를 변경해준다. foreach (DrawObject ob in MainController.Instance.GraphicModel.GrapList) { Cursor = ob.GetHandleCursor(ob.HitTest(e.Location)); return; } } }
/// <summary> /// 마우스 다운 이벤트, 새롭게 객체를 그리거나, 그려진 객체를 선택한다. /// </summary> private void DrawBox_MouseDown(object sender, MouseEventArgs e) { //마우스가 왼쪽 클릭이고, 그리기 도구에서 선택하기를 선택했을 경우 if (e.Button == MouseButtons.Left && MainController.Instance.DrawObjectType == DrawObjectType.Select) { //현재 DrawBox 상태를 아무것도 지정하지 않는다. MainController.Instance.SelectMode = SelectMode.None; foreach (DrawObject ob in MainController.Instance.GraphicModel.GrapList) { int handleNumber = ob.HitTest(e.Location); //현재 클릭된 위치의 handleNumber 를 반환한다. //handleNumber 가 0보다 크다면 DrawObject 가 선택 된 것이다. if (handleNumber > 0) { //현재 DrawBox 상태를 사이즈 변경 모드로 변경한다. MainController.Instance.SelectMode = SelectMode.Size; //사이즈 변경을 할 수 있도록 준비한다. this.mResizedObject = ob; this.mResizedObjectHandle = handleNumber; //DrawBox 그려진 모든 DrawObject 의 선택을 해제한다. this.UnSelectAll(); //현재 클릭된 DrawObejct 를 선택한다. ob.Selected = true; break; } } if (MainController.Instance.SelectMode == SelectMode.None) { foreach (DrawObject o in MainController.Instance.GraphicModel.GrapList) { if (o.HitTest(e.Location) == 0) { //Ctrl 키가 눌러지지 않은 상태에서 DrawObject 를 선택하면 모든 DrawObjec의 선택을 해제하고 현재 DrawObject 를 선택한다. if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { this.UnSelectAll(); o.Selected = true; } else if ((Control.ModifierKeys & Keys.Control) != 0 && o.Selected) { //이미 선택된 DrawObject 라면 선택을 해제한다. o.Selected = false; } else { //Ctrl 키가 눌러진 상태라면 기존 선택을 해제하지 않고 추가로 현재 DrawObject 를 선택한다. o.Selected = true; } //마우스 커서를 바꿔준다. this.Cursor = Cursors.SizeAll; //DrawBox 상태를 이동으로 변경한다. MainController.Instance.SelectMode = SelectMode.Move; break; } } } //DrawBox 의 상태가 아무것도 지정되지 않고 키보드를 누른 상태가 아니라면 DrawBox 에 선택된 모든 객체를 해제한다. if (MainController.Instance.SelectMode == SelectMode.None) { if ((Control.ModifierKeys & Keys.Control) == 0) { this.UnSelectAll(); } //DrawBox 의 상태를 영역으로 선택하기로 변경한다. MainController.Instance.SelectMode = SelectMode.NetSelection; } //현재의 마우스 위치를 저장한다. this.mLastPoint = e.Location; this.mStartPoint = e.Location; //마우스를 캡쳐한다. this.Capture = true; //DrawBox의 상태가 영역으로 선택하기 일떄, 영역 그리기를 시작한다. if (MainController.Instance.SelectMode == SelectMode.NetSelection) { ControlPaint.DrawReversibleFrame(this.RectangleToScreen(RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mLastPoint)), Color.Black, FrameStyle.Dashed); } } //마우스의 왼쪽을 클릭하고, DrawObjectType 이 선택하기가 아니라면 선택 DrawObject 를 그리기 시작한다. else if (e.Button == MouseButtons.Left && !(MainController.Instance.DrawObjectType == DrawObjectType.Select)) { //모든 DrawObject 선택 해제 this.UnSelectAll(); //현재 상태를 실행취소(Undo) & 다시실행(Redo) Command 에 등록한다. MainController.Instance.Command.AddCommand(MainController.Instance.GraphicModel.GrapList); //새로운 DrawObject 를 GrapList 에 등록한다. MainController.Instance.GraphicModel.GrapList.Insert(0, this.AddNewDrawObject(MainController.Instance.DrawObjectType, e.Location)); //마우스를 캡쳐한다. this.Capture = true; } //마우스 우클릭시 팝업 메뉴를 보여준다. else if (e.Button == System.Windows.Forms.MouseButtons.Right) { this.SetToolStripMenu(); this.contextMenuStrip1.Show(MousePosition); return; } }
public override void Start() { base.Start(); // Top Left var yDiff = 2f; var hp = new TextObject(FontScale, Color.White)//Color.DarkRed) { Order = Order, Text = "HP", X = HudPadding, Y = HudPadding, IgnoreCamera = true }; var hpSize = hp.Measure(); hpBarContainer = new RectangleObject(HudBarWidth, (int)hpSize.Y) { X = hp.X + padding + hpSize.X, Y = hp.Y - yDiff, Order = Order, Color = Color.Black, IgnoreCamera = true }; hpBar = new RectangleObject(HudBarWidth - border * 2, (int)(hpBarContainer.Height - border * 2)) { Order = Order, X = hpBarContainer.X + border, Y = hpBarContainer.Y + border, Color = Color.DarkRed, Fill = true, IgnoreCamera = true }; hpTextObj = new TextObject(FontScaleSecondary, Color.White)//Color.DarkRed) { Order = Order, X = hpBarContainer.X + hpBarContainer.Width + padding, Y = hp.Y, IgnoreCamera = true }; var energyText = new TextObject(FontScale, Color.White)//Color.DarkRed) { Text = "EN", X = HudPadding, Order = Order, Y = padding + hp.Y + hpSize.Y, IgnoreCamera = true }; var energyTextSize = energyText.Measure(); energyBarContainer = new RectangleObject(HudBarWidth, (int)energyTextSize.Y) { X = energyText.X + padding + energyTextSize.X, Y = energyText.Y - yDiff, Order = Order, Color = Color.Black, IgnoreCamera = true }; energyBar = new RectangleObject(HudBarWidth - border * 2, (int)(energyBarContainer.Height - border * 2)) { Order = Order, X = energyBarContainer.X + border, Y = energyBarContainer.Y + border, Color = Color.DarkBlue, Fill = true, IgnoreCamera = true }; energyTextObj = new TextObject(FontScaleSecondary, Color.White)//Color.DarkRed) { Order = Order, X = energyBarContainer.X + energyBarContainer.Width + padding, Y = energyText.Y, IgnoreCamera = true }; var xp = new TextObject(FontScale, Color.White)//Color.DarkGreen) { Order = Order, Text = "XP", X = HudPadding, Y = padding + energyText.Y + energyTextSize.Y, IgnoreCamera = true }; var xpSize = xp.Measure(); xpBarContainer = new RectangleObject(HudBarWidth, (int)xpSize.Y) { X = xp.X + padding + xpSize.X, Y = xp.Y - yDiff, Order = Order, Color = Color.Black, IgnoreCamera = true }; xpBar = new RectangleObject((int)(xpBarContainer.Width - border * 2), (int)(xpBarContainer.Height - border * 2)) { Order = Order, X = xpBarContainer.X + border, Y = xpBarContainer.Y + border, Color = Color.DarkOliveGreen, Fill = true, IgnoreCamera = true }; levelTextObj = new TextObject(FontScaleSecondary, Color.White)//Color.DarkGreen) { Order = Order, Text = "0% to 1", X = xpBarContainer.X + xpBarContainer.Width + padding, Y = xp.Y, IgnoreCamera = true }; // Center scoreTextObject = new TextObject(FontScaleSecondary, Color.White)//Color.DarkGreen) { Order = Order, Text = " ", Y = HudPadding, IgnoreCamera = true }; scoreModTextObject = new TextObject(FontScaleSecondary * 0.8f, Color.White)//Color.DarkGreen) { Order = Order, Y = scoreTextObject.Y + padding + scoreTextObject.Measure().Y, IgnoreCamera = true }; // Top Right spellCdBarContainer = new RectangleObject(HudBarWidth, (int)xpSize.Y) { X = Engine.Width - HudBarWidth - HudPadding, Y = HudPadding, Order = Order, Color = Color.Black, IgnoreCamera = true }; spellCdBar = new RectangleObject((int)(spellCdBarContainer.Width - border * 2), (int)(spellCdBarContainer.Height - border * 2)) { Order = Order, X = spellCdBarContainer.X + border, Y = spellCdBarContainer.Y + border, Color = Color.Gray, Fill = true, IgnoreCamera = true }; spellTextObj = new TextObject(FontScaleSecondary, Color.White)//Color.Black { Order = Order, Text = "", X = 0, Y = spellCdBarContainer.Y, IgnoreCamera = true }; // Bottom left var seedTextObj = new TextObject(FontScaleSecondary * 0.66f, Color.White, alpha: 0.66f) // Color.Black { Order = Order, Text = "Seed: " + Game.Game.Instance.Random.Seed, X = HudPadding, IgnoreCamera = true }; seedTextObj.Y = Engine.Height - HudPadding - seedTextObj.Measure().Y; Engine.SpawnObject(Name + "_hpText", hp); Engine.SpawnObject(Name + "_hpBarContainer", hpBarContainer); Engine.SpawnObject(Name + "_hpBar", hpBar); Engine.SpawnObject(Name + "_hpTextObj", hpTextObj); Engine.SpawnObject(Name + "_energyText", energyText); Engine.SpawnObject(Name + "_energyBarContainer", energyBarContainer); Engine.SpawnObject(Name + "_energyBar", energyBar); Engine.SpawnObject(Name + "_energyTextObj", energyTextObj); Engine.SpawnObject(Name + "_xpText", xp); Engine.SpawnObject(Name + "_xpBarContainer", xpBarContainer); Engine.SpawnObject(Name + "_xpBar", xpBar); Engine.SpawnObject(Name + "_levelTextObj", levelTextObj); Engine.SpawnObject(Name + "_scoreTextObj", scoreTextObject); Engine.SpawnObject(Name + "_scoreModTextObj", scoreModTextObject); Engine.SpawnObject(Name + "_spellText", spellTextObj); Engine.SpawnObject(Name + "_spellCdBarContainer", spellCdBarContainer); Engine.SpawnObject(Name + "_spellCdBar", spellCdBar); Engine.SpawnObject(Name + "_seedTextObj", seedTextObj); }