Beispiel #1
0
    public void Init(Trap trap, Action <TrapActionType, Trap> trapActionCallback)
    {
        _trapActionCallback = trapActionCallback;
        Assert.IsTrue(_trapActionCallback != null);

        _textName.text = trap.Name();
        _textDesc.text = trap.Description();

        _imageIcon.sprite = Resources.Load <Sprite>(trap.ImagePath());

        _btnClose.onClick.RemoveAllListeners();
        _btnFire.onClick.RemoveAllListeners();

        _btnClose.onClick.AddListener(() => {
            Debug.Log("閉じるが押されました");
            gameObject.SetActive(false);

            _trapActionCallback(TrapActionType.Close, trap);
        });

        _btnFire.onClick.AddListener(() => {
            Debug.Log("踏むが押されました");
            gameObject.SetActive(false);

            _trapActionCallback(TrapActionType.Fire, trap);
        });
    }