internal CBall(CBall ball) { this.ballx = ball.ballx; this.bally = ball.bally; this.ballh = ball.ballh; this.ballw = ball.ballw; this.ballvx = ball.ballvx; this.ballvy = ball.ballvy; this.ballv = ball.ballv; this.ballangle = ball.ballangle; this.ballvrot = ball.ballvrot; this.fireball = ball.fireball; this.ballsticking = ball.ballsticking; this.stickydifference = ball.stickydifference; this.ballstickstart = ball.ballstickstart; lastfade = ball.lastfade; smash = ball.smash; damage = ball.damage; setDamage(damage); }
private void GetLeftClick(Point pos, CDrawer dr) { CBall newBall; newBall = new CBall(pos, rnd.Next(1, 366)); ballList.Add(newBall); newBall.Render(dr); }
public void PrepareHit() { CSimulationManager.instance.ResetScene(); Security.SecurityWrapperService.Instance.ArmBox(); currBall = CSimulationManager.instance.GetNewBall(); currBall.transform.SetParent(GameCameraManager.Instance.tee.transform); currBall.transform.localPosition = new Vector3(0, 0.1f, 0); }
public CBall GetNewBall() { GameObject gameObject = this.InstantiateBall(); gameObject.name = "Prop_Ball::New"; this.m_ballTransform = gameObject.transform; this.m_ball = gameObject.GetComponent <CBall>(); TrailRenderer component = gameObject.GetComponent <TrailRenderer>(); component.sortingLayerName = "BallTracer"; component.sortingOrder = 2; return(this.m_ball); }
public override void Update() { Vector3 vector3; Vector3 vector31; if (this.m_target != null) { CBall component = this.m_target.GetComponent <CBall>(); if (component == null) { this.m_cameraTransform.position = this.m_initialPosition + this.CamOffset; this.m_cameraTransform.LookAt(this.m_target.transform.position); } else { BallTrajectory trajectory = component.GetTrajectory(); if (trajectory != null && trajectory.m_points.Count != 0) { BallTrajectory.Point item = component.GetTrajectory().m_points[0]; this.lastGoodStartLocation = item.pos; BallTrajectory.Point point = component.GetTrajectory().m_points[component.GetTrajectory().firstBounceFrame]; this.lastGoodBallLanding = point.pos; this.lastGoodBallResting = component.GetTrajectory().GetRestingPosition(); } if ((this.lastGoodBallLanding - this.lastGoodStartLocation).magnitude >= (this.lastGoodBallResting - this.lastGoodStartLocation).magnitude) { vector3 = this.lastGoodBallResting; vector31 = this.lastGoodBallLanding; } else { vector3 = this.lastGoodBallLanding; vector31 = this.lastGoodBallResting; } Vector3 vector32 = vector31 - vector3; float single = vector32.magnitude / 2f; vector32.Normalize(); Vector3 vector33 = vector3 + (vector32 * single); Vector3 vector34 = Vector3.Cross(Vector3.up, vector32); if (vector33.x > this.lastGoodStartLocation.x) { vector34 *= -1f; } vector34 *= 2f; vector34.y = 0.5f; this.m_cameraTransform.position = vector33 + vector34; this.m_cameraTransform.LookAt(this.m_target.transform); } } }
public void DoReplay(TFlightData data) { if (data.isValid) { this.isReplay = true; this.originalBall = data.ballTransform.GetComponent <CBall>(); this.originalBall.gameObject.SetActive(false); this.replayBall = this.currentBall; this.replayBall.name = "Prop_Ball::Replay"; //this.replayBall.SetNewTracerMaterial(ApplicationDataManager.instance.GetTracerMaterialByColor(this.originalBall.tracerColor)); //CSimulationManager.instance.ReplayShot(data); //this.numericDisplays.ResetDials(); //this.numericDisplayStatic.ResetDials(); } }
public void RemovePrevBall(CBall ball) { if (ball == null) { return; } if (!this.previousBalls.Contains(ball)) { AppLog.LogError(string.Concat("Previous balls dont contain ball ", ball.gameObject.name), true); } else { this.previousBalls.Remove(ball); } }
protected void ClearAllBalls() { while (this.previousBalls.Count > 0) { if (this.previousBalls[0] == null) { this.previousBalls.RemoveAt(0); } else { CSimulationManager.instance.DestroyBall(this.previousBalls[0]); } } CSimulationManager.instance.DestroyBall(this.currentBall); this.currentBall = null; this.previousBalls.Clear(); }
public void RemoveBallWithTracer(CBall ballWithTracer) { int num = 0; while (num < this.golfBalls.Count) { if (this.golfBalls[num].gameObject != ballWithTracer.gameObject) { num++; } else { this.golfBalls[num].SetTrailActive(false); this.golfBalls.RemoveAt(num); break; } } this.ChangeTracerDisplay(this.tracerAmount); }
//* -----------------------------------------------------------------------* /// <summary>難易度7状態の移動判定を実行します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動と判断した場合、<c>true</c>。</returns> private bool movePatternLevel7(CBall entity) { int counter = entity.counter; bool result = counter % 40 == 0; if (!result) { if (counter > 200) { result = counter % (entity.accelerateSpeed ? 3 : 10) == 0; } else if (!entity.accelerateSpeed && CBall.player.position.X - entity.position.X > 10) { entity.accelerateSpeed = true; } } return(result); }
public void BallEnd(CBall ball) { if (GameEntry.GameData.currGolfball[GameEntry.GameData.currGolfball.Count - 1].score != 0) { ball.tx_luodi.gameObject.SetActive(true); } else { ball.tx_luoshui.gameObject.SetActive(true); } if (GameEntry.GameData.currGolfball.Count < GameEntry.GameData.MaxGolfballCount && GameEntry.GameData.onLine) { PrepareHit(); } else if ((GameEntry.HitBall.redisland.Count != 8 && GameEntry.HitBall.blueisland.Count != 8) && !GameEntry.GameData.onLine) { PrepareHit(); } ShowFlightPath(GameEntry.GameData.pathBtnState); }
public CFadeBall(CBall ball) { alpha = 0.75f; x = ball.ballx; y = ball.bally; angle = ball.Ballangle; vx = vy = 0; scale = 1.0f; scaleV = -6.0f; const int max = 45; vx = (float)BBX.random.Next(-max, max + 1); vy = (float)BBX.random.Next(-max, max + 1); if (ball.ballsticking) { vy += -45; } }
public void AddBallWithTracer(CBall ballWithTracer) { this.golfBalls.Insert(0, ballWithTracer); this.startPoints.Insert(0, ballWithTracer.gameObject.transform.position); this.ChangeTracerDisplay(this.tracerAmount); }
//* -----------------------------------------------------------------------* /// <summary>難易度8状態の移動判定を実行します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動と判断した場合、<c>true</c>。</returns> private bool movePatternLevel8(CBall entity) { return(entity.counter > 200); }
internal bool collideWith(CBall otherBall) { // obviously, we don't want to collide with ourself if (otherBall == this) { return(false); } float displacementSqr; // square of the distance between the two balls float displacementX, displacementY; // two component displacement vector // get the displacement vector displacementX = otherBall.ballx - ballx; displacementY = otherBall.bally - bally; // just in case they happen to be at the exact same spot if (displacementX == 0 && displacementY == 0) { displacementX = 1; } displacementSqr = displacementX * displacementX + displacementY * displacementY; // don't collide with balls that are stuck if we are moving up if (ballsticking && otherBall.ballvy < 0) { return(false); } else if (ballvy < 0 && otherBall.ballsticking) { return(false); } // check to see if actual collision else if (displacementSqr < ballw * ballw && displacementSqr > 1) { // yep, we collided. Now we want to calculate to collision. // the algorithm is: the balls exchange velocities in the direction of the displacement // and velocity perpendicular to that remains unchanged. // First we want to normalize the displacement vector. displacementSqr = (float)Math.Sqrt(displacementSqr); displacementX /= displacementSqr; displacementY /= displacementSqr; float perpX, perpY; // vector that is perpendicular to the displacement perpX = displacementY; // simple 2-D algorithm for a perpendicular vector: perpY = -displacementX; // swap the two components and change the sign of one. // calculate the components of the velocities in these two directions. float thisVParallel, thisVPerp; float otherVParallel, otherVPerp; // take the scalar product of the normalized displacement vector with the velocity; // this gives me the projection of the velocity onto the displacement. thisVParallel = displacementX * ballvx + displacementY * ballvy; otherVParallel = displacementX * otherBall.ballvx + displacementY * otherBall.ballvy; // same for the perpendicular velocity thisVPerp = perpX * ballvx + perpY * ballvy; otherVPerp = perpX * otherBall.ballvx + perpY * otherBall.ballvy; // now swap the parallel components. float t; t = thisVParallel; thisVParallel = otherVParallel; otherVParallel = t; // reconstruct the actual velocity vector ballvx = thisVParallel * displacementX + thisVPerp * perpX; ballvy = thisVParallel * displacementY + thisVPerp * perpY; otherBall.ballvx = otherVParallel * displacementX + otherVPerp * perpX; otherBall.ballvy = otherVParallel * displacementY + otherVPerp * perpY; // now make sure the balls aren't touching otherBall.ballx = ballx + displacementX * ballw; otherBall.bally = bally + displacementY * ballh; checkVelocity(); otherBall.checkVelocity(); return(true); } else { return(false); } }
//* -----------------------------------------------------------------------* /// <summary>難易度9状態の移動判定を実行します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動と判断した場合、<c>true</c>。</returns> private bool movePatternLevel9(CBall entity) { return(entity.counter > 30 || (entity.counter & 1) == 0); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary>玉に対し移動すべきかを指示します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動すべき場合、<c>true</c>。</returns> protected override bool getMoveOrder(CBall entity) { return(movePatterns[CCursor.instance.level](entity)); }
public void DestroyBall(CBall ball) { ball.DestroySelf(); }
public void RequestDeleteBall(CBall ball) { this._gameInterface.RemovePrevBall(ball); }
//* -----------------------------------------------------------------------* /// <summary>低~中難易度状態の移動判定を実行します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動と判断した場合、<c>true</c>。</returns> private bool movePatternLowLevel(CBall entity) { return(entity.counter % (int)MathHelper.Lerp( 40, 6, CInterpolate.amountOutQuadClamp(CCursor.instance.level, 5)) == 0); }
protected void CreateNewBall() { this.currentBall = CSimulationManager.instance.GetNewBall(); this.ballHasLanded = false; this.golfCameraManager.SetTarget(this.currentBall.gameObject); }
//* -----------------------------------------------------------------------* /// <summary>玉に対し移動すべきかを指示します。</summary> /// /// <param name="entity">この状態を適用されているオブジェクト。</param> /// <returns>移動すべき場合、<c>true</c>。</returns> protected override bool getMoveOrder(CBall entity) { return(inputData[(int)EInputActionMap.enter].push); }
/// <summary> /// ゲーム初期化 /// </summary> private void NewGame() { // ゲーム状態設定 state = 1; speed = 4; // スコア初期化 score = 0; // 表示管理 timecount = 0; timeClear = timecount; // ボール初期化 Ball = new CBall { X = 298, Y = 400, SpeedX = speed, SpeedY = -speed }; // パドル初期化 Paddle = new CPaddle { X = 274, Y = 416, SpeedX = 0 }; // ブロック初期化 Block = new CBlock[50]; int x = 0; int y = 128; for (int idx = 0; idx < 50; idx++) { Block[idx] = new CBlock { X = 12 + x, Y = 32 + y }; x += 60; if (x > pictureBox1.Width - 60) { x = 0; y -= 32; } } // PictureBoxと同サイズのBitmapオブジェクトを作成 Bitmap bmp = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height); //全体を黒で塗りつぶす Graphics objGrp = Graphics.FromImage(bmp); objGrp.FillRectangle(Brushes.Black, objGrp.VisibleClipBounds); // ブロックを描く foreach (var item in Block) { objGrp.FillRectangle(Brushes.LightGreen, item.X, item.Y, item.Width, item.Height); } // ビットマップをピクチャボックスに設定する pictureBox1.Image = bmp; // リソースを解放する objGrp.Dispose(); return; }