void Start() { //may need to do this not in awake bc gm's awake is where cloneplane is set up and //it needs to exist by now for this to work shoeFalling = false; transform.parent = GameMgr.instance.clonePlane.transform; //hopework transform.position = new Vector2(transform.parent.position.x + ShoeOffsetX, transform.parent.position.y + ShoeOffsetY); parentScript = (PlaneScript)GetComponentInParent(typeof(PlaneScript)); //print ("DEBUG: shoe parent script is named " + parentScript.name); //print ("DEBUG: parent transform after doing parent thing is " + transform.parent.position.x + ", " + transform.parent.position.y); //print ("DEBUG: shoe transform after doing parent thing is " + transform.position.x + ", " + transform.position.y); //HOW DO I GET FIRE BUTTON BOUNDS? Fish it out of gm script, I guess //this is so gross #if (UNITY_ANDROID || UNITY_IPHONE) foreach (GameObject rootobjy in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()) { if (rootobjy.name == "GM") { GameMgr gmgr = (GameMgr)rootobjy.GetComponent(typeof(GameMgr)); fireCollider = gmgr.fireCollider; break; } } #endif }
public void OnTriggerEnter(Collider collider) { print(collider.name + " " + gameObject.name); if (collider.name == "Player1" || collider.name == "Player2") { switch (gameObject.name) { case "Trees": PlaneScript.StartPlayer2(); break; case "Plane": PlaneScript.SpawnBranch(); break; case "TreeBranch": PlaneScript.GetBranch(); break; case "Player2Trigger": PlaneScript.ActivatePlayer2(); break; case "End": PlaneScript.EndLevel(); break; } } }
public void FireButtonClick() { if (!is_start) { is_start = true; plane = Instantiate(Bomber) as Transform; PlaneScript ps_ = plane.GetComponent <PlaneScript>(); ps_.PlaneOverScreen += Ps__PlaneOverScreen; ps_.OnPlaneDestroed += Ps__OnPlaneDestroed; shootCooldown = shootingRate; } else { if (CanAttack) { shootCooldown = shootingRate; var bomb = Instantiate(bombPrefub) as Transform; bomb.position = new Vector2(plane.position.x, plane.position.y - 0.7f); } // bomb.position = Samolet.position; } }
void Start() { planeScript = player.GetComponent <PlaneScript>(); poolScript = mainCamera.GetComponent <ObstaclePoolScript>(); bronzeUI.fillAmount = 0f; silverUI.fillAmount = 0f; goldUI.fillAmount = 0f; }
// Update is called once per frame void Update() { plane = ObserverScript.CheckPlaneToSphereCollision(this); ResolvePlaneCollision(); SphereScript sphere2 = ObserverScript.CheckSphereOnSphereCollisions(this); }
void Start() { this.gameObject.AddComponent <BoxCollider>(); Rigidbody body = this.gameObject.AddComponent <Rigidbody>(); body.useGravity = false; body.drag = Mathf.Infinity; body.angularDrag = Mathf.Infinity; referenceObject = GameObject.Find("Plane"); referenceScript = referenceObject.GetComponent <PlaneScript>(); this.size = referenceScript.getLimit(); transform.position = new Vector3(0.0f, size * 0.5f, 0.0f); transform.rotation = Quaternion.LookRotation(new Vector3(size, 0, size)); }
//Returns the plane that the passed in sphere is colliding with public static PlaneScript CheckPlaneToSphereCollision(SphereScript sphere) { float distanceFromCenterToPlane, d2; PlaneScript collidingPlane = new PlaneScript(); foreach (PlaneScript plane in planes) { distanceFromCenterToPlane = plane.DistanceTo(sphere.transform.position); d2 = distanceFromCenterToPlane - sphere.radius; if (d2 <= 0) { collidingPlane = plane; } } return(collidingPlane); }
private void Start() { GameObject player = GameObject.FindGameObjectWithTag("Player"); PlaneScript planeScript = player.GetComponent <PlaneScript>(); image = GetComponent <Image>(); if (planeScript.starsCollected >= minScoreBronze && planeScript.starsCollected < minScoreBronze) { image.sprite = bronzeMedal; } else if (planeScript.starsCollected >= minScoreSilver && planeScript.starsCollected < minScoreGold) { image.sprite = silverMedal; } else if (planeScript.starsCollected >= minScoreGold) { image.sprite = goldMedal; } }
public void addScore(int points) { //here add to the score - and check to see if the plane needs to speed up. int newscore = score + points; //this is gross. But wev. if (score < 20 && newscore >= 20) { PlaneScript planeScriptInstance = (PlaneScript)clonePlane.GetComponent(typeof(PlaneScript)); planeScriptInstance.SetSpeed(PlaneScript.planeSpeed20); } else if (score < 30 && newscore >= 30) { PlaneScript planeScriptInstance = (PlaneScript)clonePlane.GetComponent(typeof(PlaneScript)); planeScriptInstance.SetSpeed(PlaneScript.planeSpeed30); } score = newscore; //UPDATE DISPLAY counterScoreScriptInstance.SetValue(score); }
// Start is called before the first frame update void Start() { plane = FindObjectOfType <PlaneScript>(); }