Пример #1
0
        public override void Update(Laser laser)
        {
            //���ߺϳɹ�ʽ��
            //������ǵ�ɫ/�̳��ϰ��ǻ��ɫ
            //��+��=��/��+��=��/��+��=��/��ɫ�ϳɰ�
            //�׷ֽ⻹�ǰ�

            if (this.Out == null || this.Type == PrismType.Resolve)
            {
                #region һ��������
                if (this.Out == null)
                {
                    this.Type = PrismType.Resolve;
                    In = laser;

                    switch (laser.Color)
                    {
                        case Colors.red:
                        case Colors.yellow:
                        case Colors.blue:
                        case Colors.white:
                            Out = new Laser(this, this.Father.Content, laser.Color, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle + 45);
                            Extra = new Laser(this, this.Father.Content, laser.Color, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle - 45);
                            break;
                        case Colors.orange:
                            Out = new Laser(this, this.Father.Content, Colors.red, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle + 45);
                            Extra = new Laser(this, this.Father.Content, Colors.yellow, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle - 45);
                            break;
                        case Colors.purple:
                            Out = new Laser(this, this.Father.Content, Colors.red, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle + 45);
                            Extra = new Laser(this, this.Father.Content, Colors.blue, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle - 45);
                            break;
                        case Colors.green:
                            Out = new Laser(this, this.Father.Content, Colors.blue, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle + 45);
                            Extra = new Laser(this, this.Father.Content, Colors.yellow, laser.EndPoint.X, laser.EndPoint.Y - 10, laser.Angle - 45);
                            break;

                    }
                    if(this.Focused) Out.Focused = true;
                    Selected = Out;
                }
                #endregion

                #region ����������
                else
                {
                    if (laser == In) ;
                    else if (laser.Color == In.Color)
                    {
                        Extra.Father = null;
                        Extra = laser;
                        this.Type = PrismType.Blend;
                        Out.SetColor(In.Color);
                    }
                    else
                    {
                        this.Type = PrismType.Blend;
                        Extra.Father = null;
                        Extra = laser;
                        int lc = (int)laser.Color;
                        int ic = (int)In.Color;
                        Colors color;
                        if (lc < 3 && ic < 3)
                        {
                            if (lc + ic == 1) color = Colors.purple;
                            else if (lc + ic == 2) color = Colors.orange;
                            else color = Colors.green;
                        }
                        else color = Colors.white;

                        if (Math.Abs(Math.Abs(Out.Angle - Extra.Angle) - 180) < 1)
                        {
                            float angle = Math.Abs(this.In.Angle - this.Extra.Angle);
                            if (angle > 180)
                            {
                                angle = 360 - angle;
                                angle = angle / 2 + Math.Max(this.In.Angle, this.Extra.Angle);
                            }
                            else
                            {
                                angle = angle / 2 + Math.Min(this.In.Angle, this.Extra.Angle);
                            }

                            angle = (int)(angle / 45) * 45;
                            Out.Angle = angle;
                        }
                        Out.SetColor(color);

                        //Out.Father = null;
                        //Out = new Laser(this, this.Father.Content, color, In.EndPoint.X, In.EndPoint.Y - 10, angle);
                        Out.Focused = this.Focused;
                        Selected = Out;
                    }
                }
                #endregion
            }
            Father.UpdateLaser(Out);
            if (this.Type == PrismType.Resolve) Father.UpdateLaser(Extra);
        }
Пример #2
0
 internal override void ClearLaser()
 {
     this.Selected = null;
     if (this.Out != null)
     {
         this.Out.Father = null;
         this.Out = null;
     }
     if (this.Extra != null && this.Type == PrismType.Resolve)
     {
         this.Extra.Father = null;
         this.Extra = null;
     }
     this.Type = PrismType.Resolve;
 }
Пример #3
0
 public Prism(WorkingArea father, int x, int y)
     : base(father, x, y)
 {
     Foreground = Father.Content.Load<Texture2D>("Images/MirrorMenu/prism");
     this.Type = PrismType.Resolve;
     this.Origin = new Vector2(this.Foreground.Width / 2, this.Foreground.Height / 2);
 }