Esempio n. 1
0
    /// <summary>
    /// 添加弹幕信息
    /// </summary>
    /// <param name="type"></param>
    /// <param name="danmaku"></param>
    public void AddDanmaku(DanmakuType type, Danmaku danmaku)
    {
        if (!Pause)
        {
            if (!danmakuStore.ContainsKey(type))
            {
                danmakuStore.Add(type, new List <Danmaku>());
            }
            switch (type)
            {
            case DanmakuType.DM:
                if (!DanmakuPause)
                {
                    danmakuStore[type].Add(danmaku);
                }
                break;

            case DanmakuType.GIFT:
                if (!GiftPause)
                {
                    danmakuStore[type].Add(danmaku);
                }
                break;
            }
        }
    }
Esempio n. 2
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="position"></param>
 /// <param name="type"></param>
 /// <param name="color"></param>
 /// <param name="content"></param>
 public Danmaku(double position, DanmakuType type, int color, string content)
 {
     this.Position     = position;
     this.Type         = type;
     this.DecimalColor = color;
     this.Content      = content;
 }
Esempio n. 3
0
    /// <summary>
    /// 从弹幕列表中获取一条弹幕
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    Danmaku getSingelDanmaku(DanmakuType type)
    {
        var e = danmakuStore[type][0];

        danmakuStore[type].Remove(e);
        return(e);
    }
Esempio n. 4
0
        void DanmakuDisplay()
        {
            if (selectedDanmaku == null)
            {
                return;
            }

            EditorGUILayout.LabelField("Danmaku Properties");
            EditorGUI.indentLevel++;
            selectedDanmaku.Position = EditorGUILayout.Vector2Field("Position", selectedDanmaku.Position);
            float rotation = (selectedDanmaku.Rotation % 360f + 360f) % 360f - 180f;

            selectedDanmaku.Rotation     = EditorGUILayout.Slider("Rotation", rotation, -180f, 180f);
            selectedDanmaku.Size         = EditorGUILayout.FloatField("Size", selectedDanmaku.Size);
            selectedDanmaku.Color        = EditorGUILayout.ColorField("Color", selectedDanmaku.Color);
            selectedDanmaku.Speed        = EditorGUILayout.FloatField("Speed", selectedDanmaku.Speed);
            selectedDanmaku.AngularSpeed = EditorGUILayout.FloatField("Angular Speed", selectedDanmaku.AngularSpeed);

            EditorGUILayout.LabelField("Frames", selectedDanmaku.Frames.ToString());
            EditorGUILayout.LabelField("Time", selectedDanmaku.Time.ToString());
            EditorGUI.indentLevel--;
            EditorGUILayout.LabelField("Prefab Properties");
            EditorGUI.indentLevel++;
            DanmakuPrefab prefab = selectedDanmaku.Prefab;
            DanmakuType   type   = selectedDanmaku.Type;

            EditorGUILayout.ObjectField("Prefab", prefab, typeof(DanmakuPrefab));
            type.Size  = EditorGUILayout.FloatField("Size", type.Size);
            type.Color = EditorGUILayout.ColorField("Color", type.Color);
            EditorGUILayout.LabelField("Tag", prefab.tag);
            EditorGUILayout.LabelField("Layer", LayerMask.LayerToName(selectedDanmaku.Prefab.gameObject.layer));
        }
Esempio n. 5
0
        /// <summary>
        /// 添加弹幕
        /// </summary>
        /// <param name="content">弹幕内容</param>
        /// <param name="foreground">颜色</param>
        /// <param name="type">弹幕类型</param>
        public void AddDanmaku(string content, Color foreground, DanmakuType type, int borderThickness = 0)
        {
            switch (type)
            {
            case DanmakuType.Scrollable: AddScrollableDanmaku(content, foreground, borderThickness); break;

            case DanmakuType.Bottom: AddBottomDanmaku(content, foreground, borderThickness); break;

            case DanmakuType.Top: AddTopDanmaku(content, foreground, borderThickness); break;

            default: return;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 为弹幕获取一条轨道
        /// </summary>
        /// <param name="type">弹幕类型</param>
        /// <returns>轨道编号</returns>
        int GetLine(DanmakuType type)
        {
            switch (type)
            {
            case DanmakuType.Scrollable:
                for (int i = 0; i < lines; i++)
                {
                    if (!isOccupied_Scrollable[i])
                    {
                        //没有被占用时占用这条轨道
                        isOccupied_Scrollable[i] = true;
                        return(i);
                    }
                }
                break;

            case DanmakuType.Bottom:
                for (int i = 0; i < lines; i++)
                {
                    if (!isOccupied_Bottom[i])
                    {
                        //没有被占用时占用这条轨道
                        isOccupied_Bottom[i] = true;
                        return(i);
                    }
                }
                break;

            case DanmakuType.Top:
                for (int i = 0; i < lines; i++)
                {
                    if (!isOccupied_Top[i])
                    {
                        //没有被占用时占用这条轨道
                        isOccupied_Top[i] = true;
                        return(i);
                    }
                }
                break;
            }
            //所有轨道都被占用时不绘制此弹幕
            return(-1);
        }
        void IDanmakuWindow.AddDanmaku(DanmakuType type, string comment, uint color)
        {
            if ((this as Window).CheckAccess())
            {
                //<Storyboard x:Key="Storyboard1">
                //			<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="fullScreenDanmaku">
                //				<EasingThicknessKeyFrame KeyTime="0" Value="3,0,0,0"/>
                //				<EasingThicknessKeyFrame KeyTime="0:0:1.9" Value="220,0,0,0"/>
                //			</ThicknessAnimationUsingKeyFrames>
                //		</Storyboard>
                lock (LayoutRoot.Children)
                {
                    var v = new FullScreenDanmaku();
                    v.Text.Text = comment;
                    v.ChangeHeight();
                    var wd = v.Text.DesiredSize.Width;

                    Dictionary<double, bool> dd = new Dictionary<double, bool>();
                    dd.Add(0, true);
                    foreach (var child in LayoutRoot.Children)
                    {
                        if (child is FullScreenDanmaku)
                        {
                            var c = child as FullScreenDanmaku;
                            if (!dd.ContainsKey(Convert.ToInt32(c.Margin.Top)))
                            {
                                dd.Add(Convert.ToInt32(c.Margin.Top), true);
                            }
                            if (c.Margin.Left > (SystemParameters.PrimaryScreenWidth - wd - 50))
                            {
                                dd[Convert.ToInt32(c.Margin.Top)] = false;
                            }
                        }
                    }
                    double top;
                    if (dd.All(p => p.Value == false))
                    {
                        top = dd.Max(p => p.Key) + v.Text.DesiredSize.Height;
                    }
                    else
                    {
                        top = dd.Where(p => p.Value).Min(p => p.Key);
                    }
                    // v.Height = v.Text.DesiredSize.Height;
                    // v.Width = v.Text.DesiredSize.Width;
                    Storyboard s = new Storyboard();
                    Duration duration =
                        new Duration(
                            TimeSpan.FromTicks(Convert.ToInt64((SystemParameters.PrimaryScreenWidth + wd) /
                                                               Store.FullOverlayEffect1 * TimeSpan.TicksPerSecond)));
                    ThicknessAnimation f =
                        new ThicknessAnimation(new Thickness(SystemParameters.PrimaryScreenWidth, top, 0, 0),
                            new Thickness(-wd, top, 0, 0), duration);
                    s.Children.Add(f);
                    s.Duration = duration;
                    Storyboard.SetTarget(f, v);
                    Storyboard.SetTargetProperty(f, new PropertyPath("(FrameworkElement.Margin)"));
                    LayoutRoot.Children.Add(v);
                    s.Completed += s_Completed;
                    s.Begin();
                }
            }
            else
            {
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(
                    () => (this as IDanmakuWindow).AddDanmaku(type, comment, color))
                );
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 发送弹幕
        /// </summary>
        /// <param name="content"></param>
        /// <param name="color"></param>
        /// <param name="position"></param>
        /// <param name="cid"></param>
        /// <param name="mode"></param>
        public void SendDanmaku(string content, Color color, double position, string cid, DanmakuType mode)
        {
            string url = "http://www.tucao.one/index.php";
            //message=敌台全是圣光&color=16777215&stime=13.413373&addtime=1533297826&token=demo&cid=11-4077158-1-0&mode=1&size=25&user=test&datatype=send&
            var body = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("message", content),
                new KeyValuePair <string, string>("color", color.ToInt().ToString()),
                new KeyValuePair <string, string>("stime", position.ToString()),
                new KeyValuePair <string, string>("addtime", Methods.GetUnixTimestamp().ToString()),
                new KeyValuePair <string, string>("token", "demo"),
                new KeyValuePair <string, string>("cid", cid),
                new KeyValuePair <string, string>("mode", ((int)mode).ToString()),
                new KeyValuePair <string, string>("size", "25"),
                new KeyValuePair <string, string>("user", "test"),
                new KeyValuePair <string, string>("datatype", "send")
            };
            //POST http://www.tucao.one/index.php?m=mukio&c=index&a=post&playerID=11-4077158-1-0
            Hashtable queries = new Hashtable();
            {
                queries.Add("m", "mukio");
                queries.Add("c", "index");
                queries.Add("a", "post");
                queries.Add("playerID", cid);
            }
            var t = Methods.HttpPostAsync(url, body, queries);

            AddDanmaku(content, color, mode, 2);
        }
Esempio n. 9
0
 void IDanmakuWindow.AddDanmaku(DanmakuType type, string comment, uint color)
 {
     WTF_AddLiveDanmaku(_wtf, (int)type, 0, comment, 25, (int)color, 0, 0);
 }
Esempio n. 10
0
        void IDanmakuWindow.AddDanmaku(DanmakuType type, string comment, uint color)
        {
            if ((this as Window).CheckAccess())
            {
                //<Storyboard x:Key="Storyboard1">
                //			<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="fullScreenDanmaku">
                //				<EasingThicknessKeyFrame KeyTime="0" Value="3,0,0,0"/>
                //				<EasingThicknessKeyFrame KeyTime="0:0:1.9" Value="220,0,0,0"/>
                //			</ThicknessAnimationUsingKeyFrames>
                //		</Storyboard>
                lock (LayoutRoot.Children)
                {
                    var v = new FullScreenDanmaku();
                    v.Text.Text = comment;
                    v.ChangeHeight();
                    var wd = v.Text.DesiredSize.Width;

                    Dictionary <double, bool> dd = new Dictionary <double, bool>();
                    dd.Add(0, true);
                    foreach (var child in LayoutRoot.Children)
                    {
                        if (child is FullScreenDanmaku)
                        {
                            var c = child as FullScreenDanmaku;
                            if (!dd.ContainsKey(Convert.ToInt32(c.Margin.Top)))
                            {
                                dd.Add(Convert.ToInt32(c.Margin.Top), true);
                            }
                            if (c.Margin.Left > (SystemParameters.PrimaryScreenWidth - wd - 50))
                            {
                                dd[Convert.ToInt32(c.Margin.Top)] = false;
                            }
                        }
                    }
                    double top;
                    if (dd.All(p => p.Value == false))
                    {
                        top = dd.Max(p => p.Key) + v.Text.DesiredSize.Height;
                    }
                    else
                    {
                        top = dd.Where(p => p.Value).Min(p => p.Key);
                    }
                    // v.Height = v.Text.DesiredSize.Height;
                    // v.Width = v.Text.DesiredSize.Width;
                    Storyboard s        = new Storyboard();
                    Duration   duration =
                        new Duration(
                            TimeSpan.FromTicks(Convert.ToInt64((SystemParameters.PrimaryScreenWidth + wd) /
                                                               Store.FullOverlayEffect1 * TimeSpan.TicksPerSecond)));
                    ThicknessAnimation f =
                        new ThicknessAnimation(new Thickness(SystemParameters.PrimaryScreenWidth, top, 0, 0),
                                               new Thickness(-wd, top, 0, 0), duration);
                    s.Children.Add(f);
                    s.Duration = duration;
                    Storyboard.SetTarget(f, v);
                    Storyboard.SetTargetProperty(f, new PropertyPath("(FrameworkElement.Margin)"));
                    LayoutRoot.Children.Add(v);
                    s.Completed += s_Completed;
                    s.Begin();
                }
            }
            else
            {
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(
                                                () => (this as IDanmakuWindow).AddDanmaku(type, comment, color))
                                            );
            }
        }
Esempio n. 11
0
 void IDanmakuWindow.AddDanmaku(DanmakuType type, string comment, uint color)
 {
     WTF_AddLiveDanmaku(_wtf, (int)type, 0, comment, 25, (int)color, 0, 0);
 }
Esempio n. 12
0
 internal Danmaku(int poolIndex, DanmakuType type) {
     PoolIndex = poolIndex;
     this.type = type;
     prefab = type.Prefab;
 }