示例#1
0
    public void OnClick()
    {
        int level = WeaponDB.Instance.GetWeaponLvById((int)weaponType);

        if (level == 0)
        {
            return;
        }

        if (!selected && IsCloseWeapon && dlg != null && dlg.HasCloseWeaponSelected())         // 只能选择一把近战武器
        {
            return;
        }
        if (!selected && dlg.SelectedGunWeaponCount() >= 4 && !IsCloseWeapon)
        {
            return;
        }

        //		if (!selected && GameData.Instance.selectedWeapons.Count == 0 && !IsCloseWeapon) return;

        selected = !selected;

        if (GetComponentInParent <TutorialDialog>() != null)
        {
            Debug.Log("??????????????");
            TutorialDialog td = GetComponentInParent <TutorialDialog>();
            parent = td.Param.target.GetComponent <WeaponSelectionItem>();
            parent.OnClick();
            return;
        }

        if (parent != null)
        {
            parent.selected = selected;
        }
        if (dlg != null)
        {
            dlg.OnSelectedWeaponsChanged();
        }

        if (selected)
        {
            icon.color = new Color(0.3f, 0.3f, 0.3f);
        }
        else
        {
            icon.color = Color.white;
            if (parent != null)
            {
                parent.icon.color = Color.white;
            }
        }
    }