public void OnCollisionEnter(Collision col) { GameObject collidedGameObject = col.gameObject; Debug.Log(collidedGameObject.tag); if ("Balloon" == collidedGameObject.tag) { BalloonController balloonController = collidedGameObject.GetComponent <BalloonController>(); if (null != balloonController) { float balloonCharge = balloonController.GetCharge(); // Move charge from Grounder to balloon. The moving charge is the amount // to make the balloon charge negative. // For simplicity the balloon charge will always be of the same magnitude and only // changes its sign (+/-). Debug.Log("Before" + this.ChargeStrength); this.ChargeStrength += (2f * Mathf.Abs(balloonCharge)); Debug.Log("After" + this.ChargeStrength); this.UpdateGlow(); // invert charge of balloon (set it to negative) balloonController.SetCharge(-1f * Mathf.Abs(balloonCharge)); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Player") && !cut) { cut = true; if (repellant.activeInHierarchy) { foreach (Transform child in gameObject.transform.GetChild(0).GetComponentInChildren <Transform>()) { Debug.Log(child.gameObject.name); Rigidbody kidRigid = child.gameObject.AddComponent <Rigidbody>(); Vector3 vec = new Vector3(Random.Range(-9f, 9f), Random.Range(5f, 12f)); Vector3 rot = new Vector3(Random.Range(-30f, 30f), Random.Range(30f, 30f), Random.Range(-75f, 75f)); kidRigid.velocity = vec; kidRigid.SetDensity(0); kidRigid.drag = 0.2f; kidRigid.AddTorque(rot); } } else { UIController.instance.laundry = true; pants.SetActive(false); shirt.SetActive(false); BalloonController balloon = other.gameObject.transform.root.gameObject.GetComponent <BalloonController>(); balloon.setgrav(0.07f); balloon.forceModel(heavyballoon); } } }
private void OnTriggerEnter(Collider other) { CameraBound bound = other.GetComponent <CameraBound>(); if (bound != null) { CameraController.Instance.EnteredCameraBound(bound); } else if (other.gameObject.CompareTag("Balloon")) { Vector3 dir = other.transform.position - _transform.position; dir.Normalize(); float dot = Vector3.Dot(dir, visual.forward); var speed = _rigidbody.velocity.magnitude; BalloonController balloon = other.GetComponent <BalloonController>(); if (balloon && dot > balloon.PopCoefficient && speed > balloon.RequiredSpeed) { balloon.Pop(); } else { _rigidbody.AddForce(dir * -PopForceBurst, ForceMode.Impulse); } } Collectible collectible = other.GetComponent <Collectible>(); if (collectible != null) { collectible.Pop(); } }
// don't do this anymore. can do it by making the balloons in matlab instead. IEnumerator StepPopulate() { // here we just make an array of angles and ask for new balloons at each string theColor = "red"; bool theMode = true; // restoreOnly or not? for (float angle = 0f; angle < 360f; angle += 1.0f) // be careful of the sphere collider! // NewBalloon() does the actual instantiation, etc. { BalloonController myBalloon = NewBalloon( angle, "Balloon_" + ((int)angle).ToString(), theMode, theColor); if (angle == 0) { myBalloon.SetColor(Color.green); } // else // myBalloon.SetColor(Color.Lerp (Color.red, Color.blue, pointNum)); yield return(new WaitForSeconds(0.0f)); } // keeps radius on both axes the same if circular if (isCircular) { radiusY = radiusX; } //sndAppear.Play (); }
public void OnCollisionEnter(Collision col) { GameObject collidedGameObject = col.gameObject; if (collidedGameObject.tag != "Untagged") { Debug.Log(collidedGameObject.tag); } if ("Balloon" == collidedGameObject.tag) { BalloonController balloonController = collidedGameObject.GetComponent <BalloonController>(); if (null != balloonController) { float balloonCharge = balloonController.GetCharge(); // Move charge from balloon to VdG. The moving charge is the amount // to make the balloon charge positive. // For simplicity the balloon charge will always be of the same magnitude and only // changes its sign (+/-). this.ChargeStrength -= (2f * Mathf.Abs(balloonCharge)); // invert charge of balloon (set it to positive) balloonController.SetCharge(Mathf.Abs(balloonCharge)); } } }
void initializeTarget(GameObject spawned, GameStateManager gameManager, int x, int y) { motionStartDelay += currentLevel.motionDelay; BalloonController bc = spawned.GetComponent <BalloonController>(); bc.initializeMovementStrategy(currentLevel, player, x, y, motionStartDelay); bc.setGameManager(gameManager); }
public void RemoveBalloonAfterDelay(BalloonController balloon, float delay) { WaitUntil.Seconds(delay, delegate() { if (balloon != null) { balloon.Pop(); } }); }
// Start is called before the first frame update void Start() { isDead = false; anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); goldSound = GetComponent <AudioSource>(); balloonController = FindObjectOfType <BalloonController>(); }
// Use this for initialization void Start() { BobCat = Daddy.GetComponent <BalloonController>(); active = BobCat.getShield(); if (!active) { MyShield.SetActive(false); } }
public bool RequestToLandForBalloon(BalloonController balloon) { if (IsOccupiedForBalloon) { return(false); } balloon.SetLandingPoint(LandingPointForBalloon); IsOccupiedForBalloon = true; return(true); }
public override void SafeAwake() { balloonController = GetComponent <BalloonController>(); SpeedSlider = balloonController.BuoyancySlider; base.SafeAwake(); #if DEBUG ConsoleController.ShowMessage("气球添加进阶属性"); #endif }
public void OnCollisionEnter2D(Collision2D collision) { BalloonController balloonController = collision.gameObject.GetComponent <BalloonController>(); if (balloonController != null) { balloonController.Pop(); OnDestroy(); } }
// Start is called before the first frame update void Start() { base.Setup(); m_balloonController = m_balloonController == null?GetComponentInParent <BalloonController>() : m_balloonController; if (m_balloonController != null && m_balloonRigidbody == null) { if (m_balloonController.m_balloonLocomotion != null) { m_balloonRigidbody = m_balloonRigidbody == null ? m_balloonController.m_balloonLocomotion.m_rigidbody2D : m_balloonRigidbody; } } }
public override void SafeAwake() { effectKey = AddKey("Effect", "Effect", UnityEngine.KeyCode.E); toggleToggle = AddToggle("Toggle", "Toggle", true); dragTogetherToggle = AddToggle("drag together", "together", true); balloonController = GetComponent <BalloonController>(); SpeedSlider = balloonController.BuoyancySlider; base.SafeAwake(); #if DEBUG ConsoleController.ShowMessage("气球添加进阶属性"); #endif }
// Start is called before the first frame update void Start() { startY = transform.localPosition.y; maxY = startY - 0.25f; handleGameObject = transform.Find("hori").gameObject; balloon = GetComponentInParent <BalloonController>(); var leftHandedControllers = new List <UnityEngine.XR.InputDevice>(); var desiredCharacteristics = UnityEngine.XR.InputDeviceCharacteristics.HeldInHand | UnityEngine.XR.InputDeviceCharacteristics.Left | UnityEngine.XR.InputDeviceCharacteristics.Controller; UnityEngine.XR.InputDevices.GetDevicesWithCharacteristics(desiredCharacteristics, leftHandedControllers); if (leftHandedControllers.Count > 0) { leftController = leftHandedControllers[0]; leftControllerGO = GameObject.Find("LeftController"); } }
// Set up initial UI components private void SetupUIComponents() { // タイマー TimerText = GameObject.Find("Timer"); TimerUI = GameObject.Find("TimerIcon"); if (TimerUI != null) { TimerUI.GetComponent <TimerUiController>(); } // バルーン数 BalloonCountText = GameObject.Find("BalloonCount"); if (BalloonCountText != null) { BalloonCountText.GetComponent <Text>().text = (BalloonCounter - DestroyedBalloonCount).ToString("F0") + "/" + BalloonCounter; } // 投げ数 ThrowCountText = GameObject.Find("ThrowCount"); if (ThrowCountText != null) { ThrowCountText.GetComponent <Text>().text = ThrowCounter.ToString("F0") + "/" + stage.ShootingLimit; } // ゲームモード gameMode = GameObject.Find("ModeSwitcher").GetComponent <GameModeController>(); // 画面遷移用 LoadBalGen = GameObject.Find("LoadingBalloonGenerator"); // 説明文 DescriptionUI.gameObject.SetActive(false); // バルーンコントローラー balloonController = GameObject.Find("BalloonController").GetComponent <BalloonController>(); // アイテムジェネレーター itemGenerator = GameObject.Find("ItemGenerator").GetComponent <ItemGenerator>(); // やりこみモード if (stage.GameClearCondition == Stage.ClearCondition.Yarikomi) { // やりこみモードでは、通常のヘッダー要素は使わない var header = GameObject.Find("Header"); if (header != null) { header.SetActive(false); } // 専用ヘッダーをアクティブにする YarikomiHeader.SetActive(true); } }
public void BuyShield(Text text) { BalloonController bg = UIController.instance.player.GetComponent <BalloonController>(); if (bg.hasShield) { Debug.Log("You already have a f*****g shield"); } else if (UIController.instance.GetCoins() >= 5 || IamTesting) { UIController.instance.SpendCoins(5); bg.setShield(true); Debug.Log("Shield is here? " + bg.hasShield + " " + bg.getShield()); text.text = "BOUGHT!"; //Disable the button Button button = text.GetComponentInChildren <Button>(); button.GetComponent <Button>().interactable = false; } GotMoney(); }
/*Player has died*/ public void GameOver(string deathReason) { if (dead) { return; } BalloonController bs = player.GetComponent <BalloonController>(); if (bs.getShield()) { Debug.Log("Shield saved you"); bs.setShield(false); bs.SafeTime = 4; return; } dead = true; _coins += _tempCoins; _gameOverScript.GameOver(deathReason); save(); runs++; }
public void Repopulate() { // this is from fancyPopulate GetComponent <AudioSource> ().Play(); // was sndAppear.Play (); // here we just make an array of angles and ask for new balloons at each string theColor = "red"; bool theMode = true; // restoreOnly or not? for (float angle = 0f; angle < 360f; angle += 1.0f) // be careful of the sphere collider! // NewBalloon() does the actual instantiation, etc. { BalloonController myBalloon = NewBalloon( angle, "Balloon_" + ((int)angle).ToString(), theMode, theColor); // do this from matlab if you really want to: // if (angle == 0) // myBalloon.SetColor (Color.green); } }
void Start() { Dad = transform.parent.gameObject.GetComponent <BalloonController>(); rig = transform.parent.gameObject.GetComponent <Rigidbody2D>(); active = false; }
/**<summary> * GunConsistent is the functionality for the gust hazard. A very simple switch statement that changes the direction of a * capsule cast. The capsule cast only interacts with the balloon and pushes it based on the gust strength. * GustSourceWithDelay.cs uses this function to do the same thing * </summary> */ protected void GustConsistent() { switch (m_facing) { case Direction.LEFT: if (results = Physics2D.CapsuleCast(transform.position, new Vector2(capsuleSize, capsuleSize), CapsuleDirection2D.Horizontal, 0, Vector2.left, Mathf.Infinity, layerFilter)) { if (results.transform.GetComponentInChildren <BalloonController>()) { BalloonController controller = results.transform.GetComponentInChildren <BalloonController>(); controller.m_balloonLocomotion.MoveBalloon(Vector2.left * gustStrength); Debug.Log(results.collider); } } Debug.DrawLine(transform.position, transform.position - new Vector3(3, 0, 0), Color.red); break; case Direction.UP: if (results = Physics2D.CapsuleCast(transform.position, new Vector2(capsuleSize, capsuleSize), CapsuleDirection2D.Vertical, 0, Vector2.up, Mathf.Infinity, layerFilter)) { if (results.transform.GetComponentInChildren <BalloonController>()) { BalloonController controller = results.transform.GetComponentInChildren <BalloonController>(); controller.m_balloonLocomotion.MoveBalloon(Vector2.up * gustStrength); Debug.Log(results.collider); } } Debug.DrawLine(transform.position, transform.position + new Vector3(0, 3, 0), Color.red); break; case Direction.DOWN: if (results = Physics2D.CapsuleCast(transform.position, new Vector2(capsuleSize, capsuleSize), CapsuleDirection2D.Vertical, 0, Vector2.down, Mathf.Infinity, layerFilter)) { if (results.transform.GetComponentInChildren <BalloonController>()) { BalloonController controller = results.transform.GetComponentInChildren <BalloonController>(); controller.m_balloonLocomotion.MoveBalloon(Vector2.down * gustStrength); Debug.Log(results.collider); } } Debug.DrawLine(transform.position, transform.position - new Vector3(0, 3, 0), Color.red); break; case Direction.RIGHT: if (results = Physics2D.CapsuleCast(transform.position, new Vector2(capsuleSize, capsuleSize), CapsuleDirection2D.Vertical, 0, Vector2.right, Mathf.Infinity, layerFilter)) { if (results.transform.GetComponentInChildren <BalloonController>()) { BalloonController controller = results.transform.GetComponentInChildren <BalloonController>(); controller.m_balloonLocomotion.MoveBalloon(Vector2.right * gustStrength); Debug.Log(results.collider); } } Debug.DrawLine(transform.position, transform.position + new Vector3(3, 0, 0), Color.red); break; default: Debug.DrawLine(transform.position, transform.position + new Vector3(3, 0, 0), Color.red); break; } }
void Start() { balloonController = transform.parent.parent.GetComponent <BalloonController>(); }
private void Awake() { instance = this; msg = "Consuming GDS has left you terribly ill."; }
private void Start() { _lineRenderer = GetComponent <LineRenderer>(); _balloon = FindObjectOfType <BalloonController>(); _anchor = FindObjectOfType <AnchorController>(); }
// Update is called once per frame void Update() { if (timeTillSpawn <= 0) { newPosition.x = transform.position.x; //Middle 3 //High 15 //Low -9 int r = Random.Range(0, 3); //0,1,2 if (r == 0) //Middle Gap { newPosition.y = -9; Instantiate(spike, newPosition, Quaternion.identity); newPosition.y = 15; Instantiate(spike2, newPosition, Quaternion.identity); } else if (r == 1) //Top Gap { newPosition.y = -9; Instantiate(spike, newPosition, Quaternion.identity); newPosition.y = 3; Instantiate(spike2, newPosition, Quaternion.identity); } else if (r == 2)//Bot Gap { newPosition.y = 15; Instantiate(spike, newPosition, Quaternion.identity); newPosition.y = 3; Instantiate(spike2, newPosition, Quaternion.identity); } else { ///Hacks. timeBetweenSpawns = 0; } //////////////////////////////////// timeTillSpawn = timeBetweenSpawns; if (timeBetweenSpawns > quickestSpawn) { timeBetweenSpawns -= speedUpBy; } if (timeBetweenSpawns < 5 && timeBetweenSpawns > 4) { //What you want a medal? BalloonController.setMsg("Well what did you really expect anyway?"); } if (timeBetweenSpawns < 4.5) { //Ok, We're impressed. BalloonController.setMsg("[Esc] While you still can."); //This is where the next transition key would be. } if (timeBetweenSpawns < 4) { //OMG, stop already, it's not that interesting. BalloonController.setMsg("You win, I suppose... {Press [Esc] or [r] or [q]}"); } } else { timeTillSpawn -= Time.deltaTime; } }
void Start() { StartCoroutine(nameof(SpawnCoroutine)); _balloonController = FindObjectOfType <BalloonController>(); _lastTakenTime = -1000; }
private void Update() { msgText.text = BalloonController.getMsg(); }