示例#1
0
    public BubbleData generateBubble(NPC cha, string text, GameObject talker = null)
    {
        BubbleData bubble = new BubbleData (text, new Vector2 (40, 60), new Vector2 (40, 45));

        Color textColor, textOutline, background, border;
        ColorUtility.TryParseHtmlString (cha.getTextFrontColor (), out textColor);
        ColorUtility.TryParseHtmlString (cha.getTextBorderColor (), out textOutline);
        ColorUtility.TryParseHtmlString (cha.getBubbleBkgColor (), out background);
        ColorUtility.TryParseHtmlString (cha.getBubbleBorderColor (), out border);

        bubble.TextColor = textColor;
        bubble.TextOutlineColor = textOutline;
        bubble.BaseColor = background;
        bubble.OutlineColor = border;

        if (talker != null) {
            Vector2 position = talker.transform.localPosition;
            position.y += talker.transform.localScale.y / 2;

            bubble.Destiny = position;
            bubble.Origin = new Vector2 (position.x, position.y - 10f);
        } else {
            bubble.Origin = new Vector2 (40, 60);
            bubble.Destiny = new Vector2 (40, 45);
        }

        return bubble;
    }
 public void ApplyEditorModifications(BubbleData data, GameObject target)
 {
     if (Apply(data.modifiers, m => ModifyEditorObject(target, m)))
     {
         MoveTextToTopOfObject(target);
     }
 }
        public void Populate(BubbleData data)
        {
            var layoutGroup = menuContainer.GetComponent <VerticalLayoutGroup>();

            if (widgets.Count == 0)
            {
                DiscoverWidgets();
            }

            var   horizontalPadding = layoutGroup.padding.left + layoutGroup.padding.right;
            var   items             = new List <GameObject>();
            float height            = layoutGroup.padding.top + layoutGroup.padding.bottom;
            float width             = horizontalPadding;

            RemoveAllMenuChildren();

            foreach (var widget in widgets.Where(w => w.IsValidFor(data)))
            {
                var item          = widget.CreateWidget(data);
                var rectTransform = item.GetComponent <RectTransform>();
                var rect          = rectTransform.rect;

                rectTransform.SetParent(menuContainer, false);
                height += rect.height;
                width   = Mathf.Max(width, rect.width + horizontalPadding);

                items.Add(item);
            }

            height += Mathf.Max(0, (items.Count - 1)) * layoutGroup.spacing;

            menuContainer.sizeDelta = new Vector2(width, height);
        }
 public void PerformAlternate(LevelManipulator manipulator, int x, int y)
 {
     if (manipulator.Models.ContainsKey(BubbleData.GetKey(x, y)) && (manipulator.Modifier != null))
     {
         RemoveModifier(manipulator, x, y, manipulator.Modifier);
         placer.Perform(manipulator, x, y);
     }
 }
示例#5
0
        /// <summary>
        /// Resets the Dialogue Bubble and sets new text for it.
        /// </summary>
        /// <param name="text">A string containing the text for the Dialogue Bubble to parse and print.</param>
        public void SetText(string text)
        {
            Reset();

            Text = text;

            DBubbleData = DialogueGlobals.ParseText(Text, out Text);
        }
示例#6
0
    //为了放炸弹的时候看起来很平滑,需要根据当前的位置来决定是否放炸弹如果位置不合适但是超时了也可以放炸弹
    void Update()
    {
        bool removeBubble = false;

        if (preBubbleList.Count > 0)
        {
            foreach (BubbleData data in preBubbleList)
            {
                data.delayTime += Time.deltaTime;
            }
            Vector2    center = colliderBox.Center;
            BubbleData bubble = preBubbleList[0];
            float      posy   = -bubble.row * GameConst.tileHeight;
            float      posx   = bubble.col * GameConst.tileWidth;
            switch (animatorController.Direction)
            {
            case PlayerDirection.Left:
                if (center.x <= posx)
                {
                    removeBubble = true;
                }
                break;

            case PlayerDirection.Right:
                if (center.x >= posx)
                {
                    removeBubble = true;
                }
                break;

            case PlayerDirection.Down:
                if (center.y < posy)
                {
                    removeBubble = true;
                }
                break;

            case PlayerDirection.Up:
                if (center.y > posy)
                {
                    removeBubble = true;
                }
                break;
            }
            if (bubble.delayTime > bubbleDelayTime)
            {
                removeBubble = true;
            }
        }
        if (removeBubble)
        {
            BubbleData bubble = preBubbleList[0];
            RobotAttack(bubble.row, bubble.col, bubble.power);
            preBubbleList.RemoveAt(0);
        }
    }
示例#7
0
    void addPreBubbleData(int row, int col, int power)
    {
        BubbleData data = new BubbleData();

        data.row       = row;
        data.col       = col;
        data.power     = power;
        data.delayTime = 0f;
        preBubbleList.Add(data);
    }
        public GameObject CreateWidget(BubbleData bubble)
        {
            prefab = prefab ?? GlobalState.AssetService.LoadAsset <GameObject>(PREFAB_PATH);
            data   = bubble;

            var instance = GameObject.Instantiate(prefab);

            instance.GetComponent <Button>().onClick.AddListener(DeleteAction);

            return(instance);
        }
示例#9
0
        public void CleanUp()
        {
            BubbleRasterizerState.Dispose();
            BubbleRasterizerState = null;

            BubbleImage = null;
            Speaker     = null;

            DBubbleData = null;
            FontGlyphs  = null;
        }
示例#10
0
    private void GetNeighbors(int x, int y, int[] neighbors)
    {
        var offset = (y & 1) * 2 - 1;

        neighbors[0] = BubbleData.GetKey(x + offset, y - 1);
        neighbors[1] = BubbleData.GetKey(x, y - 1);
        neighbors[2] = BubbleData.GetKey(x - 1, y);
        neighbors[3] = BubbleData.GetKey(x + 1, y);
        neighbors[4] = BubbleData.GetKey(x + offset, y + 1);
        neighbors[5] = BubbleData.GetKey(x, y + 1);
    }
示例#11
0
 private void correctBoundaries(BubbleData bubble)
 {
     if (bubble.destiny.x <= 125f)
     {
         bubble.destiny.x = 125f;
     }
     else if (bubble.destiny.x >= (800f - 125f))
     {
         bubble.destiny.x = (800f - 125f);
     }
 }
示例#12
0
 public void ShowBubble(BubbleData data)
 {
     data.origin  = sceneVector2guiVector(data.origin);
     data.destiny = sceneVector2guiVector(data.destiny);
     if (bubble != null)
     {
         bubble.GetComponent <Bubble> ().destroy();
     }
     bubble = GameObject.Instantiate(Bubble_Prefab);
     bubble.GetComponent <Bubble> ().Data = data;
     bubble.transform.parent = this.transform;
 }
示例#13
0
    public void ApplyEditorModifiers(GameObject instance, BubbleData data)
    {
        PopulateModifiers();

        if (data.modifiers != null)
        {
            foreach (var modifier in bubbleModifiers)
            {
                modifier.ApplyEditorModifications(data, instance);
            }
        }
    }
示例#14
0
    private GameObject Instantiate(BubbleData bubble)
    {
        var prf = Resources.Load(GetPrefabName(bubble.type));
        var go  = Object.Instantiate(prf) as GameObject;

        go.transform.SetParent(GameObject.Find("MainCanvas").transform);
        var rect = (go.transform as RectTransform);

        rect.transform.localPosition = Vector3.zero;
        rect.anchoredPosition        = new Vector3(bubble.x, bubble.y, 0);
        rect.localScale = Vector3.one;
        return(go);
    }
        /// <summary>
        /// Resets the Dialogue Bubble and sets new text for it.
        /// </summary>
        /// <param name="text">A string containing the text for the Dialogue Bubble to parse and print.</param>
        public void SetText(string text)
        {
            Reset();

            Text = text;

            DBubbleData = DialogueGlobals.ParseText(Text, out Text);

            if (CharPrintTimes == null || (CharPrintTimes != null && CharPrintTimes.Length != Text.Length))
            {
                CharPrintTimes = new double[Text.Length];
            }
        }
    override public GameObject PlaceBubble(BubbleData data)
    {
        var instance = CreateBubble(data);

        if (bubbleContainer != null)
        {
            instance.transform.SetParent(bubbleContainer, false);
        }

        instance.transform.localPosition = GetBubbleLocation(data.X, data.Y);

        return(instance);
    }
        /*
         * EXPORT FOR BUBBLE
         */
        public BubbleData ExportBubbleData(Widget.Charts.Models.BubbleChart.BubbleChartData bubbleChartData)
        {
            var dataSetItems = new List <BubbleDataSet>();

            foreach (var item in bubbleChartData.DataSets)
            {
                var entryOriginal = item.IF_GetValues().Select(obj => new BubbleEntry(obj.GetXPosition(), obj.GetYPosition(), obj.GetSize()));
                var dataSet       = new BubbleDataSet(entryOriginal.ToArray(), item.IF_GetLabel());
                OnIntializeDataSetBubble(item, dataSet);
                dataSetItems.Add(dataSet);
            }
            var data = new BubbleData(dataSetItems.ToArray());

            return(data);
        }
        private void ApplyModifier(LevelManipulator manipulator, int x, int y, BubbleModifierInfo modifier)
        {
            var model     = manipulator.Models[BubbleData.GetKey(x, y)];
            var modifiers = new List <BubbleData.ModifierData>(model.modifiers ?? new BubbleData.ModifierData[0]);

            manipulator.SetBubbleType(model.Type);

            modifiers.Add(new BubbleData.ModifierData
            {
                type = modifier.Type,
                data = modifier.Data,
            });

            model.modifiers = modifiers.ToArray();
        }
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            var key = BubbleData.GetKey(x, y);

            manipulator.Models.Remove(key);

            if (manipulator.Views.ContainsKey(key))
            {
                GameObject.Destroy(manipulator.Views[key]);
                manipulator.Views.Remove(key);
            }

            GlobalState.EventService.Dispatch(new LevelModifiedEvent());
            manipulator.RecomputeScores();
        }
示例#20
0
        public static Chart BuildTemperatureAttributesBubbleChart1(List <TemperatureOrigin> temperatureOrigins)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Bubble;

            var data = new Data();

            List <Dataset> datasets = new List <Dataset>();

            ChartColor[] colors = { Colors.GetRedBorder(), Colors.GetBlueBorder(), Colors.GetGreenBorder() };

            int j = 0;

            for (int i = 0; i < temperatureOrigins.Count; i++)
            {
                var dataset        = new BubbleDataset();
                var bubbleDataList = new List <BubbleData>();
                foreach (var temp in temperatureOrigins[i].TemperatureAtts)
                {
                    TimeSpan t          = (temp.Time - new DateTime(1970, 1, 1));
                    var      bubbleData = new BubbleData
                    {
                        X = (int)t.TotalSeconds,
                        Y = temp.Temp,
                        R = 5
                    };
                    bubbleDataList.Add(bubbleData);
                }
                dataset.Data        = bubbleDataList;
                dataset.BorderColor = new List <ChartColor> {
                    colors[j++]
                };
                dataset.BackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgba(255, 255, 255, 0.2)
                };
                dataset.Label = temperatureOrigins[i].Origin;
                datasets.Add(dataset);
            }

            data.Datasets = datasets;

            FixTimeLabels(chart.Options);

            chart.Data = data;

            return(chart);
        }
示例#21
0
        public GameObject CreateWidget(BubbleData bubble)
        {
            prefab     = prefab ?? GlobalState.AssetService.LoadAsset <GameObject>(PREFAB_PATH);
            definition = CreateDefinition(bubble);
            data       = bubble;

            var colors       = GetColors();
            var panel        = GameObject.Instantiate(prefab);
            var weightFields = CreateFields(panel, colors);

            InitializeButtons(panel);
            InitializeFields(colors, weightFields);
            InitializeExclusions(panel);

            return(panel);
        }
        private void RemoveModifier(LevelManipulator manipulator, int x, int y, BubbleModifierInfo modifier)
        {
            var model = manipulator.Models[BubbleData.GetKey(x, y)];

            manipulator.SetBubbleType(model.Type);

            if (model.modifiers != null)
            {
                model.modifiers = model.modifiers.Where(m => m.type != modifier.Type).ToArray();

                if (model.modifiers.Length == 0)
                {
                    model.modifiers = null;
                }
            }
        }
        override public GameObject PlaceBubble(BubbleData data)
        {
            var instance  = CreateBubble(data);
            var container = new GameObject();

            container.transform.SetParent(bubbleContainer, false);
            container.SetActive(false);

            instance.transform.SetParent(container.transform, false);

            container.transform.localPosition = GetBubbleLocation(data.X, data.Y);
            instance.transform.position       = transform.position;

            bubbles.Add(instance.transform);

            return(instance);
        }
示例#24
0
        public Chart GenerateBubbleChart()
        {
            Chart chart = new Chart
            {
                Type = "bubble"
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();

            BubbleDataset dataset = new BubbleDataset()
            {
                Label = "Bubble Dataset",
                Data  = new List <BubbleData>()
            };

            BubbleData bubbleData1 = new BubbleData();
            BubbleData bubbleData2 = new BubbleData();

            bubbleData1.x = 20;
            bubbleData1.y = 30;
            bubbleData1.r = 15;
            dataset.Data.Add(bubbleData1);

            bubbleData2.x = 40;
            bubbleData2.y = 10;
            bubbleData2.r = 10;
            dataset.Data.Add(bubbleData2);

            data.Datasets = new List <Dataset>
            {
                dataset
            };

            dataset.BackgroundColor = new List <string>()
            {
                "#FF6384"
            };
            dataset.HoverBackgroundColor = new List <string>()
            {
                "#FF6384"
            };

            chart.Data = data;

            return(chart);
        }
示例#25
0
        public static string GenerateBubbleChart()
        {
            Chart chart = new Chart();

            chart.Type = "bubble";

            Data data = new Data();

            BubbleDataset dataset = new BubbleDataset()
            {
                Label = "Bubble Dataset",
                Data  = new List <BubbleData>()
            };

            BubbleData bubbleData1 = new BubbleData();
            BubbleData bubbleData2 = new BubbleData();

            bubbleData1.x = 20;
            bubbleData1.y = 30;
            bubbleData1.r = 15;
            dataset.Data.Add(bubbleData1);

            bubbleData2.x = 40;
            bubbleData2.y = 10;
            bubbleData2.r = 10;
            dataset.Data.Add(bubbleData2);

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            dataset.BackgroundColor = new List <string>()
            {
                "#FF6384"
            };
            dataset.HoverBackgroundColor = new List <string>()
            {
                "#FF6384"
            };

            chart.Data = data;

            string code = chart.CreateChartCode("bubbleChart");

            return(code);
        }
示例#26
0
    private BubbleData generateBubble(NPC cha)
    {
        BubbleData bubble = new BubbleData(guitext, new Vector2(40, 60), new Vector2(40, 45));

        Color textColor, textOutline, background, border;

        ColorUtility.TryParseHtmlString(cha.getTextFrontColor(), out textColor);
        ColorUtility.TryParseHtmlString(cha.getTextBorderColor(), out textOutline);
        ColorUtility.TryParseHtmlString(cha.getBubbleBkgColor(), out background);
        ColorUtility.TryParseHtmlString(cha.getBubbleBorderColor(), out border);

        bubble.TextColor        = textColor;
        bubble.TextOutlineColor = textOutline;
        bubble.BaseColor        = background;
        bubble.OutlineColor     = border;

        return(bubble);
    }
示例#27
0
        private BubbleSeries GetNewSerie(BubbleData data)
        {
            Random countRandom = new Random();
            ChartYAxisValueCollection <BubbleYAxisValue> yVals = new ChartYAxisValueCollection <BubbleYAxisValue>();
            int count = data.XAxisCount;

            for (int i = 0; i < count; i++)
            {
                yVals.Add(new BubbleYAxisValue(countRandom.Next(0, count), countRandom.Next(0, count)));
            }
            BubbleSeries set1 = new BubbleSeries(yVals, "DataSet 1");

            set1.AddColor(DemoGlobal.GetRandomColor());
            set1.AddColor(DemoGlobal.GetRandomColor());
            set1.AddColor(DemoGlobal.GetRandomColor());

            return(set1);
        }
        private void RollAllRandomBubbles(LevelManipulator manipulator)
        {
            var rng     = new System.Random();
            var randoms = LevelConfiguration.CreateRandomizers(rng, manipulator.Randoms.ToArray());

            ApplyTransformation(manipulator, b =>
            {
                var modifier    = b.modifiers.First(m => m.type == BubbleModifierType.Random);
                var replacement = new BubbleData(b.X, b.Y, randoms[int.Parse(modifier.data)].GetValue());

                var modifiers = b.modifiers.Where(m => m.type != BubbleModifierType.Random).ToArray();
                if (modifiers.Length > 0)
                {
                    replacement.modifiers = modifiers;
                }

                return(replacement);
            });
        }
        private static Chart GenerateBubbleChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Bubble
            };

            var data = new Data();

            var dataset = new BubbleDataset
            {
                Label = "Bubble Dataset",
                Data  = new List <BubbleData>()
            };

            var bubbleData1 = new BubbleData();
            var bubbleData2 = new BubbleData();

            bubbleData1.X = 20;
            bubbleData1.Y = 30;
            bubbleData1.R = 15;
            dataset.Data.Add(bubbleData1);

            bubbleData2.X = 40;
            bubbleData2.Y = 10;
            bubbleData2.R = 10;
            dataset.Data.Add(bubbleData2);

            data.Datasets = new List <Dataset> {
                dataset
            };

            dataset.BackgroundColor = new List <ChartColor> {
                ChartColor.FromRgb(255, 99, 132)
            };
            dataset.HoverBackgroundColor = new List <ChartColor> {
                ChartColor.FromRgb(255, 99, 132)
            };

            chart.Data = data;

            return(chart);
        }
示例#30
0
        private static Chart GenerateBubbleChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Bubble
            };

            var data = new Data();

            var dataset = new BubbleDataset
            {
                Label = "Bubble Dataset",
                Data  = new List <BubbleData>()
            };

            var bubbleData1 = new BubbleData();
            var bubbleData2 = new BubbleData();

            bubbleData1.x = 20;
            bubbleData1.y = 30;
            bubbleData1.r = 15;
            dataset.Data.Add(bubbleData1);

            bubbleData2.x = 40;
            bubbleData2.y = 10;
            bubbleData2.r = 10;
            dataset.Data.Add(bubbleData2);

            data.Datasets = new List <Dataset> {
                dataset
            };

            dataset.BackgroundColor = new List <string> {
                "#FF6384"
            };
            dataset.HoverBackgroundColor = new List <string> {
                "#FF6384"
            };

            chart.Data = data;

            return(chart);
        }
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            var key      = BubbleData.GetKey(x, y);
            var modifier = manipulator.Modifier;

            if (manipulator.Models.ContainsKey(key) && (modifier != null))
            {
                var bubble      = manipulator.Models[key];
                var hasModifier = (bubble.modifiers != null) && bubble.modifiers.Any(m => m.type == modifier.Type);

                RemoveModifier(manipulator, x, y, modifier);

                if (!hasModifier)
                {
                    ApplyModifier(manipulator, x, y, modifier);
                }

                placer.Perform(manipulator, x, y);
            }
        }
示例#32
0
 private void correctBoundaries(BubbleData bubble)
 {
     if(bubble.destiny.x <= 125f) bubble.destiny.x = 125f;
     else if(bubble.destiny.x >= (800f - 125f)) bubble.destiny.x = (800f - 125f);
 }
示例#33
0
    public void ShowBubble(BubbleData data)
    {
        data.origin = sceneVector2guiVector(data.origin);
        data.destiny = sceneVector2guiVector(data.destiny);

        //correctBoundaries (data);

        if (bubble != null) {
            bubble.GetComponent<Bubble> ().destroy ();
        }
        bubble = GameObject.Instantiate (Bubble_Prefab);
        bubble.GetComponent<Bubble> ().Data = data;
        bubble.transform.parent = this.transform;
    }