diff --git a/My project/Assets/Scripts/Logic/Achievement/AchievementAsset.cs b/My project/Assets/Scripts/Logic/Achievement/AchievementAsset.cs index 1a213ce3f..fe046b7c6 100644 --- a/My project/Assets/Scripts/Logic/Achievement/AchievementAsset.cs +++ b/My project/Assets/Scripts/Logic/Achievement/AchievementAsset.cs @@ -68,5 +68,10 @@ namespace Logic.Achievement _achievementItems.Clear(); foreach (var item in AchievementList) _achievementItems[item.ID] = item; } + + public void ClearAchievementFinishedInfo() + { + foreach (var item in AchievementList) item.IsFinished = false; + } } } \ No newline at end of file diff --git a/My project/Assets/Scripts/Logic/Achievement/AchievementDataManager.cs b/My project/Assets/Scripts/Logic/Achievement/AchievementDataManager.cs index 892727d4a..101e99817 100644 --- a/My project/Assets/Scripts/Logic/Achievement/AchievementDataManager.cs +++ b/My project/Assets/Scripts/Logic/Achievement/AchievementDataManager.cs @@ -29,7 +29,12 @@ namespace RuntimeData string json = File.ReadAllText(path); Achievement = JsonUtility.FromJson(json); } - if (Achievement == null) Achievement = Resources.Load("Export/Achievement"); + + if (Achievement == null) + { + Achievement = Resources.Load("Export/Achievement"); + Achievement.ClearAchievementFinishedInfo(); + } FinishedCache ??= new List(); FinishedCache.Clear(); } diff --git a/My project/Assets/Scripts/Logic/Action/ActionLogic.cs b/My project/Assets/Scripts/Logic/Action/ActionLogic.cs index 3ed303e01..061d353fb 100644 --- a/My project/Assets/Scripts/Logic/Action/ActionLogic.cs +++ b/My project/Assets/Scripts/Logic/Action/ActionLogic.cs @@ -715,17 +715,14 @@ namespace Logic.Action ProjectileType.Faith, ProjectileMoveType.CoinParabola, 300); } } - - else - Main.CityLogic.CityUpdateExp(actionParams.MapData,city,wonderInfo.Exp); - - + else Main.CityLogic.CityUpdateExp(actionParams.MapData,city,wonderInfo.Exp); actionParams.GridData.ResourceUnderBuilding = actionParams.GridData.Resource; actionParams.GridData.Resource = ResourceType.Wonder; actionParams.GridData.Wonder = wonderInfo.Wonder; player.Wonder.SetWonderState(wonderInfo.WonderType,WonderState.FINISH_BUILD); actionParams.GridData.RenderMark = true; + AchievementDataManager.Instance.OnBuildWonder(actionParams.MapData, player, city, actionParams.GridData); return true; } @@ -1420,12 +1417,9 @@ namespace Logic.Action if (gridData == null) return false; actionParams.PlayerData.PlayerWealth -= GetCost(); - actionParams.MapData.AddUnitData(gridData.Id,cityData.Id,_actionId.UnitType,_actionId.GiantType); + var newUnit = actionParams.MapData.AddUnitData(gridData.Id,cityData.Id,_actionId.UnitType,_actionId.GiantType); cityData.CityInfoRenderMark = true; - - - //临时做法,用来播放VFX,获取Main,理应向MapData写入一个VFX的RenderMark的 var main = GameObject.Find("Main").GetComponent
(); if (main.MapData == actionParams.MapData)// && actionParams.PlayerData.Id == actionParams.MapData.PlayerMap.SelfPlayerData.Id) @@ -1438,8 +1432,8 @@ namespace Logic.Action var endPos = Camera.main.ScreenToWorldPoint(faithPanel.position); MapRenderer.Instance.ProjectileManager.CreateProjectile(main,actionParams.MapData,v1,endPos,ProjectileType.Faith,ProjectileMoveType.CoinParabola,score); } + AchievementDataManager.Instance.OnTrainUnit(actionParams.MapData, actionParams.PlayerData, actionParams.CityData, newUnit); } - return true; } diff --git a/My project/Assets/Scripts/Logic/Editor/AchievementEditorWindow.cs b/My project/Assets/Scripts/Logic/Editor/AchievementEditorWindow.cs index 198770480..3c5897fc0 100644 --- a/My project/Assets/Scripts/Logic/Editor/AchievementEditorWindow.cs +++ b/My project/Assets/Scripts/Logic/Editor/AchievementEditorWindow.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using Logic.Achievement; using NUnit.Framework; +using RuntimeData; using UnityEditor; using UnityEngine; @@ -98,7 +99,11 @@ namespace Logic.Editor _asset.AchievementList.Remove(item); } } - + if (Application.isPlaying && InspectorUtils.InspectorButtonWithTextWidth("清空成就完成情况(运行时)")) + { + AchievementDataManager.Instance.Achievement.ClearAchievementFinishedInfo(); + AchievementDataManager.Instance.SaveAchievementData(); + } if (_bigID != 0 && _smallID != 0) { if (InspectorUtils.InspectorButtonWithTextWidth("增加一条成就"))