【发布时间】:2021-11-29 19:22:45
【问题描述】:
我想写一个卡片交换游戏。我有一个颜色数组列表,其中值从 -1 到 6 开始。这个数组的每个元素都意味着 id 颜色。还有一个 ArrayList Player Properties,其中存储有颜色的卡片。我需要创建一个带有八个零的 ArrayList,这将暗示 id 颜色。接下来,通过该数组跳过 ArrayList Player Properties,如果数组中有元素,则将 ArrayList Colors 索引增加 +1。
例如:
ArrayList Colors =new ArrayList(){-1,0,1,2,3,4,5,6};
ArrayList Player Properties = new ArrayList(){0,4,6};
This array should imply that its element is an element of the Colors array
ArrayList buffer = new ArrayList(){0,0,0,0,0,0,0,0};
If an array comes to the input in this form: {0,4,6};
Then the index of this array is added by +1, like this: {0,1,0,0,0,1,0,1};
如何在代码中实现这一点?
我没有任何代码示例,因为我不知道如何实现它,提前抱歉我没有提供更多代码,我真的需要帮助,提前谢谢大家的帮助
【问题讨论】:
-
ArrayList 现在非常非常老了;您使用它有什么特别的原因吗?
-
@CaiusJard 没有具体原因
-
为什么
{0,1,0,0,0,1,0,1,0,0}中有10个元素? -
@CaiusJard 这是一个错误,我已经解决了这个问题
标签: c#