private void Start() { Npc_CompleteCallBack.Add("run_away", () => { RunAwayWall.SetActive(false); UIManager._instance.GetView <GameView>().Start_Run_Away(); DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.1f, 0.2f).SetLoops(-1, LoopType.Yoyo); }); Npc_CompleteCallBack.Add("sit_down_teach", () => { UIManager._instance.OpenView <TipView>().SetItem(ConfigManager.item_config.items.Find((a) => { return(a.ID == "sitdown"); })); } ); Npc_CompleteCallBack.Add("boss_start_talk", () => { game.Scene._instance.Boss.GetComponent <Boss_Controller>().StartPk(); game.Scene._instance.Boss.GetComponent <Boss_Controller>().isTalk = true; } ); Npc_CompleteCallBack.Add("boss_die_talk", () => { game.Scene._instance.Boss.GetComponent <Boss_Controller>().Died(); } ); Npc_CompleteCallBack.Add("shop_talk", () => { UIManager._instance.OpenView <ShopView>(); } ); }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "enemyhurt" || collision.gameObject.tag == "trap") { if (collision.gameObject.GetComponent <IAttackable>()._attackcallback != null) { collision.gameObject.GetComponent <IAttackable>()._attackcallback(gameObject); } if (_hurtcontroller.isdie) { return; } Time.timeScale = 0f; timers.Add(Timer.Register(0.1f, () => { Time.timeScale = 1; }, null, false, true)); DOTween.Shake(() => Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.1f, 0.5f); timers.Add(Timer.Register(0.25f, () => { foreach (var item in GetComponentsInChildren <SpriteRenderer>()) { item.material.DisableKeyword("_EMISSION"); } })); foreach (var item in GetComponentsInChildren <SpriteRenderer>()) { item.material.EnableKeyword("_EMISSION"); } _hurtcontroller.GetHurt(collision.gameObject.GetComponent <IAttackable>().Attack); } }
public new void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { if (collision.gameObject.transform.position.x > transform.position.x) { collision.gameObject.transform.rotation = Quaternion.Euler(0, 180, 0); } else { collision.gameObject.transform.rotation = Quaternion.identity; } collision.gameObject.GetComponent <PlayerHurtTrigger>()._hurtcontroller.GetHurt(1); } base.OnTriggerEnter2D(collision); if (collision.gameObject.layer == LayerMask.NameToLayer("ground") && _machine.NowStateIs("dashdown") && !(_machine.GetState("dashdown") as FishBoss_DashDownState).isProduce) { DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.3f, 1f); Debug.Log("sb!"); (_machine.GetState("dashdown") as FishBoss_DashDownState).isProduce = true; GameObject temp = GameObjectPool.GetInstance().GetGameObject("DashEffect", new Vector3(transform.position.x, dashpos[0].position.y) + new Vector3(0, 3.5f), Quaternion.identity); GameObjectPool.GetInstance().ReleaseGameObject("DashEffect", temp, 1); GameObject temp1 = GameObjectPool.GetInstance().GetGameObject("DashAttack", new Vector3(transform.position.x, dashpos[0].position.y) + new Vector3(0, 0.25f), Quaternion.identity); temp1.transform.rotation = Quaternion.identity; GameObjectPool.GetInstance().ReleaseGameObject("DashAttack", temp1, 1); GameObject temp2 = GameObjectPool.GetInstance().GetGameObject("DashAttack", new Vector3(transform.position.x, dashpos[0].position.y) + new Vector3(0, 0.25f), Quaternion.identity); temp2.transform.rotation = Quaternion.Euler(0, 180, 0); GameObjectPool.GetInstance().ReleaseGameObject("DashAttack", temp2, 1); } }
new void Start() { base.Start(); _hurtcontroller._DieCallBack = new DieCallBack(() => { _anim.SetTrigger("disappear"); CancelInvoke(); Timer.Register(1, () => { transform.position = new Vector3(diePos.position.x, diePos.position.y + 15); _anim.SetTrigger("die"); GetComponent <BoxCollider2D>().enabled = false; Timer.Register(0.5f, () => { transform.DOMoveY(diePos.position.y, 0.5f).SetEase(Ease.Linear); Timer.Register(0.5f, () => { AudioManager._instance.PlayBgm("普通"); DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.3f, 1f); }); }); }); Timer.Register(4.5f, () => { _anim.SetTrigger("diedisappear"); game.Scene._instance.ChangeCamera(0); DashBook.SetActive(true); BossTrigger.SetActive(false); }); Destroy(gameObject, 5); }); _hurtcontroller._HurtCallBack = new HurtCallBack(() => { GameObject temp2 = GameObjectPool.GetInstance().GetGameObject("主角攻击特效", transform.position, Quaternion.identity); GameObjectPool.GetInstance().ReleaseGameObject("主角攻击特效", temp2, 0.5f); if (_anim.IsAnim("下冲出现")) { if (NextTimer != null) { NextTimer.Cancel(); } ReleaseSkill(); } }); }
public static Tweener DOShakeScale(this Transform target, float duration, Vector3 strength, int vibrato = 10, float randomness = 90f) { return(DOTween.Shake(() => target.localScale, delegate(Vector3 x) { target.localScale = x; }, duration, strength, vibrato, randomness).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake)); }
public static Tweener DOShakeRotation(this Transform target, float duration, Vector3 strength, int vibrato = 10, float randomness = 90f) { return(DOTween.Shake(() => target.localEulerAngles, delegate(Vector3 x) { target.localRotation = Quaternion.Euler(x); }, duration, strength, vibrato, randomness).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake)); }
public static XTween Shake(LuaFunction getter, LuaFunction setter, float duration, float strength, int vibrato, float randomness, bool ignoreZAxis) { return(new XTween(DOTween.Shake( () => { return (Vector3)getter.call(); }, (v) => { setter.call(v); }, duration, strength, vibrato, randomness, ignoreZAxis))); }
public static Tweener DOShakePosition(this Camera target, float duration, Vector3 strength, int vibrato = 10, float randomness = 90f) { return(DOTween.Shake(() => target.transform.localPosition, delegate(Vector3 x) { target.transform.localPosition = x; }, duration, strength, vibrato, randomness).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetCameraShakePosition)); }
public void CreateShake() { Tweener tweener = DOTween.Shake(() => _cameraTransform.position, pos => _cameraTransform.position = pos, _data.Duration, _data.Strength, _data.Vibrato, _data.Randomness); _cameraTransform.position = _startPosition; }
public void ShakeScreen() { DOTween.Shake(() => shakeVector, x => shakeVector = x, shakeDuration, shakeStrength, shakeVibrationAmount, shakeRandomness, false); }
public static Tweener DOShakePosition(this Transform target, float duration, Vector3 strength, int vibrato = 10, float randomness = 90f, bool snapping = false) { return(DOTween.Shake(() => target.localPosition, delegate(Vector3 x) { target.localPosition = x; }, duration, strength, vibrato, randomness).SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake) .SetOptions(snapping)); }
public void Shake() { DOTween.Shake ( () => shakeOffset, val => shakeOffset = val, cameraShakeDuration, cameraShakeStrength, cameraShakeVibrato ); }
public void ShootWaterBall() { AudioManager._instance.PlayAudio("水球"); DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.3f, 1f); GameObject temp = GameObjectPool.GetInstance().GetGameObject("水球", shootpos.position, shootpos.rotation); temp.transform.right = (player.transform.position - transform.position).normalized; GameObjectPool.GetInstance().ReleaseGameObject("水球", temp, 1); }
private void Awake() { txt = GetComponent <TMPro.TMP_Text>(); startScale = transform.localScale; startPos = transform.localPosition; shakeTween = DOTween.Shake(() => transform.position, x => transform.position = x, 0.2f + secondsActive, new Vector3(0.3f, 0.3f, 0)); shakeTween.SetAutoKill(false).Pause(); colorTween = txt.DOColor(new Color(1, 0, 0, 0), secondsActive).SetDelay(0.2f); colorTween.SetAutoKill(false).Pause(); }
private void PlayHurt() { if (animator != null && TimeUtil.CheckInterval("virus_" + uid + "_hurt", 0.2f) ) { animator.SetTrigger("hurt"); } if (TimeUtil.CheckInterval("virus_" + uid + "_hurt_shake", CT.table.hitVirusShakeCD)) { DOTween.Shake(() => Vector3.one * mShakeScale, x => mShakeScale = x.x , CT.table.hitVirusShakeCD, Vector3.one * CT.table.hitVirusShakeScale , CT.table.hitVirusShakeTimes); } }
private void Shake() { if (shakeTween != null) { shakeTween.Kill(); } shakeTween = DOTween.Shake(() => shakingVector, (x) => { shakingVector = x; }, 0.5f, new Vector3(30, 0, 0)) .OnComplete(delegate { shakingVector = Vector2.zero; }) .OnKill(delegate { shakingVector = Vector2.zero; }); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.K)) { Time.timeScale = Time.timeScale < 1 ? Time.timeScale = 1 : 0; } if (Input.GetKeyDown(KeyCode.S)) { Vector3 shakeOffset = new Vector3(); screenShake = DOTween.Shake(() => shakeOffset, x => { shakeOffset = x; target.position += x; }, damageShakeDuration, damageShakeStrength, damageShakeVibration, damageShakeRandomness, false) .SetUpdate(false); // screenShake = target.DOMoveX(10, damageShakeDuration); // screenShake = target.DOShakePosition(damageShakeDuration, damageShakeStrength, damageShakeVibration, damageShakeRandomness, false); screenShake.OnComplete(() => { screenShake = target.DOMove(original, 0.5f).OnComplete(() => screenShake = null).SetUpdate(false); }); } }
/// <summary>Shakes a RectTransform's anchoredPosition with the given values. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="duration">The duration of the tween</param> /// <param name="strength">The shake strength on each axis</param> /// <param name="vibrato">Indicates how much will the shake vibrate</param> /// <param name="randomness">Indicates how much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware). /// Setting it to 0 will shake along a single direction.</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="fadeOut">If TRUE the shake will automatically fadeOut smoothly within the tween's duration, otherwise it will not</param> public static Tweener DOShakeAnchorPos(this RectTransform target, float duration, Vector2 strength, int vibrato = 10, float randomness = 90, bool snapping = false, bool fadeOut = true) { return(DOTween.Shake(() => target.anchoredPosition, x => target.anchoredPosition = x, duration, strength, vibrato, randomness, fadeOut) .SetTarget(target).SetSpecialStartupMode(SpecialStartupMode.SetShake).SetOptions(snapping)); }
// Use this for initialization void Start() { player = GetComponent <PlayerCtr>(); _rigi = GetComponent <Rigidbody2D>(); _hurtcontroller = new HurtController(PlayerInfoController._instance.pi.health, PlayerInfoController._instance.pi.maxhelath); _hurtcontroller._DieCallBack = new DieCallBack( () => { GetComponent <PlayerCtr>()._jump_key_press_timer = 0; GetComponent <PlayerCtr>().SitDownEffect.SetActive(false); GetComponent <PlayerCtr>().recovertimer = 0; GetComponent <PlayerCtr>().isSitDown = false; player.Inputable = false; GetComponent <Rigidbody2D>().velocity = Vector2.zero; GetComponent <Rigidbody2D>().gravityScale = 0; GetComponentInChildren <Animator>().SetTrigger("die"); UIManager._instance.OpenView <DieView>(); Timer.Register(2, () => { game.Scene._instance.ResetGame(); }, null, false, true); } ); _hurtcontroller._HurtCallBack = new HurtCallBack( () => { if (GetComponent <PlayerCtr>().isSitDown) { GetComponentInChildren <Animator>().SetTrigger("up"); GetComponent <PlayerCtr>().recovertimer = 0; GetComponent <PlayerCtr>().isSitDown = false; GetComponent <PlayerCtr>().Inputable = true; } GameObject temp2 = GameObjectPool.GetInstance().GetGameObject("主角攻击特效", transform.position, Quaternion.identity); AudioManager._instance.PlayAudio("受伤"); GameObjectPool.GetInstance().ReleaseGameObject("主角攻击特效", temp2, 0.5f); Timer.Register(0.25f, () => { GetComponentInChildren <SpriteRenderer>().material.DisableKeyword("_EMISSION"); }, null, false, true); GetComponentInChildren <SpriteRenderer>().material.EnableKeyword("_EMISSION"); DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.1f, 2); PlayerInfoController._instance.pi.health = _hurtcontroller.Health; player.Inputable = false; _hurtcontroller.isInvincible = true; Camera.main.GetComponent <VignetteAndChromaticAberration>().enabled = true; Camera.main.GetComponent <VignetteAndChromaticAberration>().chromaticAberration = 25; Time.timeScale = 0.5f; _rigi.velocity = Vector2.zero; _rigi.AddForce((-transform.right + transform.up) * 20, ForceMode2D.Impulse); Timer.Register(0.25f, () => { Time.timeScale = 1; Camera.main.GetComponent <VignetteAndChromaticAberration>().enabled = false; Camera.main.GetComponent <VignetteAndChromaticAberration>().chromaticAberration = 0; }, null, false, true); Timer.Register(0.5f, () => { _hurtcontroller.isInvincible = false; if (!_hurtcontroller.isdie) { player.Inputable = true; } }, null, false, true); }); }
void ShakeText() { DOTween.Shake(() => transform.position, x => transform.position = x, 0.1f, 10, 10, 25, false).OnComplete(delegate { transform.position = initPos; }); }
public void ShakeCamera() { _tweener = DOTween.Shake( () => _mainCamera.position, pos => _mainCamera.position = pos, 1f, 0.5f, 5, 0.7f); }
private void StartTween(TransitionItem item, float delay) { Vector2 startValue = item.startValue.f; Vector2 endValue = item.endValue.f; switch (item.type) { case TransitionActionType.XY: if (!item.startValue.b1) { startValue.x += item.target.position.x; } if (!item.startValue.b2) { startValue.y += item.target.position.y; } if (!item.endValue.b1) { endValue.x += item.target.position.x; } if (!item.endValue.b2) { endValue.y += item.target.position.y; } break; case TransitionActionType.Size: if (!item.startValue.b1) { startValue.x += item.target.size.x; } if (!item.startValue.b2) { startValue.y += item.target.size.y; } if (!item.endValue.b1) { endValue.x += item.target.size.x; } if (!item.endValue.b2) { endValue.y += item.target.size.y; } break; case TransitionActionType.Animation: if (!item.startValue.b1) { startValue.x += (( IAnimationGear )item.target).frame; } if (!item.endValue.b1) { endValue.x += (( IAnimationGear )item.target).frame; } break; } float startTime = delay; if (this._reversed) { Vector2 tmp = startValue; startValue = endValue; endValue = tmp; startTime += (this._maxTime - item.time - item.duration); } else { startTime += item.time; } switch (item.type) { case TransitionActionType.Shake: { item.tweener = DOTween.Shake(() => item.target.position, v => item.endValue.f = v, item.value.f.y, item.value.f.x, 10 /*频率*/, 90, true, true) .OnUpdate(() => this.ApplyValue(item, item.endValue)); } break; case TransitionActionType.Color: { item.tweener = DOTween.To(() => item.startValue.c, v => { item.value.c = v; }, item.endValue.c, item.duration) .OnUpdate(() => this.ApplyValue(item, item.value)); } break; default: { item.tweener = DOTween.To(() => startValue, v => { item.value.f = v; }, endValue, item.duration) .OnUpdate(() => this.ApplyValue(item, item.value)); } break; } item.tweener .SetUpdate(true) .SetEase(item.easeType) .OnStart(() => { item.hook?.Invoke(); }) .OnComplete(() => { item.hook2?.Invoke(); this.Complete(item); }); if (item.repeat != 0) { item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart); } if (startTime > 0) { item.tweener.SetDelay(startTime); } else { item.value.f = startValue; this.ApplyValue(item, item.value); } }
public void Shake() { DOTween.Shake(() => transform.position, x => transform.position = x, .5f, 10, 10, 45, true); }
public void ShakeCamera() { Tweener tweener = DOTween.Shake(() => _camera.transform.position, pos => _camera.transform.position = pos, 0.5f, 1, 15, 90, false); }
public void Skill(AttackType type) { this.type = type; switch (type) { case AttackType.单剑发射: { isCanSingal = false; transform.DOLocalMove(new Vector3(4.5f, -1.2f, 0), 0.15f).SetEase(Ease.Linear); transform.DOLocalRotate(Vector3.zero, 0.15f, RotateMode.FastBeyond360).SetEase(Ease.Linear); Timer.Register(0.25f, () => { DOTween.Shake(() => Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.1f, 0.5f); GetComponent <PolygonCollider2D>().enabled = true; ismove = true; _anim.SetTrigger("shoot"); transform.parent = null; }); Timer.Register(0.5f, () => { ResetState(); }); } break; case AttackType.群剑发射: { isCanMutli = false; Vector3 aim = parent.transform.position + new Vector3(parent.transform.right.x * 10, 10, 0); Debug.Log(aim); GameObject temp = GameObjectPool.GetInstance().GetGameObject("群剑", parent.position, parent.rotation); mutliswordtweeners.Add(temp.transform.DOMove(aim, 0.3f).SetEase(Ease.Linear)); mutliswordtweeners.Add(temp.transform.DOLocalRotate(new Vector3(0, 0, -90), 0.1f, RotateMode.FastBeyond360).SetEase(Ease.Linear).SetLoops(-1, LoopType.Incremental)); Timer.Register(0.3f, () => { foreach (var item in mutliswordtweeners) { item.Kill(); } mutliswordtweeners.Clear(); temp.transform.DOLocalRotate(new Vector3(0, 0, -90), 0.1f, RotateMode.FastBeyond360).SetEase(Ease.Linear); }); Timer.Register(1.25f, () => { temp.GetComponent <Animator>().SetTrigger("shoot"); temp.GetComponent <Mutli_Sword_Ctr>().ismove = true; }); List <GameObject> list = new List <GameObject>(); Timer.Register(0.35f, () => { Vector3[] pos = new Vector3[] { new Vector3(1.5f, -1f, 0), new Vector3(-1.5f, -1f, 0) }; for (int i = 0; i < 2; i++) { GameObject temp2 = GameObjectPool.GetInstance().GetGameObject("群剑", temp.transform.position + pos[i], Quaternion.identity); temp2.transform.right = (new Vector3(aim.x, aim.y - 7, aim.z) - temp2.transform.position).normalized; Timer.Register(0.1f + (i + 1) * 0.25f, () => { temp2.GetComponent <Animator>().SetTrigger("shoot"); temp2.GetComponent <Mutli_Sword_Ctr>().ismove = true; }); list.Add(temp2); } }); list.Add(temp); Timer.Register(3f, () => { foreach (var item in list) { GameObjectPool.GetInstance().ReleaseGameObject("群剑", item, 0); item.GetComponent <Mutli_Sword_Ctr>().ismove = false; } isCanMutli = true; }); } break; default: break; } }
new void Start() { base.Start(); _anim = GetComponent <Animator>(); _hurtcontroller._DieCallBack += () => { if (nexttimer != null) { nexttimer.Cancel(); } _anim.SetTrigger("firstdisappear"); CancelInvoke(); Timer.Register(1, () => { transform.position = new Vector3(diePos.position.x, diePos.position.y); _anim.SetTrigger("die"); GetComponent <BoxCollider2D>().enabled = false; Timer.Register(0.5f, () => { transform.DOMoveY(diePos.position.y, 0.5f).SetEase(Ease.Linear); Timer.Register(0.15f, () => { DOTween.Shake(() => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset, x => game.Scene._instance.VirtualCamera.GetComponent <CinemachineCameraOffset>().m_Offset = x, 0.3f, 1f); AudioManager._instance.PlayBgm("普通"); }); }); }); Timer.Register(1.5f, () => { NPC npc = ConfigManager.npc_config.npcs.Find((a) => { return(a.ID == 103); }); DialogView view = UIManager._instance.OpenView <DialogView>(); view.SetContenct(npc._callback_name, npc.talks.ToArray()); }); }; _hurtcontroller._HurtCallBack += () => { if (_hurtcontroller.Health > 0 && !isToSecond) { if (_hurtcontroller.Health <= 8 && Stage == 1) { isToSecond = true; if (nexttimer != null) { nexttimer.Cancel(); } CancelInvoke(); lastindex = -1; isReset = true; _anim.SetTrigger("disappear"); Timer.Register(1, () => { transform.rotation = Quaternion.identity; transform.position = ToSecondPos.position; _anim.SetTrigger("appear"); Timer.Register(0.5f, () => { _anim.SetTrigger("idle"); Timer.Register(2, () => { _anim.SetTrigger("tosecond"); Stage = 2; _anim.SetInteger("stage", Stage); Timer.Register(2f, () => { _anim.SetTrigger("disappear"); Timer.Register(1, () => { isToSecond = false; isReset = false; ReleaseSkill(); }); }); }); }); }); } else if (_anim.IsAnim("Attack2")) { _anim.SetTrigger("firstdisappear"); if (nexttimer != null) { nexttimer.Cancel(); } (_machine.GetState("attack") as Boss_AttackState).isattack = false; Timer.Register(1f, () => { ReleaseSkill(); }); } } GameObject temp2 = GameObjectPool.GetInstance().GetGameObject("主角攻击特效", transform.position, Quaternion.identity); GameObjectPool.GetInstance().ReleaseGameObject("主角攻击特效", temp2, 0.5f); }; }
private void ShakeConfirmButton() { RectTransform rect = _confirmButtonRect; DOTween.Shake(() => rect.eulerAngles, x => rect.eulerAngles = x, 1, new Vector3(0, 0, 50), 10, 10, false); }
// Start is called before the first frame update void Start() { DOTween.Shake(() => Vector3.one * hardLight.Range, x => hardLight.Range = x.x, shakeDuration, shakeStrength, shakeVibrato, 90, true, false) .SetLoops(-1, LoopType.Yoyo); }
void Shake(float intensity) { DOTween.Shake(() => transform.position, x => transform.position = x, 0.5f, 0.1f * intensity, 15, 20, true); }