private void Start() { if (instance == null) { instance = this; } }
public MadTank(Actor self, MadTankInfo info) { this.self = self; this.info = info; renderUnit = self.Trait <RenderUnit>(); screenShaker = self.World.WorldActor.Trait <ScreenShaker>(); }
private void Awake() { Instance = this; _canShake = false; _cinemachineBrain = GetComponent <CinemachineBrain>(); _vcam = GetComponent <CinemachineVirtualCamera>(); }
public override void OnHit(Transform source) { base.OnHit(source); DmgBehav.SetInvincible(1); ScreenShaker.Shake(.2f, .1f); GetComponentInChildren <PlayerHittedAnimation>().StartAnimation(); }
public MadTank(Actor self, MadTankInfo info) { this.self = self; this.info = info; wfsb = self.Trait <WithFacingSpriteBody>(); screenShaker = self.World.WorldActor.Trait <ScreenShaker>(); }
void fireWeapon(float angle) { StartCoroutine(Effects.MuzzleFlash(gun.bulletSpawnPoint)); int bulletOffset = (int)Random.Range(-gun.AngleOffset, gun.AngleOffset + 1); if (gun.gun.name == "Shotgun") { // make a shotgun blast for (int bullets = 0; bullets <= 5; bullets++) { bulletOffset = (int)Random.Range(-gun.AngleOffset, gun.AngleOffset + 1); Instantiate(bullet, gun.bulletSpawnPoint.transform.position, Quaternion.Euler(0, 0, angle + bulletOffset)); } } else { // Shoot a bullet at the proper angle Instantiate(bullet, gun.bulletSpawnPoint.transform.position, Quaternion.Euler(0, 0, angle + bulletOffset)); } // Shake that screen, boye ScreenShaker.ShakeCamera(gun.ScreenShakeAmount); // Set a delay between the next shot nextFire = Time.time + gun.FireRate; }
// Start is called before the first frame update void Start() { CVC = GetComponent <CinemachineVirtualCamera>(); SS = GetComponent <ScreenShaker>(); GameManager.Instance.OnStateChanged += StateChanged; camFollow = runner.transform.Find("Cam Follow"); }
//Byt namn till "ReferenceFxs" public void GetCamera() { //camera = GameObject.FindGameObjectWithTag("MainCamera"); screenShaker = GameObject.FindGameObjectWithTag("MainCamera").GetComponentInChildren <ScreenShaker>(); transitionFx = GameObject.FindGameObjectWithTag("Canvas").GetComponentInChildren <TransitionFx>(); screenFlashFx = GameObject.FindGameObjectWithTag("Canvas").GetComponentInChildren <ScreenFlashFx>(); }
public DetonationSequence(Actor self, MadTank mad, Target target) { this.self = self; this.mad = mad; this.target = target; move = self.Trait <IMove>(); wfsb = self.Trait <WithFacingSpriteBody>(); screenShaker = self.World.WorldActor.Trait <ScreenShaker>(); }
private void Awake() { if (Instance != null) { Destroy(gameObject); return; } Instance = this; }
public DetonationSequence(Actor self, ChargingSelfDestruct csd, Target target) { this.self = self; this.csd = csd; this.target = target; move = self.Trait <IMove>(); wfsb = self.Trait <WithFacingSpriteBody>(); screenShaker = self.World.WorldActor.Trait <ScreenShaker>(); }
private IEnumerator AscendAnimation() { yield return(new WaitForSeconds(1f)); // so the below shake commands won't be overridden by other things still happening in the map ScreenShaker.Clear(); var winner = GameController.GetFirstLivePawn(); // disable physics and such on the pawn winner.GetComponent <Rigidbody>().detectCollisions = false; winner.GetComponent <Rigidbody>().isKinematic = true; // spawn the ascend beam and make it invisibly thin to begin with var beam = Instantiate(PrefabAscendBeam, winner.transform.position, Quaternion.identity); var beamtf = beam.transform; beamtf.localScale = new Vector3(0f, 20f, 0f); while (beamtf.localScale.x < 1f) { // shake the screen as the beam opens up ScreenShaker.Shake(999f, beamtf.localScale.x * 0.08f); // increase the width of the beam over time beamtf.localScale += new Vector3(0.8f * Time.fixedDeltaTime, 0f, 0.8f * Time.fixedDeltaTime); yield return(new WaitForFixedUpdate()); } ScreenShaker.Shake(999f, 0.12f); var ascendProgress = 0f; while (ascendProgress < 1f) { ascendProgress += Time.fixedDeltaTime * 0.6f; winner.transform.localPosition += Vector3.up * Time.fixedDeltaTime * 1.2f; yield return(new WaitForFixedUpdate()); } ExitGamePanel.SetActive(true); // and close the beam again winner.HideSprite(); while (beamtf.localScale.x > 0f) { ScreenShaker.Clear(); ScreenShaker.Shake(999f, beamtf.localScale.x * 0.08f); // increase the width of the beam over time beamtf.localScale -= new Vector3(1f * Time.fixedDeltaTime, 0f, 1f * Time.fixedDeltaTime); yield return(new WaitForFixedUpdate()); } Destroy(beam); ScreenShaker.Clear(); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } }
protected override void Awake() { base.Awake(); // Cache m_BattleRoyaleManager = BattleRoyaleManager.Instance; m_CountDownStart.transform.localScale = Vector2.zero; m_TimeAndPercentCanvasGroup = m_TimeAndPercentObject.GetComponent <CanvasGroup>(); m_ScreenShaker = ScreenShaker.Instance; HideGroup(); }
private void FeedInteractable() { selectedInteractableTransform.parent.SendMessage("OnFedItem", selectedItem, SendMessageOptions.DontRequireReceiver); SetSelectedItem(ItemType.None); Utility.SendMessageToChildren( transform.parent, "SetInteraction", InteractionCanvasController.Interaction.None, SendMessageOptions.DontRequireReceiver); ScreenShaker.Shake(0.25f, 0.1f); source.PlayOneShot(clips[1]); }
protected override void Awake() { base.Awake(); // Cache m_MainCamera = MainCamera.Instance; m_MessageView = MessageView.Instance; m_HapticManager = MobileHapticManager.Instance; m_StatsManager = StatsManager.Instance; m_ScreenShaker = ScreenShaker.Instance; m_MainCamera.SetTarget(this); // Buffers m_IsMoving = false; }
public void LoadContent() { Map = new TiledMap(this, "/dungeon.json"); Camera = new Camera(graphics); player = new Player(this); Shaker = new ScreenShaker(); Map.LoadContent(); player.LoadContent(); entities.Add(player); gameTheme = CM.Load <Song>("hero_immortal"); MediaPlayer.Volume = 0.05f; MediaPlayer.IsRepeating = true; MediaPlayer.Play(gameTheme); }
private void Start() { // Get the exit collider exitCollider = gameObject.GetComponent <BoxCollider2D>(); // Get the screen shake script shaker = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <ScreenShaker>(); // Get the player object player = GameObject.FindGameObjectWithTag("Player"); // Get the main camera in the scene mainCam = Camera.main; // Get the gamecontroller to reset the waves controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); }
void Update() { if (!instance) instance = this; #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Alpha1)) ShakeScreen(2f, 0.2f, 0.05f); if (Input.GetKeyDown(KeyCode.Alpha2)) ShakeScreen(2f, 0.2f, 0.1f); if (Input.GetKeyDown(KeyCode.Alpha3)) ShakeScreen(2f, 0.4f, 0.05f); if (Input.GetKeyDown(KeyCode.Alpha4)) ShakeScreen(2f, 0.7f, 0.05f); if (Input.GetKeyDown(KeyCode.Alpha5)) ShakeScreen(2f, 1f, 0.04f); #endif }
public void Break(bool byPlayer) { // can't remove border tiles if (Border) { return; } if (byPlayer) { switch (Type) { case TileType.Normal: GameController.Inst.AddScore(Tuning.SCORE_BREAK_BLOCK); break; case TileType.Gem: GameController.Inst.AddScore(Tuning.SCORE_BREAK_GEM); break; case TileType.Gem2: GameController.Inst.AddScore(Tuning.SCORE_BREAK_GEM * 10f); break; case TileType.PowerS: case TileType.PowerL: case TileType.PowerR: case TileType.PowerB: //GameController.Inst.AddScore(Tuning.SCORE_BREAK_POWERUP); GameController.Inst.GivePowerup((PowerupType)(Type - TileType.PowerS + 1)); break; } GameController.Inst.Power += Tuning.POWER_ADD_BLOCK; } GameController.Inst.PlaySoundAt(BreakSound, m_Transform.position); Instantiate(BreakParticles, m_Transform.position, Quaternion.identity); ScreenShaker.AddShake(0.12f, 0.22f); Destroy(gameObject); }
private IEnumerator Cycle() { yield return(new WaitForSeconds(Delay)); var gobj = Instantiate(PrefabParticles, transform); gobj.transform.localPosition = Vector3.zero; gobj.transform.localRotation = Quaternion.identity; ScreenShaker.Shake(0.3f, 0.3f); XInputWrapper.Instance.AddRumble(0.4f, 0.95f); m_collider.enabled = true; yield return(new WaitForSeconds(0.15f)); m_collider.enabled = false; yield return(new WaitForSeconds(1f)); Destroy(gameObject); }
public void Explode(Rigidbody pushAway) { if (m_Exploded) { return; } // don't fire again m_Exploded = true; Destroy(gameObject, 0.1f); // shoot the player away if (pushAway != null) { var dir = (pushAway.transform.position - m_Transform.position).normalized; pushAway.AddForce(dir * Tuning.MINE_EXPLODE_FORCE, ForceMode.VelocityChange); } // pretty effects Instantiate(ExplosionParticles, m_Transform.position, Quaternion.identity); GameController.Inst.PlaySoundAt(ExplodeSound, m_Transform.position); ScreenShaker.AddShake(0.45f, 0.55f); // eraser object (removes tiles and chain-reacts mines) Instantiate(TileEraserPrefab, m_Transform.position, Quaternion.identity); }
//Start is called one time when the scene has been loaded void Start() { //We know there is only one ShakeScreen script in the scene, so we find and save the reference to it so we can use it when there is a collision. shaker = FindObjectOfType(typeof(ScreenShaker)) as ScreenShaker; }
private void FixedUpdate() { // no world input in shop if (gctl.ShopOpen || gctl.Victory || gctl.Paused) { return; } // explosion effect and stuff if (gctl.GameOver) { exhaust.Stop(); if (!didDeathAnimation) { didDeathAnimation = true; ScreenShaker.SetShake(0.8f, 0.1f); Instantiate(explosionParticles, transform.position, Quaternion.identity); gameObject.SetActive(false); } return; } #if UNITY_EDITOR if (Input.GetKeyDown("f6")) { Money += 100000; } if (Input.GetKeyDown("f7")) { Fuel = 1f; } if (Input.GetKeyDown("f8")) { Fuel = FuelMax; } #endif // animate model rotation //Debug.Log(facing); if (facing) { currentAngle += 500f * Time.fixedDeltaTime; if (currentAngle > 90f) { currentAngle = 90f; } } else { currentAngle -= 500f * Time.fixedDeltaTime; if (currentAngle < -90f) { currentAngle = -90f; } } cachedTf.localRotation = Quaternion.Euler(0f, currentAngle, 0f); if (digging) { // ignore input while digging, and animate position accelHor = 0f; accelVer = 0f; cachedRigid.isKinematic = true; cachedRigid.velocity = Vector3.zero; digProgress += Time.fixedDeltaTime * Tuning.PLAYER_DIG_SPEED; Fuel -= Time.fixedDeltaTime * Tuning.FUEL_DIGGING_RATE; SetExhaustStrength(1.0f); AnimateScale(drillDown, !digHorizontal); AnimateScale(drillForward, digHorizontal); ScreenShaker.SetShake(0.1f, 0.01f); if (digProgress > 0.5f && digTile != null) { digTile.GetComponent <Tile>().PickUp(); Destroy(digTile); digTile = null; } if (digProgress >= 1.0f) { cachedTf.position = digTarget; cachedRigid.isKinematic = false; digging = false; } else { cachedTf.position = Vector3.Lerp(digStart, digTarget, digProgress) + (digHorizontal ? Vector3.up * Random.Range(-0.025f, 0.025f) : Vector3.right * Random.Range(-0.045f, 0.045f)); } return; } // standby fuel consumption SetExhaustStrength(0.25f); Fuel -= Time.fixedDeltaTime * Tuning.FUEL_IDLE_RATE; { // update flag whether user is using controller float ctlKey = Mathf.Abs(Input.GetAxis("KeyX")) + Mathf.Abs(Input.GetAxis("KeyY")); float ctlJoy = Mathf.Abs(Input.GetAxis("JoyX")) + Mathf.Abs(Input.GetAxis("JoyY")); if (ctlJoy > 0.1f || ctlKey > 0.1f) { gctl.ControllerMode = ctlJoy > ctlKey; } //Debug.Log(gctl.ControllerMode); } float hor = Input.GetAxis("Horizontal"); float ver = Input.GetAxis("Vertical"); if (Input.GetButtonDown("Flashlight")) { Flashlight = !Flashlight; } if (Flashlight) { Fuel -= Tuning.FUEL_FLASHLIGHT_RATE * Time.fixedDeltaTime; SetExhaustStrength(1f); } // player position int playerMapX, playerMapY; GameController.WorldToMap(cachedTf.position, out playerMapX, out playerMapY); bool grounded = gctl.GetTileAt(playerMapX, playerMapY + 1) != null; // flashlight tutorial when turning it on or sufficiently deep if (!flashlightTutorialShown && (Flashlight || playerMapY >= 24)) { flashlightTutorialShown = true; TutorialManager.QueueTutorial(2); } // accelerate / decelerate accelHor = Mathf.Abs(hor) > 0.001f ? Mathf.Min(accelHor + Time.fixedDeltaTime * Tuning.PLAYER_ACCEL, 1.0f) : Mathf.Max(accelHor - Time.fixedDeltaTime * Tuning.PLAYER_DECEL, 0.0f); accelVer = Mathf.Abs(ver) > 0.001f ? Mathf.Min(accelVer + Time.fixedDeltaTime * Tuning.PLAYER_ACCEL, 1.0f) : Mathf.Max(accelVer - Time.fixedDeltaTime * Tuning.PLAYER_DECEL, 0.0f); // interact with fuel depot if (playerMapY == -1 && playerMapX >= 9 && playerMapX <= 14) { refuelText.SetActive(true); refuelText.GetComponent <TextMesh>().text = gctl.ControllerMode ? "Press A to open shop" : "Press Enter to open shop"; if (Input.GetButtonDown("Confirm")) { //Debug.Log("Do fancy thing"); //Fuel = FuelMax; Input.ResetInputAxes(); refuelText.SetActive(false); gctl.SetShopOpen(true); } } else { refuelText.SetActive(false); } // horizontal movement Vector3 movedir = lastMoveDir; if (Mathf.Abs(hor) > 0.001f) { // set horizontal speed movedir.x = hor * Tuning.PLAYER_MOVE_SPEED; Fuel -= Time.fixedDeltaTime * Tuning.FUEL_DRIVING_RATE; SetExhaustStrength(0.75f); // set model rotation facing = hor < 0f; // left/right // try digging maybe if (Mathf.Abs(hor) >= 0.85f && // deadzone grounded && Mathf.Abs(cachedRigid.velocity.y) < 0.1f && cachedRigid.useGravity && // can't dig sideways while flying gctl.GetTileAt(playerMapX + Mathf.RoundToInt(hor), playerMapY) != null) // must be a solid tile in the way { StartDigging(playerMapX + Mathf.RoundToInt(hor), playerMapY, true); } } AnimateScale(drillDown, false); AnimateScale(drillForward, grounded && Mathf.Abs(hor) > 0.1f); // vertical movement //Debug.Log(ver); if (ver > 0.5f) { movedir.y = ver * Tuning.PLAYER_FLY_SPEED; Fuel -= Time.fixedDeltaTime * Tuning.FUEL_FLYING_RATE; SetExhaustStrength(0.75f); AnimateScale(propellor, true, 2.5f); AnimateScale(drillDown, false); AnimateScale(drillForward, false); // cancel out gravity cachedRigid.useGravity = false; Vector3 vel = cachedRigid.velocity; vel.y = Mathf.Min(0.0f, vel.y + 4.0f * Time.fixedDeltaTime); cachedRigid.velocity = vel; } else { // was flying, need to accelerate again //if (!cachedRigid.useGravity) { // cachedRigid.velocity = accelVer * Tuning. //} movedir.y = 0; cachedRigid.useGravity = true; AnimateScale(propellor, !grounded, 2.5f); if (grounded && ver < -0.5f && // dead zone Mathf.Abs(cachedRigid.velocity.y) < 0.1f && cachedRigid.useGravity && // can't dig while flying gctl.GetTileAt(playerMapX, playerMapY + 1) != null) // must be a solid tile { // downwards StartDigging(playerMapX, playerMapY + 1, false); } } // if moving, save the last speed if (Mathf.Abs(hor) > 0.001f || Mathf.Abs(ver) > 0.001f) { lastMoveDir = movedir; } // apply velocity Vector3 finalMoveDir = movedir; finalMoveDir.x *= accelHor; finalMoveDir.y *= accelVer; Vector3 newpos = cachedRigid.position + finalMoveDir * Time.fixedDeltaTime; newpos.x = Mathf.Clamp(newpos.x, -(Tuning.MAP_WIDTH / 2), Tuning.MAP_WIDTH / 2.0f - 1.0f); cachedRigid.position = newpos; }
private void Awake() { shaker = this; }
private void Awake() { Instance = this; _canShake = false; }
private void OnDie() { ScreenShaker.ShakeScreenHeavy(); AudioManager.PlayDeathSound(); }
private void OnDamageTaken(int health) { ScreenShaker.ShakeScreenLight(); AudioManager.PlayHurtSound(); bloodParticleSystem.Play(); }
void Awake() { instance = this; }
void Start() { playerData.playerScore = 0; shaker = FindObjectOfType <ScreenShaker>(); socket = FindObjectOfType <WebSocketDemo>(); }
public void DeathShake() { ScreenShaker.ShakeScreen(deathShakeInstensity, deathShakeInstensity); }
public void DamageShake() { ScreenShaker.ShakeScreen(damageShakeInstensity, damageShakeDuration); }
private void Awake() { Instance = this; rootPosition = transform.localPosition; }
void Start() { instance = this; initialCameraPosition = transform.position; }
protected override void DealDamage(CharController target) { target.DmgBehav.DealPhysicalDamage(dmgInfo); MuzzleSpawner.Spawn(target.transform.position); ScreenShaker.Shake(.2f, .1f); }
// Use this for initialization void Awake() { me = this; }
void Start() { instance = this; }