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代码已经按照预期工作,并且可以理解,但您希望改进。 –