LoginSignup
0
2

More than 3 years have passed since last update.

脱出ゲームスクリプトメモ

Posted at

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;//書き加えないとToggleが使えない

public class tutorialScript : MonoBehaviour {

public GameObject wall1;
public GameObject wall2;
public GameObject wall3;
public GameObject wall4;

public GameObject close_door;//閉じた状態のドア
public GameObject open_door;//開いたドア
public GameObject close_treasurebox1;//閉じた宝箱1
public GameObject open_treasurebox1;//開いた宝箱1
public GameObject close_treasurebox2;//閉じた宝箱2
public GameObject open_treasurebox2;//開いた宝箱2

public GameObject key1;//カギ1を格納
public GameObject key2;//カギ2を格納

public Toggle key1_toggle;//カギ1を格納、アイテム選択の状態を取得するのに必要
public Toggle key2_toggle;//カギ2を格納、アイテム選択の状態を取得するのに必要

public GameObject calender_kakudai;//カレンダーの拡大画面
public GameObject treasurebox2_kakudai;//宝箱2の数字入力画面

public GameObject itemgetandclear;//下3つを表示するための全画面の透明な土台
public GameObject key1_get;//カギ1入手時に表示
public GameObject key2_get;//カギ2入手時に表示
public GameObject clear_text;//ドアを開けた時に表示

public GameObject left0;
public GameObject left1;
public GameObject left2;
public GameObject left3;
public GameObject left4;
public GameObject left5;
public GameObject left6;
public GameObject left7;
public GameObject left8;
public GameObject left9;

public GameObject center0;
public GameObject center1;
public GameObject center2;
public GameObject center3;
public GameObject center4;
public GameObject center5;
public GameObject center6;
public GameObject center7;
public GameObject center8;
public GameObject center9;

public GameObject right0;
public GameObject right1;
public GameObject right2;
public GameObject right3;
public GameObject right4;
public GameObject right5;
public GameObject right6;
public GameObject right7;
public GameObject right8;
public GameObject right9;

void Update()
{
    //613と入力し、かつ宝箱2が閉じているとき
    if (left6.activeInHierarchy == true && center1.activeInHierarchy == true &&
        right3.activeInHierarchy == true&& close_treasurebox2.activeInHierarchy == true)
    {
        close_treasurebox2.SetActive(false);
        open_treasurebox2.SetActive(true);
        treasurebox2_kakudai.SetActive(false);
        itemgetandclear.SetActive(true);
        key1_get.SetActive(true);
    }
}

public void gotowall1()
{
    wall1.SetActive(true);
    wall2.SetActive(false);
    wall3.SetActive(false);
    wall4.SetActive(false);
}

public void gotowall2()
{
    wall1.SetActive(false);
    wall2.SetActive(true);
    wall3.SetActive(false);
    wall4.SetActive(false);
}

public void gotowall3()
{
    wall1.SetActive(false);
    wall2.SetActive(false);
    wall3.SetActive(true);
    wall4.SetActive(false);
}

public void gotowall4()
{
    wall1.SetActive(false);
    wall2.SetActive(false);
    wall3.SetActive(false);
    wall4.SetActive(true);
}

//ヒエラルキーの閉じたドアに取り付ける
public void doortap()
{
    if (key2.activeInHierarchy == true && key2_toggle.isOn == true)
    {
        key2.SetActive(false);
        close_door.SetActive(false);
        open_door.SetActive(true);
        itemgetandclear.SetActive(true);
        clear_text.SetActive(true);
    }
}

//ヒエラルキーのカレンダーに取り付ける
public void calendertap()
{
    calender_kakudai.SetActive(true);
}
//ヒエラルキーのカレンダー拡大画像のボタンに取り付ける
public void calender_returntap()
{
    calender_kakudai.SetActive(false);
}

//閉じた宝箱1に取り付ける
public void treasurebox1tap()
{
    if (key1.activeInHierarchy == true && key1_toggle.isOn == true)
    {
        key1.SetActive(false);
        close_treasurebox1.SetActive(false);
        open_treasurebox1.SetActive(true);
        itemgetandclear.SetActive(true);
        key2_get.SetActive(true);
    }
}

//閉じた宝箱2に取り付ける
public void treasurebox2tap()
{
    treasurebox2_kakudai.SetActive(true);
}

//数字入力画面の下部の戻るボタンに取り付ける
public void treasurebox2_returntap()
{
    treasurebox2_kakudai.SetActive(false);
}

public void leftbuttontap()
{
    if (left0.activeInHierarchy == true)
    {
        left0.SetActive(false);
        left1.SetActive(true);
    }
    else if (left1.activeInHierarchy == true)
    {
        left1.SetActive(false);
        left2.SetActive(true);
    }
    else if (left2.activeInHierarchy == true)
    {
        left2.SetActive(false);
        left3.SetActive(true);
    }
    else if (left3.activeInHierarchy == true)
    {
        left3.SetActive(false);
        left4.SetActive(true);
    }
    else if (left4.activeInHierarchy == true)
    {
        left4.SetActive(false);
        left5.SetActive(true);
    }
    else if (left5.activeInHierarchy == true)
    {
        left5.SetActive(false);
        left6.SetActive(true);
    }
    else if (left6.activeInHierarchy == true)
    {
        left6.SetActive(false);
        left7.SetActive(true);
    }
    else if (left7.activeInHierarchy == true)
    {
        left7.SetActive(false);
        left8.SetActive(true);
    }
    else if (left8.activeInHierarchy == true)
    {
        left8.SetActive(false);
        left9.SetActive(true);
    }
    else if (left9.activeInHierarchy == true)
    {
        left9.SetActive(false);
        left0.SetActive(true);
    }
}

public void centerbuttontap()
{
    if (center0.activeInHierarchy == true)
    {
        center0.SetActive(false);
        center1.SetActive(true);
    }
    else if (center1.activeInHierarchy == true)
    {
        center1.SetActive(false);
        center2.SetActive(true);
    }
    else if (center2.activeInHierarchy == true)
    {
        center2.SetActive(false);
        center3.SetActive(true);
    }
    else if (center3.activeInHierarchy == true)
    {
        center3.SetActive(false);
        center4.SetActive(true);
    }
    else if (center4.activeInHierarchy == true)
    {
        center4.SetActive(false);
        center5.SetActive(true);
    }
    else if (center5.activeInHierarchy == true)
    {
        center5.SetActive(false);
        center6.SetActive(true);
    }
    else if (center6.activeInHierarchy == true)
    {
        center6.SetActive(false);
        center7.SetActive(true);
    }
    else if (center7.activeInHierarchy == true)
    {
        center7.SetActive(false);
        center8.SetActive(true);
    }
    else if (center8.activeInHierarchy == true)
    {
        center8.SetActive(false);
        center9.SetActive(true);
    }
    else if (center9.activeInHierarchy == true)
    {
        center9.SetActive(false);
        center0.SetActive(true);
    }
}

public void rightbuttontap()
{
    if (right0.activeInHierarchy == true)
    {
        right0.SetActive(false);
        right1.SetActive(true);
    }
    else if (right1.activeInHierarchy == true)
    {
        right1.SetActive(false);
        right2.SetActive(true);
    }
    else if (right2.activeInHierarchy == true)
    {
        right2.SetActive(false);
        right3.SetActive(true);
    }
    else if (right3.activeInHierarchy == true)
    {
        right3.SetActive(false);
        right4.SetActive(true);
    }
    else if (right4.activeInHierarchy == true)
    {
        right4.SetActive(false);
        right5.SetActive(true);
    }
    else if (right5.activeInHierarchy == true)
    {
        right5.SetActive(false);
        right6.SetActive(true);
    }
    else if (right6.activeInHierarchy == true)
    {
        right6.SetActive(false);
        right7.SetActive(true);
    }
    else if (right7.activeInHierarchy == true)
    {
        right7.SetActive(false);
        right8.SetActive(true);
    }
    else if (right8.activeInHierarchy == true)
    {
        right8.SetActive(false);
        right9.SetActive(true);
    }
    else if (right9.activeInHierarchy == true)
    {
        right9.SetActive(false);
        right0.SetActive(true);
    }
}

//ヒエラルキーのアイテム入手、クリアの土台パネルに取り付ける
public void itemgetandcleartap()
{
    if (key1_get.activeInHierarchy == true)
    {
        itemgetandclear.SetActive(false);
        key1_get.SetActive(false);
        key1.SetActive(true);
    }
    if (key2_get.activeInHierarchy == true)
    {
        itemgetandclear.SetActive(false);
        key2_get.SetActive(false);
        key2.SetActive(true);
    }
}

}

0
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2