-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spaw enemies in a visitor #5
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,13 @@ public class GameRoom : MonoBehaviour | |
|
||
Dealer Dealer { get; } = new Dealer(); | ||
|
||
public float maxTime = 20; | ||
public float minTime = 2; | ||
|
||
private float time; | ||
|
||
//The time to spawn the object | ||
public float spawnTime; | ||
void Start() | ||
{ | ||
var gameObjectFactory = new GameObjectFactory(cardPrefabMap, playerPrefab); | ||
|
@@ -39,10 +46,19 @@ void Start() | |
Dealer.DealInitialCards(VisitorPlayer); | ||
|
||
matchReferee.Setup(gameActionFactory, players: new []{HomePlayer, VisitorPlayer}); | ||
|
||
SetRandomTime(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O GameRoom não parece o lugar ideal pra controlar a estratégia do bot que vai jogar pelo visitante, acho que uma solução mais robusta seria onde o As vantagens dessa abordagem são principalmente continuar com a semântica do GameRoom só inicializar a sala e ter a lógica do Bot isolada em um lugar que facilita a extensão dela, no futuro poderemos ter varias estratégias diferentes para o bot e essa classe pode controlar isso. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Se vocês discordarem dessa proposta de solução ou não entenderem algo do que eu falei a gente pode marcar uma call pra conversar melhor |
||
time = minTime; | ||
} | ||
|
||
void SetRandomTime(){ | ||
spawnTime = Random.Range(minTime, maxTime); | ||
Debug.Log ("Next object spawn in " + spawnTime + " seconds."); | ||
} | ||
|
||
void Awake() => AddObservers(); | ||
|
||
|
||
void OnDestroy() => RemoveObservers(); | ||
|
||
void AddObservers() | ||
|
@@ -51,6 +67,16 @@ void AddObservers() | |
gameplayHUD.OnUseCard += OnHomePlayerUsedCard; | ||
} | ||
|
||
void Update(){ | ||
time += Time.deltaTime; | ||
|
||
if(time >= spawnTime){ | ||
Dealer.DealCard(VisitorPlayer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esse DealCard do visitor iria pro |
||
OnVisitorUsedCard(); | ||
time = 0; | ||
} | ||
} | ||
|
||
void RemoveObservers() | ||
{ | ||
Dealer.OnDealtCard -= gameplayHUD.OnCardDealt; | ||
|
@@ -59,8 +85,16 @@ void RemoveObservers() | |
|
||
void OnHomePlayerUsedCard(CardType card, int laneIdx) | ||
{ | ||
|
||
matchReferee.OnPlayerUsedCard(card, HomePlayer.Team, laneIdx); | ||
Dealer.DealCard(HomePlayer); | ||
|
||
} | ||
|
||
void OnVisitorUsedCard(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esse método está no lugar certo, mas ele precisa ser acessado pelo Bot, um jeito interessante seria o Bot ter uma |
||
CardType Card = VisitorPlayer.Hand.Cards[0]; | ||
matchReferee.OnPlayerUsedCard(Card, VisitorPlayer.Team, 0); | ||
|
||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
m_EditorVersion: 2019.4.9f1 | ||
m_EditorVersionWithRevision: 2019.4.9f1 (50fe8a171dd9) | ||
m_EditorVersion: 2019.4.10f1 | ||
m_EditorVersionWithRevision: 2019.4.10f1 (5311b3af6f69) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todas essas variáveis iriam para a classe do Bot descrita alí embaixo