void button_MouseHover(dfControl control, dfMouseEventArgs mouseEvent) { BrainButton but = control as BrainButton; but.OriginalWidth = but.Width; but.Width = 400; but.ZOrder = 50; }
void button_MouseLeave(dfControl control, dfMouseEventArgs mouseEvent) { BrainButton but = control as BrainButton; but.Width = but.OriginalWidth; but.ZOrder = 10; }
void button_Click(dfControl control, dfMouseEventArgs mouseEvent) { //print("Button clicked"); BrainButton bb = control as BrainButton; Settings.Brain = bb.Brain; // Settings.IsNewBrain = bb.IsNewBrain; Application.LoadLevel("Training Overview"); }
void button_DragStart(dfControl control, dfDragEventArgs dragEvent) { BrainButton bb = control as BrainButton; draggedBrain = bb.Brain; dragEvent.State = dfDragDropState.Dragging; dragEvent.Data = this; Cursor.SetCursor(mouseCursor, Vector2.zero, CursorMode.Auto); print("Drag start"); }
void new_button_Click(dfControl control, dfMouseEventArgs mouseEvent) { BrainButton bb = control as BrainButton; Settings.Brain = bb.Brain.Branch(); Application.LoadLevel("Training Overview"); // Application.LoadLevel("Training Overview"); mouseEvent.Use(); }
private void expand_click(dfControl control, dfMouseEventArgs mouseEvent) { BrainButton bb = control as BrainButton; List <Brain> brains = new List <Brain>() { bb.Brain }; mouseEvent.Use(); ExpandedState = true; AddBrains(brains); }
private float AddBox(Brain b, int level, float prev_center, Color32 color) { var top_padding = 10; var spacing = 150; // var button = _panel.AddControl<BrainButton>(); BrainButton button = _panel.AddPrefab(ListItem) as BrainButton; // as UserListItem; dfLabel NameLabel = button.Find("Brain Name Label").GetComponent <dfLabel>(); dfLabel GenerationLabel = button.Find("Generation Label").GetComponent <dfLabel>(); dfLabel FitnessLabel = button.Find("Fitness Label").GetComponent <dfLabel>(); BrainButton branchButton = button.Find("Branch Button").GetComponent <BrainButton>(); NameLabel.Text = b.Name; GenerationLabel.Text = "Generation: " + b.Generation; FitnessLabel.Text = "Fitness: " + b.BestFitness; button.Brain = b; button.Click += button_Click; button.IsNewBrain = b.IsNewBrain; button.DragStart += button_DragStart; //button.BackgroundSprite = "BLANK_TEXTURE"; button.NormalBackgroundColor = color; //button.HoverSprite = "listitem-hover"; //button.PressedSprite = "listitem-selected"; //button.Width = 150; //button.Height = 80; var center_spacing = _panel.Width / (LevelCount[level]); var center = center_spacing * CurrentCount[level] - center_spacing / 2; CurrentCount[level] += 1; button.RelativePosition = new Vector3(center - button.Width / 2, top_padding + level * spacing); var plus = branchButton; plus.Brain = b; plus.Click += new_button_Click; if (level > 0) { var line = _panel.AddControl <dfSprite>(); line.SpriteName = "vslider-track-normal"; line.Width = 12; //line.Height = spacing - button.Height; float B = spacing - button.Height; line.Height = HypotenuseLength(prev_center, center, B) + 20; Vector3 rot = Vector3.forward; float angle = Angle(B, center - prev_center); print("Angle: " + angle); line.transform.Rotate(rot, angle); float padding = 0; if (angle < 0) { padding = -5; } if (angle > 0) { padding = 5; } line.RelativePosition = new Vector3(prev_center, top_padding + level * spacing - B + padding - 2); line.ZOrder = 0; } return(center); }