Beispiel #1
0
    void AutoPlay()
    {
        BallScript ball           = GameObject.FindObjectOfType <BallScript>();
        Vector3    movingPosition = new Vector3(ball.transform.position.x, this.transform.position.y, 0.0f);

        this.transform.position = movingPosition;
    }
Beispiel #2
0
 void Start()
 {
     ball = GameObject.FindGameObjectWithTag("Ball").GetComponent <BallScript>();
     GetComponent <Animator>().SetBool("isRunning", true);
     GetComponent <Animator>().SetFloat("runningSpd", 0.8f);
     originalColor = transform.Find("Alpha_Surface").gameObject.GetComponent <SkinnedMeshRenderer>().material.color;
 }
Beispiel #3
0
    void Start()
    {
        Resources.UnloadUnusedAssets();
        playAgainButton.SetActive(false);

        //Loads the user's high score if one exists
        if (File.Exists(Application.persistentDataPath + "/HighScore.dat"))
        {
            Load();
        }

        ball        = GameObject.Find("Ball");
        ballScript  = ball.GetComponent <BallScript>();
        paddles[0]  = GameObject.Find("Paddle1");
        paddles[1]  = GameObject.Find("Paddle2");
        paddles[2]  = GameObject.Find("Paddle3");
        pScripts[0] = paddles[0].GetComponent <PaddleScript>();
        pScripts[1] = paddles[1].GetComponent <PaddleScript>();
        pScripts[2] = paddles[2].GetComponent <PaddleScript>();

        goToOptions    = GameObject.Find("GoToOptions");
        powerupManager = gameObject.GetComponent <PowerHodling>();

        canShoot = true;
        //Displays the high score if one exists
        if (highScore != 0)
        {
            highScoreText.text = "High Score: " + highScore;
        }

        objectSpawnerScript = GetComponent <ObjectSpawning>();
        canSpawnPowers      = false;
    }
Beispiel #4
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "ScoreChecker")
        {
            ballScript = other.gameObject.GetComponentInParent <BallScript>();
            if (ballScript.colorValue == 4)
            {
                dunkedColorValue      = Random.Range(1, 4);
                ballScript.colorValue = dunkedColorValue;
                var renderer = other.gameObject.GetComponentInParent <Renderer>();
                switch (dunkedColorValue)
                {
                case 1:                                                                 //
                    renderer.material.SetColor("_Color", Color.red);                    //
                    break;                                                              //

                case 2:                                                                 //Set colour value equal to the value passed
                    renderer.material.SetColor("_Color", Color.yellow);                 //from the ColorGetter and assign material colour
                    break;                                                              //accordingly to the value

                case 3:                                                                 //
                    renderer.material.SetColor("_Color", Color.blue);                   //
                    break;
                }
            }
        }
    }
Beispiel #5
0
 public override void hendleInput(BallScript ball, KeyCode key)
 {
     if (key == KeyCode.RightArrow || key == KeyCode.LeftArrow || key == KeyCode.UpArrow || key == KeyCode.DownArrow)
     {
         ball.ballState = BallState.movingBall;
     }
 }
Beispiel #6
0
    public override void AcademyReset()
    {
        int resetSeed = (int)this.resetParameters["randomSeed"];

        if (resetSeed != 0)
        {
            Random.seed = resetSeed;
        }
        float ballspeed = this.resetParameters["ballSpeed"];
        int   ballnum   = (int)this.resetParameters["ballNum"];
        float AimRandom = this.resetParameters["ballRandom"];

        foreach (GameObject b in balls)
        {
            DestroyImmediate(b.gameObject);
        }
        balls.Clear();

        for (int i = 0; i < ballnum; i++)
        {
            GameObject b      = Instantiate(Ball, Env.transform);
            BallScript script = b.GetComponent <BallScript>();
            script.SetBall(Agent, ballspeed, AimRandom);
            balls.Add(b);
        }
    }
Beispiel #7
0
    void ThrowBall()
    {
        BallScript ballScript = ball.GetComponent <BallScript>();

        ballScript.ReleaseMe(target.position);
        ball = null;
    }
Beispiel #8
0
    private void Start()
    {
        rb = gameObject.GetComponent <Rigidbody2D>();
        tr = gameObject.GetComponent <Transform>();

        ball = GameObject.Find("BallScript").GetComponent <BallScript>();
    }
Beispiel #9
0
    public override IEnumerator CAbility(int collume, int row, int offset)
    {
        BallScript ball = FieldScript.instance.collums[collume].ReturnBall(row, offset);

        BallManagerScript.PauseGame++;
        ball.activated = true;

        int counter = 0;

        BallManagerScript.PauseGame--;

        while (counter < 5)
        {
            if (FieldScript.instance.collums[collume].ReturnBall(row + 1, offset) != null)
            {
                FieldScript.instance.collums[collume].DeleteBallInstant(row + 1, offset);
                counter++;
            }

            yield return(new WaitForSeconds(5));
        }


        FieldScript.instance.collums[collume].ReturnBall(row + 1, offset).done = true;
        FieldScript.instance.collums[collume].DeleteBallInstant(row, offset);

        yield break;
    }
Beispiel #10
0
 public BallScriptPointer(BallScript ball)
 {
     this.gameobject = ball.gameObject;
     this.ball       = ball;
     this.transform  = ball.gameObject.transform;
     this.joints     = new List <JointRef> ();
 }
Beispiel #11
0
 BallScriptPointer(GameObject gameobject, BallScript ball, Transform transform)
 {
     this.gameobject = gameobject;
     this.ball       = ball;
     this.transform  = transform;
     this.joints     = new List <JointRef> ();
 }
Beispiel #12
0
    //checking if we get hit
    public void OnCollisionEnter(Collision collision)
    {
        player1Hit = true;

        /*
         * if (player1Hit == true && p1_lifeCount >= 0)
         * {
         *  player1Hit = false;
         *  Destroy((p1_healthvalue[p1_lifeCount].gameObject));
         *  p1_lifeCount -= 1;
         *  print(p1_lifeCount);
         * }
         */


        BallScript ball = collision.rigidbody.GetComponent <BallScript>();

        // p1_lifeCount -= 1;
        // Destroy(p1_lifePoint_1);


        //only if the ball is flying around, you could put other exemptions here
        if (ball != null && ball.ballState == BallScript.BallState.NORMAL)
        {
            StopAllCoroutines();                                //stop whatever you're doing
            StartCoroutine(DieCoroutine());                     //start dying
            ball.StartCoroutine(ball.HitPlayerCoroutine(this)); //remove the ball but let it know who it killed
        }
    }
Beispiel #13
0
    void Start()
    {
        ball = FindObjectOfType<BallScript>();
        ball.OnShoot += (shoot, pass) =>
        {
          if (pass)
          {
        speedBoost = 3f;
          }
          else
          {
        speedBoost = 10f;
          }

          decreaseSpeedBoostCooldown = 1.5f;
        };
        ball.BallPicked += (p) =>
        {
          speedBoost = 1f;
        };
        ball.BallReset += () =>
        {
          speedBoost = 1f;
          this.transform.position = new Vector3(ball.transform.position.x, this.transform.position.y, this.transform.position.z);
        };

        diffZ = this.transform.position.z;
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "ScoreChecker")                                       //
     {                                                                      //
         ballScript = other.gameObject.GetComponentInParent <BallScript>(); //
         if (tag == "Ground")                                               //
         {                                                                  //
             if (scoreScript.score >= 1)                                    //
             {                                                              //
                 scoreScript.score--;                                       //
             }                                                              //
         }                                                                  //
         else if (tag == "Container")                                       //
         {                                                                  //
             if (ballScript.colorValue == thisContainer)                    //When a ball/creature/throwable object is thrown into
             {                                                              //a container, check the colour values and assign score
                 scoreScript.score++;                                       //accordingly; it is done so that is never gets to a
                 scoreSound.Play();                                         //negative value
             }                                                              //
             else if (ballScript.colorValue != thisContainer)               //
             {                                                              //
                 if (scoreScript.score >= 1)                                //
                 {                                                          //
                     scoreScript.score--;                                   //
                 }                                                          //
             }                                                              //
         }                                                                  //
     }                                                                      //
 }                                                                          //
Beispiel #15
0
    //Recycle a ball withour a delay
    private IEnumerator RecycleBallWithDelay(BallScript ball)
    {
        RecycleBall(ball);
        yield return(new WaitForSeconds(0.05f));

        invokedBalls++;
    }
Beispiel #16
0
    private float timeLastTurnEnded;                                           //what time did the last turn end?

    // Use this for initialization
    void Start()
    {
        //get the GameRules and the LineScript
        gameRules = gameObject.GetComponent <GameRulesScript> ();
        line      = gameObject.GetComponent <LineScript> ();

        //link the scripts
        ballScriptR1 = ballR1.GetComponent <BallScript> ();
        ballScriptR2 = ballR2.GetComponent <BallScript> ();
        ballScriptB1 = ballB1.GetComponent <BallScript> ();
        ballScriptB2 = ballB2.GetComponent <BallScript> ();

        //set default values for LastRed and LastBlue ball
        gameRules.LastRedBall  = ballR1;
        gameRules.LastBlueBall = ballB1;

        //get a starting position for the mouse cursor
        Vector3 posInScreen = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);

        posInWorld = Camera.main.ScreenToWorldPoint(posInScreen);

        //set up some other things
        ballsMoving = false;
        hitBuilding = true;
    }
    public void LifeLoss()
    {
        if (life == 0 || gameClear)
        {
            return;
        }
        life--;
        _audioSource.PlayOneShot(LossHeartA);
        heartArray[life].SetActive(false);
//        chargeBar.transform.localScale = new Vector2(0, 1);
        if (life == 0)
        {
            gameOverUI.SetActive(true);
            ChangeBackSprite.instance.StopBGM();
            _audioSource.PlayOneShot(GameOverA, 5);
            GuideLines.instance.RemoveAll();
            StartCoroutine("NextScene");
        }
        else
        {
            speed = startYusyaSpeed;
//            StageManager.GetInstance.RestorePassableImmediately();
            GuideLines.instance.RemoveAll();
            StoveScript.instance.Reset();
            playerInstance =
                Instantiate(player, new Vector2(0, startYusyaPositionY),
                            Quaternion.FromToRotation(Vector3.right, Vector3.up))
                .GetComponent <BallScript>();
            PrepareForNextTurn();
        }
    }
Beispiel #18
0
    private void Start()
    {
        BallScript = Ball.GetComponent <BallScript>();

        greenTile = Resources.Load("GreenSquare") as TileBase;
        redTile   = Resources.Load("RedSquare") as TileBase;
    }
Beispiel #19
0
    void BallThrowing()
    {
        if (isHolding)
        {
            ballHudMeshRend.enabled = true;
            if (Input.GetMouseButton(0))
            {
                //increase propulsion force while fire button is held down
                propulsionForce += 0.25f;
                propulsionForce  = Mathf.Clamp(propulsionForce, 0f, 16f);
            }
            if (Input.GetMouseButtonUp(0))
            {
                Vector3 forward = Camera.main.transform.forward;
                //Get ball script reference for the ball being held
                ballScript = projectileObj.GetComponent <BallScript>();
                projectileObj.transform.parent = null;
                Rigidbody ballRB = projectileObj.GetComponent <Rigidbody>();
                ballRB.AddForce(forward * propulsionForce, ForceMode.Impulse);

                //mark ball as thrown
                ballScript.ballState = BallScript.BallFSM.Thrown;

                //add force in direction that camera is pointing
                propulsionForce = 0;
                //set ballscript ballState to Thrown
                isHolding = false;
            }
        }
        else if (!isHolding)
        {
            ballHudMeshRend.enabled = false;
        }
    }
Beispiel #20
0
 void Start()
 {
     goalie = GameObject.Find("Goalie");
     goaliePos = goalie.transform.position;
     bs = GameObject.Find("Ball").GetComponent<BallScript>();
     force = 0;
 }
    void spawn()
    {
        //Debug.Log(r1);
        float      x    = Random.Range(0.8f - w, w - 0.8f);
        GameObject lst  = al[al.Count - 1];
        Vector3    pos  = lst.transform.position;
        float      r2   = getr(lst.transform.localScale.x);
        float      dmin = gap + r2 + 0.6f;
        float      dx   = pos.x - x;
        float      ymin = Mathf.Sqrt(Mathf.Max(dmin * dmin - dx * dx, 0));

        y += Random.Range(Mathf.Max(ymin, 0.5f), 3f);
        float dist  = BallScript.eucdist(pos.x, x, pos.y, y);
        float rmax1 = dist - r2 - gap;
        float rmax2 = Mathf.Min(Mathf.Abs(x - (w - 0.2f)), Mathf.Abs(x - (0.2f - w)));
        //Debug.Log(rmax1 + " " + rmax2+ " " + dist + " " + dmin + " " +  ymin);
        float smax  = Mathf.Min(rmax1, rmax2) / 2.4f;
        float scale = Random.Range(0.25f, smax);
        float r1    = getr(scale);

        //Debug.Log(ming + " " + r1 + " " + r + " " + scale);
        foreach (GameObject i in al)
        {
            Vector3 posi = i.transform.position;
            float   r3   = getr(i.transform.localScale.x);
            float   di   = gap + r3 + r1;
            float   dxi  = posi.x - x;
            float   dyi  = Mathf.Sqrt(Mathf.Max(di * di - dxi * dxi, 0));
            y = Mathf.Max(posi.y + dyi, y);
        }
        GameObject ob;

        if (lst.tag == "c")
        {
            ob = Instantiate(cc);
        }
        else
        {
            ob = Instantiate(c);
        }
        ob.transform.position   = new Vector3(x, y, 0);
        ob.transform.localScale = new Vector3(scale, scale, 0);
        al.Add(ob);
        if (Random.Range(0, 5) >= 4 && al.Count >= 5)
        {
            GameObject eorb = Instantiate(orb, ob.transform);
            //eorb.transform.Translate(ob.transform.position);
            eorb.transform.Translate(new Vector3(r1 + 0.4f, 0, 0));
            eorb.transform.localScale = (new Vector3(0.05f / scale, 0.05f / scale, 0));
            if (lst.tag == "c")
            {
                eorb.GetComponent <OrbObstacle>().initlz(ob.transform.position, Vector3.back);
            }
            else
            {
                eorb.GetComponent <OrbObstacle>().initlz(ob.transform.position, Vector3.forward);
            }
        }
    }
    public void CheckMatchesForBall(BallScript ball)
    {
        matchList.Clear();

        for (int row = 0; row < ROWS; row++)
        {
            for (int column = 0; column < COLUMNS; column++)
            {
                gridBalls[row][column].visited = false;
            }
        }

        //search for matches around ball
        var initialResult = GetMatches(ball);

        matchList.AddRange(initialResult);

        while (true)
        {
            var allVisited = true;
            for (var i = matchList.Count - 1; i >= 0; i--)
            {
                var b = matchList[i];
                if (!b.visited)
                {
                    AddMatches(GetMatches(b));
                    allVisited = false;
                }
            }

            if (allVisited)
            {
                if (matchList.Count > 2)
                {
                    foreach (var b in matchList)
                    {
                        b.gameObject.SetActive(false);
                    }

                    CheckForDisconnected();

                    //remove disconnected balls
                    var i = 0;
                    while (i < ROWS)
                    {
                        foreach (var b in gridBalls[i])
                        {
                            if (!b.connected && b.gameObject.activeSelf)
                            {
                                b.gameObject.SetActive(false);
                            }
                        }
                        i++;
                    }
                }
                return;
            }
        }
    }
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag.Equals("Ball"))
     {
         BallScript otherBall = collision.gameObject.GetComponent <BallScript>();
         Rigid_Body.AddForce(otherBall.Rigid_Body.velocity);
     }
 }
    void Start()
    {
        Application.targetFrameRate = 60;

        ballScript = ballPrefab.GetComponent <BallScript>();

        player1ScoreText.text = player2ScoreText.text = "0";
    }
Beispiel #25
0
 private void Start()
 {
     instance        = this;
     _animator       = GetComponent <Animator>();
     _rigidbody2D    = GetComponent <Rigidbody2D>();
     _spriteRenderer = transform.GetChild(0).GetComponent <SpriteRenderer>();
     _audioSource    = GetComponent <AudioSource>();
 }
Beispiel #26
0
    void Start () {
        instance = this;
        r2d = GetComponent<Rigidbody2D>();
        gameStart = false;
        myPhotonView = GetComponent<PhotonView>();
        consecutiveWallHits = 0;
        consecutivePaddleHits = 0;
	}
 void Start()
 {
     Application.runInBackground = true;
     Application.targetFrameRate = 500;
     redTeamTxt  = redTeamScoreObj.GetComponent <tk2dTextMesh>();
     blueTeamTxt = blueTeamScoreObj.GetComponent <tk2dTextMesh>();
     ball        = GameObject.FindObjectOfType <BallScript>();
 }
Beispiel #28
0
        private void GenerateUsualLevel()
        {
            BallScript ballScript = ObjectPool.Instance.Get <BallScript>(AssetManager.Instance.Ball, _ballStartPosition);

            JumpScript.Instance.ResetPosition();
            BotJump.Instance.ResetPosition();
            BotJump.Instance.SetAim(ballScript);
        }
Beispiel #29
0
 //sets up the play are for the first time
 void FirstSetUp()
 {
     ballScript = ball.GetComponent <BallScript> ();
     gameState  = 1;
     playerOneScript.NewRound();
     playerTwoScript.NewRound();
     SetBallSpeed(-1);
 }
Beispiel #30
0
    //ボールオブジェクトの生成
    private void CreateSphere()
    {
        var v = new Vector3(-0.43f, 2.7f, 9.3f);
        //シーンオブジェクト(マスタークライアントが変更されても消失しない)として生成
        GameObject ballObj = PhotonNetwork.InstantiateSceneObject("PhotonSphere", v, Quaternion.identity);

        ball = ballObj.GetComponent <BallScript>();
    }
Beispiel #31
0
    public int attackingPlayer;                                             // which player scores into this goal

    void OnCollisionEnter2D(Collision2D other)                              // collision function, for when ball hits wall behind player
    {
        if (other.gameObject.tag == "Ball")                                 // if the tag on the object is 'ball'
        {
            BallScript ball = other.gameObject.GetComponent <BallScript>(); // ***?*?*?***
            GameManager.instance.GoalScored(attackingPlayer, ball);         // is it attacking player (ref. bool)
            ball.Reset();                                                   // run the reset function on the ball object
        }                                                                   //end if object is ball
    }                                                                       // END ON COLLISION
    void OnTriggerExit(Collider col)
    {
        BallScript bs = col.gameObject.GetComponent <BallScript>();

        if (bs)
        {
            bs.onHill(false, hillPhysXMat);
        }
    }
Beispiel #33
0
    void OnTriggerEnter(Collider other)
    {
        BallScript ballScript = other.GetComponent <BallScript>();

        if (ballScript)
        {
            ballScript.Die();
        }
    }
Beispiel #34
0
 // Méthode appelée lors du "réveil" de l'objet (avant même le Start)
 // Il est important de créer les singleton dans le Awake pour être sûr qu'ils soient créé avant le Start des autres objets
 void Awake()
 {
     // Unity créera l'objet même si le constructeur est privé donc on doit initialiser l'instance de notre singleton ici
     if (BallScript._instance == null) {
         BallScript._instance = this;
     } else if (BallScript._instance != this) {
         Destroy(this.gameObject);
     }
 }
Beispiel #35
0
    void Awake()
    {
        levelText = GameObject.Find("LevelText");
        levelTextPanel = GameObject.Find("ChicoWithTextBoard");

        ball = GameObject.Find("Ball");
        if (ball)
        {
            ballScript = ball.GetComponent<BallScript>();
            shootScript = ball.GetComponent<ShootLogicV3>();
        }
    }
Beispiel #36
0
	public void Start()
	{
		//gets the player object
		m_playerObj = GameObject.FindWithTag("Player");
		
		//gets teh ball script
		if(m_playerObj)
		{
			m_ballScript = m_playerObj.GetComponent<BallScript>();// typeof(BallScript));
		}

	}
Beispiel #37
0
	public void Update()
	{
		if(m_on)
		{
			m_ballScript = (BallScript)GameObject.FindObjectOfType( typeof(BallScript));
		//	Camera camera0 = Camera.mainCamera;
			if(m_ballScript)
			{


				updateLookAt();

			}
		}
	}
Beispiel #38
0
	public void Start()
	{		
		
		//get the player object
		GameObject go = GameObject.FindWithTag("Player");
		if(go)
		{
			
			//save a ref of the players gameobject
			m_playerObj=go;
			
			//get the players ballscript
			m_ballScript = m_playerObj.GetComponent<BallScript>();
		}
		
	}
 void Start()
 {
     Application.runInBackground = true;
     Application.targetFrameRate = 500;
     redTeamTxt = redTeamScoreObj.GetComponent<tk2dTextMesh>();
     blueTeamTxt = blueTeamScoreObj.GetComponent<tk2dTextMesh>();
     ball = GameObject.FindObjectOfType<BallScript>();
 }
    public virtual void InitPlayer()
    {
        if (!isInited)
        {
            id++;
            oponentDefense = oponentTeam.GetComponentsInChildren<DefensePlayer>();
            rgBody = GetComponent<Rigidbody2D>();
            ballScript = FindObjectOfType<BallScript>();

            brain = new NeuralNetwork(NeuralNetworkConst.ATTACKER_INPUT_COUNT, NeuralNetworkConst.ATTACKER_OUTPUT_COUNT,
                NeuralNetworkConst.ATTACKER_HID_LAYER_COUNT, NeuralNetworkConst.ATTACKER_NEURONS_PER_HID_LAY);
            isInited = true;
        }
    }
Beispiel #41
0
 void Awake()
 {
     ball = GameObject.Find("Ball").GetComponent<BallScript>();
     level = GameObject.Find("Level").GetComponent<LevelScript>();
 }
Beispiel #42
0
    void Awake()
    {
        // Ball
        ball = FindObjectOfType<BallScript>();

        // Players
        var players = FindObjectsOfType<PlayerScript>();
        if (players.Length == 0)
        {
          Debug.LogError("No players WTF");
        }

        foreach (var p in players)
        {
          p.OnBallPick += (pickingPlayer) =>
          {
        SelectTeam(pickingPlayer, pickingPlayer.definition.team);
          };
          p.OnShoot += (pl) =>
          {
        soundShootCooldown = 2f;
          };
        }

        mire1.SetActive(false);
        mire2.SetActive(false);
        team1 = players.Where(p => p.definition.team == TEAM1).ToList();
        team2 = players.Where(p => p.definition.team == TEAM2).ToList();

        InputHandleSelection(true);

        // Goal
        foreach (GoalScript g in FindObjectsOfType<GoalScript>())
        {
          g.OnGoal += GOAL;

          if (g.team == TEAM1) goal1 = g;
          else if (g.team == TEAM2) goal2 = g;
        }
    }
Beispiel #43
0
 void LetGoOfBall()
 {
     refactory = 0f;
     Debug.Log ("ball has left");
     ball.BPosessed = false;
     ball.unitOwner = null;
     ball.transform.SetParent(null);
     ball = null;
     hasBall = false;
 }
Beispiel #44
0
	public void Awake()
	{
		m_par = 3;
		RenderSettings.ambientLight = ambientColor;


		//unpause the game
		GameConfig.setPaused(false);
		ScoreState ss = (ScoreState)GameObject.FindObjectOfType(typeof(ScoreState));
		if(ss)
		{
			m_scoreStateGO = ss.gameObject;
		}
		//if its levle 1 reset the scores.
		int holeIndex = getHoleNomUsingCourse();
//		Debug.Log("holeIndex"+holeIndex);
		if(holeIndex==1)
		{
			setScoreForHole(getHoleNomUsingCourse(),currentNumberOfStrokes);
			setTotalScore(0);
//			m_totalScore=0;
			m_totalPar = 0;
		}else{

//			m_totalScore = getTotalScore();
		}
		ParScript ps = (ParScript)GameObject.FindObjectOfType(typeof(ParScript));
		if(ps)
		{
			m_par = ps.par;
			setParForHole(getHoleNomUsingCourse(),m_par);
			m_totalPar+=m_par;
		}else{
			setParForHole(getHoleNomUsingCourse(),m_par);
		}
		

		//get a ref to the gamescript!
		GameObject go = GameObject.FindWithTag("Player");
		if(go)
		{
			m_ballScript = go.GetComponent<BallScript>();
		}	
		
		GameManager.enterState( GameScript.State.INIT.ToString() );
		
	}
    private void Pass()
    {
        if (ball == null)
          return;

        PlayerScript nearest = gameScript.GetNearestPlayer((definition.team == GameScript.TEAM1 ? gameScript.team1 : gameScript.team2), this.gameObject);

        if (nearest != null)
        {
          // Small targeted shoot
          Vector3 direction = (nearest.transform.position - this.transform.position);
          direction.Normalize();

          Vector3 shootDirection = new Vector3(direction.x, 0.15f, direction.z);

          BallRelativePosition = Vector3.Scale(Vector3.Normalize(shootDirection), ballDistance);
          ball.ApplyBallPosition();

          Shooting(shootDirection, definition.passForce, true);

          ball = null;

          CameraShaker.ShakeCamera(0.1f, 0.15f);
        }
    }
Beispiel #46
0
 // Use this for initialization
 void Start()
 {
     blocks = GameObject.FindGameObjectsWithTag("Block");
     Ball = GameObject.Find("Ball").GetComponent<BallScript>();
     statusText = GameObject.Find("Status").GetComponent<Text>();
 }
Beispiel #47
0
    void primeForDeletion()
    {
        foreach(GameObject ball in touchingList)// for every ball in my touching list,
        {
            if(ball != null)
            {
                ballScript = ball.GetComponent<BallScript>();

                if( ballScript.color == m_color)//if this ball has the same color as me
                {
                    if(!sameColorList.Contains(ball)) // add it to the list, as long as it's not already there
                    {
                        sameColorList.Add(ball);
                    }

                }
            }
        }

        if(sameColorList.Count > 1) // if there is more than 1 ball touching me that has the same color,
        {
            isDead = true; // this ball is dead

            foreach(GameObject ball in sameColorList)// the balls touching me are dead
            {
                ball.GetComponent<BallScript>().isDead = true;
            }
        }
    }
Beispiel #48
0
    // Use this for initialization
    void Start()
    {
        sockets = new Sockets();
        client = new Client();
        opPosY = 128;
        ballPosX = 0;
        ballPosY = 0;
        buffer = new byte[6];
        gameStart = false;
        player1Score = 0;
        player2Score = 0;

        gui = GameObject.Find("GUI").GetComponent<GUIScript>();

        p1 = (Player1) GameObject.Find ("Player1").GetComponent ("Player1");
        p2 = (Player2) GameObject.Find ("Player2").GetComponent ("Player2");
        bscript = (BallScript) GameObject.Find ("GameBall").GetComponent("BallScript");
        lPaddle = GameObject.Find ("Goal2");
        bWall = GameObject.Find ("BottomWall");
        paddleRatio = (250.0f / (GameObject.Find("Goal1").transform.position.x - GameObject.Find("Goal2").transform.position.x));
        wallRatio = (250.0f / (GameObject.Find ("TopWall").transform.position.y - bWall.transform.position.y));
    }
    private void Shoot()
    {
        if (ball == null)
          return;

        // Shooooot
        Vector3 shootDirection = new Vector3(ballDirection.x, 0.25f * definition.lobForceFactor, ballDirection.z);

        Shooting(shootDirection, definition.shootForce, false);

        ball = null;

        CameraShaker.ShakeCamera(0.2f, 0.3f);
    }
 void OnTriggerEnter2D(Collider2D coll)
 {
     //broom interactions
     if(coll.gameObject.tag == "ball")
     {
         hasPossession = true;
         ball = coll.gameObject;
         ballScript = ball.GetComponent<BallScript>();
     }
 }
Beispiel #51
0
 void Start()
 {
     ball = ChangingHeights.Instance.ball;
     returnerCollider = gameObject.GetComponent<Collider>();
     ballScript = ball.gameObject.GetComponent<BallScript>();
 }
Beispiel #52
0
 void OnTriggerEnter(Collider other)
 {
     switch(other.tag)
     {
         case "Ball":
         {
             if (refactory>1f)
             {
                 ball = other.GetComponent<BallScript> ();
                 ball.BPosessed = true;
                 ball.unitOwner = this;
                 Debug.Log ("I gots da ball");
                 hasBall = true;
                 other.transform.SetParent (tran);
                 other.transform.position = tran.TransformPoint (0, 0, 1);
                 ball.StopMe ();
             }
             break;
         }
     }
 }
    void HandleBallCollision(Collider c)
    {
        if (this.ball != null)
          return;

        if (IsActive == false)
          return;

        BallScript b = c.GetComponent<BallScript>();

        // Touching the ball
        if (b != null)
        {
          touchingBall = true;

          // Link?
          if (b.linkedPlayer == null && b.IsPickable)
          {
        b.linkedPlayer = this;
        this.ball = b;

        // Reset ball direction
        ballDirection = new Vector3(definition.team == GameScript.TEAM1 ? -1 : 1, 0, 0);

        if (OnBallPick != null)
        {
          OnBallPick(this);
        }
          }
        }
    }
 public void BallLost()
 {
     ball = null;
 }
Beispiel #55
0
 void Start()
 {
     leftFoot = GameObject.Find("15_Foot_Left");
     rightFoot = GameObject.Find("19_Foot_Right");
     ball = GameObject.Find("Ball");
     head = GameObject.Find("12_Hip_Left");
     time = 0;
     timeTaken = 0;
     maxDistanceofKick = 0;
     bs = GameObject.Find("Ball").GetComponent<BallScript>();
     footPos = new List<float>();
     timeList = new List<float>();
     angleDetect = new List<Vector3>();
 }