0
所以這個程序我在有精靈。每個精靈都有其精靈可以擁有的幀數量的限制,並且我試圖弄清楚如何學習該限制,以便我可以對其進行修改。但是我一直在閱讀的代碼對我來說確實很難。我一直在閱讀它使用的一些東西(如Dictionary
和Out
),但是當我嘗試將該閱讀應用於代碼時,它只是分崩離析。因此,如果有人願意分析代碼並告訴我它說了什麼,那就太好了。完整的可以發現here,但是這是我想特別爲:需要幫助的理解代碼
class FrameData {
Dictionary<FrameType, Dictionary<Enums.Direction, int>> frameCount;
}
public FrameData() {
frameCount = new Dictionary<FrameType, Dictionary<Enums.Direction, int>>();
}
public void SetFrameCount(FrameType type, Enums.Direction dir, int count) {
if (frameCount.ContainsKey(type) == false) {
frameCount.Add(type, new Dictionary<Enums.Direction, int>());
}
if (frameCount[type].ContainsKey(dir) == false) {
frameCount[type].Add(dir, count);
} else {
frameCount[type][dir] = count;
}
}
public int GetFrameCount(FrameType type, Enums.Direction dir) {
Dictionary<Enums.Direction, int> dirs = null;
if (frameCount.TryGetValue(type, out dirs)) {
int value = 0;
if (dirs.TryGetValue(dir, out value)) {
return value;
} else {
return 0;
}
} else {
return 0;
}
}
嘗試張貼的問題在這裏-http://codereview.stackexchange.com/ – OldProgrammer
@OldProgrammer這問題將不會成爲Code Review的主題,因爲它正在尋求關於代碼如何工作的建議。 CR代碼已經按照預期工作,並且可以理解,但您希望改進。 –