void Start() { audioSource = GetComponent <AudioSource>(); if (leftTimeBar == null) { this.leftTimeBar = GameObject.Find("LeftTimeBar"); } if (countDownText == null) { this.countDownText = GameObject.Find("CountDown"); } if (player == null) { this.player = GameObject.Find("Player"); } if (finishText == null) { this.finishText = GameObject.Find("Finish"); } if (gameDirector == null) { this.gameDirector = GameObject.Find("GameDirector"); } playerScript = player.GetComponent <GamePlayerController>(); calcPointScript = gameDirector.GetComponent <CalcPoint>(); BGM = GameObject.Find("BGM"); musicScript = BGM.GetComponent <BackGroundMusic>(); startFlag = false; coroutineFlag = true; deltaTime = 0; }
void Start() { playerData = GameObject.Find("PlayerData"); playerDataScript = playerData.GetComponent <PlayerData>(); audioSource = GetComponent <AudioSource>(); if (timeKeeper == null) { timeKeeper = GameObject.Find("TimeKeeper"); } timeKeeperScript = timeKeeper.GetComponent <TimeKeeper>(); if (gameDirector == null) { gameDirector = GameObject.Find("GameDirector"); } calcPointScript = gameDirector.GetComponent <CalcPoint>(); lanceData = playerDataScript.GetLance(); gameObject.GetComponent <SpriteRenderer>().sprite = lanceData.GetLanceImage(); moveSpeed = lanceData.GetMoveSpeed(); evaTextScript = evaluation.GetComponent <SetEvaluationText>(); _rb = GetComponent <Rigidbody2D>(); GetComponent <Collider2D>().enabled = false; startPos = gameObject.transform.position; goFlag = false; backFlag = false; fracJourney = 0f; }
void Start() { fishData = GameDirector.GetFishData().Find(f => f.GetFishType() == type); fishAmount = CalcPoint.GetCaughtFish(fishData.GetFishName()); SetText(this.gameObject, fishAmount); }
private void button1_Click(object sender, EventArgs e) { List <PointF> list = new List <PointF>(); string[] lines = textBox1.Text.Split('\n'); float sum_x = 0, sum_x_2 = 0, sum_y = 0, sum_xy = 0; float minx = float.MaxValue, miny = float.MaxValue, maxx = float.MinValue, maxy = float.MinValue; foreach (string l in lines) { try { string[] items = l.Split(' '); float x = float.Parse(items[0]); float y = float.Parse(items[1]); sum_x += x; sum_x_2 += x * x; sum_y += y; sum_xy += x * y; minx = Math.Min(minx, x); miny = Math.Min(miny, y); maxx = Math.Max(maxx, x); maxy = Math.Max(maxy, y); list.Add(new PointF(x, y)); } catch (Exception) { MessageBox.Show("輸入資料有誤"); return; } } float avg_x = sum_x / list.Count; float avg_y = sum_y / list.Count; float m = (sum_xy - sum_x * avg_y) / (sum_x_2 - sum_x * avg_x); float c = avg_y - m * avg_x; float w = maxx - minx; float h = maxy - miny; miny -= h / 12; maxy += h / 12; minx -= w / 12; maxx += w / 12; w = maxx - minx; h = maxy - miny; const int W = 750; const int H = 550; Bitmap inner = new Bitmap(W, H); Graphics g = Graphics.FromImage(inner); g.Clear(Color.White); CalcPoint cp = new CalcPoint(minx, miny, maxx, maxy, W, H); g.DrawLine(Pens.Red, cp.Calculate(minx, m * minx + c), cp.Calculate(maxx, m * maxx + c)); foreach (PointF p in list) { g.DrawEllipse(Pens.Blue, new Rectangle(cp.Calculate(p.X, p.Y, -2, -2), new Size(4, 4))); } Bitmap outer = new Bitmap(W + 50, H + 50); g = Graphics.FromImage(outer); g.DrawImage(inner, 50, 0); g.DrawLine(Pens.Black, 50, 0, 50, H); g.DrawLine(Pens.Black, 50, H, W + 50, H); float dx = w / 12; float dy = h / 10; for (float x = minx; x < maxx; x += dx) { g.DrawLine(Pens.Black, cp.Calculate(x, 0).X + 50, H - 4, cp.Calculate(x, 0).X + 50, H + 4); g.DrawString(Math.Round(x, 2).ToString(), new Font("Courier New", 12, GraphicsUnit.Point), Brushes.Black, cp.Calculate(x, 0).X + 50, H); } for (float y = miny; y < maxy; y += dy) { g.DrawLine(Pens.Black, 46, cp.Calculate(0, y).Y, 54, cp.Calculate(0, y).Y); g.DrawString(Math.Round(y, 2).ToString(), new Font("Courier New", 12, GraphicsUnit.Point), Brushes.Black, 0, cp.Calculate(0, y).Y); } inner = outer; outer = new Bitmap(820, 620); g = Graphics.FromImage(outer); g.DrawImage(inner, 20, 0); g.DrawString("y", this.Font, Brushes.Black, 0, 300); g.DrawString("x", this.Font, Brushes.Black, 410, 600); g.DrawImage(Properties.Resources.label, 820 - 120, 5); pictureBox1.Image = outer; label2.Text = string.Format("斜率 m = {0}, 截距 b = {1}", Math.Round(m, 3), Math.Round(c, 3)); }
public void UndoLast() { if (undoactions.Count >= 1) { MindNodeAction action = undoactions.Last(); undoactions.Remove(action); switch (action.name) { case "CreateNode": if (action.involvedNodes.Count >= 1) { MindNode createdNode = action.involvedNodes.Pop(); redoactions.Add(new MindNodeAction(1, "DeleteNode", createdNode)); createdNode.DeleteNode(); } break; case "DeleteNode": if (action.involvedNodes.Count >= 1) { MindNode deletednode = action.involvedNodes.Pop(); redoactions.Add(new MindNodeAction(0, "CreateNode", deletednode)); if (deletednode.parent != null) { deletednode.parent.AddChildNoStyle(deletednode, false); } // Refresh Pivot Representation after reinstating node deletednode.UpdatePivots(); } break; case "MoveNodes": if (action.involvedNodes.Count >= 1) { MindNodeAction newaction = new MindNodeAction(2, "MoveNodes"); foreach (MindNode movedNode in action.involvedNodes) { newaction.involvedNodes.Push(movedNode); newaction.startpoint.Push(new CalcPoint(movedNode.xpos, movedNode.ypos)); if (action.startpoint.Count > 0) { CalcPoint oldPos = action.startpoint.Pop(); movedNode.SetPosition(oldPos.X, oldPos.Y, false); } // Refresh Pivot Representation after moving node movedNode.UpdatePivots(); } redoactions.Add(newaction); } break; case "ConnectNodes": if (action.involvedNodes.Count >= 2) { MindNodeAction newAction = new MindNodeAction(3, "DeleteConnections"); for (int i = 0; i < action.involvedNodes.Count / 2; i++) { MindNode rightnode = action.involvedNodes.Pop(); MindNode leftnode = action.involvedNodes.Pop(); newAction.involvedNodes.Push(leftnode); newAction.involvedNodes.Push(rightnode); leftnode.DeleteConnection(rightnode); } redoactions.Add(newAction); } break; case "DeleteConnections": if (action.involvedNodes.Count >= 2) { MindNodeAction newAction = new MindNodeAction(3, "ConnectNodes"); for (int i = 0; i < action.involvedNodes.Count / 2; i++) { MindNode rightnode = action.involvedNodes.Pop(); MindNode leftnode = action.involvedNodes.Pop(); MindNode rightExistingNode = GlobalNodeHandler.masterNode.GetExistingNode(rightnode.id); MindNode leftExistingNode = GlobalNodeHandler.masterNode.GetExistingNode(rightnode.id); newAction.involvedNodes.Push(leftnode); newAction.involvedNodes.Push(rightnode); //leftnode.AddConnection(rightnode); // Refresh Pivot Representation after reinstating connection //leftnode.UpdatePivots(); } redoactions.Add(newAction); } break; case "ChangeText": if (action.involvedNodes.Count >= 1) { MindNodeAction newaction = new MindNodeAction(4, "ChangeText"); MindNode changedNode = action.involvedNodes.Pop(); newaction.text = changedNode.text; newaction.involvedNodes.Push(changedNode); changedNode.SetText(action.text); redoactions.Add(newaction); } else if (action.involvedLabel != null) { MindNodeAction newaction = new MindNodeAction(4, "ChangeText"); NodeLabel changedLabel = action.involvedLabel; newaction.text = changedLabel.GetText(); newaction.involvedLabel = changedLabel; changedLabel.SetText(action.text); redoactions.Add(newaction); } break; case "Transform": if (action.involvedNodes.Count >= 1) { MindNodeAction newaction = new MindNodeAction(5, "Transform"); MindNode changedNode = action.involvedNodes.Pop(); newaction.sourceSize.X = changedNode.width; newaction.sourceSize.Y = changedNode.height; newaction.startpoint.Push(new CalcPoint(changedNode.xpos, changedNode.ypos)); newaction.involvedNodes.Push(changedNode); if (action.sourceSize.X != -1) { changedNode.width = action.sourceSize.X; changedNode.SetScaled(false); } if (action.sourceSize.Y != -1) { changedNode.height = action.sourceSize.Y; changedNode.SetScaled(false); } CalcPoint oldPos = action.startpoint.Pop(); if (oldPos != null) { changedNode.SetPosition(oldPos.X, oldPos.Y, false); } // Refresh Pivot Representation after resetting transformation changedNode.UpdatePivots(); changedNode.updateRepresentation(); redoactions.Add(newaction); } break; } } }
/// <summary> /// Initializes a new instance of the SectionDataBase object with list of parameters. /// </summary> /// <param name="point">Calculation point.</param> /// <param name="data">Object with base parameters for the section.</param> public SectionDataBase(CalcPoint point, ObjectDataBase data) : base(data) { calcPoint = point; }