예제 #1
0
    /// <summary>
    /// 指定したパラメータと位置に応じてプレイヤーを移動させる
    /// </summary>
    /// <param name="ver">縦</param>
    /// <param name="side">横</param>
    /// <param name="high">高さ</param>
    /// <param name="para">移動方向パラメータ</param>
    public void PlayerMove(int para)
    {
        if (g_play_con_Script.Get_MoveFlag())
        {
            return;
        }
        //プレイヤーの現在のポインター取得
        (g_player_ver, g_player_side, g_player_high) = g_play_con_Script.Get_Player_Pointer();
        //移動前のプレイヤーの向きを取得(ジャンプ判定用)
        int before_direction = g_direction_Script.Get_Player_Direction();

        //プレイヤーオブジェクトの向きをパラメータに応じて変更する
        g_direction_Script.Player_Direction_Change(para);
        //移動後のプレイヤーの向きを取得(ジャンプ判定用)
        int after_direction = g_direction_Script.Get_Player_Direction();

        //移動する向きに応じて処理を変える
        switch (para)
        {
        //縦プラス方向
        case g_ver_plus_Para:
            g_player_ver = g_player_ver + 1;
            break;

        //縦マイナス方向
        case g_ver_minus_Para:
            g_player_ver = g_player_ver - 1;
            break;

        //横プラス方向
        case g_side_plus_Para:
            g_player_side = g_player_side + 1;
            break;

        //横マイナス方向
        case g_side_minus_Para:
            g_player_side = g_player_side - 1;
            break;
        }
        //移動が可能か調べる
        g_is_move = Move_Check(g_player_ver, g_player_side, g_player_high);
        //移動不可状態なら
        if (!g_is_move)
        {
            //移動処理中止
            return;
        }
        //移動先に格納されているオブジェクトのタイプ
        int type = g_game_con_Script.Get_Obj_Type(g_player_ver, g_player_side, g_player_high);

        //取得したオブジェクトのタイプに応じて処理
        //空白の時
        //プレイヤーを移動させる
        if (type == 0)
        {
            //落下可能か調べる
            g_is_move = Fall_Check(g_player_ver, g_player_side, g_player_high);
            //落下不可能の時
            if (!g_is_move)
            {
                //移動処理中止
                return;
            }
            //移動先が今と同じ高さなら
            if (g_player_high - g_check_high == 0)
            {
                //移動アニメーション再生
                g_anim_Script.Player_Move_Anim();
            }
            //移動先が自分のいる場所より低い位置なら
            else if (g_player_high - g_check_high != 0)
            {
                //落下モーションを再生
                g_anim_Script.Player_Jump_Anim();
            }
            //移動先の高さの指標を変更する
            g_player_high = g_check_high;

            //移動先のポジション取得
            Vector3 get_pos = g_game_con_Script.Get_Pos(g_player_ver, g_player_side, g_player_high);
            //取得した位置にプレイヤーを移動させる
            g_appearance_move_Script.Player_Move(get_pos);
            //プレイヤーの現在地を更新する
            g_play_con_Script.Storage_Player_Pointer(g_player_ver, g_player_side, g_player_high);
        }
        //移動先が移動前の向いている方向と同じなら
        //ジャンプするか調べる
        else if (before_direction == after_direction)
        {
            //ジャンプできるか調べる
            //条件を満たせばジャンプさせる
            Jump();
        }
    }
예제 #2
0
    /// <summary>
    /// 保持している情報をもとに一手前の状態に戻す
    /// </summary>
    public void Undo_Play()
    {
        if (!g_is_undo)
        {
            return;
        }
        if (g_player_con_Script.Get_MoveFlag())
        {
            return;
        }
        g_is_undo = false;
        //プレイヤーの移動先取得
        Vector3 _player_pos = g_game_con_Script.Get_Pos(g_player_ver, g_player_side, g_player_high);

        //プレイヤー移動
        g_player_obj.transform.position = _player_pos;
        //プレイヤーの保持する指標変更
        g_player_con_Script.Storage_Player_Pointer(g_player_ver, g_player_side, g_player_high);
        //プレイヤーの向きを変更
        g_direction_Script.Player_Direction_Change(g_player_direction);

        //ダイス配列用の指標
        int _dice_pointer = 0;
        //縦・横・高さ配列用の指標
        int _point_pointer = 0;

        //保持している親の数分繰り返す
        for (int i = 0; i < g_undo_parents.Length; i++)
        {
            //親オブジェクト取得
            GameObject _work_parent = g_undo_parents[i];
            //親の子オブジェクトの数取得
            int _work_count = g_undo_dice_counters[i];

            //子オブジェクトの数分繰り返す
            for (int j = 0; j < _work_count; j++)
            {
                //子オブジェクト取得
                GameObject _work_dice = g_undo_dices[j + _dice_pointer];
                //子オブジェクトの親を今保持している親に変更
                _work_dice.transform.parent = _work_parent.transform;
                //縦の指標取得
                g_work_ver = g_dice_pointers[_point_pointer];
                //横の指標取得
                g_work_side = g_dice_pointers[_point_pointer + 1];
                //高さの指標取得
                g_work_high = g_dice_pointers[_point_pointer + 2];
                //元に戻す位置を取得
                Vector3 _undo_pos = g_game_con_Script.Get_Pos(g_work_ver, g_work_side, g_work_high);
                //子オブジェクトを移動
                _work_dice.transform.position = _undo_pos;

                //ダイスのスクリプト取得
                g_squares_Script = _work_dice.GetComponent <Dice_Squares>();
                //ダイスの移動前の指標取得
                (g_before_ver, g_before_side, g_before_high) = g_squares_Script.Get_Dice_Pointer();
                //オブジェクトの種類を取得
                int _type = g_game_con_Script.Get_Obj_Type(g_before_ver, g_before_side, g_before_high);
                //大元の配列からダイスを除去
                g_game_con_Script.Storage_Reset(g_before_ver, g_before_side, g_before_high);

                //移動後の縦・横・高さの指標に変更
                g_squares_Script.Storage_This_Index(g_work_ver, g_work_side, g_work_high);
                //大元の配列にダイス格納
                g_game_con_Script.Storage_Obj(g_work_ver, g_work_side, g_work_high, _work_dice);
                //大元の配列に種類格納
                g_game_con_Script.Storage_Obj_Type(g_work_ver, g_work_side, g_work_high, _type);

                //ダイスの移動後のマス目を取得
                g_work_after_squares = g_squares_Script.Get_Dice_Squares();
                //配列に保持しているマス目を取得する
                g_work_before_squares = Get_Dice_Squares();
                //ダイスが保持しているマス目を保持していたマス目に変更する
                g_squares_Script.Storage_Squares(g_work_before_squares);
                //変更後のマス目に応じてダイスを回転させる
                g_dice_create_Script.Undo_Squares_Change(_work_dice, g_work_before_squares, g_work_after_squares);

                //縦・横・高さ配列の指標を3つ進める
                _point_pointer += 3;
            }
            //ダイス用の配列の指標を取り出した個数分進める
            _dice_pointer += _work_count;
        }
        //手数を戻す
        g_trouble_Script.Trouble_Plus();
        //保持する変数を全て初期化
        Array_Reset();
    }