// Use this for initialization IEnumerator Start() { StartCoroutine("SpawnHandler"); cachedEnemies = new List <GameObject> (); interactiveObjects = new List <GameObject> (); removeGameObject = new List <GameObject> (); vectors = new List <Vector2> (); windScript = GetComponent <WindScript> (); waterLineScript = GetComponent <WaterLineScript> (); verticalAngle = 90; gravity = 0.01f; speed = 8f * Time.deltaTime; //ghetto way of getting the all the bowl elements that will collide bowlComponents = new List <GameObject> (); foreach (Transform child in bowl) { bowlComponents.Add(child.gameObject); } yield return(new WaitForSeconds(2f)); waterLine = waterLineScript.result; }
private void OnTriggerStay(Collider other) { if (other.tag == "Wind") { WindScript wind = other.gameObject.GetComponent <WindScript>(); Vector3 dir = other.gameObject.GetComponent <WindScript>().direction; float force = 0; if (dir.x != 0) { if (Mathf.Abs(currentRotation) == 90 || Mathf.Abs(currentRotation) == 270 || isFrog) { force = wind.windPower / Mathf.Clamp((Mathf.Abs(transform.position.x - wind.point.transform.position.x)), 0.5f, 10); } else { force = 10 / Mathf.Clamp((Mathf.Abs(transform.position.x - wind.point.transform.position.x)), 0.5f, 10); } } if (dir.z != 0) { if (Mathf.Abs(currentRotation) == 180 || currentRotation == 0 || isFrog) { force = wind.windPower / Mathf.Clamp((Mathf.Abs(transform.position.z - wind.point.transform.position.z)), 0.5f, 10); } else { force = 10 / Mathf.Clamp((Mathf.Abs(transform.position.z - wind.point.transform.position.z)), 0.5f, 10); } } rb.AddForce(dir * force); } }
void OnTriggerExit2D(Collider2D other) { WindScript wind = other.GetComponent <WindScript>(); if (wind) { windCollision = null; } }
void OnTriggerEnter2D(Collider2D other) { WindScript wind = other.GetComponent <WindScript>(); if (wind) { windCollision = wind; windDistance = windCollision.transform.position - transform.position; } }
/// <summary> /// /// </summary> /// <param name="collision"></param> private void OnTriggerEnter2D(Collider2D collider) { if (collider.tag != "Wind") { return; } WindScript wind = collider.gameObject.GetComponent <WindScript>(); if (wind != null) { this.wind = wind; } }
private void Walk() { WindScript windScript = GetComponent <WindScript> (); float windPush = windScript.windSpeed / 5 * Time.deltaTime; // move towards the target cachedEnemy.transform.position = Vector3.MoveTowards(cachedEnemy.transform.position, targetWayPoint.position, Time.deltaTime / 1.5f + windPush); if (cachedEnemy.transform.position == targetWayPoint.position) { StartCoroutine(Kill(cachedEnemy)); } }
/// <summary> /// /// </summary> /// <param name="collision"></param> private void OnTriggerExit2D(Collider2D collider) { if (collider.tag != "Wind") { return; } WindScript wind = collider.gameObject.GetComponent <WindScript>(); if (this.wind != null) { if (this.wind.indicatorUI != null) { this.wind.indicatorUI.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0, 0); } this.wind = null; } }
//flies path private void Walk() { WindScript windScript = GetComponent <WindScript> (); float windPush = windScript.windSpeed / 5 * Time.deltaTime; // move towards the target foreach (GameObject cachedEnemy in cachedEnemies) { if (windPush > 0) { cachedEnemy.transform.position = Vector3.MoveTowards(cachedEnemy.transform.position, targetWayPoint.position, Time.deltaTime / 1.5f + windPush); } if (cachedEnemy.transform.position == targetWayPoint.position) { cachedEnemies.Remove(cachedEnemy); StartCoroutine(Kill(cachedEnemy)); } } }
public void OnAwake() { avGUI = FindObjectOfType <AviatorGUI> (); ws = FindObjectOfType <WindScript> (); motionBlur = FindObjectOfType <MotionBlur> (); parachuteStrSqale = parachute.localScale; parachute.localScale = 0.01f * Vector3.one; parachute.GetChild(0).GetComponent <SkinnedMeshRenderer> ().enabled = false; hipSuitPoints = new Transform[hipSuit.childCount]; hipSuitRotations = new Vector3[hipSuit.childCount]; isMobilePlatform = Application.isMobilePlatform; for (int i = 0; i < hipSuitRotations.Length; i++) { hipSuitPoints [i] = hipSuit.GetChild(i); hipSuitRotations [i] = hipSuitPoints [i].localRotation.eulerAngles; } armSuitRotations = new Vector3[armSuits.Length]; for (int i = 0; i < armSuitRotations.Length; i++) { armSuitRotations [i] = armSuits [i].localRotation.eulerAngles; } foreach (var item in joints) { item.OnStart(); } posController.OnStartAnimation += (JointsPoseController controller) => { if (controller.NewPoseName == "Open parachute") { parachute.GetChild(0).GetComponent <SkinnedMeshRenderer> ().enabled = true; } }; posController.OnAnimationComplete += (JointsPoseController controller) => { if (controller.NewPoseName == "Open parachute") { parachute.GetChild(0).GetComponent <SkinnedMeshRenderer> ().enabled = true; } SetCurrentState(); }; }
// Update is called once per frame private void FixedUpdate() { elapsedTimeOverLastGenetion++; float windSpeed = Random.Range(windSpeedMin, windSpeedMax); float windSize = Random.Range(windSizeMin, windSizeMax); if (elapsedTimeOverLastGenetion >= generationTime) { // Create wind elapsedTimeOverLastGenetion = 0; int directionNum = Random.Range(0, 4); Vector3 windWidth = new Vector3(0, 0, 0); Vector3 position = GameObject.FindObjectsOfType <FlameScript>()[0].transform.position; Vector2 speed = new Vector2(0, 0); // var newWindPrefab = Instantiate(windPrefab) as Transform; GameObject indicatorUI = null; // Initialisation des paramètres selon la direction if (directionNum == 0) { position = new Vector3(position.x + (windSize / 2) + positionOffSet, position.y, 0); speed = new Vector2(-windSpeed, 0); windWidth = new Vector3(windSize, 60, 1); foreach (Transform anim in newWindPrefab.transform) { anim.rotation = Quaternion.Euler(new Vector3(0, 0, 180)); anim.localScale = new Vector3(0.01f, -0.02f, 1); } indicatorUI = rightIndicatorUI; } else if (directionNum == 1) { position = new Vector3(position.x - (windSize / 2) - positionOffSet, position.y, 0); speed = new Vector2(windSpeed, 0); windWidth = new Vector3(windSize, 60, 1); indicatorUI = leftIndicatorUI; } else if (directionNum == 2) { position = new Vector3(position.x, position.y + (windSize / 2) + positionOffSet, 0); speed = new Vector2(0, -windSpeed); windWidth = new Vector3(100, windSize, 1); foreach (Transform anim in newWindPrefab.transform) { anim.rotation = Quaternion.Euler(new Vector3(0, 0, -90)); anim.localScale = new Vector3(0.02f, 0.01f, 1); } indicatorUI = topIndicatorUI; } else if (directionNum == 3) { position = new Vector3(position.x, position.y - (windSize / 2) - positionOffSet, 0); speed = new Vector2(0, windSpeed); windWidth = new Vector3(100, windSize, 1); foreach (Transform anim in newWindPrefab.transform) { anim.rotation = Quaternion.Euler(new Vector3(0, 0, 90)); anim.localScale = new Vector3(0.02f, 0.01f, 1); } indicatorUI = bottomIndicatorUI; } // Assign position and scale newWindPrefab.position = position; newWindPrefab.localScale = windWidth; // Création du vent WindScript wind = newWindPrefab.GetComponent <WindScript>(); wind.speed = speed; wind.force = Random.Range(windForceMin, windForceMax); wind.indicatorUI = indicatorUI; indicatorUI.GetComponent <UnityEngine.UI.Image>().color = Color.white; } }