// It is called when player resets the game. public void Reset() { CoastController coast = (Director.GetInstance().currentSceneController as GameController).rightCoast; GoAshore(coast); transform.position = nowDestination; }
// It is called when player clicks a character. public void ClickCharacter(CharacterController character) { // When the character is onboard, it should go ashore. if (character.model.isOnboard) { CoastController temp = (boat.location == Location.Right ? rightCoast : leftCoast); boat.GoAshore(character); character.GoAshore(temp); actionManager.MoveCharacter(character); } else // When the character is onshore, it should go aboard. { // When the character and the boat are not on the same side. if (character.location != boat.location) { return; } // When the boat is full. if (boat.model.GetEmptyIndex() == -1) { return; } // Go aboard. CoastController temp = (character.location == Location.Right ? rightCoast : leftCoast);; temp.GoAboard(character); character.GoAboard(boat); actionManager.MoveCharacter(character); } game.CheckWinner(); }
// It is called when a character goes ashore. public void GoAshore(CoastController coast) { model.location = coast.location; model.isOnboard = false; transform.parent = null; SetDestination(coast.model.GetEmptyPosition()); coast.GoAshore(this); }
// It generates the GameObjects. private void GenGameObjects() { // Load River. { GameObject temp = Utils.Instantiate("Prefabs/Water", new Vector3(0, 0.5f, 0)); temp.name = "River"; } // Load LeftCoast. { GameObject temp = Utils.Instantiate("Prefabs/Stone", Coast.departure); leftCoast = temp.AddComponent <CoastController>(); temp.name = leftCoast.name = "LeftCoast"; leftCoast.location = Location.Left; } // Load RightCoast. { GameObject temp = Utils.Instantiate("Prefabs/Stone", Coast.destination); rightCoast = temp.AddComponent <CoastController>(); temp.name = rightCoast.name = "RightCoast"; rightCoast.location = Location.Right; } // Load Boat. { GameObject temp = Utils.Instantiate("Prefabs/Boat", Boat.departure); boat = temp.AddComponent <BoatController>(); temp.name = boat.name = "Boat"; } // Load Priests. for (int i = 0; i < 3; ++i) { GameObject temp = Utils.Instantiate("Prefabs/Priest", Coast.destination); characters[i] = temp.AddComponent <CharacterController>(); temp.name = characters[i].name = "Priest" + i; characters[i].GoAshore(rightCoast); } // Load Devils. for (int i = 0; i < 3; ++i) { GameObject temp = Utils.Instantiate("Prefabs/Devil", Coast.destination); characters[i + 3] = temp.AddComponent <CharacterController>(); temp.name = characters[i + 3].name = "Devil" + i; characters[i + 3].GoAshore(rightCoast); } }