Esempio n. 1
0
    //导入各种预制体资源
    public void LoadResources()
    {
        //背景设置(其实就是一个方块加点贴图。能力限制,就这么弄了)
        background             = Instantiate <Transform>(Resources.Load <Transform>("Prefabs/backGround"), new Vector3(0, 6, 3), Quaternion.identity);
        background.name        = "background";
        background.localScale += new Vector3(35, 20, 2);
        background.Rotate(new Vector3(10, 0, 180));

        //导入陆地、河流和船
        GameObject river = createObject("River", new Vector3(0, 0, -2));

        river.name = "river";

        GameObject leftLand = createObject("Land", new Vector3(-10, 0.5f, -2));

        leftLand.name = "leftLand";

        GameObject rightLand = createObject("Land", new Vector3(10, 0.5f, -2));

        rightLand.name = "rightLand";

        GameObject t_boat = createObject("Boat", new Vector3(5, 1.15f, -2.5f));

        t_boat.name = "boat";

        //设置控制器
        fromLand = new LandController(rightLand, 1);
        toLand   = new LandController(leftLand, -1);
        boat     = new BoatController(t_boat);
        //导入游戏人物对象并设置控制器
        for (int i = 0; i < 3; i++)
        {
            GameObject    temp = createObject("devil", Vector3.zero);
            ChaController cha  = new ChaController(temp, 1);
            cha.setName("devil" + i);
            cha.setPosition(fromLand.getEmptyPosition());
            cha.getOnLand(fromLand);
            fromLand.getOnLand(cha);

            people[i] = cha;
        }

        for (int i = 0; i < 3; i++)
        {
            GameObject    temp = createObject("Priests", Vector3.zero);
            ChaController cha  = new ChaController(temp, 0);

            cha.setName("priest" + i);
            cha.setPosition(fromLand.getEmptyPosition());
            cha.getOnLand(fromLand);
            fromLand.getOnLand(cha);

            people[i + 3] = cha;
        }
    }
Esempio n. 2
0
 //人物上船
 public ChaController getOffLand(string person)
 {
     for (int i = 0; i < people.Length; i++)
     {
         if (people[i] != null && people[i].getChaName() == person)
         {
             ChaController chaCon = people[i];
             people[i] = null;
             return(chaCon);
         }
     }
     return(null);
 }
Esempio n. 3
0
 /// <summary>
 ///
 /// 人物对象下船
 /// </summary>
 /// <param name="name">下船的人的名字</param>
 /// <returns>返回这个对象的控制器</returns>
 public ChaController getOffBoat(string name)
 {
     for (int i = 0; i < people.Length; i++)
     {
         if (people[i] != null && people[i].getChaName() == name)
         {
             ChaController chac = people[i];
             people[i] = null;
             return(chac);
         }
     }
     return(null);
 }
    /// <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();//判断游戏是否已经达到了结束的条件
    }
    public void moveCharacter(ChaController characterCtrl, Vector3 destination)
    {
        Vector3 halfDest   = destination;
        Vector3 currentPos = characterCtrl.getPosition();

        if (destination.y > currentPos.y)
        {
            halfDest.x = currentPos.x;
        }
        //上船时转折处理
        else
        {
            halfDest.y = currentPos.y;
        }
        SSAction action1   = CCMoveToAction.GetSSAction(halfDest, characterCtrl.Speed);
        SSAction action2   = CCMoveToAction.GetSSAction(destination, characterCtrl.Speed);
        SSAction seqAction = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> {
            action1, action2
        });

        this.RunAction(characterCtrl.getCharacter(), seqAction, this);
    }
Esempio n. 6
0
    //人物上岸,找个没人的位置给他
    public void getOnLand(ChaController cha)
    {
        int index = getEmptyIndex();

        people[index] = cha;
    }
Esempio n. 7
0
    //人物对象上船
    public void getOnBoat(ChaController chac)
    {
        int index = getEmptyIndex();

        people[index] = chac;
    }
Esempio n. 8
0
 //设置点击的人物
 public void setController(ChaController chaController)
 {
     chac = chaController;
 }