コード例 #1
0
    public void LoadResources()
    {
        terrainPos = new Vector3(-100, -7, -100);
        Terrain terrain = Instantiate(Resources.Load("Prefab/Terrain", typeof(Terrain)),
                                      terrainPos, Quaternion.identity, null) as Terrain;

        terrain.name = "terrain";

        rightCoastCtrl = new CoastController("right");
        leftCoastCtrl  = new CoastController("left");

        boatCtrl = new BoatController();

        for (int i = 0; i < 3; ++i)
        {
            MyNamespace.CharacterController temp = new MyNamespace.CharacterController("priest" + i);
            temp.SetPosition(rightCoastCtrl.GetEmptyPosition());
            temp.GetOnCoast(rightCoastCtrl);
            rightCoastCtrl.GetOnCoast(temp);
            characters[i] = temp;
        }

        for (int i = 0; i < 3; ++i)
        {
            MyNamespace.CharacterController temp = new MyNamespace.CharacterController("devil" + i);
            temp.SetPosition(rightCoastCtrl.GetEmptyPosition());
            temp.GetOnCoast(rightCoastCtrl);
            rightCoastCtrl.GetOnCoast(temp);
            characters[i + 3] = temp;
        }
    }
コード例 #2
0
    public void LoadResources()
    {
        riverPos = new Vector3(0, 0.5f, 0);
        GameObject river = Instantiate(Resources.Load("Prefab/Water", typeof(GameObject)),
                                       riverPos, Quaternion.identity, null) as GameObject;

        river.name = "river";

        rightCoastCtrl = new CoastController("right");
        leftCoastCtrl  = new CoastController("left");

        boatCtrl = new BoatController();

        for (int i = 0; i < 3; ++i)
        {
            MyNamespace.CharacterController temp = new MyNamespace.CharacterController("priest" + i);
            temp.SetPosition(rightCoastCtrl.GetEmptyPosition());
            temp.myAction.GetOnCoast(temp, rightCoastCtrl);
            //rightCoastCtrl.GetOnCoast(temp);
            characters[i] = temp;
        }

        for (int i = 0; i < 3; ++i)
        {
            MyNamespace.CharacterController temp = new MyNamespace.CharacterController("devil" + i);
            temp.SetPosition(rightCoastCtrl.GetEmptyPosition());
            temp.myAction.GetOnCoast(temp, rightCoastCtrl);
            //rightCoastCtrl.GetOnCoast(temp);
            characters[i + 3] = temp;
        }
    }
コード例 #3
0
 public void CharacterClicked(MyNamespace.CharacterController characterCtrl)
 {
     if (characterCtrl.character.IsOnBoat)
     {
         CoastController tempCoast = (boatCtrl.boat.Location == Location.right ? rightCoastCtrl : leftCoastCtrl);
         boatCtrl.GetOffBoat(characterCtrl.character.Name);
         actionManager.MoveCharacter(characterCtrl, tempCoast.GetEmptyPosition());
         characterCtrl.GetOnCoast(tempCoast);
         tempCoast.GetOnCoast(characterCtrl);
     }
     else
     {
         CoastController tempCoast = characterCtrl.character.Coast;
         if (tempCoast.coast.Location != boatCtrl.boat.Location)
         {
             return;                                                         // Boat at another side
         }
         if (boatCtrl.GetEmptyIndex() == -1)
         {
             return;                                                         // Boat is full
         }
         tempCoast.GetOffCoast(characterCtrl.character.Name);
         actionManager.MoveCharacter(characterCtrl, boatCtrl.GetEmptyPosition());
         characterCtrl.GetOnBoat(boatCtrl);
         boatCtrl.GetOnBoat(characterCtrl);
     }
     UserGUI.status = CheckGameOver();
 }
コード例 #4
0
    public void MoveCharacter(MyNamespace.CharacterController characterCtrl, Vector3 destination)
    {
        Vector3 currentPos = characterCtrl.character.Role.transform.position;
        Vector3 middlePos  = currentPos;

        //采用线段式的折线运动
        //终点纵坐标小,则为从岸上船
        //否则,从船上岸
        if (destination.y > currentPos.y)
        {
            middlePos.y = destination.y;
        }
        else
        {
            middlePos.x = destination.x;
        }
        SSAction action1 = SSMoveToAction.GetSSMoveToAction(middlePos, characterCtrl.character.movingSpeed);
        SSAction action2 = SSMoveToAction.GetSSMoveToAction(destination, characterCtrl.character.movingSpeed);
        //动作队列完成上船或上岸动作
        SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, new List <SSAction> {
            action1, action2
        });

        AddAction(characterCtrl.character.Role, seqAction, this);
    }