Exemplo n.º 1
0
    //创建对象,导入各种预制体资源
    public void loadResources()
    {
        GameObject water = Instantiate(Resources.Load("Prefabs/Water",
                                                      typeof(GameObject)), new Vector3(0, 0.5F, 0), Quaternion.identity, null) as GameObject;

        water.name = "water";
        //设置控制器
        fromShore = new ShoreController("from");
        toShore   = new ShoreController("to");
        boat      = new BoatController();
        //导入游戏人物对象并设置控制器
        for (int i = 0; i < 3; i++)
        {
            MyCharacterController cha = new MyCharacterController("priest");
            cha.setName("priest" + i);
            cha.setPosition(fromShore.getEmptyPosition());
            cha.getOnShore(fromShore);
            fromShore.getOnShore(cha);

            characters[i] = cha;
        }

        for (int i = 0; i < 3; i++)
        {
            MyCharacterController cha = new MyCharacterController("devil");
            cha.setName("devil" + i);
            cha.setPosition(fromShore.getEmptyPosition());
            cha.getOnShore(fromShore);
            fromShore.getOnShore(cha);

            characters[i + 3] = cha;
        }
    }
Exemplo n.º 2
0
 public void reset()
 {
     moveableScript.reset();
     shoreController = (SSDirector.getInstance().currentSceneController as FirstController).fromShore;
     getOnShore(shoreController);
     setPosition(shoreController.getEmptyPosition());
     shoreController.getOnShore(this);
 }
Exemplo n.º 3
0
    //如果点了某个人物判断其是在船上还是在岸上,
    //如果在船上就上岸,如果在岸上就下船
    public void characterIsClicked(MyCharacterController characterCtrl)
    {
        if (characterCtrl.isOnBoat())
        {
            ShoreController whichShore;
            if (boat.get_to_or_from() == -1)
            { // to->-1; from->1
                whichShore = toShore;
            }
            else
            {
                whichShore = fromShore;
            }

            boat.GetOffBoat(characterCtrl.getName());
            characterCtrl.moveToPosition(whichShore.getEmptyPosition());
            characterCtrl.getOnShore(whichShore);
            whichShore.getOnShore(characterCtrl);
        }
        else
        {                                   // character on shore
            ShoreController whichShore = characterCtrl.getShoreController();

            if (boat.getEmptyIndex() == -1)
            {       // boat is full
                return;
            }

            if (whichShore.get_to_or_from() != boat.get_to_or_from())   // boat is not on the side of character
            {
                return;
            }

            whichShore.getOffShore(characterCtrl.getName());
            characterCtrl.moveToPosition(boat.getEmptyPosition());
            characterCtrl.getOnBoat(boat);
            boat.GetOnBoat(characterCtrl);
        }
        userGUI.status = check_game_over();
    }
Exemplo n.º 4
0
 public void getOnShore(ShoreController shoreCtrl)
 {
     shoreController            = shoreCtrl;
     character.transform.parent = null;
     _isOnBoat = false;
 }
Exemplo n.º 5
0
 public void getOnBoat(BoatController boatCtrl)
 {
     shoreController            = null;
     character.transform.parent = boatCtrl.getGameobj().transform;
     _isOnBoat = true;
 }