public void loadResources() { GameObject water = Instantiate(Resources.Load("Perfabs/Water", typeof(GameObject)), water_pos, Quaternion.identity, null) as GameObject; water.name = "water"; fromCoast = new CoastController("from", NumDevil + NumPriest); toCoast = new CoastController("to", NumDevil + NumPriest); boat = new BoatController(); for (int i = 0; i < NumPriest; i++) { GenGameObject cha = new GenGameObject("priest"); cha.setName("priest" + i); cha.setPosition(fromCoast.getEmptyPosition()); cha.getOnCoast(fromCoast); fromCoast.getOnCoast(cha); characters[i] = cha; } for (int i = 0; i < NumDevil; i++) { GenGameObject cha = new GenGameObject("devil"); cha.setName("devil" + i); cha.setPosition(fromCoast.getEmptyPosition()); cha.getOnCoast(fromCoast); fromCoast.getOnCoast(cha); characters[i + NumPriest] = cha; } }
public void characterIsClicked(GenGameObject characterCtrl) { if (GameStatus() == 0) { if (characterCtrl.isOnBoat()) { CoastController whichCoast; if (boat.get_to_or_from() == -1) { // to->-1; from->1 whichCoast = toCoast; } else { whichCoast = fromCoast; } boat.GetOffBoat(characterCtrl.getName()); characterCtrl.moveToPosition(whichCoast.getEmptyPosition()); characterCtrl.getOnCoast(whichCoast); whichCoast.getOnCoast(characterCtrl); } else { CoastController whichCoast = characterCtrl.getCoastController(); if (boat.getEmptyIndex() == -1) { return; } if (whichCoast.get_to_or_from() != boat.get_to_or_from()) { return; } whichCoast.getOffCoast(characterCtrl.getName()); characterCtrl.moveToPosition(boat.getEmptyPosition()); characterCtrl.getOnBoat(boat); boat.GetOnBoat(characterCtrl); } userGUI.status = GameStatus(); } }
public void LoadWithNum(int pri, int dev) { restart(); if (pri != NumPriest || dev != NumDevil) { Destroy(fromCoast.coast); Destroy(toCoast.coast); fromCoast = new CoastController("from", pri + dev); toCoast = new CoastController("to", pri + dev); for (int i = 0; i < NumPriest + NumDevil; i++) { Destroy(characters[i].character); } for (int i = 0; i < pri; i++) { GenGameObject cha = new GenGameObject("priest"); cha.setName("priest" + i); cha.setPosition(fromCoast.getEmptyPosition()); cha.getOnCoast(fromCoast); fromCoast.getOnCoast(cha); characters[i] = cha; } for (int i = 0; i < dev; i++) { GenGameObject cha = new GenGameObject("devil"); cha.setName("devil" + i); cha.setPosition(fromCoast.getEmptyPosition()); cha.getOnCoast(fromCoast); fromCoast.getOnCoast(cha); characters[i + pri] = cha; } NumPriest = pri; NumDevil = dev; } }