Esempio n. 1
0
    void Paint(EditModePiece piece)
    {
        if (!piece)
        {
            return;
        }

        editMap[(int)piece.chipPosition.y, (int)piece.chipPosition.x] = selectChipID;

        //一個だけなのでDraw()は呼ばない
        piece.image.sprite = GetMapchipFromID(selectChipID);
    }
Esempio n. 2
0
    //Debug
    //public Text _debugText;

    // Use this for initialization
    void Start()
    {
        editMap           = new int[MAP_SIZE_Y, MAP_SIZE_X];
        generateViewImage = new Image[MAP_SIZE_Y, MAP_SIZE_X];

        //テストマップ
        //editMap = new int[MAP_SIZE_Y, MAP_SIZE_X] {
        //	{1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,3,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,14,0,1 },
        //	{1,0,0,0,0,0,0,0,0,0,0,0,0,1 },
        //	{1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
        //};

        //キャンバスを持ってくる
        canvas = FindObjectOfType <Canvas>();


        //マップチップのロード
        FindObjectOfType <ResourceLoader>().LoadAll();
        mapchipSprite = ResourceLoader.GetChips(R_MapChipType.MainChip);
        holeSprite    = ResourceLoader.GetChips(R_MapChipType.Hole)[0];

        //画像の割当
        currentChip.sprite = GetMapchipFromID(selectChipID);

        //ボタンの機能を設定
        toolHandImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.Hand);
        });
        toolPenImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.Pen);
        });
        toolFillRectImage.GetComponent <Button>().onClick.AddListener(() => {
            ChangeEditTool(EditToolMode.FillRect);
        });

        for (int i = 0; i < selectableChip.Length; i++)
        {
            selectableChip[i].sprite = GetMapchipFromID(ConvertSelectChipID(i));

            //ラムダ式内にループ変数を使うために、ダミーに代入
            int d = i;
            selectableChip[i].GetComponent <Button>().onClick.AddListener(() => {
                ChangeSelectChip(d);
            });
        }

        //表示領域を生成
        for (int i = 0; i < MAP_SIZE_Y; i++)
        {
            for (int j = 0; j < MAP_SIZE_X; j++)
            {
                Image chip = Instantiate(viewChipPre).GetComponent <Image>();
                chip.gameObject.name = "[stage " + j + " " + i + " ]";
                chip.rectTransform.SetParent(viewMapArea);
                chip.rectTransform.localScale = new Vector3(1, 1, 1);

                EditModePiece piece = chip.GetComponent <EditModePiece>();
                piece.image          = chip;
                piece.chipPosition.x = j;
                piece.chipPosition.y = i;

                generateViewImage[i, j] = chip;
            }
        }

        //制限時間の表示更新
        viewTime.text = limitTime.ToString() + "sec";

        //ビューポートがおかしくなる問題を修正
        RectTransform parent = viewMapArea.parent.GetComponent <RectTransform>();

        parent.anchorMin = new Vector2(0, 0);
        parent.anchorMax = new Vector2(1, 1);

        ChangeEditTool(EditToolMode.Hand);

        //描画
        SetViewSize();
        Draw();

        //音楽を再生
        AudioManager.FadeIn(2.0f, BGMType.Select, 1, true);
    }