protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); _progressTextSize = GDI.MeasureText(e.Graphics, _labelProgress.Text + @"%", Font); _labelProgress.Location = new Point((Width / 2) - (_progressTextSize.Width / 2), Height - _progressTextSize.Height - 30); Graphics _graphics = e.Graphics; _graphics.Clear(Parent.BackColor); _graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle); _graphics.SmoothingMode = SmoothingMode.HighQuality; Color _backColor = Enabled ? BackColorState.Enabled : BackColorState.Disabled; Pen _penBackground = new Pen(_backColor, _thickness); int _width = Size.Width - (_thickness * 2); Rectangle _rectangle = new Rectangle(_thickness, Size.Height / 4, _width, _width); Pen _penProgress = new Pen(_progress, _thickness); _graphics.DrawArc(_penBackground, _rectangle, 180F, 180F); _graphics.DrawArc(_penProgress, _rectangle, 180F, MathManager.GetHalfRadianAngle(Value)); _labelProgress.Text = Value + @"%"; }
public void populateBoard() { int i = 0; foreach (Transform child in transform) { Debug.Log("i is: " + i); Name = child.Find("Name").GetComponent <Text>(); Price = child.Find("Price").GetComponent <Text>(); Stock = child.Find("Stock").GetComponent <Text>(); Have = child.Find("Have").GetComponent <Text>(); Food food = new Food(); //add these lines: MathManager.RandomizeFood(); // food = FoodList[MathManager.random13[i]]; food = FoodList[i]; Name.text = food.Name; food.Instance = MathManager.InstancePrice(food.Price, food.Percent); Price.text = food.Instance.ToString(); food.Stock = MathManager.InStock(); Stock.text = food.Stock.ToString(); Have.text = food.Owned.ToString(); Debug.Log(i); i++; } }
// void Awake (){ // playermanager = GetComponent<PlayerManager>(); // } void Start() { mathManager = GameObject.FindObjectOfType <MathManager> (); createFood(); populateBoard(); changeTextColor(); }
public void buySellSomething() { int i = 0; foreach (Transform child in transform) { Stock = child.Find("Stock").GetComponent <Text>(); Have = child.Find("Have").GetComponent <Text>(); Food food = new Food(); food = FoodList[i]; Name.text = food.Name; food.Stock = MathManager.InStock(); Stock.text = food.Stock.ToString(); Color blueColor = Color.blue; Color whiteColor = Color.white; Price.color = blueColor; if (food.Stock > 0) { Have.color = blueColor; } else { Have.color = whiteColor; } Have.text = food.Owned.ToString(); i++; } changerx++; }
private Point[] GetKnobLine(int l) { var pret = new Point[2]; float cx = _knobPoint.X; float cy = _knobPoint.Y; float radius = _knobRectangle.Width / 2; float degree = (_deltaAngle * Value) / (_maximum - _minimum); degree = MathManager.DegreeToRadians(degree + _startAngle); Point Pos = new Point(0, 0); Pos.X = (int)(cx + ((radius - (_drawRatio * 10)) * Math.Cos(degree))); Pos.Y = (int)(cy + ((radius - (_drawRatio * 10)) * Math.Sin(degree))); pret[0] = new Point(Pos.X, Pos.Y); Pos.X = (int)(cx + ((radius - (_drawRatio * 10) - l) * Math.Cos(degree))); Pos.Y = (int)(cy + ((radius - (_drawRatio * 10) - l) * Math.Sin(degree))); pret[1] = new Point(Pos.X, Pos.Y); return(pret); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } }
// Start is called before the first frame update void Start() { t = Globals.tempo / 80; mathM = GetComponent <MathManager>(); jumpVelocity = gravity * timeToJumpApex; anim = GetComponent <Animator>(); playerCollider = GetComponent <Collider2D>(); anim.SetBool("isWalking", true); }
public static MathManager GetInstance() { if (!instance) { container = new GameObject(); container.name = "MathManager"; instance = container.AddComponent(typeof(MathManager)) as MathManager; DontDestroyOnLoad(container); } return(instance); }
public void Math_whentwocorrectnumbersprovided_testshouldpass() { var n1 = 2; var n2 = 3; var expectedSum = 5; var math = new MathManager(); var result = math.Add(n1, n2); Assert.AreEqual(expectedSum, result); }
public void DataTest2() { var manager = new MathManager(); int x = Convert.ToInt16(TestContext.DataRow["x"]); int y = Convert.ToInt16(TestContext.DataRow["y"]); int expected = Convert.ToInt16(TestContext.DataRow["expected "]); var result = manager.Sum(x, y); Assert.AreEqual(expected, result); }
private void Awake() { if (_instance != null) { Destroy(this.gameObject); } else { _instance = this; DontDestroyOnLoad(this.gameObject); } }
static void Main(string[] args) { var math = new MathManager(); int n1, n2; Console.WriteLine("Enter two numbersss:"); n1 = int.Parse(Console.ReadLine()); n2 = int.Parse(Console.ReadLine()); var n3 = math.Add(n1, n2); var n4 = math.Subtract(n1, n2); Console.WriteLine($"Sum: {n1}+{n2}={n3}"); Console.WriteLine($"Subtraction: {n1}-{n2}={n4}"); /* Static */ // var myconst = Math.myconstant; }
private Point GetKnobPosition(int l) { float cx = _knobPoint.X; float cy = _knobPoint.Y; float radius = _knobRectangle.Width / 2; float degree = (_deltaAngle * Value) / (_maximum - _minimum); degree = MathManager.DegreeToRadians(degree + _startAngle); Point Pos = new Point(0, 0) { X = (int)(cx + ((radius - (KnobDistance * _drawRatio)) * Math.Cos(degree))), Y = (int)(cy + ((radius - (KnobDistance * _drawRatio)) * Math.Sin(degree))) }; return(Pos); }
public void changeDay() { int i = 0; foreach (Transform child in transform) { Name = child.Find("Name").GetComponent <Text>(); Price = child.Find("Price").GetComponent <Text>(); Stock = child.Find("Stock").GetComponent <Text>(); // MoneySign = child.Find("Text (1)").GetComponent<Text>(); Food food = new Food(); food = FoodList[i]; Name.text = food.Name; food.Instance = MathManager.InstancePrice(food.Price, food.Percent); Price.text = food.Instance.ToString(); food.Stock = MathManager.InStock(); Stock.text = food.Stock.ToString(); i++; } changeNetWorth(); changerdayx++; }
// Update is called once per frame void Update() { if (FireCheck) { Vector3 mos = GameObject.Find("Main Camera").GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition); mos.z = 0.0f; BulletAngle = MathManager.GetInstance().GetTargetAngle(mos, transform.position); Quaternion rotation = Quaternion.Euler(0.0f, 0.0f, -BulletAngle); transform.rotation = rotation; vecDir = mos - transform.position; rb.AddForce(vecDir.normalized * BulletSpeed); FireCheck = false; } TimeCheck += Time.deltaTime; if (roopTime <= TimeCheck) { TimeCheck = 0.0f; gameObject.SetActive(false); } }
public void TestMethod() { var m = MathManager.GetDistance(116.38156, 39.906301, 116.441926, 39.948131); Console.WriteLine(m); }
private bool DrawDivisions(Graphics graphics, RectangleF rectangleF) { if (this == null) { return(false); } float cx = _knobPoint.X; float cy = _knobPoint.Y; float w = rectangleF.Width; float h = rectangleF.Height; float tx; float ty; float incr = MathManager.DegreeToRadians((_endAngle - _startAngle) / ((_scaleDivisions - 1) * (_scaleSubDivisions + 1))); float currentAngle = MathManager.DegreeToRadians(_startAngle); float radius = _knobRectangle.Width / 2; float rulerValue = _minimum; Pen penL = new Pen(TickColor, 2 * _drawRatio); Pen penS = new Pen(TickColor, 1 * _drawRatio); SolidBrush br = new SolidBrush(ForeColor); PointF ptStart = new PointF(0, 0); PointF ptEnd = new PointF(0, 0); var n = 0; if (_showLargeScale) { for (; n < _scaleDivisions; n++) { // draw divisions ptStart.X = (float)(cx + (radius * Math.Cos(currentAngle))); ptStart.Y = (float)(cy + (radius * Math.Sin(currentAngle))); ptEnd.X = (float)(cx + ((radius + (w / 50)) * Math.Cos(currentAngle))); ptEnd.Y = (float)(cy + ((radius + (w / 50)) * Math.Sin(currentAngle))); graphics.DrawLine(penL, ptStart, ptEnd); // Draw graduations Strings float fSize = 6F * _drawRatio; if (fSize < 6) { fSize = 6; } Font font = new Font(Font.FontFamily, fSize); double val = Math.Round(rulerValue); string str = string.Format("{0,0:D}", (int)val); SizeF size = graphics.MeasureString(str, font); if (_drawDivInside) { // graduations strings inside the knob tx = (float)(cx + ((radius - (11 * _drawRatio)) * Math.Cos(currentAngle))); ty = (float)(cy + ((radius - (11 * _drawRatio)) * Math.Sin(currentAngle))); } else { // graduation strings outside the knob tx = (float)(cx + ((radius + (11 * _drawRatio)) * Math.Cos(currentAngle))); ty = (float)(cy + ((radius + (11 * _drawRatio)) * Math.Sin(currentAngle))); } graphics.DrawString(str, font, br, tx - (float)(size.Width * 0.5), ty - (float)(size.Height * 0.5)); rulerValue += (_maximum - _minimum) / (_scaleDivisions - 1); if (n == _scaleDivisions - 1) { font.Dispose(); break; } // Subdivisions if (_scaleDivisions <= 0) { currentAngle += incr; } else { for (var j = 0; j <= _scaleSubDivisions; j++) { currentAngle += incr; // if user want to display small graduations if (_showSmallScale) { ptStart.X = (float)(cx + (radius * Math.Cos(currentAngle))); ptStart.Y = (float)(cy + (radius * Math.Sin(currentAngle))); ptEnd.X = (float)(cx + ((radius + (w / 50)) * Math.Cos(currentAngle))); ptEnd.Y = (float)(cy + ((radius + (w / 50)) * Math.Sin(currentAngle))); graphics.DrawLine(penS, ptStart, ptEnd); } } } font.Dispose(); } } return(true); }
private void DrawKnobTop() { Point knobTopPoint = new Point((_knobRectangle.X + (_knobRectangle.Width / 2)) - (KnobTopSize.Width / 2), (_knobRectangle.Y + (_knobRectangle.Height / 2)) - (KnobTopSize.Height / 2)); Rectangle knobTopRectangle = new Rectangle(knobTopPoint, KnobTopSize); _offGraphics.FillEllipse(_knobTop.Brush, knobTopRectangle); GraphicsPath borderPath = new GraphicsPath(); borderPath.AddEllipse(knobTopRectangle); VisualBorderRenderer.DrawBorderStyle(_offGraphics, _knobTopBorder, borderPath, State); float cx = _knobPoint.X; float cy = _knobPoint.Y; float w = KnobTopSize.Width; // TODO: Adjust float incr = MathManager.DegreeToRadians((_startAngle - _endAngle) / ((_buttonDivisions - 1) * (_scaleSubDivisions + 1))); float currentAngle = MathManager.DegreeToRadians(0); float radius = KnobTickSize.Width / 2; Pen penL = new Pen(TickColor, 2 * _drawRatio); PointF ptStart = new PointF(0, 0); PointF ptEnd = new PointF(0, 0); var n = 0; for (; n < _buttonDivisions; n++) { // draw divisions ptStart.X = (float)(cx + (radius * Math.Cos(currentAngle))); ptStart.Y = (float)(cy + (radius * Math.Sin(currentAngle))); ptEnd.X = (float)(cx + ((radius + (w / 50)) * Math.Cos(currentAngle))); ptEnd.Y = (float)(cy + ((radius + (w / 50)) * Math.Sin(currentAngle))); // TODO: draw lines along button border // gOffScreen.DrawLine(penL, ptStart, ptEnd); // Draw graduations Strings float fSize = 6F * _drawRatio; if (fSize < 6) { fSize = 6; } Font font = new Font(Font.FontFamily, fSize); if (n == _buttonDivisions - 1) { font.Dispose(); break; } // Subdivisions if (_buttonDivisions <= 0) { currentAngle += incr; } else { for (var j = 0; j <= _scaleSubDivisions; j++) { currentAngle += incr; } } font.Dispose(); } }
void MouseCheck() { Vector3 mos = GameObject.Find("Main Camera").GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition); mos.z = 0.0f; PlayerAngle = MathManager.GetInstance().GetTargetAngle(mos, transform.position); LookRotation(PlayerAngle); // 좌 우 보는방향 스케일 조정 SettingWeaponAngle(); // 무기 각도 회전 if (Input.GetMouseButton(1) && !IsReload && 0 != SubBulletCount) { IsReload = true; RoadingBar.SetActive(true); switch (PlayerWeaponType) // 장전사운드넣는곳 { case eWeaponType.WEAPON_PISTOL: SoundManager.Instance.PlayEffect(ReloadSound[0]); break; case eWeaponType.WEAPON_SUBMACHINE_GUN: SoundManager.Instance.PlayEffect(ReloadSound[1]); break; case eWeaponType.WEAPON_MACHINE_GUN: SoundManager.Instance.PlayEffect(ReloadSound[2]); break; case eWeaponType.WEAPON_SINPER_RIFLE: SoundManager.Instance.PlayEffect(ReloadSound[3]); break; case eWeaponType.WEAPON_HEAVY_MACHINE_GUN: SoundManager.Instance.PlayEffect(ReloadSound[4]); break; } } if (Input.GetMouseButton(0) && 0 < BulletCount && !IsReload) { if (FirstShot) { --BulletCount; CreateBullet(); FirstShot = false; AttackDelayTime = 0.0f; } AttackDelayTime += Time.deltaTime; if (AttackDelay <= AttackDelayTime) { --BulletCount; AttackDelayTime = 0.0f; CreateBullet(); } } else { AttackDelayTime += Time.deltaTime; if (AttackDelay <= AttackDelayTime) { FirstShot = true; } } }
public override void Init(MathManager mathManager) { base.Init(mathManager); }