//Top durumlarını belirleme private void StatusOfBall() { //Bütün topların hızlarını hesaba katmamız gerekiyor sarı ile kırmızı hareket ederken beyaz top dururken beyaz top ile vurmamamız için //Hareket Hızı 0.1 den düşük bir değer ise ve daha önce top hareket etmiyorsa (Hareketsiz-Hareketli-Sonuç döngüsüne uygun olması için) if (rigid.velocity.magnitude < minSpeed && yellowBall.getYellowStopped && redBall.getRedStopped) { if (ballStatus != BallStatus.Roll && ballStatus != BallStatus.Result) { ballStatus = BallStatus.Idle; return; } } //Hareket Hızı 0.1 den büyük bir değer ise top dönüyordur ve hareketsizden geldiğinden emin olmak şartı ile //Oyun başlangıcında topta yerçekiminden dolayı küçük bir hareketlenme olduğundan Time.time kullanıldı. if (rigid.velocity.magnitude > minSpeed || !yellowBall.getYellowStopped || !redBall.getRedStopped) { if (ballStatus == BallStatus.Idle) { ballStatus = BallStatus.Roll; return; } } //Top hareket ettikten sonraki sonuca ulaşmak için Hareket Hızı tekrar 0.1 den aşağı düşüyor ise if (rigid.velocity.magnitude < minSpeed && yellowBall.getYellowStopped && redBall.getRedStopped) { if (ballStatus == BallStatus.Roll) { ballStatus = BallStatus.Result; } } }
// target と同タイプなら消す。子も探索して消す public bool DestroyBalls(Ball target) { if (status != BallStatus.STOP) { return(false); } if (searched) { return(false); } if (ballType != target.ballType) { return(false); } searched = true; status = BallStatus.DESTROY; foreach (Ball ball in links) { ball.DestroyBalls(target); } return(true); }
public void ClearStatus() { status = BallStatus.NONE; matQueue = new List <Material>(); matQueue.Add(origMat); CheckStatus(); }
public string ToString(BallStatus bs) { return(Col + ";" + Row + ";" + Top.ToString() + ";" + Right.ToString() + ";" + Buttom.ToString() + ";" + Left.ToString() + ";" + bs.ToString() + ";relocate"); }
// Use this for initialization void Start() { speed = 6f; radius = 0.5f; margin = 0.1f; manager = GameObject.Find("Manager").GetComponent <Manager> (); arrowTrans = GameObject.Find("Arrow/ArrowPoint").GetComponent <Transform> (); rigid = GetComponent <Rigidbody2D> (); links = new List <Ball> (); if (transform.position == Vector3.zero) { status = BallStatus.READY; // 一番最初のボール } else { status = BallStatus.INIT; } groupNo = -1; onTop = false; searched = false; }
private void UpdateBallStatus() { if (!m_PhysicBody.CurrentlyStaticOnAPlane()) { if (m_CurrentBallStatus != BallStatus.Rolling) { m_CurrentBallStatus = BallStatus.Rolling; m_CurrentlyAiming = false; m_AimTool.SetActive(false); m_StrokeForce = 0.0f; m_ReleasedAimButton = false; } return; } if (m_CurrentlyAiming == true) { m_CurrentBallStatus = BallStatus.AimingStroke; return; } if (m_CurrentBallStatus == BallStatus.Rolling) { m_LastBallPosition = transform.position; } m_CurrentBallStatus = BallStatus.WaitingForStroke; }
//ボールの情報更新 public void BallUpdate() { switch (ballstatus) { case BallStatus.waiting: if (Input.GetButtonDown("Throw")) { ballstatus = BallStatus.throwed; ballObj.GetComponent <BallManager>().ThrowInit(new Vector2(Random.Range(-throwSize.x / 2, throwSize.x / 2), Random.Range(-throwSize.y / 2, throwSize.y / 2))); } break; case BallStatus.throwed: ballObj.GetComponent <BallManager>().Throwing(); break; case BallStatus.avoided: //特に何もしない break; case BallStatus.flying: ballObj.GetComponent <BallManager>().Fly(); break; default: Debug.Log("You are an idiot!"); break; } }
// Use this for initialization void Start() { finalCube = GameObject.FindGameObjectWithTag("finalCube"); playerStatus = player.GetComponent <BallStatus>(); playerMovement = player.GetComponent <BallMovement>(); InitializeEffects(); playerStatus.SetRespawnPosition(checkPoints[0].position); finalCube.SetActive(false); score = 0; scoreText.text = "Score: " + score.ToString(); winText.text = " "; HideCheckPoints(); GameObject[] cubi = GameObject.FindGameObjectsWithTag("cube"); // GameObject[] finalcube = GameObject.FindGameObjectsWithTag("finalCube"); nStdCubes = cubi.Length; //ncubes = cubi.Length + finalcube.Length; ncubesInPlay = nStdCubes; AssignEffects(cubi); }
// 落下指示 public bool Fall(int gNo) { if (status != BallStatus.STOP) { return(false); } Debug.Assert(gNo != -1, "invalid group no"); if (gNo != groupNo) { return(false); } status = BallStatus.FALLING; rigid.gravityScale = 1f; rigid.constraints = RigidbodyConstraints2D.None; gameObject.layer = 9; // FallingBall foreach (Ball ball in links) { ball.UnLink(this); } return(true); }
protected void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Ball") { BallStatus status = col.gameObject.GetComponent <Ball>().Status; status = new BallStatus(0.0f, 0.0f, 0.0f); for (int i = 0; i < 2; i++) { status.fAtk += gCharacter[i].GetComponent <Character>().Atk; status.fBonusDamage += gCharacter[i].GetComponent <Character>().BonusDamage; status.fCriticalRate += gCharacter[i].GetComponent <Character>().CriticalRate; } status.fCriticalRate /= 2; col.gameObject.GetComponent <Ball>().Status = status; Debug.Log("Atk : " + status.fAtk.ToString()); Debug.Log("BonusDamage : " + status.fBonusDamage.ToString()); Debug.Log("CriticalRate : " + status.fCriticalRate.ToString()); col.gameObject.GetComponent <Ball>().BuffCheck(); Debug.Log("Buff Atk : " + status.fAtk.ToString()); Debug.Log("Buff BonusDamage : " + status.fBonusDamage.ToString()); Debug.Log("Buff CriticalRate : " + status.fCriticalRate.ToString()); } }
public void BallRelease() { if (m_status == BallStatus.BallAttached) { m_status = BallStatus.BallReleased; Invoke("BallStart", 0.2f); } }
public override void BuffEffect() { BallStatus status = gBall.GetComponent <Ball>().Status; status.fCriticalRate = 100.0f; gBall.GetComponent <Ball>().Status = status; }
public void RemoveStatus(BallStatus newStatus, Material toRemove) { FlagsHelper.Unset <BallStatus>(ref status, newStatus); if (toRemove != null && matQueue.Remove(toRemove)) { CheckStatus(); } }
public override void BuffEffect() { BallStatus status = gBall.GetComponent <Ball>().Status; status.fAtk += status.fAtk * 15.0f / 100.0f; gBall.GetComponent <Ball>().Status = status; }
public void RemoveStatus(BallStatus newStatus, Material toRemove) { FlagsHelper.Unset <BallStatus>(ref status, newStatus); if (toRemove != null && matQueue.Remove(toRemove)) { CheckStatus(); } AttachedBall.RemoveStatusAllAttachedBalls(transform, newStatus, toRemove); }
// 発射待ち開始 public void Wait() { if (status != BallStatus.INIT) { return; } status = BallStatus.WAIT; GetComponent <Animator>().SetBool("FadeOut", true); }
public void AddStatus(BallStatus newStatus, Material newMat) { if (newMat != null) { GetComponent <Renderer>().sharedMaterial = newMat; matQueue.Add(newMat); } FlagsHelper.Set <BallStatus>(ref status, newStatus); CheckStatus(); }
public void Reset() { X = 0; Y = 0; dX = 0; dY = 0; Speed = 8; Bounces = 0; Status = BallStatus.Ready; }
// 発射準備完了 public void Ready() { if (status == BallStatus.WAIT) { transform.localScale = new Vector3(1, 1, 1); transform.position = arrowTrans.position; status = BallStatus.READY; manager.NextBallReady(); } }
void OnEnable() { //make sure it's not bringing any friends //Util.DestroyChildrenWithComponent<AttachedBall>(transform); status = BallStatus.NONE; origScale = transform.localScale; origMat = GetComponent <SpriteRenderer>().sharedMaterial; matQueue = new List <Material>(); matQueue.Add(origMat); }
void Awake() { GameObject gc_obj = GameObject.FindWithTag("LevelEntities"); m_levelEntities = gc_obj.GetComponent <LevelEntities>(); m_gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>(); m_directionChanged = false; m_contacts = new ContactPoint2D[5]; m_direction = new Vector2(); m_status = BallStatus.BallAttached; }
public static void AddStatusAllAttachedBalls(Transform t, BallStatus newStatus, Material mat) { AttachedBall ab; if (ab = t.GetComponent <AttachedBall>()) { ab.AddStatus(newStatus, mat); } foreach (Transform child in t) { AddStatusAllAttachedBalls(child, newStatus, mat); } }
public static void RemoveStatusAllAttachedBalls(Transform t, BallStatus status, Material material) { AttachedBall ab; if (ab = t.GetComponent <AttachedBall>()) { ab.RemoveStatus(status, material); } foreach (Transform child in t) { RemoveStatusAllAttachedBalls(child, status, material); } }
// 発射 public void Fire(float angle) { if (status != BallStatus.READY) { return; } Quaternion rotation = Quaternion.Euler(new Vector3(0, 0, angle)); Vector3 vec = new Vector2(0, speed); rigid.velocity = rotation * vec; GetComponent <CircleCollider2D> ().enabled = true; status = BallStatus.RIGING; }
// Update is called once per frame void Update() { if (!manager.Play) { rigid.velocity = Vector2.zero; status = BallStatus.END; return; } if (status == BallStatus.READY) { transform.position = arrowTrans.position; } }
public void Simulate(int millis, Size size) { float rightSide = size.Width; float leftSide = 0; if (_status == BallStatus.Regular) { _centerY = _centerY + Utility.GetMillisFractionOf(millis, _speedY); _centerX = _centerX + Utility.GetMillisFractionOf(millis, _speedX); if (_centerX - _radius <= leftSide) { _speedX = Math.Abs(_speedX); } if (_centerY - _radius <= leftSide) { _speedY = Math.Abs(_speedY); } if (_centerX + _radius >= rightSide) { _speedX = Math.Abs(_speedX) * -1; } if (_centerY + _radius >= rightSide) { _speedY = Math.Abs(_speedY) * -1; } } if (_status == BallStatus.Exploding) { _radius = _radius + Utility.GetMillisFractionOf(millis, GameConstants.ExplodeSpeed); if (_radius >= _blastRadius) { _status = BallStatus.Imploding; } } if (_status == BallStatus.Imploding) { _radius = _radius + Utility.GetMillisFractionOf(millis, GameConstants.ImplodeSpeed); if (_radius < GameConstants.MinRadius) { _status = BallStatus.Dead; } } }
void BallStatusChange(BallStatusEventParam param) { Debug.logger.Log("BallStatusChange " + param.status); if (param.ballName != gameObject.name) { return; } m_ballStatus = param.status; switch (param.status) { case BallStatus.DrawingLineFinished: { distance = Vector3.Distance(m_spawnPos, m_lineContainer.transform.position); m_lineContainer.GetComponent <LineContainer>().Stop(); } break; case BallStatus.Abort: { m_bDraged = false; m_moveDirection = Vector3.zero; if (m_lineContainer != null) { Destroy(m_lineContainer); m_lineContainer = null; if (m_fixedPoint != null) { Destroy(m_fixedPoint); m_fixedPoint = null; } if (m_distanceJoint2D != null) { Destroy(m_distanceJoint2D); m_distanceJoint2D = null; } } } break; } }
public static void AddStatusAllAttachedBallsTemp(Transform t, BallStatus newStatus, Material mat, float duration) { AttachedBall ab; if (ab = t.GetComponent <AttachedBall>()) { //we make copies so the delegate we create keeps its own state //Material oldMat = t.GetComponent<SpriteRenderer>().sharedMaterial; //Transform trans = t; ab.AddStatus(newStatus, mat); ab.StartCoroutine(Timers.Countdown(duration, () => { ab.RemoveStatus(newStatus, mat); })); } foreach (Transform child in t) { AddStatusAllAttachedBallsTemp(child, newStatus, mat, duration); } }
public void Update(Field field, Player player, Robot robot) { if (Status == BallStatus.Launch) { float angle = random.Next(30, 150); dX = (int)(Speed * Math.Cos(angle * Math.PI / 180.0f)); dY = (int)(Speed * Math.Sin(angle * Math.PI / 180.0f)); Status = BallStatus.Launched; } // Check for collision if (WallCollision()) { BounceOffWall(); } else if (PaddleCollision(robot)) { BounceOffPaddle(robot); } else if (PaddleCollision(player)) { BounceOffPaddle(player); } else { BrickCollision collision = field.Collision(this); BounceOffBrick(collision); } // Increase ball speed based on bounces if (Bounces == 5) { Speed++; Bounces = 0; } // Update ball position X += dX; Y += dY; }
// Update is called once per frame void Update() { //投げる準備~収集までの流れ switch (gameStatus) { case GameStatus.ready: ballstatus = BallStatus.waiting; mainCamera.transform.position = new Vector3(0, 10, -10); canvasObj.GetComponent <UIManager>().WaitInit(); gameStatus = GameStatus.fighting; break; case GameStatus.fighting: GameUpdate(); BallUpdate(); CameraUpdate(); break; default: Debug.Log("You are an idiot!"); break; } //デバッグモードの操作 if (Input.GetButtonDown("DebugButton")) { IsDebugging = !IsDebugging; Debug.Log("debug change!"); if (IsDebugging) { Debug.Log("debug now!"); } } }