public void EnterAVGMode(string binid) { GetComponent <AvgEngine>().Open(binid); GetComponent <AvgEngine>().enabled = true; GetComponent <AvgEngineInput>().enabled = true; enabled = false; //GetComponent<hp_gauge>().enabled = false; m_Character.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); m_Character.Move(0, false, false, true); }
private void OnCollisionEnter2D(Collision2D other) { PlatformerCharacter2D player = other.collider.GetComponent <PlatformerCharacter2D>(); if (GetComponent <Spell_2>().numberOfPlayer != player.GetComponent <PlatformerCharacter2D>().numberOfPlayer) { player.take_HP(demage); } if (GetComponent <Spell_2>().numberOfPlayer == player.GetComponent <PlatformerCharacter2D>().numberOfPlayer) { Physics2D.IgnoreCollision(other.collider, GetComponent <Collider2D>(), true); } }
void Reset(PlatformerCharacter2D aPlayer) // Set all the stats back to default values { if (ChangeGravity) { aPlayer.ResetGravityMultiplier(); } if (ChangeJumpforce) { aPlayer.ResetJumpforceMultipler(); } if (ChangeSpeed) { aPlayer.ResetMovementMultiplier(); } if (ChangeMaxFallSpeed) { aPlayer.ResetMaxFallSpeed(); } if (ChangeMaxNumberOfExtraJumps) { aPlayer.Reset_MultiJump(); } if (autoFire && aPlayer.GetComponent <Shooting>() != null) { aPlayer.GetComponent <Shooting>().AutoFire = false; } if (infinityJump) { aPlayer.infinityJump = false; } if (RefreshMultiJumpOnExit) { aPlayer.Refresh_MultiJump(); } if (OneTimeActivate) { gameObject.SetActive(true); } gameObject.SetActive(false); gameObject.SetActive(true); }
// void OnLevelWasLoaded(int level) // { // // } void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == ("Player") && other.gameObject.GetComponent <PlatformerCharacter2D> () != null) // If player hits the collider, then change its stats { GuysScript = other.gameObject.GetComponent <PlatformerCharacter2D> (); if (ChangeGravity) { GuysScript.gravityMultiplier = gravityMultiplier; } if (ChangeJumpforce) { GuysScript.jumpforceMultiplier = jumpforceMultiplier; } if (ChangeSpeed) { GuysScript.movementMultiplier = speedMultiplier; } if (ChangeMaxFallSpeed) { GuysScript.maxFallSpeed = newMaxFallSpeed; } if (ChangeMaxNumberOfExtraJumps) { GuysScript.Set_MultiJumps(newMaxNumberOfExtraJumps); } if (autoFire && GuysScript.GetComponent <Shooting>() != null) { GuysScript.GetComponent <Shooting>().AutoFire = true; } if (infinityJump) { GuysScript.infinityJump = true; } if (OneTimeActivate) { gameObject.SetActive(false); } numberOfTriggered++; } }
//update the wind objects void UpdateWind() { bool reducedGravity = false; //reduce player gravity if wind is up if (IsWindyUp()) { playerObj.GetComponent <Rigidbody2D> ().gravityScale = 1; reducedGravity = true; } //reset wind force totalWindForce = Vector3.zero; //maintain wind durations for each wind force for (int i = 0; i < windObjList.Count; i++) { //update wind object windObjList [i].ManuallyUpdate(); //remove wind vector if wind speed drops if (windObjList [i].IsCompleted()) { Destroy(windObjList [i]); windObjList.RemoveAt(i); //fix gravity if needbe if (reducedGravity && !IsWindyUp()) { playerObj.GetComponent <Rigidbody2D> ().gravityScale = 3; } } totalWindForce += windObjList [i].CalcForce(); } //apply wind to all of the objects that it can affect playerObj.transform.position += windMod * totalWindForce; //apply wind totalWindForce necessary interactableObjects objects for (int i = 0; i < interactableObjects.Count; i++) { //only apply wind to objects within designated range if (WithinRange(windRange, playerObj.GetComponent <BoxCollider2D>(), interactableObjects[i].GetComponent <BoxCollider2D>())) { interactableObjects [i].transform.position += windMod * totalWindForce; } } }
// Use this for initialization protected override void Awake() { base.Awake(); m_player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlatformerCharacter2D>(); m_playerRigidBody2D = m_player.GetComponent <Rigidbody2D>(); sightline = m_Rigidbody2D.transform.FindChild("Sightline").transform; }
public IEnumerator RespawnPlayerCoroutine() { player.transform.position = CheckPoint.transform.position; player.enabled = false; player.GetComponent <Renderer> ().enabled = false; player.GetComponent <BoxCollider2D> ().enabled = false; camera.isFollowing = false; Collectables.AddPoints(-penalty); yield return(new WaitForSeconds(2)); Application.LoadLevel(GameOver); //Debug.Log ("Player Respawn"); //yield return new WaitForSeconds (RespawnDelay); //player.transform.position = CheckPoint.transform.position; //player.enabled = true; //player.GetComponent<Renderer> ().enabled = true; //player.GetComponent<BoxCollider2D> ().enabled = true; //camera.isFollowing = true; }
// Use this for initialization public void Start() { if (Thanks.enabled) { Thanks.enabled = false; } m_Character = GameObject.FindGameObjectWithTag("Player").GetComponent <PlatformerCharacter2D>(); m_Rigidbody2D = m_Character.GetComponent <Rigidbody2D>(); }
void Update() { // Rotate the vision cone if the game isn't paused if (Time.timeScale > 0) { Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); Vector3 dir = Input.mousePosition - pos; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); if (Math.Abs(angle) > 90) { if (playerScript.m_FacingRight) { playerScript.Flip(); } } else { if (!playerScript.m_FacingRight) { playerScript.Flip(); } } // Powerups pickup if (powerUp != null) { powerupCooldown += Time.deltaTime; //print(powerupCooldown); if (powerupCooldown >= powerUpPickupTime) { powerUp.GetComponent <PowerUp>().Collect(this.transform.parent.gameObject); powerUp = null; powerupCooldown = 0; } } // Antag lost if (!AntagFocused) { antagLostCooldown += Time.deltaTime; if (antagLostCooldown >= targetLostMaxTime) { playerScript.GetComponent <PlayerScript>().Die("You lost track of your target for too long."); } } else { antagLostCooldown = 0; } } }
// Update is called once per frame void Update() { if (m_waitnpc) { if (pause) { if (CrossPlatformInputManager.GetButtonDown("B")) { if (player_name == "milk") { milk.GetComponent <Platformer2DUserControl>().SetPause(false); } else { milk.GetComponent <Platformer2DUserControlMoon>().SetPause(false); } pause = false; farm_menu.SetActive(false); } } else { if (CrossPlatformInputManager.GetButtonDown("up")) { if (player_name == "milk") { milk.GetComponent <Platformer2DUserControl>().SetPause(true); } else { milk.GetComponent <Platformer2DUserControlMoon>().SetPause(true); } pause = true; PlayerPrefs.SetInt("SaveFlag", 1); farm_menu.SetActive(true); } } } }
public virtual void Start() { Object[] objects = FindObjectsOfType <PlatformerCharacter2D>(); foreach (Object obj in objects) { PlatformerCharacter2D gObj = obj as PlatformerCharacter2D; if (gObj.netId == ownerNetworkId) { transform.SetParent(gObj.transform); bPlayer = gObj.GetComponent <BasePlayer>(); } } bPlayer = transform.GetComponentInParent <BasePlayer>(); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == ("Platform")) // objiekt jest usównay w przypadku dotkniećia z ikoljaderem trtypu platforma { Destroy(gameObject); } else if (other.tag == ("Player")) // w przypadku doknięcia playera spell _1 ma zabierać HP & być uówany. { PlatformerCharacter2D player = other.GetComponent <PlatformerCharacter2D>(); if (GetComponent <Spell_1>().numberOfPlayer != player.GetComponent <PlatformerCharacter2D>().numberOfPlayer) { player.take_HP(demage); Destroy(gameObject); } } }
private void Update() { if (isMovementEnabled) { if (!jump) { // Read the jump input in Update so button presses aren't missed. jump = CrossPlatformInputManager.GetButtonDown("Jump"); } } else { character.GetComponent <Rigidbody2D> ().velocity = Vector3.zero; character.anim.SetFloat("Speed", 0); } }
public override void HeavyAttack() { base.HeavyAttack(); _player.GetComponent <Inventory>().HasShield = false; GameObject thrown = Instantiate(thrownShield, _player.transform.position, Quaternion.identity) as GameObject; if (_player.FacingRight) { thrown.GetComponent <ThrownShield>().ThrowShield(new Vector2(1, 0)); } else { thrown.GetComponent <ThrownShield>().ThrowShield(new Vector2(-1, 0)); } transform.parent = null; _held = false; _collider.enabled = true; Destroy(gameObject); }
// Update is called once per frame void Update() { switch (state) { //main menu default: case 1: break; //game over case 2: break; //pause case 3: if (Input.GetKeyDown(KeyCode.Escape)) { pause = !pause; pausePanel.SetActive(pause); TogglePauseplayerObj(pause); ToggleBlockPause(pause); state = prevState; prevState = 3; } break; //bone menus case 4: break; //next level case 5: break; //win case 6: break; //level 1 case 7: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("level1", 7); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; state = 5; nextPanel.SetActive(true); TogglePauseplayerObj(true); ToggleBlockPause(true); } break; //level 2 case 8: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("level2", 8); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; state = 5; nextPanel.SetActive(true); TogglePauseplayerObj(true); ToggleBlockPause(true); } break; //level 3 case 9: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("level3", 9); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; state = 5; nextPanel.SetActive(true); TogglePauseplayerObj(true); ToggleBlockPause(true); } break; //level 4 case 10: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("level4", 10); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; LoadScene("win", 6); } break; //sandbox and test level case 20: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("sandbox", 20); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; state = 5; nextPanel.SetActive(true); TogglePauseplayerObj(true); ToggleBlockPause(true); } break; case 21: UpdateLevel(); if (Input.GetKeyDown(KeyCode.R)) { LoadScene("testlevel", 21); } if (playerObj.GetComponent <Rigidbody2D> ().IsTouching(goalObj.GetComponent <BoxCollider2D> ())) { prevState = state; state = 5; nextPanel.SetActive(true); TogglePauseplayerObj(true); ToggleBlockPause(true); } break; } }
// Use this for initialization protected override void Awake() { base.Awake(); m_player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlatformerCharacter2D>(); m_playerRigidBody2D = m_player.GetComponent<Rigidbody2D>(); sightline = m_Rigidbody2D.transform.FindChild("Sightline").transform; }