private void OnSettleUpdate() { if (_isClickSpace && !_isGetAward && _isSettle) { Sequence sq = DOTween.Sequence(); _isGetAward = true; _isClickSpace = false; _isSettle = false; if (VirusGameDataAdapter.GetCurLevelCoin() > 0) { int count = UnityEngine.Random.Range(10, 20); Vector3 pos = new Vector2(0f, -96f); float offset = 360f / count; for (int i = 0; i < count; i++) { float angle = offset * i - 180; bool isP = angle > -45f && angle < 135; float radius = UnityEngine.Random.Range(200f, 250f); Vector2 uiPos = pos + Quaternion.Euler(0, 0, angle) * Vector2.right * radius; EventManager.TriggerEvent(new UIVirusAddTotalCoinEvent(uiPos, isP)); } VirusGameDataAdapter.AddTotalCoin(VirusGameDataAdapter.GetCurLevelCoin()); VirusGameDataAdapter.ResetLevelCoin(); sq.AppendCallback(() => { _uiMrg.SettlePanel.UnActive(); }); sq.AppendInterval(1.5f); sq.AppendCallback(() => { _fsm.ChangeState(VirusGameState.ShowTitle); }); return; } sq.AppendCallback(() => { _uiMrg.SettlePanel.UnActive(); }); sq.AppendInterval(0.5f); sq.AppendCallback(() => { _fsm.ChangeState(VirusGameState.ShowTitle); }); } }
private void UpgradeMainFire() { int needCoin = VirusTool.GetUpgradeCoin(VirusPlayerDataAdapter.GetShootLevel()); VirusGameDataAdapter.MinusTotalCoin(needCoin); VirusPlayerDataAdapter.AddShootPower(1); }
private void OnSettleEnter() { ScenePropMrg.Instance.RemoveAll(); TimerManager.Instance.FinishTimers(); VirusGameDataAdapter.AddLevel(); float y = 15f - _virusPlayer.transform.localPosition.y; _virusPlayer.SetPlayerState(false, false); _virusPlayer.Invincible = true; Sequence sq = DOTween.Sequence(); sq.Append(_virusPlayer.transform.DOMoveY(15f, y / 15f)); sq.AppendInterval(1.0f); sq.AppendCallback(() => { _uiMrg.MainPanel.UnActive(); }); sq.AppendInterval(1.0f); sq.AppendCallback(() => { VirusSoundMrg.Instance.PlaySound(VirusSoundType.Clear); _uiMrg.SettlePanel.Active(); //_uiMrg.SettlePanel.SetCoinText(VirusGameDataAdapter.GetCurLevelCoin()); _uiMrg.CoinPanel.Active(); }); sq.AppendInterval(0.5f); sq.AppendCallback(() => { _isSettle = true; }); _isClickSpace = false; }
private void UpgradeMainSpeed() { int needCoin = VirusTool.GetUpgradeCoin(VirusPlayerDataAdapter.GetShootSpeed()); VirusGameDataAdapter.MinusTotalCoin(needCoin); VirusPlayerDataAdapter.AddShootSpeed(); }
private void Start() { VirusGameDataAdapter.Load(); _fsm.ChangeState(VirusGameState.Load); _uiMrg.SettlePanel.UnActive(); _uiMrg.RestartPanel.UnActive(); virusMrg.BindView(_uiMrg.MainPanel); }
private void OnPlayEnter() { #if UNITY_EDITOR Debug.Log("Level: " + VirusGameDataAdapter.GetLevel()); #endif _uiMrg.MainPanel.Active(); _virusPlayer.Invincible = false; _virusPlayer.SetPlayerState(true, true); virusMrg.GameStart(); }
private void OnPlayEnter() { Debug.Log("Level:" + VirusGameDataAdapter.GetLevel()); _uiMrg.TitlePanel.UnActive(); _uiMrg.UpgradePanel.UnActive(); _uiMrg.MainPanel.Active(); _virusPlayer.Invincible = false; _virusPlayer.SetPlayerState(true, true); virusMrg.GameStart(); }
public void GameStart() { _minOrderIndex = 0; _maxOrderIndex = 5000; _percent.Value = 1; _curCount = 0; _isTiped = false; _virusObjects = new List <GameObject>(); _originCount = WaveVirusDataAdapter.Load(VirusGameDataAdapter.GetLevel()); StartCoroutine(Spawn()); }
private void SpawnRightBullet() { var obj = BulletPools.Instance.Spawn("ViceBullet_1"); obj.transform.parent = _rightShootPos; obj.transform.localPosition = Vector3.zero; float value = Random.Range(5f, 10f) * VirusGameDataAdapter.GetLevel(); _rightBullet = obj.GetComponent <ViceBullet1>(); _rightBullet.Initi(); _rightBullet.Initi(value); }
private void Update() { if (_isLerp) { int totalCoin = VirusGameDataAdapter.GetCurLevelCoin(); _lastCoin = Mathf.Lerp(_lastCoin, totalCoin, Time.deltaTime * 5); if (Mathf.Abs(_lastCoin - totalCoin) < 0.1f) { _isLerp = false; } _coinText.text = VirusTool.GetStrByIntger(Mathf.CeilToInt(_lastCoin)); } }
public override void Active() { _resultBg.transform.localScale = Vector3.zero; _resultBg.transform.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBounce); gameObject.SetActive(true); _index = 0; _count = 0; _isActive = true; coinImage.sprite = _coinSheets[_index]; int i = UnityEngine.Random.Range(0, _tipStrList.Count); _tipText.text = _tipStrList[i]; _coinText.text = VirusGameDataAdapter.GetCurLevelCoin().ToString(); }
private void OnSettleUpdate() { if (IGamerProfile.Instance == null) { if (Input.GetKeyUp(KeyCode.KeypadEnter) || Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCodeTV.PadEnter01) || Input.GetKeyUp(KeyCodeTV.PadEnter02) || Input.GetKeyUp(KeyCode.JoystickButton0)) { //监听遥控器确定键消息 //_isClickSpace = true; EventManager.TriggerEvent(new FirstByteClick5DownEvent()); } } if (_isClickSpace && !_isGetAward && _isSettle) { Sequence sq = DOTween.Sequence(); _isGetAward = true; _isClickSpace = false; _isSettle = false; if (VirusGameDataAdapter.GetCurLevelCoin() > 0) { int count = UnityEngine.Random.Range(10, 20); Vector3 pos = new Vector2(0f, -96f); float offset = 360f / count; for (int i = 0; i < count; i++) { float angle = offset * i - 180; bool isP = angle > -45f && angle < 135; float radius = UnityEngine.Random.Range(200f, 250f); Vector2 uiPos = pos + Quaternion.Euler(0, 0, angle) * Vector2.right * radius; EventManager.TriggerEvent(new UIVirusAddTotalCoinEvent(uiPos, isP)); } VirusGameDataAdapter.AddTotalCoin(VirusGameDataAdapter.GetCurLevelCoin()); VirusGameDataAdapter.ResetLevelCoin(); sq.AppendCallback(() => { _uiMrg.SettlePanel.UnActive(); }); sq.AppendInterval(1.5f); sq.AppendCallback(() => { _fsm.ChangeState(VirusGameState.ShowTitle); }); return; } sq.AppendCallback(() => { _uiMrg.SettlePanel.UnActive(); }); sq.AppendInterval(0.5f); sq.AppendCallback(() => { _fsm.ChangeState(VirusGameState.ShowTitle); }); } }
private void CallBackEvent(bool isSucceed) { if (true == isSucceed) { //付费成功 //复活玩家 RevivePlayer(); VirusGameDataAdapter.UpdateTotalCoin(IGamerProfile.Instance.playerdata.playerMoney); UnActive(); } else { //付费失败 ClosePanel(); } }
private void ClickEnterBtEvent(InputKillVirus.ButtonState val) { if (val == InputKillVirus.ButtonState.DOWN) { return; } switch (_buttonState) { case ButtonState.Enter: { int playerCoin = VirusGameDataAdapter.GetTotalCoin(); if (playerCoin >= m_NeedCoin) { //确认复活 RevivePlayer(); SubCoin(); } else { //需要充值 //VirusGameMrg.Instance.m_UIMrg.BuyCoinsPanel.Active(); if (IGamerProfile.Instance != null) { HiddenPanel(); RemoveEvent(); UiGameBuyCoins com = (UiGameBuyCoins)UiSceneUICamera.Instance.CreateAloneScene(UiSceneUICamera.UISceneId.Id_UIGameBuyCoins); com.PlayerBuyCoins(m_NeedCoin); com.AddEvent(CallBackEvent); return; } else { RevivePlayer(); } } UnActive(); break; } case ButtonState.Back: { ClosePanel(); break; } } }
public override float StartCure(ICure icure, float healthValue) { if (Mathf.Abs(TotalHealth - VirusHealth.Value) > 0.1f) { _virusHealthAddEffect.StartHealthEffect(icure); } float vv = base.StartCure(icure, healthValue); var virusLevel = VirusTool.GetVirusColorLevel("VampireVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value); if (virusLevel != CurColorLevel) { CurColorLevel = virusLevel; VirusSprite.Initi(CurColorLevel); transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel); } return(vv); }
public override float StartCure(ICure iCure, float healthValue) { float vv = base.StartCure(iCure, healthValue); var virusLevel = VirusTool.GetVirusColorLevel("RegenerativeVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value); if (virusLevel != CurColorLevel) { CurColorLevel = virusLevel; VirusSprite.Initi(CurColorLevel); transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel); } if (Mathf.Abs(VirusHealth.Value - TotalHealth) < 0.1f) { _virusHealthAddEffect.StopHealthEffect(this); } return(vv); }
public virtual void Death(bool isEffect, bool isDivide, bool isCoin, bool isProp) { IsDeath = true; int level = VirusGameDataAdapter.GetLevel(); int coin = VirusTool.GetVirusDeathCoin(level); if (isEffect) { float scale = transform.localScale.x; int index = Random.Range(1, 5); var explosion = EffectPools.Instance.Spawn("Explosion" + index); explosion.transform.localScale = new Vector3(scale * 2f, scale * 2f, 1); explosion.transform.position = transform.position; explosion.GetComponent <VirusFragmentMrg>().Initi(index - 1, Random.Range(5, 10)); VirusSoundMrg.Instance.PlaySound(VirusSoundType.VirusDeath); VirusCameraShake.Instance.Shake(); } if (isCoin) { if (coin > 0) { VirusGameDataAdapter.AddLevelCoin(coin); int count = Random.Range(1, 4); for (int i = 0; i < count; i++) { EventManager.TriggerEvent(new UIVirusAddLevelCoinEvent(transform.position)); } } } if (isProp) { string propName = VirusTool.GetPropName(level); if (!propName.Equals("None") && SplitLevel > SplitLevel.Level1) { var prop = PropPools.Instance.Spawn(propName + "Prop"); prop.transform.position = transform.position; prop.GetComponent <VirusPropMove>().Initi(); ScenePropMrg.Instance.Add(prop); } } VirusMrg.Instance.Remove(gameObject); }
protected override void RunAway() { var move = transform.GetComponent <VirusMove>(); for (int i = 0; i < 3; i++) { int level = (int)(SplitLevel - 1); SplitLevel splitLevel = level < 0 ? SplitLevel.Level1 : (SplitLevel)level; float angle = Random.Range(i * 120, (i + 1) * 120); VirusData data = new VirusData(); data.VirusColorLevel = VirusTool.GetColorLevel(CurColorLevel); data.SplitLevel = splitLevel; data.MoveSpeed = move.OriginSpeed; data.MoveDirection = Quaternion.Euler(0, 0, angle) * Vector3.right; int t = VirusGameDataAdapter.GetLevel(); data.HealthValue = VirusTool.GetVirusHealthByColorLevel("DartVirus", t, data.VirusColorLevel); VirusMrg.Instance.SpawnVirus("DartVirus", data, transform.position, true); } }
public override void Injured(float damageValue, bool isEffect) { if (VirusHealth.Value - damageValue <= 0) { Death(true, true, true, true); return; } VirusHealth.Value -= damageValue; var virusLevel = VirusTool.GetVirusColorLevel("VampireVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value); if (virusLevel != CurColorLevel) { CurColorLevel = virusLevel; VirusSprite.Initi(CurColorLevel); transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel); } if (isEffect) { virusHurtEffect.StartHurtEffect(); } }
void ShowCoinData() { int coin = VirusGameDataAdapter.GetCurLevelCoin(); int jiaCheng = UnityEngine.Random.Range(10, 100); if (IGamerProfile.Instance != null) { UiSceneSelectGameCharacter.CharacterId id = UiSceneSelectGameCharacter.CharacterId.ShouYi; IGamerProfile.PlayerData.PlayerChacterData dt = IGamerProfile.Instance.playerdata.characterData[(int)id]; GameCharacter.CharacterData characterDt = IGamerProfile.gameCharacter.characterDataList[(int)id]; jiaCheng = characterDt.LevelBToVal.GetValue(dt.levelB); //关卡加成 } int jiaChengCoin = Mathf.CeilToInt(jiaCheng * coin / 100f); int totalCoin = coin + jiaChengCoin; _coinData.CoinText.text = VirusTool.GetStrByIntger(coin); _coinData.TotalCoinText.text = VirusTool.GetStrByIntger(totalCoin); _coinData.JiaChengText.text = jiaCheng.ToString() + "%:"; _coinData.JiaChengCoinText.text = VirusTool.GetStrByIntger(jiaChengCoin); }
private void Update() { if (_isLerp) { int totalCoin = VirusGameDataAdapter.GetTotalCoin(); _lastCoin = Mathf.Lerp(_lastCoin, totalCoin, Time.deltaTime * 5); if (Mathf.Abs(_lastCoin - totalCoin) < 0.1f) { _isLerp = false; _isSet = false; } _coinText.text = VirusTool.GetStrByIntger(Mathf.RoundToInt(_lastCoin)); _totalTime -= Time.deltaTime; if (_totalTime <= 0 && _num > 0) { _num--; VirusSoundMrg.Instance.PlaySound(VirusSoundType.TotalCoin); _totalTime = 0.15f; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Virus")) { if (VirusPlayerDataAdapter.GetShootCoin()) { EventManager.TriggerEvent(new UIVirusAddLevelCoinEvent(transform.position)); VirusGameDataAdapter.AddLevelCoin(1); } var baseVirus = collision.transform.GetComponent <BaseVirus>(); if (!baseVirus.IsDeath) { baseVirus.Injured(_damageValue, true); } var obj = EffectPools.Instance.Spawn("HitEffect"); obj.transform.position = transform.position; obj.transform.localScale = Vector3.one * 1.5f; BulletPools.Instance.DeSpawn(gameObject); } }
/// <summary> /// 初始化4个单元地图 /// </summary> public void Init() { m_MapData.m_MapList.Add(m_MapData.m_MapObj.transform); for (int i = 0; i < m_MapData.m_MapCount - 1; i++) { GameObject obj = QyCreateObject.Instantiate(m_MapData.m_MapObj, m_MapData.m_Parent); if (obj != null) { m_MapData.m_MapList.Add(obj.transform); } } for (int i = 0; i < m_MapData.m_MapCount; i++) { Vector3 pos = Vector3.zero; pos.x = (i - 1) * m_MapData.m_DisX; m_MapData.m_MapList[i].name = "map0" + (i + 1).ToString(); m_MapData.m_MapList[i].localPosition = pos; if (i != 1) { m_MapData.m_MapList[i].localScale = new Vector3(m_MapData.m_MinScale, m_MapData.m_MinScale, 1f); } else { m_MapData.m_MapList[i].localScale = new Vector3(m_MapData.m_MaxScale, m_MapData.m_MaxScale, 1f); } } if (IGamerProfile.Instance != null) { m_MapData.m_MaxLevel = IGamerProfile.gameLevel.mapData.Length; m_MapData.m_UnlockMaxLevel = IGamerProfile.Instance.getLastLockedMap + 1; } m_MapData.m_CurLevel = VirusGameDataAdapter.GetLevel(); //m_MapData.m_CurLevel = 2; m_MapData.m_MaxLevel = 2; m_MapData.m_UnlockMaxLevel = 1; //test InitCurrentLevel(); UpdateLevalInfo(); UpdateMapLevelLock(); }
private IEnumerator Spawn() { List <WaveVirusItem> items = WaveVirusDataAdapter.GetWaveVirus(); int count = items.Count; int cc = 0; _isSpawned = false; while (true) { yield return(new WaitForSeconds(Random.Range(0.3f, 0.8f))); VirusData data = new VirusData(); Vector3 dir = Quaternion.Euler(0, 0, Random.Range(-20f, 20f)) * Vector3.down; SplitLevel splitLevel = items[cc].SplitLevel; string virusName = items[cc].VirusName.ToString(); int level = VirusGameDataAdapter.GetLevel(); data.VirusColorLevel = items[cc].ColorLevel; data.HealthValue = VirusTool.GetVirusHealthByColorLevel(virusName, level, data.VirusColorLevel); data.MoveSpeed = 3; data.MoveDirection = dir; data.SplitLevel = splitLevel; SpawnVirus(virusName, data); cc++; if (cc >= count) { _isSpawned = true; WaveVirusDataAdapter.WaveIndex++; if (WaveVirusDataAdapter.WaveIndex >= WaveVirusDataAdapter.MaxWave) { WaveVirusDataAdapter.IsNextWave = false; } yield break; } } }
public override void Injured(float damageValue, bool isEffect) { if (VirusHealth.Value - damageValue <= 0) { Death(true, true, true, true); return; } VirusHealth.Value -= damageValue; var virusLevel = VirusTool.GetVirusColorLevel("RegenerativeVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value); if (virusLevel != CurColorLevel) { CurColorLevel = virusLevel; VirusSprite.Initi(CurColorLevel); transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel); } if (isEffect) { _virusHurtEffect.StartHurtEffect(); } _virusHealthAddEffect.StopHealthEffect(this); _totalTime = 0.5f; _ishurt = true; }
public void SetCoinText() { _coinText.text = VirusTool.GetStrByIntger(VirusGameDataAdapter.GetTotalCoin()); //Debug.Log("test ======== " + _coinText.text); }
internal void SubCoin() { //扣除玩家金币 VirusGameDataAdapter.MinusTotalCoin(m_NeedCoin); }
protected void Divide(string virusName, ColorLevel colorLevel, int count) { if (SplitLevel > SplitLevel.Level1) { Vector3 pos = transform.position; var level = SplitLevel - 1; var move = transform.GetComponent <VirusMove>(); for (int i = 0; i < count; i++) { VirusData data1 = new VirusData(); data1.VirusColorLevel = VirusTool.GetColorLevel(colorLevel); data1.SplitLevel = level; data1.MoveSpeed = move.OriginSpeed; data1.MoveDirection = Quaternion.Euler(0, 0, Random.Range(-45f, 45f)) * Vector3.up; data1.HealthValue = VirusTool.GetVirusHealthByColorLevel(virusName, VirusGameDataAdapter.GetLevel(), data1.VirusColorLevel); VirusMrg.Instance.SpawnVirus(virusName, data1, pos, false); } } }
private void Produce() { VirusData data = new VirusData(); data.SplitLevel = SplitLevel; data.VirusColorLevel = CurColorLevel; data.HealthValue = VirusTool.GetVirusHealthByColorLevel("SwallowVirus", VirusGameDataAdapter.GetLevel(), CurColorLevel); data.MoveSpeed = 4; data.MoveDirection = Quaternion.Euler(0, 0, Random.Range(0f, 360f)) * Vector3.up; float scale = VirusTool.GetScaleByLevel(data.SplitLevel); var newVirus = VirusMrg.Instance.SpawnVirus("SwallowVirus", data, transform.position, true); newVirus.transform.localScale = Vector3.zero; newVirus.transform.DOScale(new Vector3(scale, scale, 1), 0.5f).OnComplete(() => { _isRunAway = false; }); }
private void OnUpgradeEnter() { //这里是对玩家武器进行升级 bool isUpdgrade = false; string tipStr = ""; if (IGamerProfile.Instance == null) { int coin = VirusGameDataAdapter.GetTotalCoin(); int needCoin = VirusTool.GetUpgradeCoin(VirusPlayerDataAdapter.GetWeaponLevel()); //coin = 50 * needCoin; //testSyq while (true) { if (coin >= needCoin) { isUpdgrade = true; int value = VirusPlayerDataAdapter.GetUpgradeValue(); //扣除玩家金币 VirusGameDataAdapter.MinusTotalCoin(needCoin); //增加武器等级 VirusPlayerDataAdapter.AddWeaponLevel(); //增加武器伤害 VirusPlayerDataAdapter.AddShootPower(value); //增加子弹射速,暂时无用 VirusPlayerDataAdapter.AddShootSpeed(); bool b1 = VirusPlayerDataAdapter.GetShootNum() <= VirusPlayerDataAdapter.GetMaxShootNum(); bool b2 = VirusPlayerDataAdapter.UpgradeShoot(); if (b1 && b2) { //增加武器发射的子弹数量 VirusPlayerDataAdapter.AddShootNum(1); } coin = VirusGameDataAdapter.GetTotalCoin(); //升级需要的金币数 needCoin = VirusTool.GetUpgradeCoin(VirusPlayerDataAdapter.GetWeaponLevel()); } else { break; } } if (isUpdgrade) { _uiMrg.CoinPanel.SetCoinText(); _virusPlayer.Upgrade(); VirusSoundMrg.Instance.PlaySound(VirusSoundType.UpgradeGun); tipStr = "火力升级"; } } else { //对于玩家的武器属性进行配置 int indexWeapon = (int)UiSceneSelectGameCharacter.CharacterId.MainWeapon; //int levelA = IGamerProfile.Instance.playerdata.characterData[indexWeapon].levelA; int levelB = IGamerProfile.Instance.playerdata.characterData[indexWeapon].levelB; } float delayTime = 0.1f; //int level = VirusTool.UnlockViceWeapon(VirusGameDataAdapter.GetLevel()); int level = 0; //获取玩家选择的副武器 if (IGamerProfile.Instance != null) { level = IGamerProfile.Instance.gameEviroment.characterIndex; } //level = 8; //testSyq if (level > 0) { if (_virusPlayer.WeaponLevel != level) { _virusPlayer.WeaponLevel = level; //这里是升级副武器的 delayTime = 0.1f; _virusPlayer.InitiViceWeapon(level); tipStr = "装备升级"; } } if (!string.IsNullOrEmpty(tipStr)) { var tip = EffectPools.Instance.Spawn("FloatTip"); tip.transform.position = _virusPlayer.transform.position; tip.transform.localScale = new Vector3(1.5f, 1.5f, 1); tip.GetComponent <FastlaneFloatTip>().Float(tipStr, () => { EffectPools.Instance.DeSpawn(tip); }); } DOVirtual.DelayedCall(delayTime, _uiMrg.FadeOut).OnComplete(() => { _fsm.ChangeState(VirusGameState.GamePlay); }); }