// Awake is called before Start and should be used as the constructor private void Awake() { this.currentTransform = this.GetComponent <Transform>(); this.currentConstantVelocity = this.GetComponent <ConstantVelocity>(); this.cameraReference = GameObject.Find(this.camera.name); this.cameraReferenceTransform = this.cameraReference.GetComponent <Transform>(); }
// Awake is called before Start and should be used as the constructor private void Awake() { if (useSettings) { this.enableActionOnTouch = Handler.TouchEnabled; this.enableActionOnVolume = Handler.VolumeEnabled; this.enableActionOnTilt = Handler.TiltEnabled; } this.currentTransform = this.GetComponent <Transform>(); this.currentRigidbody2D = this.GetComponent <Rigidbody2D>(); this.currentBoxCollider2D = this.GetComponent <BoxCollider2D>(); this.currentConstantVelocity = this.GetComponent <ConstantVelocity>(); this.progressionPercentageReference = GameObject.Find(this.progressionPercentage.transform.name); this.jumpResetOnCollideWithReference = GameObject.Find(this.jumpResetOnCollideWith.name); this.killOnCollideWithReference = GameObject.Find(this.killOnCollideWith.name); this.triggerFlyOnCollideWithReference = GameObject.Find(this.triggerFlyOnCollideWith.name); this.triggerGlideOnCollideWithReference = GameObject.Find(this.triggerGlideOnCollideWith.name); this.triggerReverseGravityOnCollideWithReference = GameObject.Find(this.triggerReverseGravityOnCollideWith.name); var gravityScale = this.currentRigidbody2D.gravityScale; this.gravityStrength = gravityScale > 0 ? 1 : gravityScale < 0 ? -1 : 0; if (Microphone.devices.Length > 0) { this.microphoneExists = true; this.microphoneInput = Microphone.Start(Microphone.devices[0], true, 999, 44100); } }
// Awake is called before Start and should be used as the constructor private void Awake() { this.currentTransform = this.GetComponent <Transform>(); this.currentCamera = this.GetComponent <Camera>(); this.cameraStartSize = this.currentCamera.orthographicSize; this.toFollowReference = GameObject.Find(this.toFollow.name); this.toFollowReferenceTransform = this.toFollowReference.GetComponent <Transform>(); this.toFollowReferenceConstantVelocity = this.toFollowReference.GetComponent <ConstantVelocity>(); if (!differentSettingsForStates) { return; } this.toFollowReferencePlayerController = this.toFollowReference.GetComponent <PlayerController>(); this.latestState = this.toFollowReferencePlayerController.GetState(); this.SetSettingsDependingOnStates(this.latestState, out this.offset, out this.sizeMultiplier); this.latestStateSwitchOffset = this.offset; this.latestSizeMultiplier = this.sizeMultiplier; }
void Shoot(GameObject target) { float dist = (target.GetComponent <Rigidbody2D>().position - towerPosition).magnitude; if (dist > targetRadius) { target = null; return; } arrowSound.PlayOneShot(arrowSound.clip); shotEnergy = 0.0f; Rigidbody2D towerBody = this.gameObject.GetComponent <Rigidbody2D>(); Rigidbody2D targetBody = target.GetComponent <Rigidbody2D>(); Vector3 direction = targetBody.position - towerBody.position; Transform arrow = (Transform)Instantiate(projectile, towerBody.position, Quaternion.identity); ConstantVelocity arrowMovement = arrow.GetComponent <ConstantVelocity>(); arrowMovement.SetVelocity(direction.normalized * arrowSpeed); // TODO: Fix arrow rotation }
// Use this for initialization void Start() { _move = GetComponent <ConstantVelocity>(); _timer = new Timers(3); }
void Awake() { _targetMover = GetComponent <ConstantVelocity>(); }