protected override void Update() { base.Update(); if (SpriteList.Count <= 1) { return; } if (Deploy.frame <= 0) { return; } if (GameSystem.FixedFrameCount - _lastChangedFrame > Deploy.frame) { _lastChangedFrame = GameSystem.FixedFrameCount; _currSpriteIndex++; if (_currSpriteIndex >= SpriteList.Count) { if (_bAutoDestroy) { TextureEffectFactroy.DestroyEffect(this); return; } _currSpriteIndex = 0; } Renderer.material.mainTexture = SpriteList[_currSpriteIndex].texture; } }
//子弹爆炸,销毁子弹 protected virtual void DoBulletBomb() { if (InCache) { return; } //播放爆炸特效 if (Deploy.bombEffectId > 0) { var pos = Renderer.transform.position; var forward = MoveData.Forward; var speed = Deploy.bombEffectSpeed; TextureEffectFactroy.CreateEffect(Deploy.bombEffectId, SortingOrder.EnemyBullet, effect => { effect.transform.position = pos; effect.AutoDestroy(); if (speed > 0) { effect.SetAutoMove(forward, speed); } }); } //销毁子弹 BulletFactory.DestroyBullet(this); }
public void PlayShootEffect(EColor color, float startScale = 1f, Vector3?startPos = null) { var effectId = 0; switch (color) { case EColor.Red: effectId = 901; break; case EColor.Purple: effectId = 902; break; case EColor.Blue: effectId = 903; break; case EColor.BlueLight: effectId = 904; break; case EColor.Green: effectId = 905; break; case EColor.Yellow: effectId = 906; break; case EColor.Orange: effectId = 907; break; case EColor.White: effectId = 908; break; } if (effectId > 0) { var pos = startPos == null ? transform.position : (Vector3)startPos; TextureEffectFactroy.CreateEffect(effectId, SortingOrder.ShootEffect, effect => { effect.transform.position = pos; effect.transform.localScale = Vector3.one * startScale; effect.transform.DOScale(0f, 0.4f).onComplete = () => { TextureEffectFactroy.DestroyEffect(effect); }; }); } }
public override void Init(BulletDeploy deploy, Transform master, MeshRenderer model) { _material = model.material; base.Init(deploy, master, model); //初始化被击特效 TextureEffectFactroy.CreateEffect(HitEffectId, SortingOrder.Effect, e => { _hitEffect = e; _hitEffect.SetActiveSafe(false); }); }
public void Destroy() { if (_currBullet != null) { BulletFactory.DestroyBullet(_currBullet); _currBullet = null; } if (_slowEffect != null) { TextureEffectFactroy.DestroyEffect(_slowEffect); _slowEffect = null; } if (_fastEffect != null) { TextureEffectFactroy.DestroyEffect(_fastEffect); _fastEffect = null; } Destroy(gameObject); }
//检测玩家死亡时,是否需要自我销毁并播放特效 private bool CheckBulletExplosion() { if (!BulletExplosion.InExplosion) { return(false); } var pos = CacheTransform.position; var radius = BulletExplosion.Radius; var sqrDist = MathUtility.SqrDistanceXY(pos, BulletExplosion.Center); if (sqrDist < radius * radius) { BulletFactory.DestroyBullet(this); TextureEffectFactroy.CreateEffect(501, SortingOrder.ShootEffect, effect => { effect.Renderer.material.SetColor("_TintColor", ColorUtility.GetColor(Deploy.ExplosionColor)); effect.transform.position = pos; effect.AutoDestroy(); }); return(true); } return(false); }
public void Init(PlayerSupportDeploy deploy, GameObject renderObj) { Deploy = deploy; if (deploy.slowShootEffectId > 0) { TextureEffectFactroy.CreateEffect(deploy.slowShootEffectId, SortingOrder.Effect, obj => { _slowEffect = obj; _slowEffect.transform.Bind(renderObj.transform); _slowEffect.SetActiveSafe(false); }); } if (deploy.fastShootEffectId > 0) { TextureEffectFactroy.CreateEffect(deploy.fastShootEffectId, SortingOrder.Effect, obj => { _fastEffect = obj; _fastEffect.transform.Bind(renderObj.transform); _fastEffect.SetActiveSafe(false); }); } }
public void AddSupport() { var deploy = TableUtility.GetDeploy <PlayerSupportDeploy>(_master.Deploy.supprotId); if (deploy == null) { Debug.LogError("僚机ID不存在:" + _master.Deploy.supprotId); return; } var gameObj = new GameObject("support"); gameObj.transform.SetParent(null, false); gameObj.transform.localScale = _master.transform.localScale; gameObj.transform.position = _master.transform.position; TextureEffectFactroy.CreateEffect(deploy.idleEffectId, SortingOrder.PlayerSupport, effect => { effect.transform.Bind(gameObj.transform); var script = gameObj.AddComponent <PlayerSupport>(); script.Init(deploy, effect.gameObject); _supportList.Add(script); }); }