Ejemplo n.º 1
0
    void Start()
    {
        player = FindObjectOfType <PlayerController>();
        dialogueHandlerBefore = GetComponent <Fog.Dialogue.DialogueHandler>();

        triggerCol = GetComponent <Collider2D>();
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     player           = FindObjectOfType <PlayerController>();
     player.canMove   = false;
     player.canAttack = false;
     hearts.SetActive(false);
     dialogueHandler = GetComponent <Fog.Dialogue.DialogueHandler>();
     dialogueHandler.OnDialogueStart += StartFading;
     dialogueHandler.OnDialogueEnd   += StartGame;
     dialogueHandler.StartDialogue();
 }
Ejemplo n.º 3
0
 private void Awake()
 {
     if (isSingleton)
     {
         if (instance == null)
         {
             instance = this;
         }
         else if (instance != this)
         {
             Destroy(this);
         }
     }
 }
Ejemplo n.º 4
0
 private void Awake()
 {
     if (isSingleton)
     {
         if (instance == null)
         {
             instance = this;
         }
         else if (instance != this)
         {
             Destroy(this);
         }
     }
     isActive    = false;
     agent       = null;
     movingAgent = null;
 }
Ejemplo n.º 5
0
        static void CreateScrollPanel(MenuCommand menuCommand)
        {
            // Create a custom game object
            GameObject panelObj = new GameObject("Dialogue Scroll Panel");

            // Register the creation in the undo system
            Undo.RegisterCreatedObjectUndo(panelObj, "Create " + panelObj.name);
            // Cria um Canvas se ele nao existir
            Canvas canvas = FindObjectOfType <Canvas>();

            if (!canvas)
            {
                GameObject canvasObj = new GameObject("Canvas", typeof(CanvasScaler));
                Undo.RegisterCreatedObjectUndo(canvasObj, "Create " + canvasObj.name);
                canvas = canvasObj.GetComponent <Canvas>();
                CanvasScaler canvasScaler = canvasObj.GetComponent <CanvasScaler>();
                canvasScaler.uiScaleMode            = CanvasScaler.ScaleMode.ConstantPixelSize;
                canvasScaler.scaleFactor            = 1f;
                canvasScaler.referencePixelsPerUnit = 100f;
                canvas.renderMode               = RenderMode.ScreenSpaceCamera;
                canvas.worldCamera              = FindObjectOfType <Camera>();
                canvas.pixelPerfect             = true;
                canvas.sortingOrder             = 10;
                canvas.targetDisplay            = 0;
                canvas.planeDistance            = 100f;
                canvas.additionalShaderChannels = AdditionalCanvasShaderChannels.Normal | AdditionalCanvasShaderChannels.Tangent | AdditionalCanvasShaderChannels.TexCoord1;
            }
            // Adiciona o panel como filho do canvas e seta propriedades iniciais
            panelObj.transform.SetParent(canvas.transform);
            panelObj.AddComponent <DialogueScrollPanel>();
            panelObj.GetComponent <CanvasRenderer>().cullTransparentMesh = false;
            panelObj.GetComponent <Mask>().showMaskGraphic = true;
            Image img = panelObj.GetComponent <Image>();

            img.transform.localPosition = new Vector3(img.transform.localPosition.x, img.transform.localPosition.y, 0f);
            img.sprite        = AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/Background.psd");
            img.color         = Color.white;
            img.material      = null;
            img.raycastTarget = true;
            img.type          = Image.Type.Sliced;
            img.fillCenter    = true;
            int count = 0;

            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            img.rectTransform.pivot = new Vector2(0.5f, 0f);
            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0f, 0);
            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0f, 0);
            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0f, 150f);
            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            img.rectTransform.anchorMin = new Vector2(0f, 0f);
            img.rectTransform.anchorMax = new Vector2(1f, 0f);
            Debug.Log("count = " + (count++) + ":  posZ = " + img.transform.localPosition.z);
            //img.rectTransform.position = new Vector3(img.rectTransform.position.x, 0f, img.rectTransform.position.z);
            img.rectTransform.localScale = new Vector3(1f, 1f, 1f);
            // Adiciona o objeto de viewport como filho do panel
            GameObject viewObj = new GameObject("Viewport");

            Undo.RegisterCreatedObjectUndo(viewObj, "Create " + viewObj.name);
            viewObj.transform.SetParent(panelObj.transform);
            viewObj.AddComponent <Image>();
            viewObj.AddComponent <Mask>();
            img = viewObj.GetComponent <Image>();
            img.transform.localPosition = new Vector3(img.transform.localPosition.x, img.transform.localPosition.y, 0f);
            img.sprite        = AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/Background.psd");
            img.color         = Color.white;
            img.material      = null;
            img.raycastTarget = true;
            img.type          = Image.Type.Sliced;
            img.fillCenter    = true;
            viewObj.GetComponent <Mask>().showMaskGraphic = false;
            viewObj.GetComponent <CanvasRenderer>().cullTransparentMesh = false;
            panelObj.GetComponent <DialogueScrollPanel>().viewport      = img.rectTransform;
            img.rectTransform.pivot = new Vector2(0f, 0f);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0f, 0f);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0f, 0f);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0f, 0f);
            img.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0f, 0f);
            img.rectTransform.anchorMin = new Vector2(0f, 0f);
            img.rectTransform.anchorMax = new Vector2(1f, 1f);
            img.rectTransform.sizeDelta = new Vector2(0f, 0f);
            //img.rectTransform.position = new Vector3(0f, 0f, 0f);
            img.rectTransform.localScale = new Vector3(1f, 1f, 1f);
            // Adiciona o objeto de content como filho do viewport
            // O content por padrao contem um TextMeshProGUI
            GameObject contentObj = new GameObject("Content");

            Undo.RegisterCreatedObjectUndo(contentObj, "Create " + contentObj.name);
            contentObj.transform.SetParent(viewObj.transform);
            contentObj.AddComponent <ContentSizeFitter>();
            contentObj.AddComponent <TMPro.TextMeshProUGUI>();
            contentObj.GetComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            contentObj.GetComponent <ContentSizeFitter>().verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            TMPro.TextMeshProUGUI textMesh = contentObj.GetComponent <TMPro.TextMeshProUGUI>();
            textMesh.transform.localPosition = new Vector3(img.transform.localPosition.x, img.transform.localPosition.y, 0f);
            textMesh.font               = TMPro.TMP_FontAsset.defaultFontAsset;
            textMesh.fontSize           = 21;
            textMesh.color              = Color.black;
            textMesh.alignment          = TMPro.TextAlignmentOptions.TopJustified;
            textMesh.wordWrappingRatios = 0f;
            textMesh.overflowMode       = TMPro.TextOverflowModes.ScrollRect;
            textMesh.margin             = new Vector4(3, 20, 3, 1);
            panelObj.GetComponent <DialogueScrollPanel>().content = textMesh.rectTransform;
            textMesh.rectTransform.pivot = new Vector2(0f, 1f);
            textMesh.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0f, 0f);
            textMesh.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0f, 0f);
            textMesh.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0f, 0f);
            textMesh.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0f, 0f);
            textMesh.rectTransform.anchorMin  = new Vector2(0f, 1f);
            textMesh.rectTransform.anchorMax  = new Vector2(1f, 1f);
            textMesh.rectTransform.sizeDelta  = new Vector2(0f, 0f);
            textMesh.rectTransform.localScale = new Vector3(1f, 1f, 1f);
            // Configura o DialogueHandler da cena (cria se necessario)
            DialogueHandler handler = FindObjectOfType <DialogueHandler>();

            if (!handler)
            {
                GameObject go = new GameObject("Dialogue Handler", typeof(DialogueHandler));
                Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
                handler = go.GetComponent <DialogueHandler>();
            }
            handler.dialogueText     = textMesh;
            handler.useTitles        = true;
            handler.titleText        = textMesh;
            handler.dialogueBox      = panelObj.GetComponent <DialogueScrollPanel>();
            handler.useTypingEffect  = true;
            handler.fillInBeforeSkip = true;
            handler.isSingleton      = true;

            // Select newly created object
            panelObj.SetActive(false);
            Selection.activeObject = panelObj;
        }
Ejemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     player          = FindObjectOfType <PlayerController>();
     dialogueHandler = GetComponent <Fog.Dialogue.DialogueHandler>();
 }
Ejemplo n.º 7
0
 void Start()
 {
     dialogueHandler = GetComponent <Fog.Dialogue.DialogueHandler>();
     player          = FindObjectOfType <PlayerController>();
     camera          = FindObjectOfType <CameraMovement>();
 }