Example #1
0
        /// <summary>
        /// Add a branch to the current node.
        /// The type of the current node will be switched to Branching.
        /// This method is designed to be called externally by scripts.
        /// </summary>
        /// <param name="name">Internal name of the branch, unique in a node</param>
        /// <param name="destination">Name of the destination node</param>
        /// <param name="text">Text on the button to select this branch</param>
        /// <param name="imageInfo"></param>
        /// <param name="mode"></param>
        /// <param name="condition"></param>
        public void RegisterBranch(string name, string destination, string text, BranchImageInformation imageInfo,
                                   BranchMode mode, LuaFunction condition)
        {
            if (string.IsNullOrEmpty(destination))
            {
                throw new ArgumentException(
                          $"Nova: A branch must have a destination. Exception occurs at node: {currentNode.name}, text: {text}");
            }

            if (mode == BranchMode.Normal && condition != null)
            {
                throw new ArgumentException(
                          $"Nova: Branch mode is Normal but condition is not null. Exception occurs at node: {currentNode.name}, destination: {destination}");
            }

            if (mode == BranchMode.Jump && (text != null || imageInfo != null))
            {
                throw new ArgumentException(
                          $"Nova: Branch mode is Jump but text or imageInfo is not null. Exception occurs at node: {currentNode.name}, destination: {destination}");
            }

            if ((mode == BranchMode.Show || mode == BranchMode.Enable) && condition == null)
            {
                throw new ArgumentException(
                          $"Nova: Branch mode is Show or Enable but condition is null. Exception occurs at node: {currentNode.name}, destination: {destination}");
            }

            currentNode.type = FlowChartNodeType.Branching;
            lazyBindingLinks.Add(new LazyBindingEntry(currentNode, destination,
                                                      new BranchInformation(name, text, imageInfo, mode, condition)));
        }
Example #2
0
 public Selection(string text, BranchImageInformation imageInfo, bool active)
     : this(new Dictionary <SystemLanguage, string>
 {
     [I18n.DefaultLocale] = text
 }, imageInfo, active)
 {
 }
Example #3
0
 public Selection(IReadOnlyDictionary <SystemLanguage, string> texts, BranchImageInformation imageInfo,
                  bool active)
 {
     this.texts     = texts;
     this.imageInfo = imageInfo;
     this.active    = active;
 }
Example #4
0
 public BranchInformation(string name, string text, BranchImageInformation imageInfo, BranchMode mode,
                          LuaFunction condition)
 {
     this.name      = name;
     this.text      = text;
     this.imageInfo = imageInfo;
     this.mode      = mode;
     this.condition = condition;
 }
Example #5
0
 public BranchInformation(string name, string text, BranchImageInformation imageInfo, BranchMode mode,
                          LuaFunction condition)
 {
     this.name = name;
     _texts    = new Dictionary <SystemLanguage, string> {
         [I18n.DefaultLocale] = text
     };
     this.imageInfo = imageInfo;
     this.mode      = mode;
     this.condition = condition;
 }
Example #6
0
        public void Init(IReadOnlyDictionary <SystemLanguage, string> displayTexts, BranchImageInformation imageInfo,
                         string imageFolder, UnityAction onClick, bool interactable)
        {
            this.displayTexts = displayTexts;
            this.imageInfo    = imageInfo;
            this.imageFolder  = imageFolder;

            if (imageInfo != null)
            {
                var layoutElement = gameObject.AddComponent <LayoutElement>();
                layoutElement.ignoreLayout = true;

                image.type = Image.Type.Simple;
                image.alphaHitTestMinimumThreshold = 0.5f;

                transform.localPosition = new Vector3(imageInfo.positionX, imageInfo.positionY, 0f);
                transform.localScale    = new Vector3(imageInfo.scale, imageInfo.scale, 1f);
            }

            UpdateText();

            button.onClick.AddListener(onClick);
            button.interactable = interactable;
        }