// Start is called before the first frame update void Start() { OnGameStart(); EventManager.Get().EventTrigger(EventTypes.Game_OnStart); EventManager.Get().AddListener<CubeCell>(EventTypes.Cell_OnSelected,CellSelection.Get().CellSelected); Debug.Log("[消息]游戏开始"); MonoBase.Get().GetMono().AddUpdateListener(CheckFocus); }
protected override void AttackTarget(UnitBase from, UnitBase target, bool canFightBack) { //Debug.Log(AttackDistance(from,target)); from.ShowHP(); target.ShowHP(); //开启攻击协程 MonoBase.Get().GetMono().StartCoroutine(attack(from, target, canFightBack)); from.CanOperate = false; //广播攻击消息 UIManager.Get().MsgOnScreen(string.Format("{0}攻击了{1}", from.UnitName, target.UnitName)); Debug.Log(string.Format("{0}攻击了{1}", from.UnitName, target.UnitName)); }
public void PlaySound(string name, float volume) { ResManager.Get().LoadAsync <AudioClip>("Audio/Sounds/" + name, (clip) => { AudioSource audioSource = obj_Audio.AddComponent <AudioSource>(); sound_source.Add(audioSource); audioSource.clip = clip; audioSource.volume = volume; audioSource.outputAudioMixerGroup = Sounds_MixerGroup; audioSource.Play(); MonoBase.Get().GetMono().StartCoroutine(AudioTimeToLive(audioSource)); }); }
public void AddCard(CardBase cardtype) { cardsPanel.Anim_Up(0.5f); MonoBase.Get().GetMono().RunDelayTask(() => { ResManager.Get().LoadAsync <GameObject>("Prefabs/UI/Panels/HUDPanel/Card/Card", (obj) => { obj.transform.SetParent(cardContent, false); obj.GetComponent <Card>().SetCardBase(cardtype); cardtype.SetCardPanel(obj); MonoBase.Get().GetMono().StartCoroutine(cardsPanel.WaitForAnim_Down()); }); }, cooldown); cooldown = interval; }
private void OnTriggerEnter(Collider other) { var unit = other.gameObject; if (unit == target && !isDestroying) { isDestroying = true; GetComponentInChildren <Light>().range = 30; GetComponentInChildren <Light>().intensity = 1.5f; onTrigger(); GetComponent <Rigidbody>().isKinematic = true; MonoBase.Get().GetMono().RunDelayTask(() => { Destroy(gameObject); }, 0.05f); } }
public UnitSelection() { MonoBase.Get().GetMono().AddUpdateListener(() => { if (Input.GetMouseButtonDown(1)) { if (start == null) { end = null; return; } ClearSelection(); UIManager.Get().MsgOnScreen("已清除当前选择"); } }); }
public void Load() { Transform button = transform.Find("Button"); button.gameObject.AddComponent <CanvasGroup>().alpha = 1f; button.DOScale(button.localScale * 0.25f, 0.5f).SetEase(Ease.InBack).easeOvershootOrAmplitude = 2f; button.gameObject.GetComponent <CanvasGroup>().DOFade(0, 0.5f).OnComplete(() => { button.gameObject.SetActive(false); }); MonoBase.Get().GetMono().RunDelayTask(() => { StartCoroutine(LoadScene("GameMain")); }, 0.25f); }
public IEnumerator PlaySoundAndWait(string name, float volume) { bool finished = false; ResManager.Get().LoadAsync <AudioClip>("Audio/Sounds/" + name, (clip) => { AudioSource audioSource = obj_Audio.AddComponent <AudioSource>(); sound_source.Add(audioSource); audioSource.clip = clip; audioSource.volume = volume; audioSource.outputAudioMixerGroup = Sounds_MixerGroup; audioSource.Play(); finished = true; MonoBase.Get().GetMono().StartCoroutine(AudioTimeToLive(audioSource)); }); while (!finished) { yield return(new WaitForSeconds(0.5f)); } yield break; }
public void LoadAsync(GameObject gameObject, UnityAction <GameObject> callback) { //开启异步加载协程 MonoBase.Get().GetMono().StartCoroutine(LoadAsyncCoroutine(gameObject, callback)); }
/// <summary> /// 异步加载资源 /// </summary> /// <typeparam name="T">资源类型</typeparam> /// <param name="name">资源路径</param> /// <param name="callback">回调委托方法</param> public void LoadAsync <T>(string name, UnityAction <T> callback, bool instatiate = true) where T : Object { //开启异步加载协程 MonoBase.Get().GetMono().StartCoroutine(LoadAsyncCoroutine <T>(name, callback, instatiate)); }
/// <summary> /// 作用单位设置后事件 /// </summary> virtual protected void afterTargetSet() { MonoBase.Get().GetMono().RunDelayTask(() => { OnNextRound(null); }, 0.25f); }
private void OnDestroy() { MonoBase.Get().GetMono().RemoveUpdateListener(CheckFocus); UnloadGameLogic(); }
protected override void AttackTarget(UnitBase from, UnitBase target, bool canFightBack) { MonoBase.Get().GetMono().StartCoroutine(attackTarget(from, target, canFightBack)); }
public CardSystem() { MonoBase.Get().GetMono().AddUpdateListener(CoolDownTimer); }
protected override void onDestroy() { MonoBase.Get().GetMono().RemoveUpdateListener(CoolDownTimer); Debug.Log("卡牌系统销毁完毕"); }