Ejemplo n.º 1
0
    /// <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();//判断游戏是否已经达到了结束的条件
    }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
    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();
    }