void OnTriggerEnter(Collider other) { //https://docs.unity3d.com/ScriptReference/Object.FindObjectsOfType.html if (other.gameObject.CompareTag("Player")) { SpiderAI[] si = FindObjectsOfType(typeof(SpiderAI)) as SpiderAI[]; foreach (SpiderAI s in si) { s.isLoading = true; } RatAI[] ri = FindObjectsOfType(typeof(RatAI)) as RatAI[]; foreach (RatAI r in ri) { r.isLoading = true; } BatAI[] bi = FindObjectsOfType(typeof(BatAI)) as BatAI[]; foreach (BatAI b in bi) { b.isLoading = true; } GameManager gm = FindObjectOfType(typeof(GameManager)) as GameManager; Player1Controller p1 = FindObjectOfType(typeof(Player1Controller)) as Player1Controller; Player2Controller p2 = FindObjectOfType(typeof(Player2Controller)) as Player2Controller; gm.setP1HP(p1.gameObject.GetComponent <Health> ().HP); gm.setP2HP(p2.gameObject.GetComponent <Health> ().HP); SceneManager.LoadSceneAsync(Load, LoadSceneMode.Single); } }
void resetAndPrintCurrentStatus() { gamepaused = true; delay = 3f; roundCount++; Player1Controller p1 = GameObject.FindWithTag("Player1") .GetComponent <Player1Controller>(); Player2Controller p2 = GameObject.FindWithTag("Player2") .GetComponent <Player2Controller>(); p1.resetPos(); p2.resetPos(); transform.position = initialPosition; Time.timeScale = 0f; scoreboard.SetActive(true); GameObject.FindWithTag("Score1") .GetComponent <UnityEngine.UI.Text>().text = player1Score + ""; GameObject.FindWithTag("Score2") .GetComponent <UnityEngine.UI.Text>().text = player2Score + ""; }
//private float remaining; // Update is called once per frame void Update() { GameObject playerone = GameObject.Find("Player1"); Player1Controller oneaccess = playerone.GetComponent <Player1Controller>(); GameObject playertwo = GameObject.Find("Player2"); Player2Controller twoaccess = playertwo.GetComponent <Player2Controller>(); currenttime = Time.timeSinceLevelLoad; if (!oneaccess.levelComplete && !twoaccess.levelComplete) { displaytime = currenttime; } //Original script for timer. //float temp = Time.time - start; //remaining = initialtime - temp; //if(remaining < 0) //{ // SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); //} timer.text = "Time Elapsed: " + displaytime.ToString("f0"); }
private void OnTriggerEnter(Collider col) { if (col.gameObject.layer == 9) { Player1Controller P1 = col.gameObject.GetComponent <Player1Controller> (); P1.hp -= 25; //Changes color based on attack Color temp = col.gameObject.GetComponentInChildren <Light> ().color; temp.r -= .2f; //Changes intensity based on attack Light tempL = col.gameObject.GetComponentInChildren <Light>(); tempL.intensity -= .2f; CameraShake CamShake = GameObject.Find("Main Camera").GetComponent <CameraShake> (); CamShake.PlayerShake(.5f); if (P1.hp <= 0) { GameObject Cam = GameObject.Find("Main Camera"); AgentRespawn NewStat = Cam.gameObject.GetComponent <AgentRespawn> (); NewStat.Agent2InHP += 5; NewStat.Agent2dmg += 2; } } if (col.gameObject.tag == "Agent1") { Agent1Controller A1 = col.gameObject.GetComponent <Agent1Controller> (); A1.HP -= 25; } }
// Use this for initialization void Start() { isGameOver = false; restart = true; player1controller = player1.GetComponent<Player1Controller>(); player2controller = player2.GetComponent<Player2Control>(); }
void invertPlayerEnd(GameObject player) { if (player.name == "Player 1") { Player1Controller p1cScript = player.GetComponent <Player1Controller> (); p1cScript.invertExtend -= 1; if (p1cScript.invertExtend <= 0) { p1cScript.invert = 1; // Stop and Clear Particles player.GetComponentInChildren <ParticleSystem> ().Stop(true); player.GetComponentInChildren <ParticleSystem> ().Clear(); } } else if (player.name == "Player 2") { Player2Controller p2cScript = player.GetComponent <Player2Controller> (); p2cScript.invertExtend -= 1; if (p2cScript.invertExtend <= 0) { p2cScript.invert = 1; // Stop and Clear Particles player.GetComponentInChildren <ParticleSystem> ().Stop(true); player.GetComponentInChildren <ParticleSystem> ().Clear(); } } }
// Use this for initialization void Start() { rect = GetComponent <RectTransform>(); part = GetComponent <ParticleSystem>(); trans = rect.transform; button = xboxController.GetComponent <Player1Controller>(); }
// Use this for initialization void Start () { player = FindObjectOfType<Player1Controller> (); anim = FindObjectOfType<Animator> (); cam = FindObjectOfType<CameraController> (); playerCollider = playerObj.GetComponent<Collider2D> (); gun = FindObjectOfType<GunManager> (); }
public void InitiateMinigame(int playerID, Player1Controller controller, Item initiatedWithItem) { Debug.Log("InitiateMinigame"); GameManager.Instance.MinigameManager.StartMinigame(GetComponent<MinigameDisplayComponent>(), m_MinigameType, playerID, (tickResult) => OnMachineInteractionFinished(tickResult, controller)); m_CurrentlyPlayingMinigame = true; controller.DisableControls(); m_InitiatedWithItem = initiatedWithItem; }
// Use this for initialization void Start() { player = FindObjectOfType <Player1Controller> (); anim = FindObjectOfType <Animator> (); cam = FindObjectOfType <CameraController> (); playerCollider = playerObj.GetComponent <Collider2D> (); gun = FindObjectOfType <GunManager> (); }
public void ReachedGoal() { Debug.Log("reached"); Player1Controller.StartAutopilot(); LevelCompleteModal.SetActive(true); roundActive = false; Invoke("ShowGoalParticles", 0.5f); roundActive = false; }
// Update is called once per frame void Update() { time = timer.GetComponent <Controller>(); player1 = playerOne.GetComponent <Player1Controller>(); player2 = playerTwo.GetComponent <Player2Controller>(); if (time.timer <= 0) { buttonText.text = "Start"; } }
//public float bulletLife; //private float bulletLifeCounter; // Use this for initialization void Start () { rb = GetComponent<Rigidbody2D> (); player = FindObjectOfType<Player1Controller> (); if (player.transform.localScale.x < 0) { speed = -speed; } // bulletLifeCounter = bulletLife; }
// Update is called once per frame void Update() { player1 = playerOne.GetComponent <Player1Controller>(); player2 = playerTwo.GetComponent <Player2Controller>(); button = startButton.GetComponent <StartButton>(); if (button.startPressed == true) { timer -= Time.deltaTime; winText.text = ""; } var t = Mathf.Abs(timer); int seconds = (int)t % 60; int minutes = (int)t / 60; var minSec = minutes + ":" + seconds; if (seconds < 10) { minSec = minutes + ":0" + seconds; } timeRemaining.text = ""; if (timer <= 60 && timer >= 57) { timeRemaining.text = "1 Minute Remaining"; } if (timer <= 30 && timer >= 27) { timeRemaining.text = "30 Seconds Remaining"; } if (timer <= 10 && timer >= 7) { timeRemaining.text = "10 Seconds Remaining"; } if (timer <= 0) { if (player1.getScore() > player2.getScore()) { winText.text = "Player 1 Wins!"; } else if (player1.getScore() < player2.getScore()) { winText.text = "Player 2 Wins!"; } else { winText.text = "It's a Tie!"; } Stop(); } timerText.text = minSec; }
//public float bulletLife; //private float bulletLifeCounter; // Use this for initialization void Start() { rb = GetComponent <Rigidbody2D> (); player = FindObjectOfType <Player1Controller> (); if (player.transform.localScale.x < 0) { speed = -speed; } // bulletLifeCounter = bulletLife; }
// Invert Player Controller, keep track of that in Player Script // Keep track of multiple calls to extend the invert period void invertPlayerStart(GameObject player) { if (player.name == "Player 1") { Player1Controller p1cScript = player.GetComponent <Player1Controller> (); p1cScript.invert = -1; p1cScript.invertExtend += 1; } else if (player.name == "Player 2") { Player2Controller p2cScript = player.GetComponent <Player2Controller> (); p2cScript.invert = -1; p2cScript.invertExtend += 1; } startCountdown(3.0f); }
private void OnMachineInteractionFinished(MinigameTickResult tickResult, Player1Controller controller) { if (gameObject == null) { return; } Debug.Log("I am a machine, my name is " + gameObject.name + " and I finished a minigame with result " + tickResult.ToString()); m_CurrentlyPlayingMinigame = false; m_LastEndedTimestamp = Time.time; controller.EnableControls(); if (tickResult == MinigameTickResult.EarlySuccess) { m_InitiatedWithItem.OnSuccessFullMachineInteraction(); } }
public void SetUp() { // Camera new GameObject().AddComponent <Camera>(); // Player1 player1 = new GameObject().AddComponent <Player1Controller>(); player1.gameObject.AddComponent <BoxCollider2D>(); player1.gameObject.AddComponent <Rigidbody2D>(); player1.gameObject.AddComponent <Animator>(); player1.Jumping = new GameObject().AddComponent <AudioSource>(); player1.speed = 10; player1.jumpForce = 10; player1.gameObject.tag = "Player1"; player1.stepParticles = new GameObject().AddComponent <ParticleSystem>(); player1.feetPos1 = new GameObject().transform; player1.feetPos2 = new GameObject().transform; }
// void OnGUI() // { // if (GUI.Button (new Rect (Screen.width / 2 - Screen.width / 16, Screen.height / 2 - Screen.height / 5.5f, Screen.width / 8, Screen.height / 14), "Sua Vez")) // { // player1.NextRound(); // } // } public void Start() { quemComeca = Random.Range(0, 2); gameActive = true; Player1Status status; for (int i = 1; i <= 1; i++) { GameObject player_prefab = Resources.Load <GameObject>("Prefabs/Player1"); //GameObject player_obj = (GameObject)GameObject.Instantiate(player_prefab); Player1Controller player = (Player1Controller)Oplayer1.GetComponent("Player1Controller"); status = (Player1Status)Oplayer1.GetComponent("Player1Status"); status.controller = this; // TextMesh textoHpInimigo = (TextMesh)transform.Find ("Player life text").GetComponent("TextMesh"); player.player_number = i; if (i == 1) { player.Init(this); } // SetPlayerPosition (player_obj, i); } for (int i = 2; i <= 2; i++) { Player2Status status2; GameObject player_prefab = Resources.Load <GameObject>("Prefabs/Player2"); //GameObject player_obj = (GameObject)GameObject.Instantiate(player_prefab); Player2Controller player2 = (Player2Controller)Oplayer2.GetComponent("Player2Controller"); status2 = (Player2Status)Oplayer2.GetComponent("Player2Status"); status2.controller = this; //TextMesh textoHpInimigo = (TextMesh)transform.Find ("Player life text").GetComponent("TextMesh"); player2.player_number = i; if (i == 2) { player2.Init(this); } // SetPlayerPosition (player_obj, i); } // cardcontroller = (CardController)player1.GetComponent("CardController"); // properties = (AbstractCard)player1.GetComponent("AbstractCard"); }
void Awake() { GameObject player1Object = GameObject.FindGameObjectWithTag("Player1"); if (player1Object != null) { p1con = player1Object.GetComponent <Player1Controller>(); } if (p1con == null) { Debug.Log("Cannot find 'Player1Controller' script"); } anim = gameObject.GetComponent <Animator>(); rb = this.GetComponent(typeof(Rigidbody2D)) as Rigidbody2D; attackcol.enabled = false; attackcol2.enabled = false; attackcol3.enabled = false; }
private void OnTriggerEnter(Collider col) { if (col.gameObject.layer == 9) { Player1Controller P1 = col.gameObject.GetComponent <Player1Controller> (); P1.hp -= 25; if (P1.hp <= 0) { GameObject Cam = GameObject.Find("Main Camera"); AgentRespawn NewStat = Cam.gameObject.GetComponent <AgentRespawn> (); NewStat.Agent2InHP += 5; NewStat.Agent2dmg += 2; } } if (col.gameObject.tag == "Agent1") { Agent1Controller A1 = col.gameObject.GetComponent <Agent1Controller> (); A1.HP -= 25; } }
void invertPlayerEnd(GameObject player) { if (player.name == "Player 1") { Player1Controller p1cScript = player.GetComponent <Player1Controller> (); p1cScript.invertExtend -= 1; if (p1cScript.invertExtend <= 0) { p1cScript.invert = 1; } } else if (player.name == "Player 2") { Player2Controller p2cScript = player.GetComponent <Player2Controller> (); p2cScript.invertExtend -= 1; if (p2cScript.invertExtend <= 0) { p2cScript.invert = 1; } } }
protected override void OnCantMove <T>(T component) { //Declare hitPlayer and set it to equal the encountered component. Player1Controller hitPlayer = component as Player1Controller; //Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted. //hitPlayer.LoseFood(playerDamage); //Set the attack trigger of animator to trigger Enemy attack animation. //animator.SetTrigger("MuffinManAttack_Left"); //if (hitPlayer.collider.tag == "Player") { //animator.Play("MuffinManAttack_Left"); /// Attack Left //// /*if ((current.x >= target.x)) * { * animator.Play("MuffinManAttack_Left"); * } * //// Attack Right //// * else if ((current.x <= target.x)) * { * animator.SetTrigger("MuffinManAttack_Right"); * //Debug.Log(isAttackingRight); * } * /// Attack Up //// * else if ((current.y < 0) & (current.y == target.y)) * { * animator.Play("MuffinManAttack_Up"); * //Debug.Log(isAttackingUp); * } * /// Attack Down //// * else if ((current.y > 0) & (current.y == target.y)) * { * animator.Play("MuffinManAttack_Down"); * //Debug.Log(isAttackingDown); * } * * // }*/ }
void Start() { GameObject playerControllerObject = GameObject.FindWithTag("Player 1"); if (playerControllerObject != null) { player1Controller = playerControllerObject.GetComponent <Player1Controller>(); } if (player1Controller == null) { Debug.Log("Cannot find 'Player1Controller' script"); } playerControllerObject = GameObject.FindWithTag("Player 2"); if (playerControllerObject != null) { player2Controller = playerControllerObject.GetComponent <Player2Controller>(); } if (player2Controller == null) { Debug.Log("Cannot find 'Player1Controller' script"); } }
// Update is called once per frame void Update() { p1 = FindObjectOfType(typeof(Player1Controller)) as Player1Controller; p2 = FindObjectOfType(typeof(Player2Controller)) as Player2Controller; if (first == true && gm.town == true && p1 != null && p2 != null) { p1.canmove = false; p2.canmove = false; first = false; panel.gameObject.SetActive(true); one.gameObject.SetActive(true); } if (Input.GetKeyDown(KeyCode.Space)) { if (count <= 6) { if (gm.town == true) { //p1.canmove = false; switch (count) { case 0: one.gameObject.SetActive(false); two.gameObject.SetActive(true); count += 1; break; case 1: two.gameObject.SetActive(false); three.gameObject.SetActive(true); count += 1; break; case 2: three.gameObject.SetActive(false); four.gameObject.SetActive(true); count += 1; break; case 3: four.gameObject.SetActive(false); five.gameObject.SetActive(true); count += 1; break; case 4: five.gameObject.SetActive(false); six.gameObject.SetActive(true); count += 1; break; case 5: six.gameObject.SetActive(false); seven.gameObject.SetActive(true); count += 1; break; case 6: seven.gameObject.SetActive(false); panel.gameObject.SetActive(false); p1.canmove = true; p2.canmove = true; count += 1; break; } } } } }
// Use this for initialization void Start () { player = FindObjectOfType<Player1Controller> (); }
// Use this for initialization void Start() { player = FindObjectOfType <Player1Controller> (); following = true; }
public void Awake() { botao = botao.GetComponent <Button> (); player1 = GetComponent <Player1Controller> (); player2 = GetComponent <Player2Controller> (); }
// Use this for initialization void Start () { player = FindObjectOfType<Player1Controller> (); following = true; }
private void Awake() { Instance = this; playerInput = GetComponent <PlayerInput>(); }
public void SetData(Player1Controller bc) { if (cardPosition == POSITION.DECK) { player1 = bc; ataque = properties.ataque; defesa = properties.defesa; SpriteRenderer img = (SpriteRenderer)transform.Find("Background").GetComponent("SpriteRenderer"); img.sprite = properties.card_back; img = (SpriteRenderer)transform.Find("Card Picture").GetComponent("SpriteRenderer"); img.enabled = false; img.sprite = properties.card_image; TextMesh txt = (TextMesh)transform.Find("Card Name").GetComponent("TextMesh"); txt.text = properties.card_name; txt.GetComponent<Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Description").GetComponent("TextMesh"); txt.text = properties.card_description.ToString(); txt.GetComponent<Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Command").GetComponent("TextMesh"); txt.text = properties.comando.ToString(); txt.GetComponent<Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Ataque").GetComponent("TextMesh"); txt.text = ataque.ToString(); txt.GetComponent<Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Defesa").GetComponent("TextMesh"); txt.text = defesa.ToString(); txt.GetComponent<Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Tipo").GetComponent("TextMesh"); txt.text = properties.card_tipo; txt.GetComponent<Renderer>().enabled = false; // Renderer borda = (Renderer)transform.Find("borda").GetComponent("Renderer"); // borda.GetComponent<Renderer>().enabled = false; } else if (cardPosition == POSITION.HAND) { player1 = bc; ataque = properties.ataque; defesa = properties.defesa; // Renderer borda = (Renderer)transform.Find("borda").GetComponent("Renderer"); // borda.GetComponent<Renderer>().enabled = true; SpriteRenderer img = (SpriteRenderer)transform.Find("Card Picture").GetComponent("SpriteRenderer"); img.enabled = true; img.sprite = properties.card_image; TextMesh txt = (TextMesh)transform.Find("Card Name").GetComponent("TextMesh"); txt.text = properties.card_name; txt.GetComponent<Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Description").GetComponent("TextMesh"); txt.text = properties.card_description.ToString(); txt.GetComponent<Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Command").GetComponent("TextMesh"); txt.text = properties.comando.ToString(); txt.GetComponent<Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Ataque").GetComponent("TextMesh"); txt.text = ataque.ToString(); txt.GetComponent<Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Defesa").GetComponent("TextMesh"); txt.text = defesa.ToString(); txt.GetComponent<Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Tipo").GetComponent("TextMesh"); txt.text = properties.card_tipo; txt.GetComponent<Renderer>().enabled = true; } }
// Use this for initialization void Start() { player = FindObjectOfType <Player1Controller> (); }
public void SetData(Player1Controller bc) { if (cardPosition == POSITION.DECK) { player1 = bc; ataque = properties.ataque; defesa = properties.defesa; SpriteRenderer img = (SpriteRenderer)transform.Find("Background").GetComponent("SpriteRenderer"); img.sprite = properties.card_back; img = (SpriteRenderer)transform.Find("Card Picture").GetComponent("SpriteRenderer"); img.enabled = false; img.sprite = properties.card_image; TextMesh txt = (TextMesh)transform.Find("Card Name").GetComponent("TextMesh"); txt.text = properties.card_name; txt.GetComponent <Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Description").GetComponent("TextMesh"); txt.text = properties.card_description.ToString(); txt.GetComponent <Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Command").GetComponent("TextMesh"); txt.text = properties.comando.ToString(); txt.GetComponent <Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Ataque").GetComponent("TextMesh"); txt.text = ataque.ToString(); txt.GetComponent <Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Defesa").GetComponent("TextMesh"); txt.text = defesa.ToString(); txt.GetComponent <Renderer>().enabled = false; txt = (TextMesh)transform.Find("Card Tipo").GetComponent("TextMesh"); txt.text = properties.card_tipo; txt.GetComponent <Renderer>().enabled = false; // Renderer borda = (Renderer)transform.Find("borda").GetComponent("Renderer"); // borda.GetComponent<Renderer>().enabled = false; } else if (cardPosition == POSITION.HAND) { player1 = bc; ataque = properties.ataque; defesa = properties.defesa; // Renderer borda = (Renderer)transform.Find("borda").GetComponent("Renderer"); // borda.GetComponent<Renderer>().enabled = true; SpriteRenderer img = (SpriteRenderer)transform.Find("Card Picture").GetComponent("SpriteRenderer"); img.enabled = true; img.sprite = properties.card_image; TextMesh txt = (TextMesh)transform.Find("Card Name").GetComponent("TextMesh"); txt.text = properties.card_name; txt.GetComponent <Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Description").GetComponent("TextMesh"); txt.text = properties.card_description.ToString(); txt.GetComponent <Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Command").GetComponent("TextMesh"); txt.text = properties.comando.ToString(); txt.GetComponent <Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Ataque").GetComponent("TextMesh"); txt.text = ataque.ToString(); txt.GetComponent <Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Defesa").GetComponent("TextMesh"); txt.text = defesa.ToString(); txt.GetComponent <Renderer>().enabled = true; txt = (TextMesh)transform.Find("Card Tipo").GetComponent("TextMesh"); txt.text = properties.card_tipo; txt.GetComponent <Renderer>().enabled = true; } }