/* * Constructor * */ public BallManager(Core c, Game g, BallGenerator gen) { core = c; game = g; generator = new Random(); ballGenerator = gen; }
//------------------------------------------------------- // Private Function //------------------------------------------------------- // プレイヤーの入力を検知し、ピースを選択状態にする private void Idle() { if (Input.GetMouseButtonDown(0)) { selectedPiece = ballController.GetNearestPiece(Input.mousePosition); currentState = GameState.PieceMove; } }
private void SelectPiece() { selectedPiece = board.GetNearestPiece(Input.mousePosition); var piece = board.InstantiatePiece(Input.mousePosition); piece.SetKind(selectedPiece.GetKind()); piece.SetSize((int)(board.pieceWidth * 1.2f)); piece.SetPieceAlpha(SelectedPieceAlpha); selectedPieceObject = piece.gameObject; selectedPiece.SetPieceAlpha(SelectedPieceAlpha); currentState = GameState.PieceMove; }
private bool IsMatchPiece(BallGenerator piece) { // ピースの情報を取得 var pos = GetPieceBoardPos(piece); var kind = piece.GetKind(); // 縦方向にマッチするかの判定 MEMO: 自分自身をカウントするため +1 する var verticalMatchCount = GetSameKindPieceNum(kind, pos, Vector2.up) + GetSameKindPieceNum(kind, pos, Vector2.down) + 1; // 横方向にマッチするかの判定 MEMO: 自分自身をカウントするため +1 する var horizontalMatchCount = GetSameKindPieceNum(kind, pos, Vector2.right) + GetSameKindPieceNum(kind, pos, Vector2.left) + 1; return(verticalMatchCount >= GameManager.MachingCount || horizontalMatchCount >= GameManager.MachingCount); }
// ピースが盤面上のどの位置にあるのかを返す private Vector2 GetPieceBoardPos(BallGenerator piece) { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (board[i, j] == piece) { return(new Vector2(i, j)); } } } return(Vector2.zero); }
public void SwitchPiece(BallGenerator p1, BallGenerator p2) { // 位置を移動する var p1Position = p1.transform.position; p1.transform.position = p2.transform.position; p2.transform.position = p1Position; // 盤面データを更新する var p1BoardPos = GetPieceBoardPos(p1); var p2BoardPos = GetPieceBoardPos(p2); board[(int)p1BoardPos.x, (int)p1BoardPos.y] = p2; board[(int)p2BoardPos.x, (int)p2BoardPos.y] = p1; }
public GameSceneState CreateState() { var ballInitState = ballRender.GetRender().CreateState(new Vector2(ballInstantiatePos.x, canvasRect.sizeDelta.y)); var barInitState = barRender.Target.CreateState(); return(new GameSceneState { ballInitState = ballInitState, ballState = new [] { ballInitState }.ToList(), ballGenerator = BallGenerator.RandomPos(100, 200), barState = barInitState, barInitState = barInitState, canvasSize = canvasRect.sizeDelta, uiState = uiRender.Target.CreateState(), }); }
// initialization void Start() { //AddComponents arduino = gameObject.AddComponent <Arduino_Access>() as Arduino_Access; // Get Components provider = FindObjectOfType <LeapProvider>() as LeapProvider; initialPosition = gameObject.transform.position; currTransform = GetComponent <Transform>(); GameObject ballGeneratorObject = GameObject.Find("LightBall Generator"); ballGenerator = ballGeneratorObject.GetComponent <BallGenerator>(); }
/*==============================================================================*/ /* 初期化処理 */ /*==============================================================================*/ void Start() { generateStructInstance(); initRequest(); initBingoMasuInfo(); for (int masu = 0; masu < BINGO_MASU_MAX; masu++) { updateBingoMasuObjectDisplayState(masu); //DisplayStateの初期化をGameObjectのsetActiveにも反映させる } initBingoTable(); initNotifyStock(); PayoutManagerInstance = GameObject.Find("Main Camera").GetComponent <PayoutManager>(); CreditManagerInstance = GameObject.Find("Main Camera").GetComponent <CreditManager>(); BallGeneratorInstance = GameObject.Find("BallEntrance").GetComponent <BallGenerator>(); }
// Use this for initialization void Awake() { playerOneScore = 0; playerTwoScore = 0; gameTimer = 60; brickGenerator = gameObject.GetComponent <BrickGenerator>(); ballGenerator = gameObject.GetComponent <BallGenerator>(); brickGenerator.Generate(); ballGenerator = gameObject.GetComponent <BallGenerator>(); player1 = Instantiate(player1, new Vector3(-4.33f, 7.57f), Quaternion.identity); player1Script = player1.GetComponent <Player>(); player2 = Instantiate(player2, new Vector3(25.62f, 7.57f), Quaternion.identity); player2Script = player2.GetComponent <Player>(); ballGenerator.Startup(); gameState = GameState.Unpaused; }
public BallGenerator GetNearestPiece(Vector3 input) { var minDist = float.MaxValue; BallGenerator nearestPiece = null; // 入力値と盤面のピース位置との距離を計算し、一番距離が短いピースを探す foreach (var p in board) { var dist = Vector3.Distance(input, p.transform.position); if (dist < minDist) { minDist = dist; nearestPiece = p; } } return(nearestPiece); }
void Start() { worldBounds = transform.Find("WorldBounds").GetChild(0).GetComponent <EdgeCreator>(); enemyManager = transform.Find("EnemyManager").GetComponent <EnemyGenerator>(); ballManager = transform.Find("BallManager").GetComponent <BallGenerator>(); lvlDisplay = transform.Find("GameStatsBar").Find("LevelDisplay").GetComponent <LevelDisplayController>(); lifeDisplay = transform.Find("GameStatsBar").Find("LifeDisplay").GetComponent <LifeDisplay>(); gameOver = transform.Find("GameOver").gameObject; obstacleManager = transform.Find("ObstacleManager").GetComponent <ObstacleGenerator>(); background = transform.Find("Background").GetComponent <BackgroundBehavior>(); /*feedback = transform.Find("FilledFeedback").GetComponent<FillerFeedbackScript>();*/ progressPie = transform.Find("GameStatsBar").Find("ProgressPie").GetComponent <ProgressPie>(); // kickstart the first level enemyManager.numEnemies = currLevel; LevelBegin(); }
public Engine() { graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); core = new Core(); ballGenerator = new BallGenerator(core, this); ball = new BallManager(core, this, ballGenerator); background = new Image(); frame = new Image(); music = new GameAudio(); cameraPos = new Vector3(400f, 300f, 0f); gameOver = new Image(); this.graphics.PreferredBackBufferWidth = 1280; this.graphics.PreferredBackBufferHeight = 720; //this.graphics.IsFullScreen; // sets what texture each methid should load //and how many effects it needs to draw (this, num of effects, which text valuse to load) explosion = new ColouredParticle(this, 3, 5); Components.Add(explosion); smoke = new ColouredParticle(this, 3, 6); Components.Add(smoke); redblast = new ColouredParticle(this, 3, 1); Components.Add(redblast); greenblast = new ColouredParticle(this, 3, 4); Components.Add(greenblast); purpleblast = new ColouredParticle(this, 3, 3); Components.Add(purpleblast); blueblast = new ColouredParticle(this, 3, 2); Components.Add(blueblast); Rnote = new ColouredParticle(this, 3, 7); Components.Add(Rnote); Bnote = new ColouredParticle(this, 3, 8); Components.Add(Bnote); Gnote = new ColouredParticle(this, 3, 9); Components.Add(Gnote); Pnote = new ColouredParticle(this, 3, 10); Components.Add(Pnote); //this.graphics.IsFullScreen = true; }
private void Start() { ballCount = 1024 * groupCount; // Calculate the buffer size. bufferSize = groupCount * threadCount; particles = new Particle[bufferSize]; // Create compute buffer. buffer = new ComputeBuffer(bufferSize, sizeof(float) * particleStructSize); // Obtain the handle to the kernel to run. kernelHandle = shader.FindKernel("CSMain"); // Generate the specified number of balls game objects. IObjectGenerator bg = new BallGenerator(); balls = bg.Generate(gameObject, ballCount); // Generate the particles, using the positions of the ball game objects. Particle[] initialBufferData = new Particle[ballCount]; for (int i = 0; i < ballCount; ++i) { Particle particle = new Particle(); particle.mass = 2; particle.position = balls[i].transform.position; particle.velocity = new Vector3(0, 10, 0); particle.acceleration = new Vector3(0, -10f, 0); particle.damping = 0; initialBufferData[i] = particle; } // Set the data. buffer.SetData(initialBufferData); // Set the buffer on the compute shader. shader.SetBuffer(kernelHandle, "buffer", buffer); }
/// <summary> /// ボールの間隔、x座標に関してランダムにボールを生成します。これは、ゲームが実行中のみ機能します。 /// </summary> static GameSceneState MaybeRandomGenerateBall(GameSceneState state) { if (state.gameState != GameState.Playing) { return(state); } var latestBall = GetLast(state.ballState); var nextPos = state.ballGenerator?.MaybeGenerate(state.canvasSize, latestBall); if (nextPos.HasValue) { state.ballGenerator = BallGenerator.RandomPos(50, 300); var ballXPos = state.barState.movePos.GetPos(RandomEnum <BarPosition> .GetRandom()).x; // ボールを生成する(yの相対位置、x方向はランダム) var ballPos = new Vector2(ballXPos, latestBall.position.y + nextPos.Value); var newBall = state.ballInitState; newBall.movesBall = true; newBall.position = ballPos; state.ballState.Add(newBall); } return(state); }
void Awake() { Singleton = this; }
void Awake() { grid.GetComponent<Grid>(); Instance = this; }
// Use this for initialization void Start() { IObjectGenerator bg = new BallGenerator(); bg.Generate(gameObject, ballCount); }
void OnEnable() { _ballGenerator = new BallGenerator(MinPosition, MaxPosition, BallPrefab, BallContainer); }