protected void Hearing() { // If the bee is heading towards the hive, don't interrupt if (mainTarget != null && mainTarget.gameObject == hive.gameObject) { return; } // If the noise maker is not set if (playerNoiseMaker == null) { player = GameObject.FindGameObjectWithTag("Player"); playerNoiseMaker = player.GetComponent <NoiseMaker>(); } // If we did not fail to find the player's noise maker if (playerNoiseMaker != null) { // If we're close enough to hear the player if (Vector3.Distance(player.transform.position, transform.position) <= playerNoiseMaker.volume + hearingRadius) { HearPlayer(player); } } }
/// <summary> /// Updates preloaded chunks and execute second pass of generation that necessite the chunk /// to be surrounded by loaded chunks. E.g: Trees that generates on chunk borders. /// </summary> public static void UpdateLoaded() { int numUpdatedChunk = 0; foreach (Chunk chunk in m_LoadedChunk.Values) { if (numUpdatedChunk > 8) { break; } if (chunk.Updated == false) { chunk.Update(); } if (chunk.isSurrounded && !m_RenderList.ContainsKey(chunk.Position) && !chunk.isRendered) { m_RenderList.Add(chunk.Position, chunk); chunk.isRendered = true; NoiseMaker.GenerateChunk(chunk); numUpdatedChunk++; //NoiseMaker.GenerateChunkDecoration(chunk); // Generate the landscape. } } }
private bool CanHear(GameObject target) { if (GameManager.Instance.player == null) { return(false); } //Get the target's noise maker if they have one. NoiseMaker targetNoiseMaker = target.GetComponent <NoiseMaker>(); if (targetNoiseMaker == null) { return(false); } //Stops detecting the target if they are not moving. if (targetNoiseMaker.volumeDistance == 0) { return(false); } //If the distance from target is less than the noise/hearing distance, we can hear it. float distanceToTarget = Vector3.Distance(transform.position, target.transform.position); if ((targetNoiseMaker.volumeDistance + hearingDistance) > distanceToTarget) { hearingPosition = target.transform.position; return(true); } return(false); }
public bool CanHear(GameObject target) { // Get the target's NoiseMaker NoiseMaker targetNoise = target.GetComponent <NoiseMaker>(); // If they don't have one, they can't make noise, so return false if (!targetNoise) { hearingColor = Color.red; return(false); } // However, If they do have one else { // If volume from target occured in our hearing distance if (Vector3.Distance(target.transform.position, tf.position) <= hearingDistance) { //if volume is loud enough for us to hear (greater than our quietest hearing capabilty) if (targetNoise.volume >= hearingMinVolume) { hearingColor = Color.green; return(true); } } // Otherwise, we did not hear it, return false hearingColor = Color.red; return(false); } }
public bool?MakeNoiseOfGaussian(int curvesNo, double surrounding) { if (curvesNo < 0) { return(null); } IList <IList <DataPoint> > curves = SeriesAssist.GetCopy(ModifiedCurves, curvesNo, 0); for (int i = 0; i < curves.Count; i++) { curves[i] = NoiseMaker.OfGaussian(curves[i], surrounding); if (!SeriesAssist.IsChartAcceptable(curves[i], 0)) { return(false); } } for (int i = 0; i < curves.Count; i++) { ModifiedCurves[i].Points.Clear(); SeriesAssist.CopyPoints(curves[i], ModifiedCurves[i]); } return(true); }
private static float GetHeight(int x, int z) { float biome = NoiseMaker.GetHumidity(x, z); float normalizedNoise = (NoiseMaker.fastNoise2.GetSimplexFractal(x, z) * NoiseMaker.Amplitude + 1f) / 2; return((normalizedNoise) * ((Chunk.CHUNK_SIZE * 16) / 2)); }
public override void OnTakeDamage(GameObject attacker, float dmgAmount, EDamageType dmgType = EDamageType.Generic) { base.OnTakeDamage(attacker, dmgAmount, dmgType); HitNoiseSource.Play(); // Alert nearby AI NoiseMaker.MakeNoise(transform, 100.0f, attacker); }
// Update is called once per frame void Update() { if (player == null) //if player slot is empty { player = GameObject.FindWithTag("Player"); //fill it with player noise = player.GetComponent <NoiseMaker>(); //get player's noise maker } }
public ActionResult <String> MacRequest(NoiseRequest request) { Logger.LogInformation($"REQUEST KEY :: {JsonConvert.SerializeObject(request)}"); var response = NoiseMaker.MakeMAC(request.Key, request.Message); Logger.LogInformation($"RESPONSE :: {response}"); return(Ok(String.Empty)); }
[HideInInspector] public bool carrying; //Bool used for speed changes when carrying a collectable. // Start is called before the first frame update void Start() { //Links this object to its components. GameManager.Instance.player = this.gameObject; anim = GetComponent <Animator>(); tf = gameObject.GetComponent <Transform>(); noiseMaker = GetComponent <NoiseMaker>(); noiseMaker.maxVolume = noiseMaker.volumeDistance; currentSpeed = moveSpeed; }
// Start is called before the first frame update void Start() { // Get Components characterController = GetComponent <CharacterController>(); characterController.enabled = true; anim = GetComponent <Animator>(); noiseMaker = GetComponent <NoiseMaker>(); previousPosition = transform.position; }
public static Color GetColor(BLOCK_TYPE type, int x, int z) { var color = m_Palette[type]; if (type == BLOCK_TYPE.Grass) { color = color.LinearInterpolate(new Color(1, 1, 0), NoiseMaker.GetHumidity(x, z)); } return(color); }
void Update() { if (!recording) { if (Input.GetMouseButtonDown(0) && FindObjectsOfType <NoiseMaker>().Length < 32) { // Start recording. recording = true; startTime = Time.time; current = GameObject.Instantiate(noiseMakerPrefab).GetComponent <NoiseMaker>(); current.transform.parent = GameManager.levelTransform; current.audioSource.clip = Microphone.Start(null, false, maxSeconds, frequency); current.gameObject.SetActive(false); } if (Input.GetMouseButtonUp(1)) { // Delete the clicked noise maker. RaycastHit[] hits = Physics.RaycastAll(Camera.main.ScreenPointToRay(Input.mousePosition)); if (hits.Length > 0 && hits[0].transform.tag == "NoiseMaker") { GameObject.Destroy(hits[0].transform.gameObject); } } } else // is recording { if (Input.GetMouseButtonUp(0) || !Microphone.IsRecording(null)) { // Finish recording and start the playback. Microphone.End(null); int recordSamples = (int)((Time.time - startTime) * frequency); float[] recordData = new float[recordSamples]; current.audioSource.clip.GetData(recordData, 0); current.audioSource.clip = AudioClip.Create("Noise", recordSamples, 1, frequency, false); current.audioSource.clip.SetData(recordData, 0); recording = false; // Spawn the noise maker. Vector3 position = Camera.main.ScreenToWorldPoint(Input.mousePosition); current.transform.position = new Vector3(position.x, Mathf.Max(-current.transform.localScale.y, position.y), 0.0f); current.gameObject.SetActive(true); current.audioSource.Play(); } else if (Input.GetMouseButtonUp(1)) { // Stop (cancel) recording. Microphone.End(null); recording = false; GameObject.Destroy(current.gameObject); } } }
public bool CanHear(GameObject target) { // If we are in range if (Vector3.Distance(tf.position, target.GetComponent <Transform> ().position) < hearingRadius) { // AND, they are making noise NoiseMaker targetNoiseMaker = target.GetComponent <NoiseMaker>(); if (targetNoiseMaker.isMakingNoise) { return(true); } } // else return(false); }
// Start is called before the first frame update void Start() { if (player == null) //if player slot is empty { player = GameObject.FindWithTag("Player"); //fill it with player noise = player.GetComponent <NoiseMaker>(); //get player's noise maker } score = 0; //initialize score scoreText.text = "" + score; //update score text in UI livesText.text = "Lives: " + lives; //update lives in UI Controller[] allPlayers = FindObjectsOfType <Controller>(); //list of all controllers Controller[] humanPlayers = FindObjectsOfType <PlayerController>(); //list of all player controllers Controller[] aiPlayers = FindObjectsOfType <AIController>(); //list of all ai controllers }
public virtual void Start() { // set spawn position to the position they were placed in at runtime spawnPosition = transform.position; targetPosition = spawnPosition; // Link the controller to this pawn controller = GetComponent <Controller>(); // set senses to the gameObject sight = GetComponent <LineOfSight>(); hearing = GetComponent <Hearing>(); noiseMaker = GetComponent <NoiseMaker>(); hitbox = GetComponent <Hitbox>(); }
//if enemy can hear player public bool CanHear(GameObject target) { NoiseMaker targetNoiseMaker = target.GetComponent <NoiseMaker>(); if (targetNoiseMaker != null) { Vector3 vectorToTarget = target.transform.position - transform.position; if (hearingDistance + targetNoiseMaker.NoiseRadius > vectorToTarget.magnitude) { gizmoColor = Color.green; return(true); } } gizmoColor = Color.red; return(false); }
// Start is called before the first frame update void Start() { //get the character controller on this object characterController = GetComponent <CharacterController>(); //get the tank data component on this object data = GetComponent <TankData>(); tf = GetComponent <Transform>(); noiseMaker = GetComponent <NoiseMaker>(); if (!noiseMaker) { noiseMaker = gameObject.AddComponent <NoiseMaker>(); } }
bool CanHear(GameObject other) { //check if the other thing is making noise NoiseMaker otherNM = other.GetComponent <NoiseMaker>(); if (otherNM.isMakingNoise) { //check if the other thing is close enough to be heard if (Vector3.Distance(transform.position, other.transform.position) <= hearingRadius) { //then say "yes" we can hear them (true) return(true); } } //If we made it this far, and we didn't return true, then return false return(false); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { Godot.Engine.TargetFps = 0; LoadReference(); CreateBlockOutline(); ModelLoader.LoadModels(); NoiseMaker.Initialize(); if (MultiThreaded) { var threadStart1 = new ThreadStart(ChunkManager.UpdateThread); Threads[0] = new Thread(threadStart1); Threads[0].Start(); } }
public bool CanHear(GameObject target) { //get noisemaker from target NoiseMaker noise = target.GetComponent <NoiseMaker>(); if (noise != null) { float adjustedVolumeDistance = noise.volumeDistance - Vector3.Distance(tf.position, target.transform.position); if (adjustedVolumeDistance > 0) { Debug.Log("I heard a noise!"); return(true); } } return(false); }
private void OnTriggerStay2D(Collider2D collision) { // Getting the player's noisemaker component NoiseMaker other = target.GetComponent <NoiseMaker>(); // If it is not present, than we get null and output that if (other == null) { // Do Nothing hearPlayer = false; } // If it is not than we do some functions else if (other == other.volume) { hearPlayer = true; } }
private bool CanHear(GameObject target) { // Get the target's noise maker NoiseMaker targetNoiseMaker = target.GetComponent <NoiseMaker>(); //if they don't have a noise maker. we can't hear them. if (targetNoiseMaker == null) { return(false); } //If the distance between us and the target is less than the sum of the noise distance and hearing distance, we can hear i float distanceToTarget = Vector3.Distance(transform.position, target.transform.position); if ((targetNoiseMaker.volumeDistance + hearingDistance) > distanceToTarget) { return(false); } return(false); }
public static void GenerateVegetation(ref Chunk chunk, int x, int z) { RandomNumberGenerator Rng = NoiseMaker.Rng; float height = chunk.HighestBlockAt(x, z) + 1; // Place the decoration above the ground. float temp = NoiseMaker.GetTemperature((int)(chunk.Position.x * 16) + x, (int)(chunk.Position.y * 16) + z); // Placing plateaus //if (Rng.RandiRange(0, 10000) < 1) //{ // int treeHeight = Rng.RandiRange(10, 50); // int depth = Rng.RandiRange(25, 70); // int width = Rng.RandiRange(25, 70); // chunk.AddBlocks(Plateau.CreatePlateau(width, treeHeight, depth), new Vector3(0, height - 2, 0)); //} // Vegetation if (temp > 0.75f) // Flower { if (Rng.Randf() < 0.2f) { chunk.AddSprite(new Vector3(x, height, z), Models.Flower); } } else if (temp < 0.25f) // Fern { if (Rng.Randf() < 0.1f) { chunk.AddSprite(new Vector3(x, height, z), Models.Fern); } } //else // Tree //{ // if (Rng.Randf() < 0.1f) // chunk.AddSprite(new Vector3(x, height, z), Models.Grass); // else if (Rng.Randf() < 0.005f) // chunk.AddBlocks(OakTree.GetTreeData(), new Vector3(x - 8, height, z - 8)); //} }
public static bool OnClosestAudibleNoise(AnglerfishController __instance, NoiseMaker noiseMaker) { var qsbAngler = __instance.GetWorldObject <QSBAngler>(); if (__instance._currentState is AnglerfishController.AnglerState.Consuming or AnglerfishController.AnglerState.Stunned) { return(false); } if ((noiseMaker.GetNoiseOrigin() - __instance.transform.position).sqrMagnitude < __instance._pursueDistance * __instance._pursueDistance) { if (qsbAngler.TargetTransform != noiseMaker.GetAttachedBody().transform) { qsbAngler.TargetTransform = noiseMaker.GetAttachedBody().transform; if (__instance._currentState != AnglerfishController.AnglerState.Chasing) { __instance.ChangeState(AnglerfishController.AnglerState.Chasing); } qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler)); return(false); } } else if (__instance._currentState is AnglerfishController.AnglerState.Lurking or AnglerfishController.AnglerState.Investigating) { __instance._localDisturbancePos = __instance._brambleBody.transform.InverseTransformPoint(noiseMaker.GetNoiseOrigin()); if (__instance._currentState != AnglerfishController.AnglerState.Investigating) { __instance.ChangeState(AnglerfishController.AnglerState.Investigating); } qsbAngler.SendMessage(new AnglerDataMessage(qsbAngler)); } return(false); }
public bool CanHear(TankData otherTank) { // get the noisemaking ability of the other tank NoiseMaker otherNoise = otherTank.gameObject.GetComponent <NoiseMaker>(); // if it doesnt exist, we cant hear it. if (otherNoise == null) { return(false); } else { // if it does exist, check if we are closer then (volume * hearingModifer if (Vector3.Distance(otherTank.transform.position, transform.position) <= otherNoise.soundVolume * hearingModifer) { return(true); } } // if i get here, and i havent heard it yet, then i cant hear it. return(false); }
// Use this for initialization void Awake() { this.noise = GetComponent<NoiseMaker>(); this.view = GetComponent<View>(); }
// Start is called before the first frame update void Start() { tf = gameObject.GetComponent <Transform>(); noiseMaker = gameObject.GetComponent <NoiseMaker>(); GameManager.instance.Player = this.gameObject; }
private void OnEnable() { noiseMaker = target as NoiseMaker; Undo.undoRedoPerformed += RefreshCreator; }
// Start is called before the first frame update void Awake() { playerNoise = GameManager.instance.player.GetComponent <NoiseMaker>(); }