// Use this for initialization void Start() { if (instance == null) { instance = this; } }
// Update is called once per frame void Update() { // is there a ball yet? if (!isBallSpawned) { if (numPlayers == 2) { isBallSpawned = true; Debug.Log("Ball Spawned"); m_ball = (GameObject)Instantiate(Ball, new Vector3(0, .3f, 0f), Quaternion.identity); NetworkServer.Spawn(m_ball); spawnNewBall(); } } else { // check if ball is out of boundarys if (m_ball.transform.position.z < -5f) { // right player won PointsScript s = (PointsScript)PointsClient.GetComponent(typeof(PointsScript)); s.RpcPlusOne(); spawnNewBall(); } else if (m_ball.transform.position.z > 5f) { // left player won PointsScript s = (PointsScript)PointsHost.GetComponent(typeof(PointsScript)); s.RpcPlusOne(); spawnNewBall(); } } }
private void Awake() { mPauseMenu.SetActive(false); mGameOverMenu.SetActive(false); mWinnerMessage.SetActive(false); jsonSavePath = Application.persistentDataPath + "/Points.json"; mData = new PointsScript(); }
public void LoadScore() { mData = JsonUtility.FromJson <PointsScript>(File.ReadAllText(jsonSavePath)); mRedPoints = mData.mRedPoints; mBluePoints = mData.mBluePoints; mGreenPoints = mData.mGreenPoints; mYellowPoints = mData.mYellowPoints; }
//movimentacao da garrafa void MoveBottle() { Rigidbody2D rb = GetComponent <Rigidbody2D> (); rb.velocity = new Vector2(0, speed); monicaScript = GameObject.Find("Monica").GetComponent <MonicaScript>();//ele procura o scrpit da monica para associar os pontos e score ptScript = GameObject.Find("Score").GetComponent <PointsScript>(); }
public void Load() { mPoints = JsonUtility.FromJson <PointsScript>(File.ReadAllText(Application.persistentDataPath + "/Points.json")); mRedScore.GetComponent <TextMeshProUGUI>().text = mPoints.mRedPoints.ToString(); mBlueScore.GetComponent <TextMeshProUGUI>().text = mPoints.mBluePoints.ToString(); mYellowScore.GetComponent <TextMeshProUGUI>().text = mPoints.mYellowPoints.ToString(); mGreenScore.GetComponent <TextMeshProUGUI>().text = mPoints.mGreenPoints.ToString(); mGameEnded1 = mPoints.mGameEnded; }
// Update is called once per frame void Update() { // Updates the current level based on the number of points of the user // Each three points raises the level by one PointsScript pointsScript = GameObject.Find("PointsText").GetComponent <PointsScript>(); CurrentLevel = Mathf.FloorToInt(pointsScript.CurrentPoints / 3); levelText.text = "Nivel = " + CurrentLevel; }
public GameObject prnt; //Parent obj is attached here void OnCollisionEnter(Collision collision) { foreach (ContactPoint contact in collision.contacts) { PointsScript.points(pts); if (parent == true) { Destroy(prnt); } Destroy(gameObject); } }
public void OnSaveButton() { PointsScript mPoints = new PointsScript(); mPoints.mRedPoints = mRedPoints; mPoints.mBluePoints = mBluePoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = true; string mJson = JsonConvert.SerializeObject(mPoints, Formatting.Indented); File.WriteAllText(Application.persistentDataPath + "/Points.json", mJson); }
private void Start() { mNumberOfPlayers = 0; mPlayerIndex = 0; jsonSavePath = Application.persistentDataPath + "/Data.json"; mData = new DataScript(); mPoints = new PointsScript(); mColor = new ColorScript(); mMainMenu.SetActive(true); LoadColor(); Load(); LoadGameEndData(); }
public void SaveScore() { if (mWinner == "Player 1") { PointsScript mPoints = new PointsScript(); mRedPoints += 500; mPoints.mRedPoints = mRedPoints; mPoints.mBluePoints = mBluePoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = false; string jsonData = JsonUtility.ToJson(mPoints); File.WriteAllText(jsonSavePath, jsonData); } else if (mWinner == "Player 2") { PointsScript mPoints = new PointsScript(); mBluePoints += 500; mPoints.mBluePoints = mBluePoints; mPoints.mRedPoints = mRedPoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = false; string jsonData = JsonUtility.ToJson(mPoints); File.WriteAllText(jsonSavePath, jsonData); } else if (mWinner == "Player 3") { PointsScript mPoints = new PointsScript(); mYellowPoints += 500; mPoints.mBluePoints = mBluePoints; mPoints.mRedPoints = mRedPoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = false; string jsonData = JsonUtility.ToJson(mPoints); File.WriteAllText(jsonSavePath, jsonData); } else if (mWinner == "Player 4") { PointsScript mPoints = new PointsScript(); mGreenPoints += 500; mPoints.mBluePoints = mBluePoints; mPoints.mRedPoints = mRedPoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = false; string jsonData = JsonUtility.ToJson(mPoints); File.WriteAllText(jsonSavePath, jsonData); } }
public void MenuButton() { PointsScript mPoints = new PointsScript(); mPoints.mRedPoints = mRedPoints; mPoints.mBluePoints = mBluePoints; mPoints.mYellowPoints = mYellowPoints; mPoints.mGreenPoints = mGreenPoints; mPoints.mGameEnded = true; string mjson = JsonConvert.SerializeObject(mPoints, Formatting.Indented); File.WriteAllText(Application.persistentDataPath + "/Points.json", mjson); Time.timeScale = 1f; SceneManager.LoadScene(1); }
private PointsScript ptScript; // Para se comunicar com o SpaceshipScript // Start is called before the first frame update void Start() { ptScript = GameObject.Find("Pontuacao").GetComponent <PointsScript> (); // Adicionar speed à velocidade do obstáculo Rigidbody2D rb = GetComponent <Rigidbody2D> (); rb.velocity = new Vector2(speed, 0); //(X, Y) // Faz o obstáculo rodar em si mesmo aleatoriamentre entre -200 e 200 graus rb.angularVelocity = Random.Range(-200, 200); // Destroi o obstáculo após 3s, que ele não está mais visível na tela Destroy(gameObject, 3); }
void Start() { Random.InitState((int)System.DateTime.Now.Ticks); maskRenderer = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); ptScript = GameObject.Find("player").GetComponent <PointsScript>(); playerScript = GameObject.Find("player").GetComponent <PlayerScript>(); bonusScript = GameObject.Find("BonusControl").GetComponent <BonusScript>(); if (gameObject.tag != "DogTag") //os objetos OldMan e Young possuem diferentes skins, o cachorro é o único que não precisa dessa função { selectSkin(); } adjustMovement(); }
void Awake (){ pointsScript = GameObject.FindGameObjectWithTag("Manager").GetComponent<PointsScript>(); coreCollider = GameObject.FindGameObjectWithTag("Core").GetComponent<Collider2D>(); thisCollider = GetComponent<Collider2D>(); }
void Awake() { points = GameObject.FindObjectOfType <PointsScript> (); }
private PointsScript ptScript; // Para se comunicar com o scriptNave // Start is called before the first frame update void Start() { ptScript = GameObject.Find("Pontuacao").GetComponent <PointsScript> (); }