0
所以我創建了一個基於瓷磚的遊戲,如果主要玩家控制的角色步入地圖上的某些區域,他/她獲得能量提升或中毒,具體取決於玩家角色踩/落地的瓦片。我已經創建了一個包含player對象的二維數組。所以我想問一下,我應該如何在地圖上的某些位置上實施助推或中毒角色。所以我想知道是否必須創建一個額外的維度來在我的地圖中添加這些特殊的「區域」,或者我創建了一個額外的鏈接列表來存儲特殊的「區域」並實施它們?具有特殊屬性的瓷磚
public final class Engine
{
private int maximumAttackerWarrior;
private int maximumDefenderWarrior;
private int attackerWarrior;
private int defenderWarrior;
private final Random rand;
private ArrayList<Integer> defenderA;
private ArrayList<Integer> attackerA;
/**
* Constructor of class Engine
*/
public Engine() {
// initialise instance variables
rand = new Random();
maximumAttackerWarrior = 0;
maximumDefenderarrior = 0;
attackerWarrior = 0;
defenderWarrior = 0;
defenderDices = new ArrayList<Integer>();
attackerDices = new ArrayList<Integer>();
}
public map{
// purely for visualization purposes
Zones [][] map =
{
{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};}}
是,幫助這麼多非常感謝你我的朋友,我想我會去GoF的享元模式閱讀起來。 – 2014-10-30 05:42:16