public void loadResources()
    {
        Vector3    river_pos = new Vector3(0, 0.5F, 0);
        GameObject river     = Instantiate(Resources.Load("Perfabs/River", typeof(GameObject)), river_pos, Quaternion.identity, null) as GameObject;

        river.name = "river";
        fromCoast  = new CoastCon("from");
        toCoast    = new CoastCon("to");
        boat       = new BoatCon();
        for (int i = 0; i < 3; i++)
        {
            ChaCon cha = new ChaCon("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++)
        {
            ChaCon cha = new ChaCon("devil");
            cha.setName("devil" + i);
            cha.setPosition(fromCoast.getEmptyPosition());
            cha.getOnCoast(fromCoast);
            fromCoast.getOnCoast(cha);
            characters [i + 3] = cha;
        }
        userGUI.tips = AI.getInstance().tip(fromCoast, toCoast, boat);
    }
Пример #2
0
    public int check(CoastCon fromCoast, CoastCon toCoast, BoatCon boat)          // 0->not finish, 1->lose, 2->win
    {
        int fromP = 0, fromD = 0, toP = 0, toD = 0;

        int[] fromCount = fromCoast.getCharacterNum();
        fromP += fromCount[0];
        fromD += fromCount[1];

        int[] toCount = toCoast.getCharacterNum();
        toP += toCount[0];
        toD += toCount[1];

        if (toP + toD == 6)
        {
            return(2);                //win
        }
        int[] boatCount = boat.getCharacterNum();
        if (boat.getStatus() == -1)
        {
            toP += boatCount[0]; toD += boatCount[1];   // boat at toCoast
        }
        else
        {
            fromP += boatCount[0]; fromD += boatCount[1];       // boat at fromCoast
        }
        if (fromP < fromD && fromP > 0)
        {
            return(1);                            //lose
        }
        if (toP < toD && toP > 0)
        {
            return(1);                   //lose
        }
        return(0);                       // not finish
    }
Пример #3
0
    public void loadResources()
    {
        Vector3    river_pos = new Vector3(0, 0.5F, 0);
        GameObject river     = Instantiate(Resources.Load("Perfabs/River", typeof(GameObject)), river_pos, Quaternion.identity, null) as GameObject;

        river.name = "river";
        fromCoast  = new CoastCon("from");
        toCoast    = new CoastCon("to");
        boat       = new BoatCon();
    }
Пример #4
0
    public int tip(CoastCon fromCoast, CoastCon toCoast, BoatCon boat)
    {
        int fromP = 0, fromD = 0, toP = 0, toD = 0, boatst = 0;

        int[] fromCount = fromCoast.getCharacterNum();
        fromP += fromCount[0];
        fromD += fromCount[1];

        int[] toCount = toCoast.getCharacterNum();
        toP += toCount[0];
        toD += toCount[1];

        int[] boatCount = boat.getCharacterNum();
        if (boat.getStatus() == -1)
        {
            boatst = 1;
        }
        else
        {
            boatst = 0;
        }
        if (boat.getStatus() == -1)
        {
            toP += boatCount[0]; toD += boatCount[1];   // boat at toCoast
        }
        else
        {
            fromP += boatCount[0]; fromD += boatCount[1];       // boat at fromCoast
        }
        Debug.Log(fromP.ToString() + ' ' + fromD.ToString() + ' ' + get(boatst, fromP, fromD).ToString());
        for (int o = 0; o <= 1; o++)
        {
            for (int i = 0; i <= 3; i++)
            {
                for (int j = 0; j <= 3; j++)
                {
                    if (trans[get(boatst, fromP, fromD), get(o, i, j)] == 1)
                    {
                        return(get(boatst, i, j));
                    }
                }
            }
        }

        return(-1);
    }
    public void ClickCha(ChaCon cha)
    {
        if (cha.isOnBoat())
        {
            CoastCon nowCoast;
            if (boat.getStatus() == -1)
            {
                nowCoast = toCoast;                                      // to->-1; from->1
            }
            else
            {
                nowCoast = fromCoast;
            }
            boat.getOffBoat(cha.getName());

            Vector3 end_pos    = nowCoast.getEmptyPosition();                                                 //动作分离版本改变
            Vector3 middle_pos = new Vector3(cha.getGameObject().transform.position.x, end_pos.y, end_pos.z); //动作分离版本改变
            actionManager.moveCha(cha.getGameObject(), middle_pos, end_pos, cha.move_speed);                  //动作分离版本改变

            cha.getOnCoast(nowCoast);
            nowCoast.getOnCoast(cha);
        }
        else                                                                            // character on coast
        {
            CoastCon nowCoast = cha.getCoastCon();
            if (boat.getEmptyIndex() == -1)
            {
                return;                                          // boat is full
            }
            if (nowCoast.getStatus() != boat.getStatus())
            {
                return;                                                         // boat is not on the side of character
            }
            nowCoast.getOffCoast(cha.getName());

            Vector3 end_pos    = boat.getEmptyPosition();                                                     //动作分离版本改变
            Vector3 middle_pos = new Vector3(end_pos.x, cha.getGameObject().transform.position.y, end_pos.z); //动作分离版本改变
            actionManager.moveCha(cha.getGameObject(), middle_pos, end_pos, cha.move_speed);                  //动作分离版本改变

            cha.getOnBoat(boat);
            boat.getOnBoat(cha);
        }
        userGUI.status = Judger.getInstance().check(fromCoast, toCoast, boat);
        userGUI.tips   = AI.getInstance().tip(fromCoast, toCoast, boat);
    }
Пример #6
0
 public void ClickCha(ChaCon cha)
 {
     if (cha.isOnBoat())
     {
         CoastCon nowCoast;
         if (boat.getStatus() == -1)
         {
             nowCoast = toCoast;                                      // to->-1; from->1
         }
         else
         {
             nowCoast = fromCoast;
         }
         boat.getOffBoat(cha.getName());
         cha.moveToPosition(nowCoast.getEmptyPosition());
         cha.getOnCoast(nowCoast);
         nowCoast.getOnCoast(cha);
     }
     else                                                                            // character on coast
     {
         CoastCon nowCoast = cha.getCoastCon();
         if (boat.getEmptyIndex() == -1)
         {
             return;                                          // boat is full
         }
         if (nowCoast.getStatus() != boat.getStatus())
         {
             return;                                                         // boat is not on the side of character
         }
         nowCoast.getOffCoast(cha.getName());
         cha.moveToPosition(boat.getEmptyPosition());
         cha.getOnBoat(boat);
         boat.getOnBoat(cha);
     }
     userGUI.status = check();
 }
Пример #7
0
 public void ClickCha(ChaCon cha)
 {
     if (cha.isOnBoat())
     {
         CoastCon nowCoast;
         if (boat.getStatus() == -1)
         {
             nowCoast = toCoast;
         }
         else
         {
             nowCoast = fromCoast;
         }
         boat.getOffBoat(cha.getName());
         cha.moveToPosition(nowCoast.getEmptyPosition());
         cha.getOnCoast(nowCoast);
         nowCoast.getOnCoast(cha);
     }
     else
     {
         CoastCon nowCoast = cha.getCoastCon();
         if (boat.getEmptyIndex() == -1)
         {
             return;
         }
         if (nowCoast.getStatus() != boat.getStatus())
         {
             return;
         }
         nowCoast.getOffCoast(cha.getName());
         cha.moveToPosition(boat.getEmptyPosition());
         cha.getOnBoat(boat);
         boat.getOnBoat(cha);
     }
     userGUI.status = check();
 }