void Start() { mState1 = State1.ScaleUp; mState2_IsFadingOut = false; mShakeDirects = new Vector3[] { new Vector3(-1F, 1F, 0F) , new Vector3(1F, -1.2F, 0F) , new Vector3(1.2F, 1F, 0F) , new Vector3(-1.2F, -0.8F, 0F) }; mSprWeb = Pool_GameObj.GetObj(Prefab_GoSpriteWeb).GetComponent <tk2dSprite>(); if (NameSprite != null && NameSprite != "") { mSprWeb.spriteId = mSprWeb.GetSpriteIdByName(NameSprite); } Transform ts = mSprWeb.transform; mSprWeb.gameObject.SetActive(true); ts.parent = transform; ts.localPosition = Vector3.zero; Color c = ColorInitialize; c.a = 1F; mSprWeb.color = c; mTsWeb = ts; mTimeWaitFadeout = TimeWebScaleUp + TimeShake - TimeFadeOut; mColorWeb = mSprWeb.color; }
void Handle_GunFire(Player p, Gun g, int score) { //Debug.Log("Handle_GunFire"); Bullet prefabBullet = ModuleBullet.Get_PrefabBullet_Used(g); //tk2dAnimatedSprite ani; if (prefabBullet == null) { return; } GunLevelType gLvType = g.GetLevelType(); GunPowerType gPowerType = g.GetPowerType(); int NumInstance = 2 + (int)gLvType;//生成的数量 float widthBullet = WidthBulletNormal[(int)g.GetLevelType()]; Vector3 posOffset = new Vector3(-widthBullet * NumInstance / 2F, 0F); for (int i = 0; i != NumInstance; ++i) { Bullet b = Pool_GameObj.GetObj(prefabBullet.gameObject).GetComponent <Bullet>(); b.Prefab_GoAnisprBullet = Prefab_AniBullet; b.Prefab_SpriteNameSet = gPowerType == GunPowerType.Normal ? nameSetAniBulletNor : nameSetAniBulletLizi; BulletEx_Splitor bEx_Splitor = b.gameObject.AddComponent <BulletEx_Splitor>(); bEx_Splitor.FactorSplit = NumInstance; b.transform.position = g.local_GunFire.position + g.AniSpr_GunPot.transform.rotation * posOffset; posOffset.x += widthBullet; b.Score = score; b.Fire(p, null, g.AniSpr_GunPot.transform.rotation); } }
private static GameObject CreateModel(GameObject modelPerf, out tk2dSpriteAnimator animator, Vector3 posOff, Color color, Transform parentTs) { var model = Pool_GameObj.GetObj(modelPerf); model.SetActive(true); animator = model.GetComponent <tk2dSpriteAnimator>() ?? model.GetComponentInChildren <tk2dSpriteAnimator>(); var crenderers = model.GetComponentsInChildren <Renderer>(); foreach (var r in crenderers) { r.enabled = true; } var aniTs = model.transform; aniTs.parent = parentTs.parent; aniTs.position = parentTs.position + posOff; aniTs.rotation = parentTs.rotation; var tk2Ds = model.GetComponentsInChildren <tk2dSprite>(); foreach (var tks in tk2Ds) { tks.color = color; } return(model); }
/// <summary> /// 死亡动画 /// </summary> /// <param name="delayTotal"></param> protected virtual void DeathAnimation(float delayTotal) { //播放死亡动画 if (Prefab_GoAniDead == null) { return; } var goDieAnimation = Pool_GameObj.GetObj(Prefab_GoAniDead); goDieAnimation.GetComponent <tk2dSprite>().color = Colour; var goDieAniTs = goDieAnimation.transform; goDieAnimation.SetActive(true); goDieAniTs.parent = GameMain.Singleton.FishGenerator.transform; goDieAniTs.position = new Vector3(MTs.position.x, MTs.position.y, MTs.position.z); goDieAniTs.rotation = MTs.rotation; var dshadow = YxShadow.AddShadow(goDieAnimation); dshadow.SetRecycleShadowModel(Prefab_GoAniDead, goDieAniTs, delayTotal); var fishRecycleDelay = goDieAnimation.AddComponent <RecycleDelay>(); fishRecycleDelay.delay = delayTotal; fishRecycleDelay.Prefab = Prefab_GoAniDead; }
private void PushOneStack(int coinNum, int fishOdd, int gunScore) { //return; if (coinNum <= 0) { return; } //CoinStack coinStackNew = Instantiate(Prefab_coinStack) as CoinStack; CoinStack coinStackNew = Pool_GameObj.GetObj(Prefab_coinStack.gameObject).GetComponent <CoinStack>(); Transform coinStackNewTs = coinStackNew.transform; mCoinStackCurrentDepth = mCoinStacks.Count == 0 ? 0F : mCoinStackCurrentDepth - 0.1F; coinStackNewTs.parent = transform; coinStackNewTs.localRotation = Quaternion.identity; coinStackNewTs.localPosition = new Vector3(-mCoinStacks.Count * (OneStackWidth + OneStackSpace), 0F, mCoinStackCurrentDepth); coinStackNew.PileUp(coinNum, GetCoinStackHeight(fishOdd, gunScore), mCurCoinStackBGColor); mCurCoinStackBGColor = !mCurCoinStackBGColor; coinStackNew.EvtDisappear += Handle_CoinStackDisappear; coinStackNew.EvtRoleToHead += Handle_CoinStackRollToHead; mCoinStacks.Enqueue(coinStackNew); //mState_IsMovingStacks = true; }
public void Fire(Player from, Fish tar, Quaternion dir) { GameMain gm = GameMain.Singleton; if (tar != null) { mTargetFish = tar; IsLockingFish = true; Vector3 targetDir = tar.transform.position - mTs.position; targetDir.z = 0F; targetDir.Normalize(); targetDir = Quaternion.Euler(0F, 0F, Random.Range(-90F, 90F)) * targetDir + from.transform.up;//得出子弹偏向 Random.Range(0,2)==0?-90F:90F mTs.rotation = Quaternion.FromToRotation(Vector3.up, targetDir); } else { IsLockingFish = false; mTs.rotation = dir; } mTs.parent = gm.TopLeftTs; Text_CoinNum.text = Score.ToString(); Text_CoinNum.Commit(); Owner = from; ++Owner.GunInst.NumBulletInWorld; BackStageSetting bss = gm.BSSetting; if (bss.IsBulletCrossWhenScreenNet.Val && gm.IsScreenNet()) { MoveArea = gm.WorldDimension; } else { MoveArea = from.AtScreenArea; } if (mBulletGO == null) { mBulletGO = Pool_GameObj.GetObj(Prefab_GoAnisprBullet); tk2dSpriteAnimator aniSprBullet = mBulletGO.GetComponent <tk2dSpriteAnimator>(); if (aniSprBullet != null) { //aniSprBullet.clipId = aniSprBullet.GetClipIdByName(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); //Debug.Log(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); aniSprBullet.Play(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); //aniSprBullet.PlayFrom("1",0.1F); } mBulletGO.SetActive(true); mBulletGO.transform.parent = mTs; mBulletGO.transform.localPosition = Vector3.zero; mBulletGO.transform.localRotation = Quaternion.identity; } }
IEnumerator _Coro_FlytProcess(Vector3 fishDieWorldPos, FlyingCoinType t, int num, float delay) { yield return(new WaitForSeconds(delay)); //播放声音 if (GameMain.Singleton.SoundMgr.snd_Coin != null && t == FlyingCoinType.Sliver) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Coin); } if (GameMain.Singleton.SoundMgr.snd_Gold != null && t == FlyingCoinType.Glod) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Gold); } Vector3 fishDielocalPos = transform.InverseTransformPoint(fishDieWorldPos); fishDielocalPos.z = 0F; FlyingCoin useGoldPrefab = t == FlyingCoinType.Glod ? Prefab_GoldBig : Prefab_Gold; //生成币 FlyingCoin[] golds = new FlyingCoin[num]; Vector3 startLocalPos = fishDielocalPos - new Vector3(AppearOffsetX * (num - 1) * 0.5F, AppearOffsetY * (num - 1) * 0.5F, 0F); startLocalPos += startLocalPos.normalized * 38.4F;//*1.3F,为延长距离,使得金币更像是鱼中飞出 float maxTime = 0F; for (int i = 0; i != num; ++i) { //golds[i] = Instantiate(useGoldPrefab) as FlyingCoin; golds[i] = Pool_GameObj.GetObj(useGoldPrefab.gameObject).GetComponent <FlyingCoin>(); golds[i].FlySpeed = FlySpeed; Transform goldTs = golds[i].transform; goldTs.parent = transform; goldTs.localRotation = Quaternion.identity; goldTs.localPosition = startLocalPos + new Vector3(AppearOffsetX * i, AppearOffsetY * i, 0F); float flyNeedTime = golds[i].FlytoPosZero(Curve_Scale); if (flyNeedTime > maxTime) { maxTime = flyNeedTime; } yield return(new WaitForSeconds(AppearInterval)); } yield return(new WaitForSeconds(maxTime - AppearInterval * num)); for (int i = 0; i != num; ++i) { Pool_GameObj.RecycleGO(null, golds[i].gameObject); //Destroy(golds[i].gameObject); } }
IEnumerator _Coro_Popup(int num, Vector3 worldPos, Transform tsParent, int odds) { //tk2dTextMesh digit = Instantiate(Prefab_Digit) as tk2dTextMesh; var digit = Pool_GameObj.GetObj(Prefab_Digit.gameObject).GetComponent <tk2dTextMesh>(); digit.gameObject.SetActive(true); digit.text = YxUtiles.GetShowNumberToString(num); digit.Commit(); var ts = digit.transform; ts.parent = tsParent; ts.localRotation = Quaternion.identity; var scale = Mathf.Min(0.5f + odds / 5f * 0.3f, 1.5f); ts.localScale = new Vector3(scale, scale, 1F); var oriPos = worldPos; oriPos.z = Defines.GlobleDepth_DieFishPopDigit; ts.position = oriPos; var elapse = 0F; var c = Prefab_Digit.color; while (elapse < Duration) { yield return(0); var prct = elapse / Duration; ts.position = oriPos + new Vector3(0F, Curve_OffsetY.Evaluate(prct), 0F); digit.Commit(); elapse += Time.deltaTime; } yield return(new WaitForSeconds(2)); elapse = 0; while (elapse < Duration) { var prct = elapse / Duration; c.a = Curve_Alpha.Evaluate(prct); digit.color = c; digit.Commit(); elapse += Time.deltaTime; yield return(0); } //Destroy(digit.gameObject); digit.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_Digit.gameObject, digit.gameObject); }
IEnumerator _Coro_Popup(int num, Vector3 worldPos, Transform tsParent, int fishTypeIdx) { //tk2dTextMesh digit = Instantiate(Prefab_Digit) as tk2dTextMesh; tk2dTextMesh digit = Pool_GameObj.GetObj(Prefab_Digit.gameObject).GetComponent <tk2dTextMesh>(); digit.gameObject.SetActive(true); digit.text = num.ToString(); digit.Commit(); Transform ts = digit.transform; ts.parent = tsParent; ts.localRotation = Quaternion.identity; float scale = 1F; if (mScaleDatasMap.TryGetValue(fishTypeIdx, out scale)) { ts.localScale = new Vector3(scale, scale, 1F); } else { ts.localScale = Vector3.one; } Vector3 oriPos = worldPos; oriPos.z = Defines.GlobleDepth_DieFishPopDigit; ts.position = oriPos; float elapse = 0F; Color c = Prefab_Digit.color; while (elapse < Duration) { float prct = elapse / Duration; ts.position = oriPos + new Vector3(0F, Curve_OffsetY.Evaluate(prct), 0F); c.a = Curve_Alpha.Evaluate(prct); digit.color = c; digit.Commit(); elapse += Time.deltaTime; yield return(0); } //Destroy(digit.gameObject); digit.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_Digit.gameObject, digit.gameObject); }
/// <summary> /// 创建锁鱼子弹 /// </summary> /// <param name="p">开枪者</param> /// <param name="g">枪</param> /// <param name="score">分数</param> /// <param name="isLock"></param> /// <param name="bulletId">子弹id</param> private void Handle_GunFire(Player p, Gun g, int score, bool isLock, int bulletId) { if (!isLock) { return; } var prefabBullet = g.Prefab_BulletNormal;//ModuleBullet.Get_PrefabBullet_Used(g); var b = Pool_GameObj.GetObj(prefabBullet.gameObject).GetComponent <Bullet>(); b.Id = bulletId; b.transform.position = g.local_GunFire.position; b.Score = score; /*var upToward = mLockedTarget[p.Idx].transform.position - g.TsGun.position; * upToward.z = 0F; * var targetDir = Quaternion.FromToRotation(Vector3.up, upToward);*/ b.Fire(p, mLockedTarget[p.Idx], g.TsGun.rotation); }
void Handle_GunFire(Player p, Gun g, int score) { if (!Fireable[p.Idx]) { return; } Bullet prefabBullet = Get_PrefabBullet_Used(g); if (prefabBullet == null) { return; } Bullet b = Pool_GameObj.GetObj(prefabBullet.gameObject).GetComponent <Bullet>(); b.transform.position = g.local_GunFire.position; b.Score = score; b.Fire(p, null, g.AniSpr_GunPot.transform.rotation); }
public void Fire(Player from, Fish tar, Quaternion dir) { GameMain gm = GameMain.Singleton; _mTargetFish = tar; IsLockingFish = tar != null; _mTs.rotation = dir; _mTs.parent = gm.TopLeftTs; var old = _mTs.localPosition; old.z = 0; _mTs.localPosition = old; Text_CoinNum.text = Score.ToString(); Text_CoinNum.Commit(); Owner = from; ++Owner.GunInst.NumBulletInWorld; BackStageSetting bss = gm.BSSetting; MoveArea = gm.WorldDimension; if (_mBulletGo == null) { _mBulletGo = Pool_GameObj.GetObj(Prefab_GoAnisprBullet); tk2dSpriteAnimator aniSprBullet = _mBulletGo.GetComponent <tk2dSpriteAnimator>(); if (aniSprBullet != null) { //aniSprBullet.clipId = aniSprBullet.GetClipIdByName(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); //YxDebug.Log(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); aniSprBullet.Play(Prefab_SpriteNameSet.Texts[from.Idx % Prefab_SpriteNameSet.Texts.Length]); //aniSprBullet.PlayFrom("1",0.1F); } _mBulletGo.SetActive(true); _mBulletGo.transform.parent = _mTs; var pos = Vector3.zero; _mBulletGo.transform.localPosition = pos; pos.z -= 10; Text_CoinNum.transform.localPosition = pos; _mBulletGo.transform.localRotation = Quaternion.identity; } }
/// <summary> /// 开枪(创建子弹) /// </summary> /// <param name="p">开枪者</param> /// <param name="g">枪</param> /// <param name="score">分数</param> /// <param name="isLock"></param> /// <param name="bulletId"></param> void Handle_GunFire(Player p, Gun g, int score, bool isLock, int bulletId) { if (isLock) { return; } var prefabBullet = g.Prefab_BulletNormal;//Get_PrefabBullet_Used(g);//找到枪对应的子弹 啬 if (prefabBullet == null) { return; } var b = Pool_GameObj.GetObj(prefabBullet.gameObject).GetComponent <Bullet>(); b.Id = bulletId; b.transform.position = g.local_GunFire.position; b.Score = score; b.Fire(p, null, g.TsGun.rotation);//g.AniSpr_GunPot.transform.rotation); }
IEnumerator _Coro_GenerateBubble() { int numGenerated = 0; Vector3 localPos = new Vector3(0F, 0F, 0.01F); while (numGenerated < NumGenerate) { //tk2dSprite sprBubble = Instantiate(Prefab_Bubble) as tk2dSprite; tk2dSprite sprBubble = Pool_GameObj.GetObj(Prefab_Bubble.gameObject).GetComponent <tk2dSprite>(); sprBubble.gameObject.SetActive(true); sprBubble.transform.parent = transform; sprBubble.transform.localPosition = localPos; localPos.z += 0.01F; StartCoroutine(_Coro_BubbleScaleUp(sprBubble)); //sprBubble. ++numGenerated; yield return(new WaitForSeconds(InttervalBubble)); } }
void Handle_GunFire(Player p, Gun g, int score) { if (mLockedTarget[p.Idx] == null) { return; } //Debug.Log("Handle_GunFire fire fish = " + mLockedTarget[p.Idx].name+" p.idx = "+p.Idx); Bullet prefabBullet = ModuleBullet.Get_PrefabBullet_Used(g); Bullet b = Pool_GameObj.GetObj(prefabBullet.gameObject).GetComponent <Bullet>(); b.transform.position = g.local_GunFire.position; b.Score = score; Quaternion targetDir; Vector3 upToward = mLockedTarget[p.Idx].transform.position - g.TsGun.position; upToward.z = 0F; targetDir = Quaternion.FromToRotation(Vector3.up, upToward); b.Fire(p, mLockedTarget[p.Idx], targetDir); //Debug.Log("Handle_GunFire fire fish = " + mLockedTarget[p.Idx].name); }
protected override void DeathAnimation(float delayTotal) { if (Prefab_GoAniDead == null) { return; } foreach (var pos in Positions) { var goDieAnimation = Pool_GameObj.GetObj(Prefab_GoAniDead); goDieAnimation.GetComponent <tk2dSprite>().color = Colour; var goDieAniTs = goDieAnimation.transform; goDieAnimation.SetActive(true); goDieAniTs.parent = MTs; goDieAniTs.localPosition = pos; goDieAniTs.rotation = MTs.rotation; goDieAniTs.parent = GameMain.Singleton.FishGenerator.transform; var fishRecycleDelay = goDieAnimation.AddComponent <RecycleDelay>(); fishRecycleDelay.delay = delayTotal; fishRecycleDelay.Prefab = Prefab_GoAniDead; } }
void Die(Player killer, float delay, int oddsMulti) { Attackable = false; Vector3 deadWorldPos = mTs.position; //if (EvtDieStart != null) // EvtDieStart = null; //������ײ�� GetComponent <Collider>().enabled = false; //����ԭ���� //AniSprite.renderer.enabled = false; //Destroy(AniSprite.renderer.gameObject); //foreach () Component[] renderers = GetComponentsInChildren(typeof(Renderer)); foreach (Component r in renderers) { ((Renderer)r).enabled = false; } float delayTotal = delay + TimeDieAnimation; //������������ if (Prefab_GoAniDead != null) { GameObject goDieAnimation = Pool_GameObj.GetObj(Prefab_GoAniDead); goDieAnimation.SetActive(true); goDieAnimation.transform.parent = GameMain.Singleton.FishGenerator.transform; goDieAnimation.transform.position = new Vector3(mTs.position.x, mTs.position.y, Defines.GlobleDepth_DieFish); goDieAnimation.transform.rotation = mTs.rotation; RecycleDelay fishRecycleDelay = goDieAnimation.AddComponent <RecycleDelay>(); fishRecycleDelay.delay = delayTotal; fishRecycleDelay.Prefab = Prefab_GoAniDead; } //�ɱ� if (Odds != 0) { killer.Ef_FlyCoin.FlyFrom(deadWorldPos, oddsMulti * Odds, delayTotal); } //���� if (Odds <= 10) { if (GameMain.Singleton.SoundMgr.snd_Score != null) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Score[0]); } } else if (Odds > 10 && Odds < 25) { if (GameMain.Singleton.SoundMgr.snd_Score != null) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Score[1]); } } else { if (GameMain.Singleton.SoundMgr.snd_Score != null) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Score[2]); } } if (Snds_Die != null && Snds_Die.Length != 0) { GameMain.Singleton.SoundMgr.PlayOneShot(Snds_Die[Random.Range(0, Snds_Die.Length)]); } //yield return new WaitForSeconds(delayTotal); //ɾ�������� Clear(); }
private IEnumerator _Coro_FlytProcess(Vector3 fishDieWorldPos, int num, float delay) { int numFly; var typeCoin = FlyingCoinType.Sliver; if (num < 10) { numFly = num; } else { numFly = num / 5 + (num % 5 != 0 ? 1 : 0); if (numFly > 11) { numFly = 11; //最大飞11颗 } typeCoin = FlyingCoinType.Glod; } yield return(new WaitForSeconds(delay)); //播放声音 if (PlaySound && GameMain.Singleton != null) { var musicMgr = Facade.Instance <MusicManager>(); if (typeCoin == FlyingCoinType.Sliver) { musicMgr.Play("getsilver"); } if (typeCoin == FlyingCoinType.Glod) { musicMgr.Play("getgold"); } } var fishDielocalPos = transform.InverseTransformPoint(fishDieWorldPos); fishDielocalPos.z = 0F; //var useGoldPrefab = t==FlyingCoinType.Glod ? Prefab_GoldBig : Prefab_Gold; FlyingCoin useGoldPrefab; float offy; if (typeCoin == FlyingCoinType.Glod) { useGoldPrefab = Prefab_GoldBig; offy = 12; } else { useGoldPrefab = Prefab_Gold; offy = 6.5f; } //生成币 var golds = new FlyingCoin[numFly]; var startLocalPos = fishDielocalPos; // -new Vector3(AppearOffsetX * (num - 1) * 0.5F, AppearOffsetY * (num - 1) * 0.5F, 0F); //startLocalPos += startLocalPos.normalized * 38.4F;//*1.3F,为延长距离,使得金币更像是鱼中飞出 var maxTime = 0F; var con = new GameObject("coins"); var ts = con.transform; if (coinSpace++ > 50) { coinSpace = 0; } ts.parent = GetCoinsContainer(); ts.localPosition = new Vector3(0, 0, coinSpace * 0.0001f); ts.localRotation = Quaternion.identity; var target = Vector3.zero; for (var i = 0; i < numFly; ++i) { var gold = Pool_GameObj.GetObj(useGoldPrefab.gameObject).GetComponent <FlyingCoin>(); golds[i] = gold; gold.FlySpeed = FlySpeed; var goldTs = gold.transform; goldTs.parent = ts; goldTs.localRotation = Quaternion.identity; var offPos = new Vector3(AppearOffsetX * i, AppearOffsetY * i, 0F); offPos = fishDielocalPos.x < transform.localRotation.x ? -offPos : offPos; goldTs.localPosition = startLocalPos + offPos; var flyNeedTime = gold.FlytoPosZero(Curve_Scale, target); target.y += offy; if (flyNeedTime > maxTime) { maxTime = flyNeedTime; } yield return(new WaitForSeconds(AppearInterval)); } yield return(new WaitForSeconds(maxTime - AppearInterval * numFly)); var coinNum = Pool_GameObj.GetObj(CoinNumPerfab.gameObject).GetComponent <tk2dTextMesh>(); var coinNumTs = coinNum.transform; coinNum.text = num.ToString(); coinNumTs.parent = ts; coinNumTs.localRotation = Quaternion.identity; coinNumTs.localPosition = new Vector3(0, target.y, 10); while (_nextStop) { yield return(new WaitForSeconds(WaitTime)); } _nextStop = true; yield return(new WaitForSeconds(WaitTime)); _nextStop = false; var times = 1; var pos = ts.localPosition; while (times < MoveCount) { ts.localPosition = pos; pos.x -= HMoveSpeed; times++; yield return(new WaitForSeconds(WaitTime)); } //消失 for (var i = 0; i != numFly; ++i) { Pool_GameObj.RecycleGO(null, golds[i].gameObject); //Destroy(golds[i].gameObject); } Destroy(con); }