コード例 #1
0
ファイル: GameMain.cs プロジェクト: BATTLEHAWK00/MyFirstGame
 // 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);
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 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));
     });
 }
コード例 #4
0
 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;
 }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
 public UnitSelection()
 {
     MonoBase.Get().GetMono().AddUpdateListener(() => {
         if (Input.GetMouseButtonDown(1))
         {
             if (start == null)
             {
                 end = null; return;
             }
             ClearSelection();
             UIManager.Get().MsgOnScreen("已清除当前选择");
         }
     });
 }
コード例 #7
0
ファイル: StartGame.cs プロジェクト: BATTLEHAWK00/MyFirstGame
    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);
    }
コード例 #8
0
    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;
    }
コード例 #9
0
 public void LoadAsync(GameObject gameObject, UnityAction <GameObject> callback)
 {
     //开启异步加载协程
     MonoBase.Get().GetMono().StartCoroutine(LoadAsyncCoroutine(gameObject, callback));
 }
コード例 #10
0
 /// <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));
 }
コード例 #11
0
ファイル: Buff.cs プロジェクト: BATTLEHAWK00/MyFirstGame
 /// <summary>
 /// 作用单位设置后事件
 /// </summary>
 virtual protected void afterTargetSet()
 {
     MonoBase.Get().GetMono().RunDelayTask(() => {
         OnNextRound(null);
     }, 0.25f);
 }
コード例 #12
0
ファイル: GameMain.cs プロジェクト: BATTLEHAWK00/MyFirstGame
 private void OnDestroy()
 {
     MonoBase.Get().GetMono().RemoveUpdateListener(CheckFocus);
     UnloadGameLogic();
 }
コード例 #13
0
 protected override void AttackTarget(UnitBase from, UnitBase target, bool canFightBack)
 {
     MonoBase.Get().GetMono().StartCoroutine(attackTarget(from, target, canFightBack));
 }
コード例 #14
0
 public CardSystem()
 {
     MonoBase.Get().GetMono().AddUpdateListener(CoolDownTimer);
 }
コード例 #15
0
 protected override void onDestroy()
 {
     MonoBase.Get().GetMono().RemoveUpdateListener(CoolDownTimer);
     Debug.Log("卡牌系统销毁完毕");
 }