public void LoadResources() { characters = new ICharacterController[6]; GameObject river = Instantiate(Resources.Load("Prefabs/River", typeof(GameObject)), new Vector3(0, -0.25f, 0), Quaternion.identity, null) as GameObject; river.name = "river"; boat = new BoatController(); leftLand = new LandController(-1); rightLand = new LandController(1); for (int i = 0; i < 3; ++i) { ICharacterController priest = new ICharacterController(0, "priest" + i); priest.setPosition(rightLand.getEmptyPosition()); priest.getOnLand(rightLand); rightLand.getOnLand(priest); characters[i] = priest; } for (int i = 0; i < 3; ++i) { ICharacterController devil = new ICharacterController(1, "devil" + i); devil.setPosition(rightLand.getEmptyPosition()); devil.getOnLand(rightLand); rightLand.getOnLand(devil); characters[i + 3] = devil; } }
public void reset() { landController = (GameDirector.getInstance().currentSceneController as FirstController).rightLand; getOnLand(landController); setPosition(landController.getEmptyPosition()); landController.getOnLand(this); }
public void genGameObjects() { characters = new ICharacterController[6]; boat = new BoatController(); leftLand = new LandController(-1); rightLand = new LandController(1); for (int i = 0; i < 3; i++) { ICharacterController priest = new ICharacterController(0, "priest" + i); priest.setPosition(rightLand.getEmptyPosition()); priest.getOnLand(rightLand); rightLand.getOnLand(priest); characters[i] = priest; } for (int i = 0; i < 3; i++) { ICharacterController demon = new ICharacterController(1, "demon" + i); demon.setPosition(rightLand.getEmptyPosition()); demon.getOnLand(rightLand); rightLand.getOnLand(demon); characters[i + 3] = demon; } }
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; } }
void Awake() { try { GameObject landPrefab = Pattern.Factory.PrefabFactory.Instance.CreatePrefab("Lands", "BasicLand", false); this.landSizeX = landPrefab.transform.localScale.x; this.landSizeY = landPrefab.transform.localScale.y; for (int x = 0; x < landNumX; ++x) { this.landList.Add(new List <LandController>()); for (int y = 0; y < landNumY; ++y) { LandController land = Instantiate(landPrefab , new Vector3( this.transform.position.x + landSizeX * x , this.transform.position.y + landSizeY * y , this.transform.position.z) , Quaternion.identity , this.transform).GetComponent <LandController>(); this.landList[x].Add(land); } } } catch (System.NullReferenceException ex) { throw ex; } catch (System.Exception ex) { throw ex; } }
//重置 public void Reset() { moveable.Reset(); landController = (Director.getInstance().currentSceneController as FirstController).fromLand; getOnLand(landController); setPosition(landController.getEmptyPosition()); landController.getOnLand(this); }
public void reset() { move.reset(); landController = (SSDirector.getInstance().currentSceneController as FirstController).startLand; getOnLand(landController); setPosition(landController.getEmptyPlace()); landController.addObj(this); }
//导入各种预制体资源 public void LoadResources() { //背景设置(其实就是一个方块加点贴图。能力限制,就这么弄了) background = Instantiate <Transform>(Resources.Load <Transform>("Prefabs/backGround"), new Vector3(0, 6, 3), Quaternion.identity); background.name = "background"; background.localScale += new Vector3(35, 20, 2); background.Rotate(new Vector3(10, 0, 180)); //导入陆地、河流和船 GameObject river = createObject("River", new Vector3(0, 0, -2)); river.name = "river"; GameObject leftLand = createObject("Land", new Vector3(-10, 0.5f, -2)); leftLand.name = "leftLand"; GameObject rightLand = createObject("Land", new Vector3(10, 0.5f, -2)); rightLand.name = "rightLand"; GameObject t_boat = createObject("Boat", new Vector3(5, 1.15f, -2.5f)); t_boat.name = "boat"; //设置控制器 fromLand = new LandController(rightLand, 1); toLand = new LandController(leftLand, -1); boat = new BoatController(t_boat); //导入游戏人物对象并设置控制器 for (int i = 0; i < 3; i++) { GameObject temp = createObject("devil", Vector3.zero); ChaController cha = new ChaController(temp, 1); cha.setName("devil" + i); cha.setPosition(fromLand.getEmptyPosition()); cha.getOnLand(fromLand); fromLand.getOnLand(cha); people[i] = cha; } for (int i = 0; i < 3; i++) { GameObject temp = createObject("Priests", Vector3.zero); ChaController cha = new ChaController(temp, 0); cha.setName("priest" + i); cha.setPosition(fromLand.getEmptyPosition()); cha.getOnLand(fromLand); fromLand.getOnLand(cha); people[i + 3] = cha; } }
public void loadResources() { GameObject water = Instantiate(Resources.Load("pf_water", typeof(GameObject)), water_pos, Quaternion.identity, null) as GameObject; water.name = "water"; fromCoast = new LandController("from"); toCoast = new LandController("to"); boat = new BoatController(); loadCharacter(); }
public void getOnBoat(BoatController boatController, int pos) { landController = null; if (pos == 0) { character.transform.rotation = Quaternion.AngleAxis(90, Vector3.up); } else { character.transform.rotation = Quaternion.AngleAxis(270, Vector3.up); } character.transform.parent = boatController.getBoat().transform; onBoat = true; }
public void getOnLand(LandController land) { landController = land; if (land.getType() == -1) { character.transform.rotation = Quaternion.AngleAxis(90, Vector3.up); } else { character.transform.rotation = Quaternion.AngleAxis(270, Vector3.up); } character.transform.parent = null; onBoat = false; }
/// <summary> /// 如果点了某个人物,判断其是在船上还是陆地上 /// 如果在船上,则上岸;否则,上船 /// </summary> /// <param name="chac">某个人</param> public void isClickCha(ChaController chac) { //上岸 if (chac.isOnBoat()) { LandController whichLand; if (boat.getOnWhere() == -1) { whichLand = toLand; } else { whichLand = fromLand; } boat.getOffBoat(chac.getChaName()); //chac.movePosition(whichLand.getEmptyPosition()); // chac.setDestination(whichLand.getEmptyPosition()); actionManager.moveCharacter(chac, whichLand.getEmptyPosition());//动作执行 chac.getOnLand(whichLand); whichLand.getOnLand(chac); } //上船 else { LandController whichLand = chac.getLandCont(); if (boat.getEmptyIndex() == -1) { return; } if (whichLand.getSide() != boat.getOnWhere()) { return; } whichLand.getOffLand(chac.getChaName()); //chac.movePosition(boat.getEmptyPos()); // chac.setDestination(boat.getEmptyPos()); actionManager.moveCharacter(chac, boat.getEmptyPos());//动作执行 chac.getOnBoat(boat); boat.getOnBoat(chac); } userGUI.Status = isOver();//判断游戏是否已经达到了结束的条件 }
public void ClickCharacter(ICharacterController character) { if (userGUI.status != 0 || !boat.available()) { return; } if (character.isOnBoat()) { LandController land; if (boat.getBoatPos() == 0) { land = leftLand; } else { land = rightLand; } boat.getOffBoat(character.getName()); actionManager.moveCharacter(character, land.getEmptyPosition()); character.getOnLand(land); land.getOnLand(character); } else { LandController land = character.getLandController(); if (boat.getEmptyIndex() == -1) { return; } int landPos = land.getType(), boatPos = (boat.getBoatPos() == 0) ? -1 : 1; if (landPos != boatPos) { return; } land.getOffLand(character.getName()); actionManager.moveCharacter(character, boat.getEmptyPosition()); character.getOnBoat(boat, boat.getEmptyIndex()); boat.getOnBoat(character); } userGUI.status = checkResult(); }
public void characterIsClicked(MyCharacterController characterCtrl) { if (characterCtrl.isOnBoat()) { LandController 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.getOnLand(characterCtrl); } else { // character on coast LandController whichCoast = characterCtrl.getCoastController(); if (boat.getEmptyIndex() == -1) { // boat is full return; } if (whichCoast.get_type() != boat.get_to_or_from()) // boat is not on the side of character { return; } whichCoast.getOffLand(characterCtrl.getName()); characterCtrl.moveToPosition(boat.getEmptyPosition()); characterCtrl.getOnBoat(boat); boat.GetOnBoat(characterCtrl); } userGUI.status = check_game_over(); }
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(); }
/// <summary> /// /// </summary> public MainWindow() { mainWindow = this; InitializeComponent(); RailRoadController railRoadController = new RailRoadController(); railRoadController.MdiParent = this; railRoadController.WindowState = FormWindowState.Maximized; railRoadController.Show(); PlatformController platformController = new PlatformController(); platformController.MdiParent = this; platformController.WindowState = FormWindowState.Maximized; platformController.Show(); TrainPlacementController trainPlacementController = new TrainPlacementController(); trainPlacementController.MdiParent = this; trainPlacementController.WindowState = FormWindowState.Maximized; trainPlacementController.Show(); MountainController mountainController = new MountainController(); mountainController.MdiParent = this; mountainController.WindowState = FormWindowState.Maximized; mountainController.Show(); VarHeightBuildingController varHeightBuildingController = new VarHeightBuildingController(); varHeightBuildingController.MdiParent = this; varHeightBuildingController.WindowState = FormWindowState.Maximized; varHeightBuildingController.Show(); LandController landController = new LandController(); landController.MdiParent = this; landController.WindowState = FormWindowState.Maximized; landController.Show(); LandPropertyController landPropertyController = new LandPropertyController(); landPropertyController.MdiParent = this; landPropertyController.WindowState = FormWindowState.Maximized; landPropertyController.Show(); StationPassagewayController stationPassagewayController = new StationPassagewayController(); stationPassagewayController.MdiParent = this; stationPassagewayController.WindowState = FormWindowState.Maximized; stationPassagewayController.Show(); SlopeRailRoadController slopeRailRoadController = new SlopeRailRoadController(); slopeRailRoadController.MdiParent = this; slopeRailRoadController.WindowState = FormWindowState.Maximized; slopeRailRoadController.Show(); //RoadController roadController = new RoadController(); //roadController.MdiParent = mainWindowMDI; //roadController.Show(); BulldozeController bulldozeController = new BulldozeController(); bulldozeController.MdiParent = this; bulldozeController.Show(); BGMPlaylist bgmplaylist = new BGMPlaylist(); bgmplaylist.MdiParent = this; bgmplaylist.Show(); }
public void getOnBoat(BoatController bo) { landController = null; obj.transform.parent = bo.getGameobj().transform; onBoat = true; }
//人物下船 public void getOnLand(LandController land) { landController = land; character.transform.parent = null; onBoat = false; }
//人物上船。设置船为人物的父对象 public void getOnBoat(BoatController boat) { landController = null; character.transform.parent = boat.getGameobj().transform; onBoat = true; }
public void getOnLand(LandController la) { landController = la; obj.transform.parent = null; onBoat = false; }