Exemplo n.º 1
0
 private void Awake()
 {
     artifactsPanel = FindObjectOfType <ArtifactsPanel>();
     artifactButton = GetComponent <Button>();
     artifactButton.OnClick(() => artifactsPanel.SelectedArtifact = Artifact);
     artifactImage = transform.Find("image_artifact").GetComponent <Image>();
     blendMode     = artifactImage.GetComponent <UIBlendMode>();
 }
Exemplo n.º 2
0
    private void Awake()
    {
        selectedArtifactImage             = transform.Find("image_selected-artifact").GetComponent <Image>();
        selectedArtifactImage.color       = Color.clear;
        selectedArtifactBlendMode         = selectedArtifactImage.GetComponent <UIBlendMode>();
        selectedArtifactNameText          = transform.Find("text_selected-artifact-name").GetComponent <Text>();
        selectedArtifactNameText.text     = string.Empty;
        selectedArtifactScanInfoText      = transform.Find("text_selected-artifact-scan-info").GetComponent <Text>();
        selectedArtifactScanInfoText.text = string.Empty;
        analyzeSelectedArtifactButton     = transform.Find("button_analyze-artifact").GetComponent <Button>();
        analyzeSelectedArtifactButton.OnClick(() => {
            if (SelectedArtifact == null || SelectedArtifact.Status != ArtifactStatus.Found)
            {
                return;
            }

            WorkshopController.AnalyzeArtifact(SelectedArtifact);
            UpdateArtifactView();
        });
        contentParent = transform.Find("panel_artifacts/panel_scroll/content");

        foreach (var artifact in ServiceLocator.State.Artifacts)
        {
            if (artifact.Status == ArtifactStatus.NotFound)
            {
                continue;
            }

            var artifactButton = BaseView.AddUIElement("button_artifact", contentParent).GetComponent <ArtifactButton>();
            artifactButton.Initialize(artifact);
        }
        artifactsScroll = transform.Find("panel_artifacts/panel_scroll").GetComponent <ScrollRect>();
        artifactsScroll.verticalNormalizedPosition = 1;
        scrollUpButton = transform.Find("panel_artifacts/button_scroll-up").GetComponent <Button>();
        scrollUpButton.OnClick(() => artifactsScroll.verticalNormalizedPosition =
                                   Mathf.Clamp(artifactsScroll.verticalNormalizedPosition + 1 / ((RectTransform)contentParent).sizeDelta.y * 165, 0, 1));
        scrollDownButton = transform.Find("panel_artifacts/button_scroll-down").GetComponent <Button>();
        scrollDownButton.OnClick(() => artifactsScroll.verticalNormalizedPosition =
                                     Mathf.Clamp(artifactsScroll.verticalNormalizedPosition - 1 / ((RectTransform)contentParent).sizeDelta.y * 165, 0, 1));

        SelectedArtifact = ServiceLocator.State.Artifacts[0];
    }