Exemplo n.º 1
0
 public GameObject GetCurrentLandSide(Riverside _side)
 {
     if (_side == Riverside.Left)
     {
         return(leftLand);
     }
     else
     {
         return(rightLand);
     }
 }
    public bool isSwimming = false; //判断船是否在移动,移动中时不能上下船

    void Awake()
    {
        side        = Riverside.Right;
        seatPoints  = new Transform[transform.childCount];
        isSeatEmpty = new bool[transform.childCount];
        for (int i = 0; i < transform.childCount; i++)
        {
            seatPoints[i]  = transform.GetChild(i).transform;
            isSeatEmpty[i] = true;
        }
    }
Exemplo n.º 3
0
    /* public void excuse() {
     * public void excuse() {
     *  Debug.Log(this.name + "is excusing");
     *  //如果物体和船在同一侧才能操作
     *  Debug.Log(this.side);
     *  Debug.Log(gameController.boat.side);
     *  //船不在移动,且游戏没有输时才可以对人进行操作
     *  if (gameController.boat.isSwimming == false && gameController.isLose == false)
     *  {
     *      if (this.side == gameController.boat.side)
     *      {
     *          Debug.Log(this.name + "on the same side");
     *          if (isOnBoat == false && gameController.boat.count < 2) //如果人在岸上且船未满
     *          {
     *              Debug.Log(this.name + "is get on the boat");
     *              for (int i = 0; i < gameController.boat.isSeatEmpty.Length; i++)
     *              {
     *                  if (gameController.boat.isSeatEmpty[i] == true) //找到一个空位置做进去
     *                  {
     *                      Debug.Log("find this seat: " + i);
     *                      this.transform.position = gameController.boat.seatPoints[i].position;
     *                      transform.SetParent(gameController.boat.transform);
     *                      gameController.GetCurrentLandSide(this.side).GetComponent<Land>().isSeatEmpty[index] = true;
     *                      gameController.boat.isSeatEmpty[i] = false;
     *                      index = i;
     *                      isOnBoat = true;
     *
     *                      gameController.GetCurrentLandSide(this.side).GetComponent<Land>().count--;
     *                      gameController.GetCurrentLandSide(this.side).GetComponent<Land>().manAndDevil -= this.charactor;
     *                      gameController.boat.count++;
     *                      gameController.boat.manAndDevil += this.charactor;
     *                      break;
     *                  }
     *              }
     *          }
     *          else if (isOnBoat == true)
     *          { //如果人在船上
     *              Land currentLandSide = gameController.GetCurrentLandSide(gameController.boat.side).GetComponent<Land>();
     *              Debug.Log("current Land Side is " + currentLandSide.side);
     *              for (int i = 0; i < currentLandSide.isSeatEmpty.Length; i++)
     *              {
     *                  if (currentLandSide.isSeatEmpty[i] == true)
     *                  { //找到岸上的一个空位置坐进去
     *                      this.transform.position = currentLandSide.seatPoints[i].position;
     *                      this.transform.SetParent(currentLandSide.transform);
     *                      gameController.boat.isSeatEmpty[index] = true;
     *                      currentLandSide.isSeatEmpty[i] = false;
     *                      index = i;
     *
     *                      gameController.GetCurrentLandSide(this.side).GetComponent<Land>().count++;
     *                      gameController.GetCurrentLandSide(this.side).GetComponent<Land>().manAndDevil += this.charactor;
     *                      gameController.boat.manAndDevil -= this.charactor;
     *                      gameController.boat.count--;
     *                      isOnBoat = false;
     *                      break;
     *                  }
     *              }
     *          }
     *      }
     *  }
     * }
     */

    public void ChangeSide()
    {
        if (side == Riverside.Left)
        {
            side = Riverside.Right;
        }
        else
        {
            side = Riverside.Left;
        }
    }
 public void  excuse()
 {
     //船没有在移动,且船上有人,且游戏没有输掉也没有赢
     if (isSwimming == false && this.count != 0 && gameController.isLose == false && gameController.isWin == false)
     {
         if (this.side == Riverside.Left)
         {
             StartCoroutine(MoveToPosition(new Vector3(3f, 0.2f, 0f)));
             this.side = Riverside.Right;
             this.BroadcastMessage("ChangeSide", SendMessageOptions.DontRequireReceiver);
         }
         else
         {
             StartCoroutine(MoveToPosition(new Vector3(-3f, 0.2f, 0f)));
             this.side = Riverside.Left;
             this.BroadcastMessage("ChangeSide", SendMessageOptions.DontRequireReceiver);
         }
     }
 }