示例#1
0
    // method to find a preview image to show in the ui.
    private void ExtractCurrentPausePreviewImage(IFlowObject aObject)
    {
        IAsset articyAsset = null;

        // to figure out which asset we could show in our preview, we first try to see if it is an object with a speaker
        var dlgSpeaker = aObject as IObjectWithSpeaker;

        if (dlgSpeaker != null)
        {
            // if we have a speaker, we extract it, because now we have to check if it has a preview image.
            ArticyObject speaker = dlgSpeaker.Speaker;
            if (speaker != null)
            {
                var speakerWithPreviewImage = speaker as IObjectWithPreviewImage;
                if (speakerWithPreviewImage != null)
                {
                    // our speaker has the property for preview image and we assign it to our asset.
                    articyAsset = speakerWithPreviewImage.PreviewImage.Asset;
                }
            }
        }

        // if we have no asset until now, we could try to check if the target itself has a preview image.
        if (articyAsset == null)
        {
            var objectWithPreviewImage = aObject as IObjectWithPreviewImage;
            if (objectWithPreviewImage != null)
            {
                articyAsset = objectWithPreviewImage.PreviewImage.Asset;
            }
        }
    }
    void EndCurrentPuzzle()
    {
        if (CurPuzzle == Puzzles.Length - 1)
        {
            base.PlayFirstBranch();
            Slot_Container sc         = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");
            ArticyObject   curStartOn = sc.Template.Slot_Feature.Slot_Feature_Slot;
            var            a          = curStartOn as IObjectWithFeatureSlot_Feature;
            if (a != null)
            {
                sc.Template.Slot_Feature.Slot_Feature_Slot = a.GetFeatureSlot_Feature().Slot_Feature_Slot;
            }
            else
            {
                Debug.LogError("no slot feature in EndCurrentPuzzle");
            }

            SceneManager.LoadScene(1);
            // SceneManager.LoadScene(1);
        }
        else
        {
            Puzzles[CurPuzzle].gameObject.SetActive(false);
            CurPuzzle++;
            Puzzles[CurPuzzle].gameObject.SetActive(true);
            SetupLerpFade(1f, 0f, 1.5f);
            GameState = eGameState.FADE_IN;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (bIsBubbleSpeechActive)
        {
            if (CurrentHub == null)
            {
                CurrentFadeTime -= Time.deltaTime;
                if (CurrentFadeTime <= 0.0f)
                {
                    bIsBubbleSpeechActive = false;


                    ArticyObject element = DialogueManager.instance.GetNextDialogueElementFromFragment(CurrentDialogueFragment);

                    if (element != null && element != CurrentDialogueFragment)
                    {
                        ContinueBubbleCascadeFromElement(element);
                    }
                    else
                    {
                        HideAllBubbles();
                        AudioManager.instance.UpdateMusicVolume();
                    }
                }
            }
        }
    }
示例#4
0
 public void setProp(string aProperty, object aValue)
 {
     if ((aProperty == "SmallTextValue"))
     {
         SmallTextValue = System.Convert.ToString(aValue);
         return;
     }
     if ((aProperty == "NumberValue"))
     {
         NumberValue = System.Convert.ToSingle(aValue);
         return;
     }
     if ((aProperty == "MediumTextValue"))
     {
         MediumTextValue = System.Convert.ToString(aValue);
         return;
     }
     if ((aProperty == "SmallTextValue_02"))
     {
         SmallTextValue_02 = System.Convert.ToString(aValue);
         return;
     }
     if ((aProperty == "gene"))
     {
         gene = ((ArticyObject)(aValue));
         return;
     }
     if ((aProperty == "colere"))
     {
         colere = ((ArticyObject)(aValue));
         return;
     }
 }
 public void setProp(string aProperty, object aValue)
 {
     if ((aProperty == "Sound"))
     {
         Sound = ((ArticyObject)(aValue));
         return;
     }
 }
示例#6
0
 public void setProp(string aProperty, object aValue)
 {
     if ((aProperty == "ChapterImage"))
     {
         ChapterImage = ((ArticyObject)(aValue));
         return;
     }
 }
示例#7
0
    // when the user actually clicked the zone, the real fun begins.
    // depending on currently held item or not; the underlying condition and its outcome we could end up with a new dialogue or change of scene.
    public void OnPointerClick(PointerEventData eventData)
    {
        // What follows are a bunch of checks, but most of the times we end up with a specific object that triggers something in our logic.
        // this could be a new dialogue telling us that unlocking the door worked; a new dialogue fragment telling us that we can't pickup what the zone represents yet; or a scene change
        ArticyObject outcomeObject = null;

        // using an item means we want to combine the currently held item with the zone, when using a key(item) on a door(zone) for example
        // otherwise we just interact with the zone directly
        if (inventory.IsUsingItem)
        {
            // we check if the used item can interact with our zone
            if (articyZone.Template.ZoneCondition.ItemToInteractWith == inventory.CurrentlyUsedItem)
            {
                // while item and zone seem to match together, we have a condition to check aswell
                var itemInteractResult = articyZone.Template.ZoneCondition.InteractionCondition.CallScript();
                if (itemInteractResult)
                {
                    // make sure we don't keep the item in our hand
                    inventory.StopUsingItem();
                    // so we used the correct item, and we were allowed to interact with the zone
                    // now we trigger the valid interaction script ...
                    articyZone.Template.ZoneCondition.InstructionIfItemValid.CallScript();
                    // and tell the scene manager about a potential target outcome object (new dialogue, new scene etc.)
                    outcomeObject = articyZone.Template.ZoneCondition.LinkIfItemValid;
                }
            }
            else
            {
                // make sure we don't keep the item in our hand
                inventory.StopUsingItem();
                // the item is not the correct one, so we trigger the invalid dialog option
                outcomeObject = articyZone.Template.ZoneCondition.LinkIfItemInvalid;
            }
        }
        else
        {
            // lets check if we can click, and then we follow depending on the outcome
            var result = articyZone.Template.ZoneCondition.ClickCondition.CallScript();
            if (result)
            {
                // we were allowed to click it, so we call its click instruction
                articyZone.Template.ZoneCondition.OnClickInstruction.CallScript(sceneHandler);
                // and get its target outcome object
                outcomeObject = articyZone.Template.ZoneCondition.IfConditionTrue;
            }
            else
            {
                // so the condition was invalid, maybe we have an object
                outcomeObject = articyZone.Template.ZoneCondition.IfConditionFalse;
            }
        }

        // if we have an outcomeObject we pass it to the scene handler
        if (outcomeObject != null)
        {
            sceneHandler.ContinueFlow(outcomeObject);
        }
    }
 public void setProp(string aProperty, object aValue)
 {
     if ((aProperty == "ItemName"))
     {
         ItemName = System.Convert.ToString(aValue);
         return;
     }
     if ((aProperty == "ItemIcon"))
     {
         ItemIcon = ((ArticyObject)(aValue));
         return;
     }
 }
    protected void SetSpeakerImage(ArticyObject speaker)
    {
        Asset speakerImageAsset = ((speaker as IObjectWithPreviewImage).PreviewImage.Asset as Asset);

        if (speakerImageAsset != null)
        {
            SpeakerImage.sprite = speakerImageAsset.LoadAssetAsSprite();
        }
        else
        {
            Debug.LogWarning("Tried to load speaker image with null image asset");
        }
    }
示例#10
0
    // Use this for initialization
    void Start()
    {
        if (myRef.HasReference)
        {
            var obj = myRef.GetObject();
            //Debug.Log (obj);

            DialogueFragment test = ArticyDatabase.GetObject <DialogueFragment> (obj.TechnicalName);
            //Debug.Log (test);
            //On peut recuperer les proprietes du DialogueFragment avec nomdufragment.propriete
            //Debug.Log(test.Text);
            //Debug.Log (test.Speaker);

            toPrint = test.Text;
            speaker = test.Speaker;
            Debug.Log(speaker);

            //Debug.Log (toPrint);
            //Debug.Log (speaker);

            //Debug.Log (test.Children);
            //Debug.Log (test.OutputPins);
            test.GetInputPins();
            test.GetOutputPins();
            //print (test.InputPins);
            //print (test.OutputPins);
            //print(test.Children);


            /*
             *
             * for (int i = 0; i < test.InputPins.Count; i++) {
             *      print(test.InputPins[i]);
             *      print (test.InputPins [i].Id);
             *      print (test.InputPins [i].Text);
             * }
             *
             * for (int j = 0; j < test.OutputPins.Count; j++) {
             *      print (test.OutputPins [j]);
             *      print (test.OutputPins [j].Id);
             *      print (test.OutputPins [j].Text);
             * }
             *
             * for (int k = 0; k < test.Children.Count; k++) {
             *      print (test.Children [k]);
             * }
             */
        }
    }
示例#11
0
    public void OnBranchesUpdated(IList <Branch> aBranches)
    {
        if (aBranches == null || aBranches.Count == 0)
        {
            Debug.LogWarning("NULL or 0 branches in OnBranchesUpdated()."); return;
        }
        Debug.Log("Num branches: " + aBranches.Count);

        int branchID = Random.Range(0, aBranches.Count);

        branchID = 0; // normally this would be random but for now just go to the Ship
        Branch         branch        = aBranches[branchID];
        ArticyObject   targetObject  = (ArticyObject)branch.Target;
        Slot_Container slotContainer = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");

        slotContainer.Template.Slot_Feature.Slot_Feature_Slot = targetObject;
    }
示例#12
0
    private void Awake()
    {
        instance = this;

        if (ConscienceDialogueFolder.HasReference)
        {
            ArticyObject conscienceFolder = ConscienceDialogueFolder.GetObject <ArticyObject>();

            if (conscienceFolder != null)
            {
                for (int i = 0; i < conscienceFolder.Children.Count; ++i)
                {
                    template_conscience dialogue = conscienceFolder.Children[i] as template_conscience;

                    if (dialogue != null)
                    {
                        DialogueList.Add(dialogue);
                    }
                }
            }
        }
    }
示例#13
0
    // Update is called once per frame
    void Update()
    {
        ArticyObject spk = myDialogue.GetComponent <getDialogue>().speaker;
        string       txt = myDialogue.GetComponent <getDialogue> ().toPrint;

        string thisSpeaker = spk.ToString();
        string a           = "(Articy.Eai.ASS)";

        Debug.Log(thisSpeaker);
        Debug.Log(a);

        if (thisSpeaker.Contains(a))
        {
            //Debug.Log ("toto");
            //mytext.text = ""+txt;
            print(txt);
            Text.text = txt;
        }
        else
        {
            Debug.Log("tata");
        }
    }
    private static string GetNameForGameObject(ArticyObject aObject)
    {
        string finalName   = aObject.TechnicalName;
        var    displayName = aObject as IObjectWithDisplayName;

        if (displayName != null)
        {
            finalName = displayName.DisplayName;
        }

        var target = aObject as IObjectWithTarget;

        if (target != null)
        {
            var targetObject = target.Target;
            if (targetObject != null)
            {
                return(GetNameForGameObject(targetObject));
            }
        }

        return(finalName);
    }
示例#15
0
 public void setProp(string aProperty, object aValue)
 {
     if ((aProperty == "ValidCombination"))
     {
         ValidCombination = ((ArticyObject)(aValue));
         return;
     }
     if ((aProperty == "CombinationResult"))
     {
         CombinationResult = ((ArticyObject)(aValue));
         return;
     }
     if ((aProperty == "LinkIfSuccess"))
     {
         LinkIfSuccess = ((ArticyObject)(aValue));
         return;
     }
     if ((aProperty == "LinkIfFailure"))
     {
         LinkIfFailure = ((ArticyObject)(aValue));
         return;
     }
 }
示例#16
0
    public void ProceedDialogue(DialogueFragment choiceFragment = null)
    {
        CurrentDialogueFragment.OutputPins[0].Evaluate();
        if (choiceFragment == null)
        {
        }
        else
        {
            CurrentDialogueFragment = choiceFragment;
            CurrentDialogueFragment.OutputPins[0].Evaluate();
        }

        ArticyObject element = GetNextDialogueElementFromFragment(CurrentDialogueFragment);

        if (SaveManager.instance.GetCurrentPlayerState().GetCurrentDayNumberNotIndexThisHasOneAddedToIt() == 22)
        {
            IntroController.instance.CheckCustomNameBooleans();
        }

        DialogueFragment fragment = element as DialogueFragment;
        Hub hub = element as Hub;

        if (fragment != null)
        {
            CurrentDialogueFragment = fragment;
            DialogueScreen.instance.UpdateFromDialogueFragment(CurrentDialogueFragment);
        }
        else if (hub != null)
        {
            DialogueScreen.instance.UpdateFromHub(CurrentDialogueFragment);
        }
        else
        {
            EndDialogueInstantly();
        }
    }
 /// <summary>
 /// Convenience method to get the value of a property from an articy object.
 /// The only reason we are using reflection here is to make sure this class always compiles and does not rely on generated code files.
 /// </summary>
 private static _T GetProperty <_T>(ArticyObject aObject, string aProperty)
 {
     return((_T)aObject.GetType().GetProperty(aProperty, BindingFlags.Instance | BindingFlags.Public).GetValue(aObject, null));
 }
    public void ContinueBubbleCascadeFromElement(ArticyObject element)
    {
        CurrentFadeTime = FadeTime;

        //clicked on speaker bubble
        //if (element == null)
        //{
        //    element = DialogueManager.instance.GetNextDialogueElementFromFragment(CurrentDialogueFragment);
        //}

        // end
        if (element == null)
        {
            HideAllBubbles();
            bIsBubbleSpeechActive = false;
            return;
        }

        DialogueFragment fragment = element as DialogueFragment;
        Hub hub = element as Hub;

        bIsBubbleSpeechActive = true;

        HideAllBubbles();

        //for (int i = 0; i < SpeechBubbleOptions.Count; ++i)
        //{
        //    SpeechBubbleOptions[i].HideBubble();
        //}

        if (fragment != null)
        {
            CurrentDialogueFragment.OutputPins[0].Evaluate();
            //CurrentDialogueFragment.
            CurrentDialogueFragment = fragment;
            //if (SpeechBubbleSpeaker != null)
            //{
            //    Destroy(SpeechBubbleSpeaker.gameObject);
            //}

            MakeSpeakerBubble();

            CurrentHub = null;
        }
        else if (hub != null)
        {
            CurrentHub = hub;

            MakeSpeakerBubble(false);

            hub.OutputPins[0].Evaluate();

            for (int i = 0; i < hub.OutputPins[0].Connections.Count; ++i)
            {
                //if(hub.OutputPins[0].Connections[i].)
                DialogueFragment frag = hub.OutputPins[0].Connections[i].Target as DialogueFragment;
                if (frag.InputPins[0].Evaluate())
                {
                    SpeechBubble newBubble = Instantiate(GetSpeechBubbleForString(frag.Text));
                    newBubble.ShowBubble(frag);
                    newBubble.gameObject.transform.SetParent(SpeechBubbleMarkers[i].gameObject.transform);
                    newBubble.gameObject.transform.localPosition = new Vector3();
                    newBubble.gameObject.transform.localScale    = new Vector3(1, 1, 1);
                    newBubble.InitOrbit();



                    SpawnedBubbles.Add(newBubble);
                    //SpeechBubbleOptions[i].ShowBubble(frag);
                }
            }
        }
        else
        {
            Debug.LogError("Fail ott pls fix speechbubblemanager");
            SpeechBubbleSpeaker.HideBubble();
        }
    }
    /// <summary>
    /// this method is called for every articy object in the location, starting with the location itself
    /// </summary>
    private static void GenerateChildren(Transform aParent, ArticyObject aChild, int aPixelsToUnits, Rect aOverallBounds, Dictionary <string, Type> aAttachBehaviours, ref int aZindex)
    {
        // the children collection is usually unsorted, but in this case we have to worry about proper ordering regarding z sorting
        // luckly the plugin has a way to return the children sorted by a user defined method, in this case we sort our children by their zindex
        var sortedChildren = aChild.GetSortedChildren <IObjectWithZIndex>((x, y) => x.ZIndex.CompareTo(y.ZIndex) * -1);

        foreach (var sortedChild in sortedChildren)
        {
            var  child          = sortedChild as ArticyObject;
            var  gameObjectName = GetNameForGameObject(child);
            bool hasZoneScript  = false;

            #region Create new Gameobject for our Location child
            // we create a game object for the new object and parent it to our previous game object
            var childGameObject = new GameObject(gameObjectName);
            childGameObject.transform.SetParent(aParent, false);
            EditorUtility.SetDirty(childGameObject);
            Rect bounds    = new Rect();
            bool boundsSet = false;

            // then we add an articyReference to it, storing the articy object that this new game object represents with it
            var artRef = childGameObject.AddComponent <ArticyReference>();
            artRef.reference = new ArticyRef()
            {
                id = child.Id
            };
            #endregion

            #region Attach Behaviours By Template to the new game object
            // now we use the previously created cache of behaviours for specific templates.
            // So first we check via reflection, if the object has a template property
            var templateProp = child.GetType().GetProperty("Template");
            if (templateProp != null)
            {
                // and if it does, we get the value of its Template property
                var templateObj = templateProp.GetValue(child, null);
                if (templateObj != null)
                {
                    // now we can extract its class name, which usually is the Template Technical name with a Template suffix "Condition_ZoneTemplate" for example.
                    var  templateName = templateObj.GetType().Name;
                    Type behaviour;
                    // and here we ask the cache if it has a registered behaviour under the current template name
                    if (aAttachBehaviours.TryGetValue(templateName, out behaviour))
                    {
                        // if it does, we add a new script component using the stored type
                        childGameObject.AddComponent(behaviour);
                        // we also store if it was a clickable zone behaviour, because then we have to create the collider and enable it
                        // location images for example could also have an attached behaviour, but we don't want them to interfere with our raycasting
                        if (behaviour == typeof(ClickableZone))
                        {
                            hasZoneScript = true;
                        }
                    }
                }
            }
            #endregion

            #region Create a Collider if it has vertices
            // all objects with vertices will be converted to game objects with polygon collider.
            var vertices = child as IObjectWithVertices;
            if (vertices != null)
            {
                // first we add the component to our create game object
                var collider = childGameObject.AddComponent <PolygonCollider2D>();
                // then we calculate the overall bounds of this polygon
                bounds = ArticyUtility.GetBounds(vertices.Vertices);

                // and then we convert the articy vertices to unity vertices (flipped y axis and different pixel scaling)
                var colliderPoints = new Vector2[vertices.Vertices.Count];
                int i = 0;
                foreach (var vec in vertices.Vertices)
                {
                    var v = new Vector2(vec.x / aPixelsToUnits, (bounds.yMax - vec.y) / aPixelsToUnits);
                    colliderPoints[i++] = v;
                }
                // after we have converted the points, we can store them
                collider.SetPath(0, colliderPoints);

                // we need the bounds again, if this object does not only contain vertices, but also represents an image
                bounds = ArticyUtility.GetBounds(collider.points);

                // only if this is a clickable zone, we initially enable the collider.
                collider.enabled = hasZoneScript;

                boundsSet = true;
            }
            #endregion

            #region Create and setup Spriter renderer for location images

            // our location images, have a reference to an articy reference
            // we use that to fill a sprite renderer with the image
            var image = child as ILocationImage;
            if (image != null)
            {
                SpriteRenderer spriteRenderer = null;
                // use reflection to get the Image
                var asset = GetProperty <ArticyObject>(child, "ImageAsset");
                if (asset != null)
                {
                    // make sure it is an actual image asset
                    var imageAsset = asset as IAsset;
                    if (imageAsset != null && imageAsset.Category == AssetCategory.Image)
                    {
                        // add a new sprite renderer to our game object
                        spriteRenderer = childGameObject.AddComponent <SpriteRenderer>();

                        // load the underlying texture
                        var tex = imageAsset.LoadAsset <Texture2D>();
                        // we also need the cliprect, as the image might be cropped
                        var clipRect = GetProperty <Rect>(child, "ClipRect");
                        // convert the clip rect to a sprite source rect
                        var sourceRect = ArticyUtility.ConvertToSpriteSourceRect(tex, clipRect);
                        // the sorting order is reversed in regards to our zindex,
                        spriteRenderer.sortingOrder = 1000 - aZindex;
                        // and finally convert the texture to a sprite using our calculated source rect
                        spriteRenderer.sprite = Sprite.Create(tex, sourceRect, new Vector2());
                        if (!boundsSet)
                        {
                            bounds.width  = tex.width / (float)aPixelsToUnits;
                            bounds.height = tex.height / (float)aPixelsToUnits;
                        }
                    }
                }
            }
            #endregion

            #region Adjust the objects transformations

            var trans     = childGameObject.transform;
            var transform = child as IObjectWithTransformation;
            if (transform != null)
            {
                // change the position
                trans.localPosition = new Vector3(transform.Transform.Translation.x / aPixelsToUnits,
                                                  aOverallBounds.height - bounds.height - (transform.Transform.Translation.y / aPixelsToUnits));
                // Todo: scale and rotating
            }
            #endregion

            aZindex++;

            // some objects inside a location, can have children themselves, so we just recursively call GenerateChildren again
            GenerateChildren(childGameObject.transform, child, aPixelsToUnits, aOverallBounds, aAttachBehaviours, ref aZindex);
        }
    }
 public void SetFlowPlayerStartOn(ArticyObject articyObject)
 {
     //Debug.Log("SetFlowPlayerStartOn(): type: " + articyObject.GetType() + ", name: " + articyObject.name);
     StaticStuff.FlowDebug("SetFlowPlayerStartOn(): type: " + articyObject.GetType() + ", name: " + articyObject.name);
     FlowPlayer.StartOn = articyObject;
 }