// Use this for initialization
 void Start()
 {
     ball       = GameObject.FindObjectOfType <BallMovement>();
     pinSetter  = GameObject.FindObjectOfType <PinSetter>();
     scoreBoard = GameObject.FindObjectOfType <ScoreDisplay>();
     EndgamePanel.SetActive(false);
 }
Exemplo n.º 2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Ball")
        {
            PlayAnimation();

            blockCount--;
            BallMovement movement = collision.gameObject.GetComponent <BallMovement>();
            if (movement)
            {
                if (movement.isPowerUpMode())
                {
                    blockCount = 0;
                }
            }
            UpdateMaterialByBlockCount();
            if (blockCount <= 0)
            {
                Destroy(this.gameObject);
            }

            if (gameManager)
            {
                gameManager.SendMessage("OnDestroyBrick");
            }
        }
    }
Exemplo n.º 3
0
    void Start()
    {
        startPosition = transform.position;
        Movement      = GetComponent <BallMovement>();

        ResetPosition();
    }
Exemplo n.º 4
0
    public void ShowResults()
    {
        BallMovement ball            = FindObjectOfType <BallMovement> ();
        Text         finalResultText = finalResultUI.transform.Find("Results").GetComponentInChildren <Text> ();

        finalResultText.text = string.Format("{0} : {1}", ball.leftScore, ball.rightScore);
    }
Exemplo n.º 5
0
    // 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);
    }
Exemplo n.º 6
0
    public BallMovement SpawnBall(BallMovement ballTemplate)
    {
        BallMovement bm = Instantiate(ballTemplate);

        activeBalls.Add(bm);
        return(bm);
    }
Exemplo n.º 7
0
 public static bool Prefix(BallMovement __instance)
 {
     __instance.outOfBounds          = false;
     __instance.m_isShotReadyToStart = true;
     __instance.m_ballIsNotMoving    = true;
     return(false);
 }
Exemplo n.º 8
0
 void Awake()
 {
     Init();
     swipeControl  = GetComponent <BallControl>();
     ballTransform = ball.transform;
     ballMovement  = ball.GetComponent <BallMovement>();
 }
Exemplo n.º 9
0
    public void PopBall()
    {
        GameManager._instance.NotifyBallPopped(gameObject.tag);

        GameObject LeftBall  = ObjectPoolList._instance.SpawnObject(nextPrefabOnPop.ToString(), transform.position);
        GameObject RightBall = ObjectPoolList._instance.SpawnObject(nextPrefabOnPop.ToString(), transform.position);

        if (LeftBall != null)
        {
            BallMovement LeftBallMove = LeftBall.GetComponent <BallMovement>();
            if (LeftBallMove != null)
            {
                LeftBallMove.SetBallxDirection(-1);
                LeftBallMove.InitialJump();
            }
        }

        if (RightBall != null)
        {
            BallMovement RightBallMove = RightBall.GetComponent <BallMovement>();
            if (RightBallMove != null)
            {
                RightBallMove.SetBallxDirection(1);
                RightBallMove.InitialJump();
            }
        }

        gameObject.SetActive(false);
    }
Exemplo n.º 10
0
 void OnTriggerEnter(Collider col)
 {
     Debug.Log("Triggered");
     if (abandoned)
     {
         if (col.gameObject == orphanObj)
         {
             Destroy(orphanObj);
             Destroy(this.gameObject);
         }
     }
     else
     {
         GameObject GO = col.gameObject;
         if (GO.GetComponent <BallMovement>() != null)
         {
             if (GO.GetComponent <BallMovement>() == parent)
             {
                 return;
             }
         }
         if (GO.GetComponent <Monster>() != null)
         {
             Vector3    relDir = this.transform.position - GO.transform.position;
             Quaternion quat   = Quaternion.FromToRotation(GO.transform.forward, relDir);
             GameObject.Find("character").GetComponent <character> ().hookAttach(GO, quat);
             this.transform.parent = GO.transform;
             velocity = Vector3.zero;
         }
         else
         {
             origin.gameObject.GetComponent <character>().hookAbandon();
         }
     }
 }
Exemplo n.º 11
0
    // Actives the power up on the player given (true = player 1, false = player 2)
    public void ActivatePowerup(bool player)
    {
        Debug.Log("DECOY ACTIVATED");
        // Get the real ball's script to access the force vector
        BallMovement ballMvmt = GameObject.Find("Ball").GetComponent <BallMovement>();

        // Load a ball prefab from the Resources folder
        GameObject decoy = (GameObject)Instantiate(Resources.Load("Prefabs/Ball", typeof(GameObject)), ballMvmt.gameObject.transform.position, Quaternion.identity);

        // Rename it so it cannot affect score/be hit by anything like a real ball can
        decoy.name = "Decoy";

        // Get the decoy's script
        BallMovement decoyMvmt = decoy.GetComponent <BallMovement>();

        // Move the decoy based on the real ball's force vector
        if (player)
        {
            decoyMvmt.TennisForce(new Vector3(ballMvmt.forceVector.x + Random.Range(0, 5), ballMvmt.forceVector.y + Random.Range(-5, 5)));
        }
        else
        {
            decoyMvmt.TennisForce(new Vector3(ballMvmt.forceVector.x + Random.Range(-5, 0), ballMvmt.forceVector.y + Random.Range(-5, 5)));
        }
    }
Exemplo n.º 12
0
 private void Start()
 {
     _line        = GetComponent <LineRenderer>();
     ballMovement = GetComponentInChildren <BallMovement>();
     //_line.SetVertexCount(3);
     _line.positionCount = 2;
 }
Exemplo n.º 13
0
    void OnCollisionEnter2D(Collision2D collect)
    {
        // PowerUp 2: Decrease ball speed
        if (collect.gameObject.name == "Player")
        {
            // Delay power up collection
            StartCoroutine("wait");

            // Play sound when power up is collected
            audio2Source      = GetComponent <AudioSource> ();
            audio2Source.clip = powerUp2Clip;
            audio2Source.PlayOneShot(audio2Source.clip);

            // Need to link the change with the object
            GameObject Ball = GameObject.Find("Ball");
            // Define a reference to access the other script.
            BallMovement ballMovement = Ball.GetComponent <BallMovement> ();
            // Increase the speed of the ball
            ballMovement.speedBall = ballMovement.speedBall - 2;
            // Make power up disappear
            gameObject.SetActive(false);
        }
        if (collect.gameObject.name == "WallBottom")
        {
            // Make power up disappear
            gameObject.SetActive(false);
        }
    }
Exemplo n.º 14
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ballMovement = other.GetComponent <BallMovement>();

        if (ballMovement != null && canScore)
        {
            if (team == 1)
            {
                GameManager.instance.AddScore(1);
            }
            else
            {
                GameManager.instance.AddScore(0);
            }

            canScore = false;

            other.gameObject.GetComponent <SpriteRenderer>().enabled            = false;
            other.transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;
            other.gameObject.GetComponent <TrailRenderer>().enabled             = false;
            other.transform.position = spawnPoint;
            ballMovement.ResetSpeed();

            StartCoroutine(SpawnDelay(other.transform));
            return;
        }

        GetTarget(other);

        if (target != null)
        {
            Debug.Log("Gottem");
            target.Hit(100, DamageType.physical, Vector2.zero, 0.25f);
        }
    }
Exemplo n.º 15
0
    public void Score(Identifier scorer)
    {
        BallMovement initialMovement = new BallMovement();

        switch (scorer)
        {
        case Identifier.Player:
            scorePlayer++;
            textScorePlayer.text = scorePlayer.ToString();
            initialMovement.dirX = -1;
            break;

        case Identifier.Computer:
            scoreComputer++;
            textScoreComputer.text = scoreComputer.ToString();
            initialMovement.dirX   = 1;
            break;
        }

        GameObject     ballObject     = Instantiate(ball).gameObject;
        BallController ballController = ballObject.GetComponent <BallController>();

        ballController.currentMovement = initialMovement;
        Debug.Log("Score");
    }
Exemplo n.º 16
0
    public IEnumerator SetUpGameState(LevelSpawner lSpawner, int levelTime, string levelName, BallMovement playerB)
    {
        playerBall            = playerB;
        gamePaused            = true;
        playerBall.gamePaused = true;
        pauseButton.Pause();
        playerStarted    = false;
        timeText.color   = new Color(0.749f, 0.749f, 0.749f);
        levelSpawner     = lSpawner;
        currentLevelTime = levelTime;
        currentLevel     = levelName;
        timeText.text    = levelTime.ToString("0000");
        livesText.text   = currentLives.ToString("00");
        //Play Teleport In Animation + Sound
        playerAnim = playerBall.GetComponent <Animator>();
        audioSource.PlayOneShot(teleportIn);
        playerAnim.Play("teleportIn");

        yield return(new WaitForSeconds(teleportIn.length));

        playerStarted         = true;
        gamePaused            = false;
        playerBall.gamePaused = false;

        pauseButton.UnPause();
    }
Exemplo n.º 17
0
    public void SpawnGameGridTiles(Level levelToSpawn)
    {
        int xPos = -1;
        int yPos = 0;

        for (int i = 0; i < levelToSpawn.gameGridTileIds.Count; i++)
        {
            if (i % 10 == 0)
            {
                xPos++;
                yPos = 0;
            }
            yPos++;
            if (levelToSpawn.gameGridTileIds[i] != 0)
            {
                Tile tile = Instantiate(gameGridTilePrefabs[levelToSpawn.gameGridTileIds[i]], new Vector3(xPos, 1, yPos - 1), Quaternion.identity).GetComponent <Tile>();
                gameGrid.AddTileToGrid(tile, i);
            }
            else
            {
                gameGrid.AddTileToGrid(null, i);
            }
            if (i == levelToSpawn.playerPos)
            {
                playerBall = Instantiate(player, new Vector3(xPos, 1, yPos - 1), Quaternion.Euler(-25f, 45, 0)).GetComponent <BallMovement>();
                playerBall.SetGameGrid(gameGrid);
                gameGrid.AddPlayer(playerBall.transform, i);
            }
        }
    }
Exemplo n.º 18
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Ball")
        {
            BallMovement ballMovement = collision.gameObject.GetComponent <BallMovement>();
            bounce = ballMovement.direction;

            // If collision hit the top of the boxcollider
//			if (collision.contacts[0].normal == gameObject.transform.up)
//				Debug.Log("Hit the bottom of the boxcollider");
//			else if (collision.contacts[0].normal == -gameObject.transform.up)
//				Debug.Log("Hit the top of the boxcollider");
//			else if (collision.contacts[0].normal == gameObject.transform.right)
//				Debug.Log("Hit the left side of the boxcollider");
//			else if (collision.contacts[0].normal == -gameObject.transform.right)
//				Debug.Log("Hit the right side of the boxcollider");

            if (collision.contacts[0].normal == gameObject.transform.up || collision.contacts[0].normal == -gameObject.transform.up)
            {
                Debug.Log("Hit top or bottom");
                bounce.y = -bounce.y;
            }
            else if (collision.contacts[0].normal == gameObject.transform.right || collision.contacts[0].normal == -gameObject.transform.right)
            {
                Debug.Log("Hit right or left side");
                bounce.x = -bounce.x;
            }
            ballMovement.direction = bounce;
            Destroy(gameObject);
        }
    }
 private void Start()
 {
     if (null == m_BallMovement)
     {
         m_BallMovement = GetComponentInChildren <BallMovement>();
     }
 }
Exemplo n.º 20
0
    void Start()
    {
        if (spawnWithBall)
            ball = ((GameObject)Instantiate(ballObject, attachmentPoint.position, attachmentPoint.rotation)).GetComponent<BallMovement>();
        hasBall = spawnWithBall;

        fireCharges = maxFireCharges;
    }
Exemplo n.º 21
0
 void Start()
 {
     ballMovement   = FindObjectOfType <BallMovement>();
     paddleMovement = FindObjectOfType <PaddleMovement>();
     gm             = GameManager.GetInstance();
     GameManager.changeStateDelegate += Spawn;
     Spawn();
 }
Exemplo n.º 22
0
 // Get the difference in position between the ball and the camera at the start
 void Start()
 {
     ball     = GameObject.FindObjectOfType <BallMovement>();
     offset_x = ball.transform.position.x - transform.position.x;
     offset_y = ball.transform.position.y - transform.position.y;
     offset_z = ball.transform.position.z - transform.position.z;
     offset   = new Vector3(offset_x, offset_y, offset_z);
 }
Exemplo n.º 23
0
 void Find()
 {
     ball        = GameObject.Find("Ball").GetComponent <BallMovement>();
     scorePanel1 = GameObject.Find("Panel 1").transform;
     scorePanel2 = GameObject.Find("Panel 2").transform;
     scoreText1  = scorePanel1.GetChild(0).GetComponent <Text>();
     scoreText2  = scorePanel2.GetChild(0).GetComponent <Text>();
 }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     b         = ball.GetComponent <BallMovement>();
     ps        = this.GetComponent <PowerupSpawn>();
     t         = 0;
     powerUpOn = false;
     player    = 1;
 }
Exemplo n.º 25
0
 private void Start()
 {
     desiredPosition = transform.position;
     spriteRenderer  = GetComponent <SpriteRenderer>();
     spriteWidth     = spriteRenderer.size.x;
     gameStatus      = FindObjectOfType <GameStatus>();
     ballMovement    = FindObjectOfType <BallMovement>();
 }
Exemplo n.º 26
0
 public void SendBall(Vector3 targetPosition)
 {
     if (socketReady)
     {
         BallMovement sendBall = new BallMovement(targetPosition);
         Send(JsonUtility.ToJson(sendBall));
     }
 }
Exemplo n.º 27
0
 public Ball(GameObject ballGameObject, BallType ballType)
 {
     GameObject       = ballGameObject;
     Type             = ballType;
     RigidBody2D      = ballGameObject.GetComponent <Rigidbody2D>();
     CircleCollider2D = ballGameObject.GetComponent <CircleCollider2D>();
     BallMovement     = ballGameObject.GetComponent <BallMovement>();
 }
Exemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        ballMov          = FindObjectOfType <BallMovement>();
        playerController = GetComponent <PlayerController>();
        eventHandler     = FindObjectOfType <EventHandler>();

        player1 = GameObject.FindGameObjectWithTag("Player1");
        player2 = GameObject.FindGameObjectWithTag("Player2");
    }
Exemplo n.º 29
0
    //////////////////////////////////////////////////////

    public void PlayGame()
    {
        IsPaused = false;
        WinCanvas.SetActive(false);
        LoseCanvas.SetActive(false);
        _ball         = BallManager.Instance.SpawnBall(Ball);
        _ballMovement = _ball.GetComponent <BallMovement>();
        _ballMovement.SetDefaultBallMovement();
    }
Exemplo n.º 30
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        BallMovement ball = collision.GetComponent <BallMovement>();

        if (ball)
        {
            game.Scores(scoreSide);
        }
    }
Exemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        GameObject ball = GameObject.Find("Ball");

        ballMovementScript     = ball.GetComponent <BallMovement> ();
        ballTransform          = ball.transform;
        relativePositionToBall = transform.position - ballTransform.position;
        initialPositionX       = transform.position.x;
    }
Exemplo n.º 32
0
	// Use this for initialization
	void Start () {
		ballMvnt = GameObject.Find("Ball").GetComponent<BallMovement>();
		
		// Get all of the the child go's audio sources
		AudioSource[] children_asrcs = GetComponentsInChildren<AudioSource>();
		// Assign them
		layer0src = children_asrcs[0];
		layer1src = children_asrcs[1];
		layer2src = children_asrcs[2];
		layer3src = children_asrcs[3];
		// Play the first layer at 80 bpm
		layer0src.PlayOneShot(layer0_80bpm, 1.0f);
	}
Exemplo n.º 33
0
    public void AttachEnter(GameObject ballObj)
    {
        if (!hasBall)
        {
            ball = ballObj.GetComponent<BallMovement>();
            hasBall = true;
        }

        rigidbody.AddForce(ball.rigidbody.velocity / catchForceDampening, ForceMode.VelocityChange);
        ball.SetPosition(attachmentPoint.position);
        ball.Freeze(attachmentPoint);
        fireCharges = maxFireCharges;
        catchSound.Play();
    }
Exemplo n.º 34
0
	// Use this for initialization
	void Start () {
		// Find and assign all relevent vars
		player1 = GameObject.Find ("Player1");
		player2 = GameObject.Find ("Player2");
		racket_p1 = GameObject.Find ("racket_p1");
		racket_p2 = GameObject.Find ("racket_p2");
		ball = GameObject.Find ("Ball").transform;
		ballMovement = ball.GetComponent<BallMovement> ();
		PauseGame ();
		player1_spawn = GameObject.Find ("player1_spawn").transform.position;
		player2_spawn = GameObject.Find ("player2_spawn").transform.position;
		player_1 = player1.GetComponent<Player1> ();
		player_2 = player2.GetComponent<Player2> ();
		
		stinger_source = gameObject.GetComponentInChildren<AudioSource>();
	}