public void SetColor(NodeColors c) { switch (c) { case NodeColors.Red: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Red]; MyColor = NodeColors.Red; break; case NodeColors.Orange: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Orange]; MyColor = NodeColors.Orange; break; case NodeColors.Yellow: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Yellow]; MyColor = NodeColors.Yellow; break; case NodeColors.Blue: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Blue]; MyColor = NodeColors.Blue; break; case NodeColors.Green: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Green]; MyColor = NodeColors.Green; break; case NodeColors.Purple: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Purple]; MyColor = NodeColors.Purple; break; } }
public void PickColor() { MyColor = (NodeColors)Random.Range(((int)NodeColors.First + 1), GameManager.instance.NumberOfColors); //Debug.Log((int)MyColor); switch (MyColor) { case NodeColors.Red: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Red]; break; case NodeColors.Orange: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Orange]; break; case NodeColors.Yellow: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Yellow]; break; case NodeColors.Blue: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Blue]; break; case NodeColors.Green: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Green]; break; case NodeColors.Purple: transform.GetComponent <SpriteRenderer>().color = ColorManager.instance.PossibleColors[(int)NodeColors.Purple]; break; } }
public int[] TarjanRecursive() { NodeColors[] nodeColors = new NodeColors[Data.NodesCount]; NodeStack <int> stack = new NodeStack <int>(); if (!TarjanRecursiveStart(stack, nodeColors)) { throw new Exception("Invalid data for Tarjan"); } return(Util.ListToArray <int>(stack)); }
/// <summary> /// Paints background of the node. /// </summary> /// <param name="e">Context information.</param> protected virtual void PaintBackground(NodeRendererEventArgs e) { Graphics g = e.Graphics; bool mouseOver = e.Node.IsMouseOver; Region oldClip = g.Clip; Rectangle clipRect=e.NodeBounds; clipRect.Width--; clipRect.Height--; g.SetClip(clipRect, CombineMode.Replace); // Prepare colors NodeColors colors=new NodeColors(); colors.NodeTopGradientBegin = m_ColorTable.NodeTopGradientBegin; colors.NodeTopGradientMiddle = m_ColorTable.NodeTopGradientMiddle; colors.NodeTopGradientEnd = m_ColorTable.NodeTopGradientEnd; colors.NodeTopGradientType = m_ColorTable.NodeTopGradientType; colors.NodeTopGradientAngle = m_ColorTable.NodeTopGradientAngle; colors.NodeBottomGradientBegin = m_ColorTable.NodeBottomGradientBegin; colors.NodeBottomGradientMiddle = m_ColorTable.NodeBottomGradientMiddle; colors.NodeBottomGradientEnd = m_ColorTable.NodeBottomGradientEnd; colors.NodeBottomGradientType = m_ColorTable.NodeBottomGradientType; colors.NodeBottomGradientAngle = m_ColorTable.NodeBottomGradientAngle; if(mouseOver) { colors.NodeTopGradientBegin = m_ColorTable.NodeMouseOverTopGradientBegin; colors.NodeTopGradientMiddle = m_ColorTable.NodeMouseOverTopGradientMiddle; colors.NodeTopGradientEnd = m_ColorTable.NodeMouseOverTopGradientEnd; colors.NodeTopGradientType = m_ColorTable.NodeMouseOverTopGradientType; colors.NodeTopGradientAngle = m_ColorTable.NodeMouseOverTopGradientAngle; colors.NodeBottomGradientBegin = m_ColorTable.NodeMouseOverBottomGradientBegin; colors.NodeBottomGradientMiddle = m_ColorTable.NodeMouseOverBottomGradientMiddle; colors.NodeBottomGradientEnd = m_ColorTable.NodeMouseOverBottomGradientEnd; colors.NodeBottomGradientType = m_ColorTable.NodeMouseOverBottomGradientType; colors.NodeBottomGradientAngle = m_ColorTable.NodeMouseOverBottomGradientAngle; } // Paint Background, Top Part Rectangle bounds=DisplayHelp.GetDrawRectangle(ElementStyleDisplay.GetBackgroundRectangle(e.Style,e.NodeBounds)); GraphicsPath path; if (g.SmoothingMode == SmoothingMode.AntiAlias) { Rectangle r = bounds; r.Width--; path = ElementStyleDisplay.GetBackgroundPath(e.Style, r, eStyleBackgroundPathPart.TopHalf); } else path = ElementStyleDisplay.GetBackgroundPath(e.Style, bounds, eStyleBackgroundPathPart.TopHalf); path.CloseAllFigures(); Rectangle backRect = bounds; backRect.Height = backRect.Height/2; PaintBackgroundPart(g, backRect, path, colors.NodeTopGradientBegin, colors.NodeTopGradientEnd, colors.NodeTopGradientType, colors.NodeTopGradientAngle); Rectangle ellipse = new Rectangle(bounds.X, bounds.Y - bounds.Height / 2, bounds.Width, bounds.Height); GraphicsPath pathFill=new GraphicsPath(); pathFill.AddEllipse(ellipse); PathGradientBrush pathBrush = new PathGradientBrush(pathFill); pathBrush.CenterColor = colors.NodeTopGradientMiddle; pathBrush.SurroundColors = new Color[] { Color.Transparent }; pathBrush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Y); Blend blend = new Blend(); blend.Factors = new float[] { 0f, .8f, 1f }; blend.Positions = new float[] { .0f, .8f, 1f }; pathBrush.Blend = blend; pathFill.Dispose(); g.FillPath(pathBrush, path); pathBrush.Dispose(); path.Dispose(); // Bottom Part if (g.SmoothingMode == SmoothingMode.AntiAlias) { Rectangle r = bounds; r.Width--; path = ElementStyleDisplay.GetBackgroundPath(e.Style, r, eStyleBackgroundPathPart.BottomHalf); } else path = ElementStyleDisplay.GetBackgroundPath(e.Style, bounds, eStyleBackgroundPathPart.BottomHalf); path.CloseAllFigures(); backRect.Y += backRect.Height; PaintBackgroundPart(g, backRect, path, colors.NodeBottomGradientBegin, colors.NodeBottomGradientEnd, colors.NodeBottomGradientType, colors.NodeBottomGradientAngle); ellipse = new Rectangle(bounds.X, bounds.Y + bounds.Height / 2 - 2, bounds.Width, bounds.Height + 4); pathFill=new GraphicsPath(); pathFill.AddEllipse(ellipse); pathBrush = new PathGradientBrush(pathFill); pathBrush.CenterColor = colors.NodeBottomGradientMiddle; pathBrush.SurroundColors = new Color[] { Color.Transparent }; pathBrush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom); blend = new Blend(); blend.Factors = new float[] { 0f, .5f, 1f }; blend.Positions = new float[] { .0f, .4f, 1f }; pathBrush.Blend = blend; //path.Dispose(); g.FillPath(pathBrush, path); pathBrush.Dispose(); pathFill.Dispose(); path.Dispose(); if (oldClip != null) g.Clip = oldClip; else g.ResetClip(); }