public void loadResources() { GameObject river = Instantiate(Resources.Load("prefabs/river", typeof(GameObject)), riverPos, Quaternion.identity, null) as GameObject; river.name = "river"; startLand = new LandController("from"); endLand = new LandController("to"); boat = new BoatController(); for (int i = 0; i < 3; i++) { chCtrl.CharacterController _ch = new chCtrl.CharacterController("priest"); _ch.setName("priest[" + i + "]"); _ch.setPosition(startLand.getEmptyPlace()); _ch.getOnLand(startLand); startLand.addObj(_ch); ch[i] = _ch; } for (int i = 0; i < 3; i++) { chCtrl.CharacterController _ch = new chCtrl.CharacterController("devil"); _ch.setName("devil[" + i + "]"); _ch.setPosition(startLand.getEmptyPlace()); _ch.getOnLand(startLand); startLand.addObj(_ch); ch[i + 3] = _ch; } }
public void objectClicked(chCtrl.CharacterController _ch) { if (_ch.isOnBoat()) //obj is on boat { LandController land; if (boat.getState() == -1) { land = endLand; } else { land = startLand; } boat.getOffBoat(_ch.getName()); _ch.movePos(land.getEmptyPlace()); _ch.getOnLand(land); land.addObj(_ch); } else //obj is on land { LandController land = _ch.getLandController(); if (boat.getEmptyNum() == -1) { return; //full boat } if (land.getState() != boat.getState()) { return; //different side } land.removeObj(_ch.getName()); _ch.movePos(boat.getEmptyPlace()); _ch.getOnBoat(boat); boat.getOnBoat(_ch); } userGUI.status = check(); }