void Awake() { var c1 = MorlnResources.Load("Characters/Body"); var controller = MorlnResources.Load <RuntimeAnimatorController>("Characters/Body"); Animator.runtimeAnimatorController = controller; }
public void SetAndRefresh(Communication.Proto.Equip equip) { Equip = equip; if (Equip != null) { SprEquip.atlas = MorlnDownloadResources.Load <UIAtlas>("ResourcesForDownload/Equip/EquipIcon/Atlas-EquipIcons"); var sprName = EquipUtil.GetEquipSpriteName(Equip.EquipCode, Equip.Type); SprEquip.spriteName = sprName; } else { SprEquip.atlas = MorlnResources.Load <UIAtlas>("atlases/Atlas-PushLevelUI"); SprEquip.spriteName = "未获得装备"; } }
private IEnumerator DelayPlayUnlockEffect() { yield return(new WaitForSeconds(1)); var effectPrefab = MorlnResources.Load("UI/PushLevelUI/Point_Animation", typeof(GameObject)) as GameObject; if (effectPrefab) { var go = PrefabHelper.InstantiateAndReset(effectPrefab, transform); go.transform.localPosition = Vector3.zero; go.transform.localScale = new Vector3(0.5f, 0.5f, 1); yield return(new WaitForSeconds(2)); Destroy(go); } }
IEnumerator GuideCoroutine() { transform.localPosition = new Vector3(0, 0, -500); gameObject.layer = 8; var boxCollider = GetComponent <BoxCollider>(); if (!boxCollider) { boxCollider = gameObject.AddComponent <BoxCollider>(); } boxCollider.size = new Vector3(2000, 2000, 0); boxCollider.center = Vector3.zero; boxCollider.isTrigger = true; //选择昵称 boxCollider.enabled = false; SelectNicknamePanel.Load(); while (!SelectNicknamePanel.NicknameSelectOk) { yield return(new WaitForEndOfFrame()); } UMengPlugin.UMengEvent(EventId.NICKNAME_FINISH, new Dictionary <string, object> { { "random_times", SelectNicknamePanel.RandomTimes } }); MusicManager.Instance.CrossFadeOut(); //加载GameUI MainRoot.Goto(MainRoot.UIStateName.Game); while (!GameManager.Instance) { yield return(new WaitForEndOfFrame()); } SelectNicknamePanel.UnloadInterface();//此时才能销毁SelectNicknamePanel,不然会突变 GameUI.Instance.gameObject.SetActive(false); #region 故事板 _next = false; var mangaPrefab = MorlnResources.Load("UI/FreshmanGuide/Prefabs/Manga") as GameObject; var manga = PrefabHelper.InstantiateAndReset(mangaPrefab, transform); manga.transform.SetSortingLayer("Foreground"); manga.GetComponentInChildren <Animator>().enabled = true; Destroy(manga, 24f); yield return(new WaitForSeconds(22.5f)); _next = true; //while (!_next) yield return new WaitForEndOfFrame(); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "故事板完" } }); GameUI.Instance.gameObject.SetActive(true); #region 消教学 _next = false; boxCollider.enabled = false; GameData.RivalBossData = new DefenseData("鸡妈妈", 1, 90005, 100, 100); GameManager.Instance.ClearDefenserSetAIAndCameraAndTimeScale(); var grid = GameManager.Instance.MyGrid; grid.ResetCells(5, 5, null); GameData.InitVegetableTypeCount = 4; //填入预设的蔬菜 const string text = @"0 1 0 3 4 4 3 2 1 0 0 2 4 2 1 3 1 0 4 3 0 1 4 3 2"; grid.CreateCandysAsPreset(text); GameManager.Instance.ResetAndRefreshAndStartFreshmanGuideRound(); #region 母子对话 yield return(new WaitForSeconds(1.5f)); var lines = new[] { new Line(false, "慢着,老娘我先陪你练练", 2.5f), new Line(true, "妈,我怕伤着你", 1.1f), new Line(false, "少废话,接招", 2f) }; var bubblePrefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/Bubble"); var bubbleGo = PrefabHelper.InstantiateAndReset(bubblePrefab, transform); var bubbleSpr = bubbleGo.GetComponentInChildren <UISprite>(); var talkLabel = bubbleGo.GetComponentInChildren <UILabel>(); foreach (var line in lines) { bubbleSpr.transform.localScale = new Vector3(line.Left ? -1 : 1, 1, 1); talkLabel.text = line.Text; yield return(new WaitForSeconds(line.Length)); } Destroy(bubbleGo); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "母子对话完" } }); //开始遮罩教学 var prefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/GuideMask-Sanxiao"); GameObject go = null; if (prefab) { go = PrefabHelper.InstantiateAndReset(prefab, MainRoot.Instance.transform); } else { Debug.LogError("不能没有这个Prefab!"); } while (!_next) { //监测是否完成操作,完成则_next = true; if (GameData.MyEnergy > 0) { _next = true; } yield return(new WaitForEndOfFrame()); } Destroy(go); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "三消教学完" } }); #region 蓄力值 _next = false; boxCollider.enabled = true; prefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/GuideMask-Energy"); go = null; if (prefab) { go = PrefabHelper.InstantiateAndReset(prefab, MainRoot.Instance.transform); } else { Debug.LogError("不能没有这个Prefab!"); } while (!_next) { yield return(new WaitForEndOfFrame()); } Destroy(go); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "教蓄力值完" } }); #region 使用技能 while (true) { if (GameData.MyEnergy >= GameData.MyEnergyCapacity) { break; } yield return(new WaitForEndOfFrame()); } _next = false; boxCollider.enabled = false; prefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/GuideMask-UseSkill"); go = null; if (prefab) { go = PrefabHelper.InstantiateAndReset(prefab, MainRoot.Instance.transform); } else { Debug.LogError("不能没有这个Prefab!"); } while (!_next) { if (GameData.MyEnergy < 120) { _next = true; //证明使用过技能了 } yield return(new WaitForEndOfFrame()); } Destroy(go); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "使用技能完" } }); #region 成了伤害 while (true) { if (GameData.RivalHealthList[1] <= 0) { break; } yield return(new WaitForEndOfFrame()); } _next = false; yield return(new WaitForSeconds(2)); boxCollider.enabled = true; prefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/GuideMask-Damage"); go = null; if (prefab) { go = PrefabHelper.InstantiateAndReset(prefab, MainRoot.Instance.transform); } else { Debug.LogError("不能没有这个Prefab!"); } while (!_next) { yield return(new WaitForEndOfFrame()); } Destroy(go); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "对战完" } }); #region 结局 _next = false; boxCollider.enabled = false; while (true) { if (GameData.RivalHealthList[0] <= 0 || _next) { break; } yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(2)); GameData.LastRoundWin = true; MainRoot.Goto(MainRoot.UIStateName.EndRound); while (!EndRoundUI.Instance) { yield return(new WaitForEndOfFrame()); } EndRoundUI.Instance.PlayEndRoundProcess_FreshmanGuide(3, new List <Currency> { new Currency((int)CurrencyType.Coin, CommonData.MyUser.Money10), new Currency((int)CurrencyType.Diamond, CommonData.MyUser.Money1) }, null); prefab = MorlnResources.Load <GameObject>("UI/FreshmanGuide/Prefabs/GuideMask-KillFellow"); go = null; if (prefab) { go = PrefabHelper.InstantiateAndReset(prefab, MainRoot.Instance.transform); } else { Debug.LogError("不能没有这个Prefab!"); } while (!_next) { yield return(new WaitForEndOfFrame()); } Destroy(go); #endregion UMengPlugin.UMengEvent(EventId.GUIDE_PROGRESS, new Dictionary <string, object> { { "state", "引导完" } }); }
/// <summary> /// 从施法者播放扔技能动画开始 /// </summary> protected void Start() { if (_gameManager == null) { Debug.LogError("没有Initialize就Start了"); Destroy(this); return; } var skillParameterConfig = ConfigManager.GetConfig(ConfigManager.ConfigType.SkillParameterConfig) as SkillParameterConfig; SkillParameter curSkillConfig = null; if (skillParameterConfig != null) { curSkillConfig = skillParameterConfig.SkillParameterList.Find(x => (SkillEnum)x.SkillCode == _skillCode); } else { Debug.LogError("没有skillParameterConfig"); } List <IntVector2> sanxiaoTakeEffectCells = null; switch (_skillCode) { case SkillEnum.CreateStripe: #region 101 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } sanxiaoTakeEffectCells = _gameManager.MyGrid.CreateStripe(count); } break; #endregion case SkillEnum.CreateBomb: #region 102 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } sanxiaoTakeEffectCells = _gameManager.MyGrid.CreateBomb(count); } break; #endregion case SkillEnum.CreateColorful: #region 103 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } sanxiaoTakeEffectCells = _gameManager.MyGrid.CreateColorful(count); } break; #endregion case SkillEnum.AllHint: #region 104 { var time = 0.3f; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { time = curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level; } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } _gameManager.PlaySkillEffect_AllHints(time); } break; #endregion case SkillEnum.HideGenre: #region 105 { var time = 1f; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { time = curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level; } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } _gameManager.PlaySkillEffect_HideGenre(time); } break; #endregion case SkillEnum.GoldenFinger: #region 106 { var time = 0.1f; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { time = curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level; } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } _gameManager.MyGrid.StartGoldenFinger(time); } break; #endregion case SkillEnum.Ice: #region 202 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } _gameManager.SkillMaskContainer.Show(_gameManager.SkillMaskContainer.IceMaskPrefab, count); } break; #endregion case SkillEnum.Shake: #region 204 { var amplitude = 0.01f; var time = 1f; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { amplitude = curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level; time = curSkillConfig.ConstantList[2] + curSkillConfig.ConstantList[3] * _level; } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } UIShake.ShakeAUI(GameUI.Instance.gameObject, amplitude, time); } break; #endregion case SkillEnum.Stone: #region 205 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } _gameManager.MyGrid.AddStoneToQueue(count); } break; #endregion case SkillEnum.Lock: #region 206 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } sanxiaoTakeEffectCells = _gameManager.MyGrid.FormLocks(count); } break; #endregion case SkillEnum.Brick: #region 207 { var count = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { count = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } sanxiaoTakeEffectCells = _gameManager.MyGrid.FormBricks(count); } break; #endregion case SkillEnum.ReduceEnergy: #region 209 { var reduce = 1; if (curSkillConfig != null && curSkillConfig.ConstantList.Count >= 2) { reduce = Mathf.FloorToInt(curSkillConfig.ConstantList[0] + curSkillConfig.ConstantList[1] * _level); } else { Debug.LogError("没有技能参数配置或常数数量不对Code:" + _skillCode); } GameData.MyEnergy = Mathf.Max(0, GameData.MyEnergy - reduce); } break; #endregion default: Debug.LogError("没有就别调用,浪费CPU!"); Destroy(this); break; } if (sanxiaoTakeEffectCells != null && sanxiaoTakeEffectCells.Count > 0) { var bulletPrefab = MorlnResources.Load <GameObject>("UI/GameUI/SkillScatterEffects/ScatterEffectBullet-" + _skillCode); if (bulletPrefab) { var trackPrefab = MorlnResources.Load <GameObject>("UI/GameUI/SkillScatterEffects/ScatterEffectTrack"); if (trackPrefab) { foreach (var sanxiaoTakeEffectCell in sanxiaoTakeEffectCells) { var track = PrefabHelper.InstantiateAndReset <SkillScatterEffectTrackInfo>(trackPrefab, transform); track.transform.localPosition = transform.InverseTransformPoint( GameManager.Instance.FightingPanel.transform.TransformPoint( GameManager.Instance.SkillEffectInfo.GetScatterPoint(_skillCode))); var dir = GameManager.Instance.transform.InverseTransformPoint( GameManager.Instance.MyGrid.transform.TransformPoint( GameManager.Instance.MyGrid.GetCellPosition(sanxiaoTakeEffectCell))) - track.transform.localPosition; track.transform.right = dir; track.transform.localScale = (Vector2.one * dir.magnitude / 500).ToVector3(1); var bullet = PrefabHelper.InstantiateAndReset(bulletPrefab, track.TrackPoint); Destroy(track.gameObject, track.Lifespan); } } } } switch (_skillCode) { //TODO:需要特别设置销毁时间的在这里添加代码 default: Destroy(this); break; } }