public void onClickNextPath() { if (pathIndex < AiPathManager.getInstance().getPathCount() - 1) { pathIndex += 1; this.mAiPath = AiPathManager.getInstance().getPath(pathIndex); mPointListPanel.clear(); } }
public void onClickPrePath() { if (pathIndex > 0) { pathIndex -= 1; this.mAiPath = AiPathManager.getInstance().getPath(pathIndex); mPointListPanel.clear(); } }
public void onClickLoadPath() { AiPathManager.getInstance().load(@"E:\Git\quick-cocos2d-x-2.2.5-plus-release\project\framework\module\fishing\res\config\table_ai.tab"); onClickNextPath(); return; string filepath = FileDialogDLL.showOpenFileDialog(); if (filepath.Length > 0) { //this.mAiPath = AIPath.loadFromJson(filepath); //updateItemList(); } }
void OnGUI() { GameObject activeGameObject = Selection.activeGameObject; if (null == activeGameObject) { return; } PathRender pathRender = activeGameObject.GetComponent <PathRender>(); if (null == pathRender) { return; } FishPath fishPath = pathRender.FishPathData; if (null == fishPath) { if (GUILayout.Button("创建新路径", GUILayout.Width(100))) { pathRender.FishPathData = new FishPath(); fishPath = pathRender.FishPathData; } return; } NGUIEditorTools.DrawHeader("Control Points", true); { GUILayout.BeginHorizontal(); GUILayout.Space(3f); GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); fishPath.renderPath = EditorGUILayout.Toggle("Render Path", fishPath.renderPath); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); fishPath.lineColor = EditorGUILayout.ColorField("Line Color", fishPath.lineColor); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); fishPath.baseSpeed = EditorGUILayout.FloatField("Speed", fishPath.baseSpeed); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); fishPath.mPathId = EditorGUILayout.IntField("PathId", fishPath.mPathId); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Load")) { string filepath = EditorUtility.OpenFilePanel("Load", Application.dataPath + "/Resources/Pathes/", "bytes"); if (filepath.Length > 0) { fishPath = AiPathManager.getInstance().loadOnePath(filepath); pathRender.FishPathData = fishPath; EditorUtility.SetDirty(Selection.activeGameObject); } } GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save INI")) { AiPathManager.getInstance().saveIni(fishPath); } GUILayout.Space(5); if (GUILayout.Button("Save TAB")) { AiPathManager.getInstance().saveTab(fishPath); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Reset Path")) { if (EditorUtility.DisplayDialog("Resetting path?", "Are you sure you want to delete all control points?", "Delete", "Cancel")) { fishPath.ResetPath(); EditorUtility.SetDirty(Selection.activeGameObject); return; } } if (selectIndex > -1 && selectIndex < fishPath.numberOfControlPoints) { FishPathControlPoint point = fishPath.controlPoints[selectIndex]; if (point) { point.highLight = GUILayout.Toggle(point.highLight, "HighLight"); point.color = EditorGUILayout.ColorField("Line Colour", point.color); point.mTime = EditorGUILayout.FloatField("Time", point.mTime); point.mSpeedScale = EditorGUILayout.FloatField("SpeedScale", point.mSpeedScale); point.mRotationChange = EditorGUILayout.FloatField("RotationChange", point.mRotationChange); } } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("添加控制点")) { fishPath.AddPoint(); EditorUtility.SetDirty(pathRender); } EditorGUILayout.EndHorizontal(); mScroll = GUILayout.BeginScrollView(mScroll); bool delete = false; for (int i = 0; i < fishPath.numberOfControlPoints; i++) { GUI.backgroundColor = selectIndex == i ? Color.white : new Color(0.8f, 0.8f, 0.8f); GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f)); GUILayout.Space(5f); GUILayout.Label(i.ToString(), GUILayout.Width(24f)); if (GUILayout.Button("hello", "OL TextField", GUILayout.Height(25f))) { selectIndex = i; fishPath.SelectedLineIndex = selectIndex; } if (GUILayout.Button("X", GUILayout.Width(22f))) { fishPath.DeletePoint(i); if (selectIndex == i) { selectIndex = -1; } i--; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(3f); GUILayout.EndHorizontal(); } if (GUI.changed) { fishPath.CaculateFinePoints(); EditorUtility.SetDirty(Selection.activeGameObject); EditorApplication.MarkSceneDirty(); } }
// Use this for initialization void Start() { AiPathManager.getInstance().initialize(Application.dataPath + "/Resources/Configs/table_ai.bytes"); GameTableManager.getInstance().initialize(); }
public void onEventFishSeason(int seasonIndex, bool modifyFlag = false) { if (modifyFlag) { this.onModifyOneSeason(seasonIndex); return; } GameObject sourcePoint = GameObject.Find("Anchor_BottomLeft"); Transform objBottomLeft = sourcePoint.transform; int childCnt = objBottomLeft.childCount; for (int i = 0; i < childCnt;) { Transform child = objBottomLeft.GetChild(i); GameObject.DestroyImmediate(child.gameObject); childCnt = objBottomLeft.childCount; } OneFishSeason season = FishConfigManager.getInstance().getOneSeason(seasonIndex); TableFish fishtable = (TableFish)GameTableManager.getInstance().GetTable("table_fish"); foreach (FishSeasonInfo seasoninfo in season.seasonInfoList) { foreach (SingleFishOfSeason singlefish in seasoninfo.fishList) { TableFish.FishRecord record = fishtable.getRecordByFishKindId(singlefish.mFishKindId); if (record == null) { continue; } float fFishLength = record.width; //Debug.Log(record.name); GameObject fishObj = (GameObject)GameObject.Instantiate(Resources.Load("FishPrefabs/Prefab_Fish_" + record.name)); fishObj.transform.parent = sourcePoint.transform; fishObj.transform.localScale = Vector3.one * record.scaleFactor; //fishObj.transform.localPosition = new Vector3(singlefish.mFishPos.x + seasoninfo.mCenterPoint.x-1200,singlefish.mFishPos.y + seasoninfo.mCenterPoint.y,0); Fish fishComponent = fishObj.AddComponent <Fish>(); fishComponent.Rotation = seasoninfo.mAngle; fishComponent.AiPath = AiPathManager.getInstance().getPath(seasoninfo.mAiId); fishComponent.BaseSpeed = seasoninfo.mSpeed; fishComponent.FishWidth = record.width; float fDelay = 0.0f; if (seasoninfo.mCenterPoint.x <= 0) { fishObj.transform.localPosition = new Vector3(-fFishLength, seasoninfo.mCenterPoint.y + singlefish.mFishPos.y, 0); //fishObj.transform.localPosition.y = seasoninfo.mCenterPoint.y + singlefish.mFishPos.y; fDelay = (singlefish.mFishPos.x - seasoninfo.mCenterPoint.x) / seasoninfo.mSpeed; } else if (seasoninfo.mCenterPoint.x >= 1280) { fishObj.transform.localPosition = new Vector3(1280 + fFishLength, seasoninfo.mCenterPoint.y + singlefish.mFishPos.y, 0); //fishObj.transform.localPosition.y = seasoninfo.mCenterPoint.y + singlefish.mFishPos.y; fDelay = (singlefish.mFishPos.x + seasoninfo.mCenterPoint.x - 1280) / seasoninfo.mSpeed; } else if (seasoninfo.mCenterPoint.y <= 0) { fishObj.transform.localPosition = new Vector3(seasoninfo.mCenterPoint.x + singlefish.mFishPos.x, -fFishLength, 0); //fishObj.transform.localPosition.y = (-1) * fFishLength; fDelay = (singlefish.mFishPos.y - seasoninfo.mCenterPoint.y) / seasoninfo.mSpeed; } else if (seasoninfo.mCenterPoint.y >= 720) { fishObj.transform.localPosition = new Vector3(seasoninfo.mCenterPoint.x + singlefish.mFishPos.x, 720 + fFishLength, 0); //fishObj.transform.localPosition.y = 720 + fFishLength; fDelay = (singlefish.mFishPos.y + seasoninfo.mCenterPoint.y - 720) / seasoninfo.mSpeed; } else { fishObj.transform.localPosition = new Vector3(seasoninfo.mCenterPoint.x + singlefish.mFishPos.x, seasoninfo.mCenterPoint.y + singlefish.mFishPos.y, 0); //fishObj.transform.localPosition.y = (seasoninfo.mCenterPoint.y + singlefish.mFishPos.y); fDelay = 0.0f; } Vector3 pos = fishObj.transform.localPosition; fishObj.transform.localPosition = new Vector3(pos.x, 720 - pos.y, 0); if (seasonIndex == 4) { Debug.Log(fishObj.transform.localPosition + " " + fDelay); } fishComponent.DelayActiveTime = fDelay; } } }
void OnGUI() { GameObject activeGameObject = Selection.activeGameObject; if (null == activeGameObject) { return; } PathRender pathRender = activeGameObject.GetComponent <PathRender>(); if (null == pathRender) { return; } if (GUILayout.Button("加载路径文件", GUILayout.Width(100))) { string filePath = EditorUtility.OpenFilePanel("Open Ai Bytes", Application.dataPath + "/Resources/Pathes/", "bytes"); if (filePath.Length > 0) { selectedPathId = 0; AiPathManager.getInstance().initialize(filePath); } } int pathCnt = AiPathManager.getInstance().getPathCount(); if (pathCnt == 0) { return; } selectedPathId = EditorGUILayout.IntSlider("AI index", selectedPathId, 0, pathCnt); FishPath fishPath = pathRender.FishPathData; if (GUILayout.Button("更新路径", GUILayout.Width(100))) { pathRender.FishPathData = AiPathManager.getInstance().getPath(selectedPathId); fishPath = pathRender.FishPathData; EditorUtility.SetDirty(Selection.activeGameObject); } NGUIEditorTools.DrawHeader("Control Points", true); { if (null == fishPath) { return; } GUILayout.BeginHorizontal(); GUILayout.Space(3f); GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); fishPath.renderPath = EditorGUILayout.Toggle("Render Path", fishPath.renderPath); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); fishPath.lineColor = EditorGUILayout.ColorField("Line Color", fishPath.lineColor); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); fishPath.baseSpeed = EditorGUILayout.FloatField("Speed", fishPath.baseSpeed); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Load")) { string filepath = EditorUtility.OpenFilePanel("Load", Application.dataPath + "/Resources/Pathes/", "bytes"); if (filepath.Length > 0) { //fish.FishPathData = PathConfigManager.GetInstance().Load(filepath); //fish.FishPathData.FileName = Path.GetFileName(filepath); EditorUtility.SetDirty(Selection.activeGameObject); } } mScroll = GUILayout.BeginScrollView(mScroll); for (int i = 0; i < fishPath.numberOfControlPoints; i++) { GUI.backgroundColor = selectIndex == i ? Color.white : new Color(0.8f, 0.8f, 0.8f); GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f)); GUILayout.Space(5f); GUILayout.Label(i.ToString(), GUILayout.Width(24f)); if (GUILayout.Button("hello", "OL TextField", GUILayout.Height(25f))) { selectIndex = i; fishPath.SelectedLineIndex = selectIndex; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(3f); GUILayout.EndHorizontal(); } if (GUI.changed) { fishPath.CaculateFinePoints(); EditorUtility.SetDirty(Selection.activeGameObject); } }