Ejemplo n.º 1
0
 public MyCharacterController GetOffBoat(string passenger_name)
 {
     for (int i = 0; i < passenger.Length; i++)
     {
         if (passenger[i] != null && passenger[i].getName() == passenger_name)
         {
             MyCharacterController charactorCtrl = passenger[i];
             passenger[i] = null;
             return(charactorCtrl);
         }
     }
     Debug.Log("Cant find passenger in boat: " + passenger_name);
     return(null);
 }
Ejemplo n.º 2
0
 public MyCharacterController getOffCoast(string passenger_name)
 {   // 0->priest, 1->devil
     for (int i = 0; i < passengerPlaner.Length; i++)
     {
         if (passengerPlaner[i] != null && passengerPlaner[i].getName() == passenger_name)
         {
             MyCharacterController charactorCtrl = passengerPlaner[i];
             passengerPlaner[i] = null;
             return(charactorCtrl);
         }
     }
     Debug.Log("cant find passenger on coast: " + passenger_name);
     return(null);
 }
Ejemplo n.º 3
0
        public void characterIsClicked(MyCharacterController characterCtrl)
        {
            // actionManager.select = characterCtrl;
            //  actionManager.chamove(characterCtrl);
            if (characterCtrl.isOnBoat())
            {
                CoastController whichCoast;
                if (boat.get_to_or_from() == -1)
                { // to->-1; from->1
                    whichCoast = toCoast;
                }
                else
                {
                    whichCoast = fromCoast;
                }

                boat.GetOffBoat(characterCtrl.getName());
                actionManager.moveCharacter(characterCtrl, whichCoast.getEmptyPosition());
                //  characterCtrl.moveToPosition(whichCoast.getEmptyPosition());
                characterCtrl.getOnCoast(whichCoast);
                whichCoast.getOnCoast(characterCtrl);
            }
            else
            {                                   // character on coast
                CoastController whichCoast = characterCtrl.getCoastController();

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

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

                whichCoast.getOffCoast(characterCtrl.getName());
                actionManager.moveCharacter(characterCtrl, boat.getEmptyPosition());
                // characterCtrl.moveToPosition(boat.getEmptyPosition());
                characterCtrl.getOnBoat(boat);
                boat.GetOnBoat(characterCtrl);
            }
            userGUI.status = check_game_over();
        }
Ejemplo n.º 4
0
        public void moveCharacter(MyCharacterController characterCtrl, Vector3 destination)
        {
            Vector3 currentPos = characterCtrl.getPos();
            Vector3 middlePos  = currentPos;

            if (destination.y > currentPos.y)
            {       //from low(boat) to high(coast)
                middlePos.y = destination.y;
            }
            else
            {   //from high(coast) to low(boat)
                middlePos.x = destination.x;
            }
            SSAction action1   = moveBoat.getAction(middlePos, characterCtrl.movingSpeed);
            SSAction action2   = moveBoat.getAction(destination, characterCtrl.movingSpeed);
            SSAction seqAction = SequenceAction.getAction(1, 0, new List <SSAction> {
                action1, action2
            });

            this.addAction(characterCtrl.getGameobj(), seqAction, this);
        }
Ejemplo n.º 5
0
        private void loadCharacter()
        {
            for (int i = 0; i < 3; i++)
            {
                MyCharacterController cha = new MyCharacterController("priest");
                cha.setName("priest" + i);
                cha.setPosition(fromCoast.getEmptyPosition());
                cha.getOnCoast(fromCoast);
                fromCoast.getOnCoast(cha);

                characters[i] = cha;
            }

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

                characters[i + 3] = cha;
            }
        }
Ejemplo n.º 6
0
        public void GetOnBoat(MyCharacterController characterCtrl)
        {
            int index = getEmptyIndex();

            passenger[index] = characterCtrl;
        }
Ejemplo n.º 7
0
        public void getOnCoast(MyCharacterController characterCtrl)
        {
            int index = getEmptyIndex();

            passengerPlaner[index] = characterCtrl;
        }
Ejemplo n.º 8
0
 public void setController(MyCharacterController characterCtrl)
 {
     characterController = characterCtrl;
 }