mycj_demo/mycj/Assets/Game/Scripts/Application/01Modle/FBRoundModel.cs
2024-12-02 09:37:47 +08:00

128 lines
3.5 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Felix-BangFBRoundModel
//   へ     /|
//  /7    ∠_/
//  / │    
//  Z _,    /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │
//  / へ   / ノ<|
//  ヽ_ノ  (_  │//
//  7       |
//  ―r ̄ ̄`ー―_
// Describe
// Createtime
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FBFramework;
namespace FBApplication
{
public class FBRoundModel : FBModel
{
#region
private const float f_roundInterval = 3f; //回合之间的间隔时间 3秒
private const float f_spawnInterval = 1f; //两怪物出生间隔 1秒
#endregion
#region
private List<FBRound> f_rounds = new List<FBRound>();
private int f_roundIndex = -1; //当前回合的索引
private bool f_allRoundsComplete = false; //是否所有怪物都出来
private Coroutine f_coroutine;
#endregion
#region
public override string Name
{
get { return FBConsts.M_RoundModel; }
}
/// <summary> 回合索引 </summary>
public int RoundIndex
{
get { return f_roundIndex; }
}
/// <summary> 总回合数 </summary>
public int RoundTotal
{
get { return f_rounds.Count; }
}
/// <summary> 所有回合是否完成 </summary>
public bool AllRoundComplete
{
get { return f_allRoundsComplete; }
}
#endregion
#region
public void LoadLevel(FBLevel level)
{
f_rounds = level.Rounds;
}
public void StartRound()
{
f_coroutine = FBGame.Instance.StartCoroutine(RunRound());
}
public void StopRound()
{
FBGame.Instance.StopCoroutine(f_coroutine);
}
IEnumerator RunRound()
{
f_roundIndex = -1;
f_allRoundsComplete = false;
for (int i = 0; i < f_rounds.Count; i++)
{
f_roundIndex = i;
//回合开始
FBRoundStartArgs e = new FBRoundStartArgs
{
RoundIndex = f_roundIndex,
RoundTotal = RoundTotal
};
SendEvent(FBConsts.E_RoundStart, e);
FBRound round = f_rounds[i];
for (int k = 0; k < round.Count; k++)
{
//出怪间隔
yield return new WaitForSeconds(f_spawnInterval);
//出怪事件
FBSpawnMonsterArgs spawnArgs = new FBSpawnMonsterArgs
{
MonsterID = round.MonsterID
};
SendEvent(FBConsts.E_SpawnMonster,spawnArgs);
if (i == f_rounds.Count -1 && k == round.Count - 1)
f_allRoundsComplete = true;
}
//回合间隔
if(!f_allRoundsComplete)
yield return new WaitForSeconds(f_roundInterval);
}
}
#endregion
#region
#endregion
}
}