// Use this for initialization void Start() { tf = gameObject.transform; // Load noisemaker noisemaker = GetComponent <Noisemaker>(); }
private IEnumerator TestNoteRoutine(Noisemaker NoisemakerBeingTested) { NoisemakerBeingTested.StartPlaying(); yield return(new WaitForSeconds(1)); if (!NoisemakerBeingTested.Input.On) { NoisemakerBeingTested.StopPlaying(); } }
// Start is called before the first frame update public virtual void Start() { senses = GetComponent <AISenses>(); tf = GetComponent <Transform>(); noisemaker = GetComponent <Noisemaker>(); homePoint = tf.position; }
// Start is called before the first frame update public virtual void Start() { // Store my senses component senses = GetComponent <AISenses>(); tf = GetComponent <Transform>(); // Load noisemaker noisemaker = GetComponent <Noisemaker>(); // Save home point homePoint = tf.position; }
void Awake() { if (Instance != null && Instance != this) { Debug.Log("Noisemaker got destroyeed\n"); Destroy(gameObject); } Instance = this; // Debug.Log("Starting @ " + AudioListener.volume + "\n"); //AudioListener.volume = 0.5f + global_volume * 0.05f; AudioListener.volume = global_volume * 0.1f; // Debug.Log("Now at @ " + AudioListener.volume + "\n"); }
public bool CanHear(GameObject target) { Noisemaker targetNoisemaker = target.GetComponent <Noisemaker>(); if (targetNoisemaker != null) { Vector3 vectorToTarget = target.transform.position - this.transform.position; if (hearingDistance + targetNoisemaker.noiseRadius > vectorToTarget.magnitude) { gizmoColor = Color.green; return(true); } } gizmoColor = Color.red; return(false); }
public bool CanHear(Transform target) { //If the target does not have a noisemaker we cannot hear them noisemaker = target.GetComponent <Noisemaker>(); if (noisemaker == null) { return(false); } //If they do have a noisemaker, check distance -- if it is <= (PlayerVolume * hearingScale), then we can hear them if (Vector3.Distance(target.position, transform.position) <= noisemaker.PlayerVolume * hearingScale) { return(true); } //Otherwise enemies cannot hear player return(false); }
public bool canAttack = false; //A bool to allow the enemy to attack or not attack // Start is called before the first frame update public virtual void Start() { bulletPrefab.tag = "Bullet"; // Store my senses component senses = GetComponent <AISenses>(); tf = GetComponent <Transform>(); rb = GetComponent <Rigidbody2D>(); controller = GetComponent <PlayerController>(); // Load noisemaker noisemaker = GetComponent <Noisemaker>(); }
public bool CanHear(GameObject target) { Noisemaker targetNoiseMaker = target.GetComponent <Noisemaker>(); if (targetNoiseMaker == null) { return(false); } Transform targetTf = target.GetComponent <Transform>(); if (Vector3.Distance(targetTf.position, tf.position) <= targetNoiseMaker.volume * hearingScale) { return(true); } return(false); }
public void shoot() { Noisemaker noisemaker = gameObject.GetComponent <Noisemaker>(); // Check cooldown timer to see if we can shoot. // Instantiate the cannon ball. GameObject firedCannonBall = Instantiate(cannonBallPrefab, firePoint.transform.position, Quaternion.identity) as GameObject; Rigidbody cannonRB = firedCannonBall.GetComponent <Rigidbody>(); // Propel the cannon ball forward with Rigidbody.AddForce() cannonRB.AddForce(firePoint.transform.forward * data.shotSpeed); // The cannon ball needs some data: Who fired it, and how much damage will it do? Cannonball cannonBall = firedCannonBall.GetComponent <Cannonball>(); cannonBall.attack = new Attack(this.gameObject, data.cannonballDamage); Debug.Log(cannonBall.attack); gameObject.SendMessage("AddNoise", value: 5, SendMessageOptions.DontRequireReceiver); sfx.Play(); }
bool CanHear(GameObject target) { float hearingDistance; Noisemaker source = target.GetComponent <Noisemaker>(); if (source == null) { return(false); } else { if (source.isMakingNoise == true) { hearingDistance = hearingSensitivity * source.noiseVolume; if (Vector3.Distance(target.GetComponent <Transform>().position, tf.position) < hearingDistance) { return(true); } } } //if somehow this is reached, you can't hear them return(false); }
// god this sucks. Should be an interface. TODO learn how to use interfaces and make this an interface // also, mounts should be a part of this private static void DoThingsForNewComponents(GameObject newcomponent) { Display display = newcomponent.GetComponentInChildren <Display>(); if (display != null) { display.NewlyPlaced(); return; } Label label = newcomponent.GetComponentInChildren <Label>(); if (label != null) { label.NewlyPlaced(); return; } Noisemaker noisemaker = newcomponent.GetComponentInChildren <Noisemaker>(); if (noisemaker != null) { noisemaker.NewlyPlaced(); return; } }
private void Awake() { noisemaker = GetComponent <Noisemaker>(); }
private static void LoadNoisemaker(GameObject LoadedObject, SavedNoisemaker save) { Noisemaker noisemaker = LoadedObject.GetComponentInChildren <Noisemaker>(); noisemaker.ToneFrequency = save.ToneFrequency; }
public static SavedObjectV2 CreateSavedObjectFrom(ObjectInfo worldsave) { //SavedObjectV2 newsavedobject = SaveManager.ObjectTypeToSavedObjectType(save.ObjectType); SavedObjectV2 newsavedobject = null; switch (worldsave.ComponentType) { case ComponentType.CustomObject: newsavedobject = new SavedCustomObject(); CreateCustomSavedObject((SavedCustomObject)newsavedobject, worldsave); break; case ComponentType.CircuitBoard: CircuitBoard board = worldsave.GetComponent <CircuitBoard>(); newsavedobject = new SavedCircuitBoard { x = board.x, z = board.z, color = board.GetBoardColor }; break; case ComponentType.Wire: InputInputConnection IIConnection = worldsave.GetComponent <InputInputConnection>(); newsavedobject = new SavedWire { InputInput = IIConnection, length = worldsave.transform.localScale.z }; break; case ComponentType.Button: newsavedobject = new SavedButton(); break; case ComponentType.PanelButton: newsavedobject = new SavedPanelButton(); break; case ComponentType.Delayer: Delayer delayer = worldsave.GetComponent <Delayer>(); newsavedobject = new SavedDelayer { OutputOn = delayer.Output.On, DelayCount = delayer.DelayCount }; break; case ComponentType.Display: Display display = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedDisplay { Color = display.DisplayColor }; break; case ComponentType.PanelDisplay: Display paneldisplay = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedPanelDisplay { Color = paneldisplay.DisplayColor }; break; case ComponentType.Inverter: Inverter notgate = worldsave.GetComponent <Inverter>(); newsavedobject = new SavedInverter { OutputOn = notgate.Output.On }; break; case ComponentType.Label: Label label = worldsave.GetComponent <Label>(); newsavedobject = new SavedLabel { text = label.text.text, FontSize = label.text.fontSize }; break; case ComponentType.PanelLabel: Label panellabel = worldsave.GetComponent <Label>(); newsavedobject = new SavedPanelLabel { text = panellabel.text.text, FontSize = panellabel.text.fontSize }; break; case ComponentType.Switch: // SWITCH-F*****G-CEPTION Switch circuitswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedSwitch { on = circuitswitch.On }; break; case ComponentType.PanelSwitch: Switch panelswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedPanelSwitch { on = panelswitch.On }; break; case ComponentType.Peg: newsavedobject = new SavedPeg(); break; case ComponentType.ThroughPeg: newsavedobject = new SavedThroughPeg(); break; case ComponentType.Blotter: Blotter blotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedBlotter { OutputOn = blotter.Output.On }; break; case ComponentType.ThroughBlotter: Blotter throughblotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedThroughBlotter { OutputOn = throughblotter.Output.On }; break; case ComponentType.ColorDisplay: newsavedobject = new SavedColorDisplay(); break; case ComponentType.PanelColorDisplay: newsavedobject = new SavedPanelColorDisplay(); break; case ComponentType.Noisemaker: Noisemaker noisemaker = worldsave.GetComponentInChildren <Noisemaker>(); newsavedobject = new SavedNoisemaker { ToneFrequency = noisemaker.ToneFrequency }; break; case ComponentType.SnappingPeg: newsavedobject = new SavedSnappingPeg(); break; case ComponentType.Mount: newsavedobject = new SavedMount(); break; case ComponentType.VerticalSnappingPeg: newsavedobject = new SavedVerticalSnappingPeg(); break; case ComponentType.none: Debug.LogError("BIG ERROR tried to save a component with no type!"); break; } newsavedobject.LocalPosition = worldsave.transform.localPosition; newsavedobject.LocalEulerAngles = worldsave.transform.localEulerAngles; if (newsavedobject.CanHaveChildren) { newsavedobject.Children = FindChildSaves(worldsave); } return(newsavedobject); }