Exemplo n.º 1
0
    private void UpdateField()
    {
        LilyAcolasia.CardGame game = this.gameOperator.Round.Current;
        for (int i = 0; i < 5; i++)
        {
            SpriteRenderer wrapperMaterial = this.FieldWrapper[i].GetComponent <SpriteRenderer>();

            if (game.Fields[i].Color == LilyAcolasia.Color.Blue)
            {
                wrapperMaterial.sprite = areaBlue;
            }
            else if (game.Fields[i].Color == LilyAcolasia.Color.Green)
            {
                wrapperMaterial.sprite = areaGreen;
            }
            else if (game.Fields[i].Color == LilyAcolasia.Color.White)
            {
                wrapperMaterial.sprite = areaWhite;
            }
            else if (game.Fields[i].Color == LilyAcolasia.Color.Red)
            {
                wrapperMaterial.sprite = areaRed;
            }
            else if (game.Fields[i].Color == LilyAcolasia.Color.Black)
            {
                wrapperMaterial.sprite = areaBlack;
            }
        }
    }
Exemplo n.º 2
0
    private bool operationHandler(string from, string to, string cardStr)
    {
        if (this.currentGameState != GameState.UserAction)
        {
            return(false);
        }
        LilyAcolasia.GameInput input = this.gameEnumerator.Current;

        if (from.Contains("Hand") && to.Contains("Field"))
        {
            int field = to[to.IndexOf("Field") + 5] - '0';
            input.input(LilyAcolasia.Command.Discard, cardStr, field.ToString());
        }
        else if (from.Contains("Field") && to == "Trash")
        {
            int field = from[from.IndexOf("Field") + 5] - '0';
            LilyAcolasia.CardGame game = this.gameOperator.Round.Current;
            if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
            {
                if (game.LastTrashed.Power == 5)
                {
                    return(false);
                }
                input.input(LilyAcolasia.Command.Special, cardStr, field.ToString());
            }
            else
            {
                input.input(LilyAcolasia.Command.Trash, cardStr, field.ToString());
            }
        }
        else if (from.Contains("Hand") && to == "Trash" && this.gameOperator.Round.Current.IsFilled)
        {
            input.input(LilyAcolasia.Command.Next);
            this.gameEnumerator.MoveNext();
            return(false);
        }
        else
        {
            return(false);
        }

        this.gameEnumerator.MoveNext();
        Debug.Log(gameOperator.Round.Current.ToString());
        Debug.Log(gameOperator.Round.Current.Status.ToString());

        GameEffect.Special(-1, gameOperator.Round.Current.Turn);
        if (this.gameOperator.Round.Current.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
        {
            GameEffect.CutIn(this.gameOperator.Round.Current.LastTrashed.Power);
            audioSource.clip = soundCutIn;
            audioSource.Play();
            this.currentGameState = GameState.CutIn;
        }
        else
        {
            this.currentGameState = GameState.CmdWait;
        }

        return(this.observer.IsCmdSuccess);
    }
Exemplo n.º 3
0
 private void StartRound()
 {
     this.gameEnumerator.MoveNext();
     LilyAcolasia.CardGame game = this.gameOperator.Round.Current;
     this.lastTurn = this.gameOperator.Round.Current.Turn;
     Debug.Log(game.ToString());
     currentGameState = GameState.RoundStart;
 }
Exemplo n.º 4
0
    private void processEvent()
    {
        int turn = this.gameOperator.Round.Current.Turn;

        LilyAcolasia.CardGame  game  = this.gameOperator.Round.Current;
        LilyAcolasia.GameInput input = this.gameEnumerator.Current;

        this.frameCounter++;

        if (this.currentGameState == GameState.RoundEnd)
        {
            if (!GameEffect.IsRoundEnd)
            {
                if (this.gameOperator.Round.HasNextRound())
                {
                    StartRound();
                }
                else
                {
                    this.currentGameState = GameState.GameEnding;
                    var round = this.gameOperator.Round;
                    this.frameCounter = 0;
                    if (round.Point1 > round.Point2)
                    {
                        if (level == 4)
                        {
                            achievements.WarfareLost();
                        }
                        else if (level == 1)
                        {
                            achievements.MimicLost();
                        }
                        else if (level == 0)
                        {
                            achievements.HumanLost();
                        }
                        gameEndingState = 0;
                    }
                    else if (round.Point1 < round.Point2)
                    {
                        if (level == 4)
                        {
                            achievements.WarfareWin();
                        }
                        else if (level == 1)
                        {
                            achievements.MimicWin();
                        }
                        else if (level == 0)
                        {
                            achievements.HumanWin();
                        }

                        bool isPerfect = true;
                        foreach (LilyAcolasia.Field f in game.Fields)
                        {
                            if (f.Winner != USER_TURN)
                            {
                                isPerfect = false;
                                break;
                            }
                        }
                        if (isPerfect)
                        {
                            achievements.Perfect();
                        }

                        gameEndingState = 1;
                    }
                    else
                    {
                        if (level == 4)
                        {
                            achievements.WarfareDraw();
                        }
                        else if (level == 1)
                        {
                            achievements.MimicDraw();
                        }
                        else if (level == 0)
                        {
                            achievements.HumanDraw();
                        }

                        gameEndingState = 2;
                    }
                }
            }
        }
        else if (this.currentGameState == GameState.GameEnding)
        {
            this.bgmSource.volume *= 0.95f;
            if (frameCounter > GAME_ENDING_WAIT)
            {
                if (gameEndingState == 0)
                {
                    GameEffect.GameEnd(0);
                    audioSource.clip = soundGameLost;
                    audioSource.Play();
                }
                else if (gameEndingState == 1)
                {
                    GameEffect.GameEnd(1);
                    audioSource.clip = soundGameWin;
                    audioSource.Play();
                }
                else if (gameEndingState == 2)
                {
                    GameEffect.GameEnd(2);
                    audioSource.clip = soundGameDraw;
                    audioSource.Play();
                }
                this.currentGameState = GameState.GameEnd;
                this.frameCounter     = 0;
            }
        }
        else if (this.currentGameState == GameState.GameEnd)
        {
            if (!GameEffect.IsGameEnd)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    CameraFade.StartAlphaFade(Color.black, false, 0.5f, 0.5f, () => {
                        if (this.netuser != null)
                        {
                            this.netuser.Close();
                            DestroyObject(this.netuser.gameObject);
                        }
                        SceneManager.LoadScene("Title");
                    });
                }
                else if (demoAi != null)
                {
                    demoAi = null;
                    CameraFade.StartAlphaFade(Color.black, false, 0.5f, 0.5f, () => {
                        if (this.netuser != null)
                        {
                            this.netuser.Close();
                            DestroyObject(this.netuser.gameObject);
                        }
                        SceneManager.LoadScene("Game");
                    });
                }
            }
        }
        else if (this.currentGameState == GameState.CutIn)
        {
            if (!GameEffect.IsCutIn)
            {
                int n = game.LastTrashed.Power;

                if (n == 5)
                {
                    if (demoAi == null && game.Turn == USER_TURN)
                    {
                        this.currentGameState = GameState.ColorChoice;
                        ColorChoice.Show((color) =>
                        {
                            LilyAcolasia.GameInput ipt = this.gameEnumerator.Current;
                            ipt.input(LilyAcolasia.Command.Special, color);
                            this.gameEnumerator.MoveNext();
                            this.currentGameState = GameState.UserAction;
                            audioSource.clip      = soundSkillColor;
                            audioSource.Play();
                        });
                    }
                    else
                    {
                        this.currentGameState = GameState.AIAction;
                    }
                }
                else if (n == 9)
                {
                    this.currentGameState = demoAi == null && turn == USER_TURN ? GameState.UserAction : GameState.AIAction;
                }
                else
                {
                    GameEffect.Special(n, game.Turn);
                    this.currentGameState = demoAi == null && turn == USER_TURN ? GameState.UserAction : GameState.AIAction;
                }
                this.frameCounter = 0;
            }
        }
        else if (this.currentGameState == GameState.RoundStart)
        {
            if (this.frameCounter >= TURN_WAIT)
            {
                this.frameCounter     = 0;
                this.currentGameState = GameState.TurnStart;
            }
        }
        else if (this.currentGameState == GameState.TurnStart)
        {
            if (this.frameCounter >= TURN_WAIT)
            {
                this.frameCounter     = 0;
                this.currentGameState = demoAi == null && turn == USER_TURN ? GameState.UserAction : GameState.AIAction;
            }
        }
        else if (this.currentGameState == GameState.CmdWait)
        {
            if (this.frameCounter >= CMD_WAIT)
            {
                this.frameCounter = 0;


                if (game.Status == LilyAcolasia.GameStatus.Status.End)
                {
                    input.input(LilyAcolasia.Command.Next);
                    this.gameEnumerator.MoveNext();

                    if (game.Status == LilyAcolasia.GameStatus.Status.RoundEnd)
                    {
                        this.currentGameState = GameState.RoundEnd;
                        GameEffect.RoundEnd(game.Winner);
                    }
                    else
                    {
                        this.currentGameState = GameState.TurnStart;
                    }
                }
                else if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
                {
                    GameEffect.Special(-1, game.Turn);
                    input.input(LilyAcolasia.Command.Special);
                    this.gameEnumerator.MoveNext();
                }
                else
                {
                    this.currentGameState = demoAi == null && turn == USER_TURN ? GameState.UserAction : GameState.AIAction;
                }
            }
        }
        else if (this.currentGameState == GameState.UserAction)
        {
            if (this.demoAi != null)
            {
                if (game.Status != LilyAcolasia.GameStatus.Status.WaitSpecialInput || this.frameCounter >= AI_WAIT)
                {
                    this.frameCounter = 0;

                    var next = demoAi.next(game);
                    input.input(next.Item1, next.Item2, next.Item3.ToString());

                    this.gameEnumerator.MoveNext();
                    this.frameCounter     = 0;
                    this.currentGameState = GameState.CmdWait;
                    GameEffect.Special(-1, game.Turn);
                    if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
                    {
                        GameEffect.CutIn(game.LastTrashed.Power);
                        audioSource.clip = soundCutIn;
                        audioSource.Play();
                        this.currentGameState = GameState.CutIn;
                    }
                }
            }
            else
            {
                if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput && !game.LastTrashed.HasSpecialInput)
                {
                    this.currentGameState = GameState.CmdWait;
                    this.frameCounter     = 0;
                    GameEffect.Special(game.LastTrashed.Power, game.Turn);
                }
            }

            this.frameCounter = 0;
        }
        else if (this.currentGameState == GameState.AIAction)
        {
            if (game.Status != LilyAcolasia.GameStatus.Status.WaitSpecialInput || this.frameCounter >= AI_WAIT)
            {
                this.frameCounter = 0;

                if (this.level == 0)
                {
                    if (!netuser.IsConnected)
                    {
                        GameEffect.GameEnd(3);
                        this.netuser.Close();
                        DestroyObject(this.netuser.gameObject);
                        this.currentGameState = GameState.GameEnd;
                        return;
                    }
                    string next = netuser.message();

                    if (next == null)
                    {
                        GameEffect.GameEnd(3);
                        this.netuser.Close();
                        DestroyObject(this.netuser.gameObject);
                        this.currentGameState = GameState.GameEnd;
                        return;
                    }
                    else if (next == "")
                    {
                        return;
                    }
                    input.input(next);
                }
                else
                {
                    var next = ai.next(game);
                    input.input(next.Item1, next.Item2, next.Item3.ToString());
                }
                this.gameEnumerator.MoveNext();
                this.frameCounter     = 0;
                this.currentGameState = GameState.CmdWait;
                GameEffect.Special(-1, game.Turn);
                if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
                {
                    GameEffect.CutIn(game.LastTrashed.Power);
                    audioSource.clip = soundCutIn;
                    audioSource.Play();
                    this.currentGameState = GameState.CutIn;
                }
            }
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="n">Round number.</param>
 /// <param name="name1">Player1 name.</param>
 /// <param name="name2">Player2 name.</param>
 public GameRound(int n, string name1, string name2, GameRandom random, bool rev)
 {
     this.game = new CardGame(name1, name2, random, rev);
 }