public Vector2 GridToPosition(int col, int row) { CellManager.CellID cellId = new CellManager.CellID(); cellId.x = col; cellId.y = row; return(CellManager.GetCellPosition(cellId)); }
public override void Update(float fDeltaTime) { base.Update(fDeltaTime); if (m_isOver) { return; } Vector2 lpos = m_ball.transform.localPosition; lpos += m_dir * m_cmd.Speed * fDeltaTime; if (CheckPoint(m_ball.transform.localPosition, lpos)) { if (m_cmd.Result == 0 || m_cmd.Result == 2) { GameObject.Destroy(m_ball); } else { m_ball.transform.localPosition = CellManager.GetCellPosition(m_cmd.DestGrid); m_balls.AddBall(m_cmd.BallId, m_ball, (ELevelBallType)m_cmd.Type); m_ball.GetComponent <Collider2D>().enabled = true; AudioMgr.PlayAudio(205); } m_ball = null; m_isOver = true; } else { m_ball.transform.localPosition = lpos; Vector2 pos = m_ball.transform.position; if ((pos.x + GlobalData.m_ballRadius >= GlobalData.m_windowWidth / 2 || pos.x - GlobalData.m_ballRadius <= -GlobalData.m_windowWidth / 2)) { if (m_hasBouncedBack && (m_cmd.Result == 0 || m_cmd.Result == 2)) { GameObject.Destroy(m_ball); m_ball = null; m_isOver = true; return; } m_dir.x = -m_dir.x; m_hasBouncedBack = true; AudioMgr.PlayAudio(202); } } }