//构造函数 public TYYCoreDataSav() { tyyCurrentSavePath.Add(@Environment.CurrentDirectory + @"\dat\sav\rec_loc.txt"); tyyCurrentSavePath.Add(@Environment.CurrentDirectory + @"\dat\sav\rec_map.txt"); String[] mapLoc = File.ReadAllLines(tyyCurrentSavePath[0], Encoding.ASCII); int x = Convert.ToInt32(mapLoc[0]); int y = Convert.ToInt32(mapLoc[1]); tyyMapName = File.ReadAllText(tyyCurrentSavePath[1], Encoding.ASCII); if (tyyMapName == "") { TYYCoreGUI.tyyErrMsg("Application Crash cause your Save File Broken!"); Application.Exit(); } tyyMapLoc = new Point(x, y); }
/// <summary> /// 参数_fileToget请使用TYYObjectName类成员 /// </summary> /// <param name="_mapName"></param> /// <param name="_fileToget"></param> //初始化物体构造函数 public TYYCoreMapCharger(String _mapName, String _fileToget) { this.tyyCurrentToget = _fileToget; String currentPathForGen = currentPath + @_mapName + TYYSpecialSymbol.tyySeparator; currentPath = currentPathForGen + @_mapName;//@"\maps\**map\**map+"?"" String[] mapObjectloc; try { mapObjectloc = File.ReadAllLines(currentPath + /*@"_obj"*/ _fileToget + TYYSpecialSymbol.tyyTxt, Encoding.ASCII); }//获取物体&地图转化坐标 catch { mapObjectloc = new String[1]; } // ////// /////// if (_fileToget == TYYObjectName.tyyTree || _fileToget == TYYObjectName.tyyWater) { tyyMapObjectLoc = tyyConvertToPoint(mapObjectloc, null /*objs*/); tyyMapObjectNum = mapObjectloc.Length / 2; } ////// /////// //地图转化 else if (_fileToget == TYYObjectName.tyyTr) { int index = 0; List <Point> trPoints = tyyConvertToPoint(mapObjectloc, TYYObjectName.tyyTr); int trLength = trPoints.Count; for (int i = 0; i < trLength / 3; i++) { this.tyyPointStart.Add(trPoints[index]); index++; this.tyyPointEnd.Add(trPoints[index]); index++; this.tyyMapTrCharacterLocCur.Add(trPoints[index]); index++; } //获取转化地图的角色生成坐标 try { String[] trNxtPoints = File.ReadAllLines(currentPath + "_trN" + TYYSpecialSymbol.tyyTxt, Encoding.ASCII); this.tyyMapTrCharacterNxt = this.tyyConvertToPoint(trNxtPoints, null); } catch { TYYCoreGUI.tyyErrMsg("Bad Error"); } this.tyyMapLocName = File.ReadAllText(currentPathForGen + "info" + TYYSpecialSymbol.tyyTxt, Encoding.Default); //设置任务 try { this.LEVEL_INDEX = Convert.ToInt32(File.ReadAllText(currentPathForGen + "level" + TYYSpecialSymbol.tyyTxt, Encoding.Default)); } catch { this.LEVEL_INDEX = 99; } //进入地图时说的话 } ////// /////// //NPC else if (_fileToget == TYYObjectName.tyyNpc) { String[] mapNpcLoc; try { String[] getNam = File.ReadAllLines(currentPath + "_npc_n" + TYYSpecialSymbol.tyyTxt, Encoding.ASCII); this.tyyNpcNamIns = new List <String>(getNam); mapNpcLoc = File.ReadAllLines(currentPath + "_npc_loc" + TYYSpecialSymbol.tyyTxt, Encoding.Default); } catch { return; } //获取坐标 this.tyyNpcloc = this.tyyConvertToPoint(mapNpcLoc, TYYObjectName.tyyNpc); //加载图片 foreach (String img in tyyNpcNamIns) { Image curImg = Image.FromFile(currentPath + "_" + img + TYYSpecialSymbol.tyyPng); this.tyyNpcImg.Add(curImg); } // try { for (int n_index = 0; n_index <= this.tyyObjNpcInfo.Count; n_index = n_index + 2) { this.tyyNpcNam.Add(this.tyyObjNpcInfo[n_index]); } } catch { } // try { for (int d_index = 1; d_index <= this.tyyObjNpcInfo.Count; d_index = d_index + 2) { this.tyyObjNpcDlg.Add(this.tyyObjNpcInfo[d_index]); } } catch { } tyyMapObjectNum = this.tyyNpcloc.Count; } ////// /////// //泛型物体 else if (_fileToget == TYYObjectName.tyyGen) { String[] ObjNames; try { ObjNames = File.ReadAllLines(currentPath + /*@"_obj"*/ _fileToget + TYYSpecialSymbol.tyyTxt, Encoding.Default); if (ObjNames.Length == 0) { return; } } catch { return; } this.tyyGenObjName = new List <String>(ObjNames); int N_Index = -1; foreach (String names in tyyGenObjName) { N_Index++; Image GenObj = Image.FromFile(currentPathForGen + names + TYYSpecialSymbol.tyyPng); this.tyyGenObjImg.Add(GenObj); String[] GenObjPoint = File.ReadAllLines(currentPathForGen + names + TYYSpecialSymbol.tyyTxt, Encoding.Default); this.tyyGenObjLoc.AddRange(this.tyyConvertToPoint(GenObjPoint, TYYObjectName.tyyGen)); this.tyyGenDlgList[N_Index] = new List <string>(this.tyyObjGenDlg); } } }
private void tyyEscDlg_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: if (buttonChoseIndex == 0) { buttonChoseIndex = 2; TYYCoreGUI.tyyButtonColorChange(buttonContinue, true); TYYCoreGUI.tyyButtonColorChange(buttonExit, false); } else { buttonChoseIndex--; TYYCoreGUI.tyyButtonColorChange(buttonList[buttonChoseIndex + 1], true); TYYCoreGUI.tyyButtonColorChange(buttonList[buttonChoseIndex], false); } break; case Keys.Down: if (buttonChoseIndex == 2) { buttonChoseIndex = 0; TYYCoreGUI.tyyButtonColorChange(buttonExit, true); TYYCoreGUI.tyyButtonColorChange(buttonContinue, false); } else { buttonChoseIndex++; TYYCoreGUI.tyyButtonColorChange(buttonList[buttonChoseIndex - 1], true); TYYCoreGUI.tyyButtonColorChange(buttonList[buttonChoseIndex], false); } break; case Keys.Space: if (buttonChoseIndex == 0) //继续 { this.Hide(); } else if (buttonChoseIndex == 1) //保存 { TYYCoreGUI.tyyErrMsg("So sorry that we don't offer Save Function in this game" + "\n" + "VWRD is terribly sorry"); //TYYCoreDataSav saveData = new TYYCoreDataSav(); //saveData.tyySaveMapInfo(_mapLoc, _mapPath); } else if (buttonChoseIndex == 2) //退出 { Application.Exit(); } break; case Keys.Escape: this.Hide(); break; default: return; } axButPlayer.Ctlcontrols.stop(); axButPlayer.Ctlcontrols.play(); }
private void tyyIndex_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: if (buttonChoseIndex == 0) { buttonChoseIndex = 2; tyyButtonColorChange(buttonPlay, true); tyyButtonColorChange(buttonExit, false); } else { buttonChoseIndex--; tyyButtonColorChange(buttonList[buttonChoseIndex + 1], true); tyyButtonColorChange(buttonList[buttonChoseIndex], false); } break; case Keys.Down: if (buttonChoseIndex == 2) { buttonChoseIndex = 0; tyyButtonColorChange(buttonExit, true); tyyButtonColorChange(buttonPlay, false); } else { buttonChoseIndex++; tyyButtonColorChange(buttonList[buttonChoseIndex - 1], true); tyyButtonColorChange(buttonList[buttonChoseIndex], false); } break; case Keys.Space: if (buttonChoseIndex == 0) { this.axButPlayer.Dispose(); this.CenterToScreen(); mainFrame.ShowDialog(); } else if (buttonChoseIndex == 1) { TYYCoreGUI.tyyErrMsg("This game do not need any settings" + "\n" + "VWRD is terribly sorry"); //setFrame.ShowDialog(); } else if (buttonChoseIndex == 2) { Application.Exit(); } break; default: return; } try { axButPlayer.Ctlcontrols.stop(); axButPlayer.Ctlcontrols.play(); } catch { return; } }
private void tyyInitObjects(String objectType) { int index = 0; type = objectType; if (objectType != TYYObjectName.tyyGen) { while (index < ObjMapCharger.tyyMapObjectNum) { PictureBox objPic = new PictureBox(); if (objectType == TYYObjectName.tyyTree) { ObjectsTre.Add(objPic); ObjectsTre[index].Parent = _mainMap; ObjectsTre[index].BackColor = Color.Transparent; ObjectsTre[index].Image = TYYCoreDataDyn.tyyObjectTree; ObjectsTre[index].Size = TYYCoreDataDyn.tyyObjectTreeSize; ObjectsTre[index].Location = ObjMapCharger.tyyMapObjectLoc[index]; //Clean when first time run these code } if (objectType == TYYObjectName.tyyWater) { ObjectsWat.Add(objPic); ObjectsWat[index].Size = TYYCoreDataDyn.tyyObjectWaterSize; ObjectsWat[index].Parent = _mainMap; ObjectsWat[index].BackColor = Color.Transparent; ObjectsWat[index].Location = ObjMapCharger.tyyMapObjectLoc[index]; } if (objectType == TYYObjectName.tyyNpc) { ObjectsNpc.Add(objPic); ObjectsNpc[index].Parent = _mainMap; ObjectsNpc[index].BackColor = Color.Transparent; ObjectsNpc[index].Image = ObjMapCharger.tyyNpcImg[index]; ObjectsNpc[index].Size = new Size(TYYCoreDataDyn.tyyInitCharacterSize); ObjectsNpc[index].Location = ObjMapCharger.tyyNpcloc[index]; } index++; } } else { try { while (index < ObjMapCharger.tyyGenObjName.Count) { PictureBox objPic = new PictureBox(); ObjectsGen.Add(objPic); ObjectsGen[index].Parent = _mainMap; ObjectsGen[index].BackColor = Color.Transparent; ObjectsGen[index].Image = ObjMapCharger.tyyGenObjImg[index]; ObjectsGen[index].Size = ObjMapCharger.tyyGenObjImg[index].Size; ObjectsGen[index].Location = ObjMapCharger.tyyGenObjLoc[index]; index++; } } catch { TYYCoreGUI.tyyErrMsg("Bad Error:Gen Obj init fail!"); return; } } if (objectType == TYYObjectName.tyyWater) { ObjAnimation.tyyObjWat.Clear(); ObjWaterAnimation.tyyDynSource = ObjDataDyn.tyyWaterImages; ObjWaterAnimation.tyyDynList = ObjectsWat; ObjAnimation.tyyObjWat.AddRange(ObjectsWat); ObjAnimation.tyyWatNums = ObjMapCharger.tyyMapObjectNum; return; } else if (objectType == TYYObjectName.tyyTree) { ObjAnimation.tyyObjTre.Clear(); ObjAnimation.tyyObjTre.AddRange(ObjectsTre); ObjAnimation.tyyTreNums = ObjMapCharger.tyyMapObjectNum; } else if (objectType == TYYObjectName.tyyNpc) { ObjAnimation.tyyObjNpc.Clear(); ObjAnimation.tyyObjNpc.AddRange(ObjectsNpc); //dlgs ObjAnimation.tyyNpcDlgs = ObjMapCharger.tyyObjNpcDlg; // inside name ObjAnimation.tyyNpcNamesIns = ObjMapCharger.tyyNpcNamIns; // correct name ObjAnimation.tyyNpcNames = ObjMapCharger.tyyNpcNam; ObjAnimation.tyyNpcNums = ObjMapCharger.tyyMapObjectNum; } else if (objectType == TYYObjectName.tyyGen) { ObjAnimation.tyyObjGen.Clear(); ObjAnimation.tyyObjGen.AddRange(ObjectsGen); ObjAnimation.tyyGenDlgs = ObjMapCharger.tyyGenDlgList; ObjAnimation.tyyGenNames = ObjMapCharger.tyyGenObjName; ObjAnimation.tyyGenNums = ObjMapCharger.tyyGenObjName.Count; } }