void Awake() { groundScript = GameObject.Find("GroundTriggerCollider").GetComponent <GroundScript> (); highScoreText = GameObject.Find("highScoreText").GetComponent <LeaderBoardScript> (); // PreLoad PlayerPrefs to cut down loadtime when checking the HighScore. highScoreText.LeaderBoard(); }
void OnCollisionEnter2D(Collision2D target) { // Get Standing Groud Type GroundScript groundScriptComponent = target.gameObject.GetComponent <GroundScript>(); standingGroundType = groundScriptComponent.groundType; rigidBody2DComponent.velocity = Vector2.zero; currentPlayerState = PlayerState.Standing; transform.SetParent(target.gameObject.transform); GetPreviousPositionOfParent(); if (initialCollide == false) { if (groundScriptComponent.GetStepped() == false) { groundScriptComponent.Stepped(); GameObject.Find("_ScoreManager").GetComponent <ScoreManagerScript>().AddScore(); } GameObject.Find("_AudioManager").GetComponent <AudioManagerScript>().PlayCoinSound(); StartCoroutine(target.gameObject.GetComponent <GroundScript>().LandingEffect()); GameObject landingEffect = Instantiate(landingEffectPrefab, transform.position, Quaternion.identity); Destroy(landingEffect, 0.1f); } else { initialCollide = false; } }
public void ResetMap() { ground = GameObject.Find("ground"); groundScript = ground.GetComponent <GroundScript>(); groundScript.GenerateSprite(); groundScript.UpdateCollider(); }
public BlockType CheckType() { if (Physics.Raycast(transform.GetChild(0).position, transform.GetChild(0).TransformDirection(Vector3.down), out groundBlock, layerMask)) { GroundScript ground = groundBlock.collider.GetComponentInParent <GroundScript>(); return(ground.GetType()); } return(BlockType.Regular); }
public bool CheckSocket() { if (Physics.Raycast(transform.GetChild(0).position, transform.GetChild(0).TransformDirection(Vector3.down), out groundBlock, layerMask)) { GroundScript ground = groundBlock.collider.GetComponentInParent <GroundScript>(); return(ground.freeSocket); } return(false); }
public void Revive() { // Time.timeScale = 1f; newGround = groundHolder.transform.GetChild(0).gameObject; newGroundScript = newGround.GetComponent <GroundScript>(); newGroundScript.velocity /= 2; newGroundScript.Stepped(); player.transform.position = new Vector3(newGround.transform.position.x, newGround.transform.position.y + 1, newGround.transform.position.z); player.GetComponent <JumpShootPlayerScript>().RevivePlayer(); }
private void OnTriggerExit2D(Collider2D collision) { GroundScript ground = collision.GetComponent <GroundScript>(); if (ground) { prevGround = ground; SpawnGround(); } }
private void SpawnGround() { if (prevGround != null) { GroundScript newGround = Instantiate(groundRef); newGround.gameObject.SetActive(true); prevGround.SetNextGround(newGround.gameObject); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); GroundScript ground = (GroundScript)target; if (GUILayout.Button("Generate Meshes")) { ground.CreateMesh(); } }
public void Revive() { audioManager.StopDeadSound(); backgroundMusic.Play(); Time.timeScale = 1f; newGround = groundHolder.transform.GetChild(0).gameObject; newGroundScript = newGround.GetComponent <GroundScript>(); newGroundScript.velocity = 0; player.transform.position = new Vector3(newGround.transform.position.x, newGround.transform.position.y + 1, newGround.transform.position.z); player.GetComponent <PlayerScript>().RevivePlayer(); }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag("player").transform; heightAchievs = 100f; gameover = false; groundScript = ground.GetComponent <GroundScript>(); platforms = new ObjectPoolerScript[poolers.Length]; GroundRisingText.enabled = false; for (int i = 0; i < poolers.Length; ++i) { platforms[i] = poolers[i].GetComponent <ObjectPoolerScript>(); } }
public void SetSocket(bool freeSocket) { GroundScript ground = groundBlock.collider.GetComponentInParent <GroundScript>(); if (freeSocket) { ground.freeSocket = true; } if (!freeSocket) { ground.freeSocket = false; } }
void Start() { groundScript = GameObject.Find("GroundTriggerCollider").GetComponent <GroundScript> (); scoreText = GameObject.Find("score").GetComponent <ScoreTextScript> (); spawnObject = GameObject.Find("Spawner").GetComponent <SpawnerScript> (); rayCasterScript = gameObject.GetComponent <RayCastScript> (); gameManager = GameObject.Find("GameManager").GetComponent <GameManagerScript> (); scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreManager> (); cam1 = GameObject.Find("MainCamera").GetComponent <Camera>(); cam2 = GameObject.Find("SecondCamera").GetComponent <Camera>(); // leaderBoardScript = GameObject.Find ("LeaderBoard").GetComponent<LeaderBoardScript> (); }
private void Awake() { WallScript wall = GetComponent <WallScript>(); LayerMask layerMask = 1 << LayerMask.NameToLayer("Ground"); RaycastHit groundBlock; if (Physics.Raycast(actualTransform.transform.position, actualTransform.TransformDirection(Vector3.down), out groundBlock, layerMask)) { GroundScript ground = groundBlock.collider.GetComponentInParent <GroundScript>(); ground.type = wall.type; ground.freeSocket = false; } }
void OnCollisionEnter2D(Collision2D target) { GroundScript groundScriptComponent = target.gameObject.GetComponent <GroundScript>(); if (groundScriptComponent == null) { return; } if (transform.position.y <= target.transform.position.y + 1) { return; } SetPositionIntoParentBound(target.transform); // Get Standing Groud Type standingGroundType = groundScriptComponent.groundType; rigidBody2DComponent.velocity = Vector2.zero; rigidBody2DComponent.gravityScale = 0; currentPlayerState = PlayerState.Standing; animatorComponent.SetBool("Jumping", false); transform.SetParent(target.gameObject.transform); GetPreviousPositionOfParent(); if (initialCollide == false) { if (groundScriptComponent.GetStepped() == false) { // if (groundScriptComponent.groundType == GroundScript.GroundType.Shoe) { jsGM.AddScore(true); Destroy(groundScriptComponent.transform.GetChild(0).gameObject); } // if (groundScriptComponent.groundType == GroundScript.GroundType.Shoe) { jsGM.AddScore(true); } // else jsGM.AddScore(); jsGM.AddScore(); groundScriptComponent.Stepped(); GameObject landingEffect = Instantiate(landingEffectPrefab, transform.position, Quaternion.identity); Destroy(landingEffect, 0.2f); // play circle burst landingEffectPrefab2.Play(); } StartCoroutine(target.gameObject.GetComponent <GroundScript>().LandingEffect()); } else { initialCollide = false; } }
public void SelectGround(RaycastHit hit) { if (isHeroSelected) { isHeroSelected = false; GroundScript gs = hit.transform.GetComponent <GroundScript>(); //Debug.Log("Ground Hit index " + gs.xGridIndex + " " + gs.yGridIndex); int x = gs.xGridIndex; int y = gs.yGridIndex; if (selectedHero.IsGroundHighlighted(x, y)) { selectedHero.MoveToSelectedTile(x, y); } selectedHero.OnDeselect(); } else { if (selectedHero != null) { selectedHero.OnDeselect(); } } }
private void Awake() { Instance = this; NMSurface = GetComponent <NavMeshSurface>(); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); gs = FindObjectOfType <GroundScript>(); remainingCharges = Charges; }