Example #1
0
        private void    ProcessArtefact(Player player, OnBoardItem boardItem, Artefact artefact)
        {
            if (player.CanAddArtefact(artefact) == false)
            {
                this.replaceArtefactImage.sprite = this.icons2[artefact];

                this.promptPlayer    = player;
                this.promptBoardItem = boardItem;
                this.promptArtefact  = artefact;

                this.PromptArtefactEvent.Invoke();
            }
            else
            {
                this.AddArtefactToPlayer(player, artefact, boardItem);
            }
        }
Example #2
0
        private void    AddArtefactToPlayer(Player player, Artefact artefact, OnBoardItem boardItem)
        {
            Artefact replacedArtefact = player.AddOrReplaceArtefact(artefact);

            if (replacedArtefact == null)
            {
                this.board.DeleteItemOnLocation(this.askRegionIndex, this.askSpotIndex);
            }
            else
            {
                boardItem.item = replacedArtefact;
            }

            if (replacedArtefact != null)
            {
                this.playPlayerFoundArtifact.PlayRandom();
                this.foundArtefact.sprite = this.icons2[artefact];
                this.foundArtefact.transform.parent.gameObject.SetActive(true);

                //this.DisplayMessage("Vous avez trouvé " + artefact + " et déposé " + replacedArtefact + "!", "Continuez", () =>
                //{
                //	this.gamePhase = GamePhase.PlayerIdle;
                //	this.NextPhase();
                //});
            }
            else
            {
                this.playPlayerFoundArtifact.PlayRandom();
                this.foundArtefact.sprite = this.icons2[artefact];
                this.foundArtefact.transform.parent.gameObject.SetActive(true);

                //this.DisplayMessage("Vous avez trouvé " + artefact + "!", "Récupérez", () =>
                //{
                //	this.gamePhase = GamePhase.PlayerIdle;
                //	this.NextPhase();
                //});
            }
        }
Example #3
0
        public void NextPhase()
        {
            switch (this.gamePhase)
            {
            case GamePhase.SelectPlayers:
                this.SelectPlayersEvent.Invoke();
                break;

            case GamePhase.PickCards:
                ++this.turnCounter;
                this.GenerateTurnOrders(this.turnOrders);

                this.DisplayMessage("Piochez vos cartes de déplacement", "Débutez", () =>
                {
                    this.gamePhase = GamePhase.MoveAndBattlePhase;
                    this.NextPhase();
                });
                break;

            case GamePhase.MoveAndBattlePhase:
                this.DisplayMessage("Exécutez vos déplacements et résolvez les combats", "Poursuivez", () =>
                {
                    this.gamePhase = GamePhase.PlayerIdle;
                    this.NextPhase();
                });
                break;

            case GamePhase.PlayerIdle:
                if (this.turnOrders.Count == 0)
                {
                    this.gamePhase = GamePhase.SecondIdle;
                    this.NextPhase();
                    break;
                }

                this.FirstIdleEvent.Invoke();

                this.currentPlayer = this.turnOrders[0];
                this.idleTurnImage.gameObject.SetActive(true);
                //this.idleTurnImage.GetComponentsInChildren<Image>()[1].color = GameManager.colors[this.currentPlayer];
                this.idleTurnImage.GetComponentsInChildren <Image>()[1].sprite = this.pictures[this.currentPlayer];
                this.turnOrders.RemoveAt(0);

                // TODO Ajoutez l'image
                //this.idleTurnImage.gameObject.SetActive(true);
                //this.DisplayMessage("Débutez votre tour " + this.currentPlayer, "Débutez", () =>
                //{
                //	//this.idleTurnImage.gameObject.SetActive(false);
                this.gamePhase = GamePhase.AskPlayerSpot;
                //	this.NextPhase();
                //});

                for (int i = 0; i < this.characters.Length; i++)
                {
                    this.characters[i].SetActive(i == this.currentPlayer);
                }

                this.playNewPlayerTurn.PlayRandom();

                break;

            case GamePhase.AskPlayerSpot:
                Location location = this.board.players[this.currentPlayer].location;

                Debug.Log(this.currentPlayer + " is at " + location);
                if (location.regionIndex == -1)
                {
                }
                else
                {
                    Object.FindObjectOfType <DragAndDropPlayer>().originPosition = this.spots[location.regionIndex * this.board.spotPerRegion + location.spotIndex].transform.position + Vector3.up;
                }

                this.AskPlayerSpotEvent.Invoke();
                break;

            case GamePhase.ConfirmPlayerSpot:
                this.ConfirmPlayerSpotEvent.Invoke();

                Player player = this.board.players[this.currentPlayer];

                if (this.askRegionIndex == -2)                         // Fighting god.
                {
                    this.DisplayConfirm("La montagne sacrée! Combattez", "Succès", "Échec", isYes =>
                    {
                        if (isYes == true)
                        {
                            this.playGodDefeated.PlayRandom();
                            this.gamePhase = GamePhase.EndGame;
                            this.NextPhase();
                        }
                        else
                        {
                            player.location.GoToTemple();

                            this.playPlayerDefeatedByGod.PlayRandom();

                            this.DisplayMessage("Retournez dans votre temple (sans récolter de cartes)", "Poursuivez", () =>
                            {
                                this.gamePhase = GamePhase.PlayerIdle;
                                this.NextPhase();
                            });
                        }
                    });
                }
                else if (this.askRegionIndex == -1)                         // Temple.
                {
                    this.DisplayMessage("Pigez les cartes.", "Poursuivez", () =>
                    {
                        this.gamePhase = GamePhase.PlayerIdle;
                        this.NextPhase();
                    });
                }
                else
                {
                    OnBoardItem boardItem = this.board.GetBoardItemFromLocation(this.askRegionIndex, this.askSpotIndex);

                    player.location.regionIndex = this.askRegionIndex;
                    player.location.spotIndex   = this.askSpotIndex;

                    if (boardItem != null)
                    {
                        if (boardItem.item.type == Item.Type.Monster)
                        {
                            Monster monster = (boardItem.item as Monster);

                            this.DisplayConfirm("Un monstre! Combattez!", "Succès", "Échec", isYes =>
                            {
                                if (isYes == true)
                                {
                                    this.playPlayerDefeatsMonster.PlayRandom();
                                    this.ProcessArtefact(player, boardItem, monster.artefact);
                                }
                                else
                                {
                                    this.playPlayerDefeatedByMonster.PlayRandom();
                                    player.location.GoToTemple();

                                    this.DisplayMessage("Retournez dans votre temple (sans récolter de cartes)", "Poursuivez", () =>
                                    {
                                        this.gamePhase = GamePhase.PlayerIdle;
                                        this.NextPhase();
                                    });
                                }
                            });
                        }
                        else if (boardItem.item.type == Item.Type.Artefact)
                        {
                            this.ProcessArtefact(player, boardItem, boardItem.item as Artefact);
                        }
                    }
                    else
                    {
                        this.DisplayMessage("Pigez une carte de malédiction et donnez-la face cachée à un autre joueur", "Continuez", () =>
                        {
                            this.gamePhase = GamePhase.WatchClue;
                            this.NextPhase();
                        });
                    }
                }

                break;

            case GamePhase.WatchClue:
                OnBoardItem boardItem2 = this.board.boardItems[Random.Range(0, this.board.boardItems.Count)];

                if (boardItem2.item.type == Item.Type.Artefact)
                {
                    this.artefactClueModel.SetActive(true);
                    this.artefactClueModel.transform.localPosition = this.spots[boardItem2.location.regionIndex * this.board.spotPerRegion + boardItem2.location.spotIndex].transform.position + Vector3.up;
                }
                else if (boardItem2.item.type == Item.Type.Monster)
                {
                    this.monsterClueModel.SetActive(true);
                    this.monsterClueModel.transform.localPosition = this.spots[boardItem2.location.regionIndex * this.board.spotPerRegion + boardItem2.location.spotIndex].transform.position + Vector3.up;
                }

                this.WatchClueEvent.Invoke();

                this.StopAllCoroutines();
                this.StartCoroutine(this.HighlightClue());
                break;

            case GamePhase.SecondIdle:
                this.SecondIdleEvent.Invoke();

                this.DisplayMessage("La montagne sacrée s'agite", "Poursuivez", () =>
                {
                    this.gamePhase = GamePhase.GodTurn;
                    this.NextPhase();
                });

                break;

            case GamePhase.GodTurn:
                this.GodTurnEvent.Invoke();

                if (Random.Range(0F, 1F) > this.board.newMonsterRate)
                {
                    Location location2 = new Location()
                    {
                        regionIndex = Random.Range(0, this.board.regionsCount),
                        spotIndex   = Random.Range(0, this.board.spotPerRegion)
                    };

                    OnBoardItem boardItem3 = this.board.GetBoardItemFromLocation(location2.regionIndex, location2.spotIndex);

                    if (boardItem3 != null)
                    {
                        if (boardItem3.item.type == Item.Type.Artefact)
                        {
                            this.playGodCreatesMonster.PlayRandom();

                            boardItem3.item = new Monster(boardItem3.item as Artefact);

                            this.DisplayMessage("Un monstre est apparu!", "Poursuivez", () =>
                            {
                                this.gamePhase = GamePhase.PickCards;
                                this.NextPhase();
                            });
                        }
                    }
                    else
                    {
                        Artefact artefact = this.board.PopRandomArtefactFromPool();

                        if (artefact != null)
                        {
                            this.playGodCreatesArtifact.PlayRandom();
                            this.board.boardItems.Add(new OnBoardItem(artefact, location2));

                            this.DisplayMessage("Un artéfact est apparu!", "Poursuivez", () =>
                            {
                                this.gamePhase = GamePhase.PickCards;
                                this.NextPhase();
                            });
                        }
                    }
                }
                else                        // if (Random.Range(0F, 1F) > this.board.newArtefactRate)
                {
                    Artefact artefact = this.board.PopRandomArtefactFromPool();

                    if (artefact != null)
                    {
                        Location location2 = this.board.GetEmptyLocation();

                        if (location2 != null)
                        {
                            this.playGodCreatesArtifact.PlayRandom();
                            this.board.boardItems.Add(new OnBoardItem(artefact, location2));

                            this.DisplayMessage("Un artéfact est apparu!", "Poursuivez", () =>
                            {
                                this.gamePhase = GamePhase.PickCards;
                                this.NextPhase();
                            });
                        }
                    }
                }
                //else
                //{
                //	this.DisplayMessage("Le royaume est paisible (on entend des crickets)", "Poursuivez", () =>
                //	{
                //		this.gamePhase = GamePhase.PickCards;
                //		this.NextPhase();
                //	});
                //}

                break;

            case GamePhase.EndGame:
                this.GenerateTurnOrders(this.turnOrders);

                this.board.winner = this.currentPlayer;
                // Make sure the winner is not counted.
                this.turnOrders.Remove(this.currentPlayer);

                this.rankings[0].sprite = this.pictures[this.currentPlayer];

                for (int i = 0; i < this.turnOrders.Count; i++)
                {
                    this.rankings[i + 1].sprite = this.pictures[this.turnOrders[i]];
                }

                for (int i = this.playersCount; i < this.rankings.Length; i++)
                {
                    this.rankings[i].gameObject.SetActive(false);
                }

                Player first = this.board.players[this.currentPlayer];
                Player last  = this.board.players[this.turnOrders[this.turnOrders.Count - 1]];

                if (first.artefacts.Count > 0)
                {
                    int n;

                    do
                    {
                        n = Random.Range(0, first.artefacts.Count);

                        int total = 0;

                        for (int i = 0; i < this.board.firstSacrifices.Count; i++)
                        {
                            if (this.board.firstSacrifices[i].slot == first.artefacts[n].slot)
                            {
                                ++total;
                            }
                        }

                        if (total < 4)
                        {
                            break;
                        }

                        if (first.artefacts.Count == 1)
                        {
                            goto comboBREAKER;
                        }
                    }while (true);

                    if (first.artefacts[n].slot == Artefact.Slot.Head)
                    {
                        this.firstSacrificeDescription.text = "Tête: Les joueurs débutent la partie avec -1 cartes en main (max -4)";
                    }
                    else if (first.artefacts[n].slot == Artefact.Slot.Body)
                    {
                        this.firstSacrificeDescription.text = "Armure: Certains sites requièrent +1 carte de déplacement pour être atteints (max + 1 / site). Un collant est apposé à coté des sites en question.";
                    }
                    else if (first.artefacts[n].slot == Artefact.Slot.Shield)
                    {
                        this.firstSacrificeDescription.text = "Bouclier: Les probabilités d’apparition des monstres sont augmentées de 20 % (max + 80 %)";
                    }
                    else if (first.artefacts[n].slot == Artefact.Slot.Weapon)
                    {
                        this.firstSacrificeDescription.text = "Arme: La difficulté des monstres est augmentée de +1 niveau de puissance (max +4)";
                    }

                    this.board.firstSacrifices.Add(first.artefacts[n]);
                    first.artefacts.RemoveAt(n);

                    this.classementTerminezButton.SetActive(false);
                    this.classementContinuezButton.SetActive(true);
                    this.skipFirstButton.SetActive(false);
                }
                else
                {
                    this.classementContinuezButton.SetActive(false);

                    if (last.artefacts.Count == 0)
                    {
                        this.classementTerminezButton.SetActive(true);
                        this.skipFirstButton.SetActive(false);
                    }
                    else
                    {
                        this.classementTerminezButton.SetActive(false);
                        this.skipFirstButton.SetActive(true);
                    }
                }

comboBREAKER:

                if (last.artefacts.Count > 0)
                {
                    this.lastPicture.sprite = this.pictures[this.turnOrders[this.turnOrders.Count - 1]];

                    for (int i = 0; i < this.lastSelector.choices.Length; i++)
                    {
                        this.lastSelector.choices[i].gameObject.SetActive(false);
                    }

                    for (int i = 0; i < last.artefacts.Count; i++)
                    {
                        string slot = null;

                        if (last.artefacts[i].slot == Artefact.Slot.Head)
                        {
                            slot = "Tête";
                        }
                        else if (last.artefacts[i].slot == Artefact.Slot.Body)
                        {
                            slot = "Armure";
                        }
                        else if (last.artefacts[i].slot == Artefact.Slot.Weapon)
                        {
                            slot = "Arme";
                        }
                        else if (last.artefacts[i].slot == Artefact.Slot.Shield)
                        {
                            slot = "Bouclier";
                        }

                        this.lastSelector.choices[(int)last.artefacts[i].slot].gameObject.SetActive(true);
                        this.lastSelector.choices[(int)last.artefacts[i].slot].GetComponentInChildren <Text>().text = slot;
                    }

                    this.firstTerminezButton.SetActive(false);
                    this.firstContinuezButton.SetActive(true);
                }
                else
                {
                    this.firstTerminezButton.SetActive(true);
                    this.firstContinuezButton.SetActive(false);
                }

                this.EndGameEvent.Invoke();
                break;
            }
        }