예제 #1
0
        public games SaveGame(games game, string winner)
        {
            var res = new games();

            try
            {
                if (game == null || game.id == 0)
                {
                    return(res);
                }
                if (!_players.Contains(winner) || (winner == "computer" && game.opponent == "player") || (winner == "player 2" && game.opponent == "computer"))
                {
                    if (winner != "draw")
                    {
                        return(res);
                    }
                }

                game.winner = winner;
                db.SaveGame(game);
                res = game;
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #2
0
        public games AddGame(string opponent, string mark)
        {
            var res = new games();

            try
            {
                if (!_opponents.Contains(opponent))
                {
                    return(res);
                }
                if (!_marks.Contains(mark))
                {
                    return(res);
                }

                res = new games
                {
                    id            = 0,
                    opponent      = opponent,
                    created       = DateTime.Now,
                    playerOneMark = mark
                };
                db.SaveGame(res);
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #3
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);

        if (TxtTitle.Text.Trim() == "")
        {
            Response.Write("<script>alert('标题不能为空')</script>");
        }
        else if (str.Trim() == "")
        {
            Response.Write("<script>alert('文章不能为空')</script>");
        }
        else
        {
            try
            {
                using (var db = new CstwebEntities())
                {
                    games ne;
                    if (neid == 0)
                    {
                        ne = new games();
                    }
                    else
                    {
                        ne = db.games.First <games>(a => a.id == neid);
                    }

                    ne.gamename = TxtTitle.Text.Trim();
                    ne.body     = str.Trim();
                    ne.addtime  = DateTime.Now;
                    int status = Convert.ToInt16(DdlStatus.SelectedValue);
                    ne.status = status;
                    if (neid == 0)
                    {
                        db.games.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'games.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'games.aspx';</script>");
                    }
                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
        }
    }
예제 #4
0
        public games GetGame(int id)
        {
            var res = new games();

            msg = string.Empty;
            try
            {
                res = GetGames().FirstOrDefault(x => x.id == id);
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #5
0
    public override void Awake()

    {
        base.Awake();


        instance             = this;
        m_battleStateManager = new BattleStateMachineManager();

        m_battleStateManager.Init();

        m_battleStateManager.SetState(BattleStateIndex.BattleReady);

        m_character.Init();

        m_character.SetState(UnitStateIndex.Idle);

        Refresh();
    }
예제 #6
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    games ne = db.games.FirstOrDefault <games>(a => a.id == id);
                    db.games.Remove(ne);
                    db.SaveChanges();
                    Response.Write("<script>alert('删除成功');window.location = 'games.aspx';</script>");
                }
                catch { Response.Write("<script>alert('删除失败')</script>"); }
            }
        }
    }
예제 #7
0
        public logs AddLog(games game, int turn, int position, string player, string mark)
        {
            var res = new logs();

            try
            {
                if (game == null || game.id == 0)
                {
                    return(res);
                }
                if (!_players.Contains(player))
                {
                    return(res);
                }
                if (!_marks.Contains(mark))
                {
                    return(res);
                }
                if (turn < 1 || 9 < turn)
                {
                    return(res);
                }
                if (position < 0 || 8 < position)
                {
                    return(res);
                }

                res = new logs
                {
                    id       = 0,
                    gameID   = game.id,
                    player   = player,
                    mark     = mark.ToString(),
                    turn     = turn,
                    position = position
                };
                db.SaveLog(res);
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         neid = Convert.ToInt32(Request.QueryString["id"]);
         if (!IsPostBack)
         {
             using (var db = new CstwebEntities())
             {
                 games ne = db.games.First <games>(a => a.id == neid);
                 TxtTitle.Text           = ne.gamename;
                 myEditor.InnerHtml      = ne.body;
                 DdlStatus.SelectedValue = ne.status.ToString();
             }
         }
     }
     catch
     {
         neid = 0;
     }
 }
예제 #9
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);
        if (TxtTitle.Text.Trim() == "") Response.Write("<script>alert('标题不能为空')</script>");
        else if (str.Trim() == "") Response.Write("<script>alert('文章不能为空')</script>");
        else
            try
            {
                using (var db = new CstwebEntities())
                {
                    games ne;
                    if (neid == 0)
                        ne = new games();
                    else
                        ne = db.games.First<games>(a => a.id == neid);

                    ne.gamename = TxtTitle.Text.Trim();
                    ne.body = str.Trim();
                    ne.addtime = DateTime.Now;
                    int status = Convert.ToInt16(DdlStatus.SelectedValue);
                    ne.status = status;
                    if (neid == 0)
                    {
                        db.games.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'games.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'games.aspx';</script>");
                    }

                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
    }
예제 #10
0
    static void Main()
    {
        const int MAX = 10000;
        char      option;

        games[] game   = new games[MAX];
        int     amount = 0;

        do
        {
            Console.WriteLine("1 - Add a new game");
            Console.WriteLine("2 - Show all the data of a certain game");
            Console.WriteLine
                ("3 - Show all games of a certain platform and category");
            Console.WriteLine("4 - Find games containing a certain text");
            Console.WriteLine("5 - Update a record");
            Console.WriteLine("6 - Delete a record");
            Console.WriteLine("7 - Sort data alphabetically");
            Console.WriteLine("8 - Eliminate redundant spaces");
            Console.WriteLine("Q - Quit the application");
            option = Convert.ToChar(Console.ReadLine());

            switch (option)
            {
            case '1':     // Add a new game
                if (amount > MAX)
                {
                    Console.WriteLine("Database is full");
                }
                else
                {
                    game[amount].title = "";     // MEJORA PLS
                    while (game[amount].title == "")
                    {
                        Console.Write("Title: ");
                        game[amount].title = Console.ReadLine();
                    }
                    Console.Write("Category: ");     // TO DO ¿Descripcion?
                    game[amount].category = Console.ReadLine();
                    Console.Write("Platform: ");
                    game[amount].platform = Console.ReadLine();

                    while (game[amount].year < 1940 ||
                           game[amount].year > 2100)
                    {
                        Console.Write("Year: ");
                        game[amount].year =
                            Convert.ToInt32(Console.ReadLine());
                    }
                    game[amount].rating = 11;     // MEJORA PLS
                    while (game[amount].rating < 0 ||
                           game[amount].rating > 10)
                    {
                        Console.Write("Rating: ");
                        game[amount].rating =
                            Convert.ToDouble(Console.ReadLine());
                    }
                    Console.Write("Comments: ");
                    game[amount].comments = Console.ReadLine();
                    amount++;
                }
                break;

            case '2':     // Show all the data of a certain game
                char   election;
                int    searchNumber;
                string searchTitle;
                bool   found = false;
                Console.Write
                    ("Search by number or exact title (n / t)? ");
                election = Convert.ToChar(Console.ReadLine().ToUpper());
                if (election == 'N')     // TO DO ¿Numero?
                {
                    Console.Write("Number: ");
                    searchNumber = Convert.ToInt32(Console.ReadLine()) + 1;
                    if (searchNumber < 0 || searchNumber > amount)
                    {
                        Console.WriteLine("No games at that number");
                    }

                    else
                    {
                        Console.Write(game[searchNumber].title + " - ");
                        Console.Write(game[searchNumber].category + " - ");
                        Console.Write(game[searchNumber].platform + " - ");
                        Console.Write(game[searchNumber].year + " - ");
                        Console.Write(game[searchNumber].rating + " - ");
                        Console.WriteLine(game[searchNumber].comments);
                    }
                }
                if (election == 'T')
                {
                    Console.Write("Title: ");
                    searchTitle = Console.ReadLine().ToUpper();
                    for (int i = 0; i < amount; i++)
                    {
                        if (game[i].title == searchTitle)
                        {
                            Console.Write(game[i].title + " - ");
                            Console.Write(game[i].category + " - ");
                            Console.Write(game[i].platform + " - ");
                            Console.Write(game[i].year + " - ");
                            Console.Write(game[i].rating + " - ");
                            Console.WriteLine(game[i].comments);
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        Console.Write("No games with that title");
                    }
                }
                else
                {
                    Console.WriteLine("Wrong option");
                }
                break;

            case '3':     // Show all games of a certain platform and category
                string searchCategory;
                string searchPlatform;
                int    countPlatCat = 0;
                Console.Write("Category: ");
                searchCategory = Console.ReadLine();
                Console.Write("Platform: ");
                searchPlatform = Console.ReadLine();

                for (int i = 0; i < amount; i++)
                {
                    if (game[i].category == searchCategory &&
                        game[i].platform == searchPlatform)
                    {
                        Console.Write(i + " - ");
                        Console.Write(game[i].title + " - ");
                        Console.Write(game[i].year + " - ");
                        Console.WriteLine(game[i].rating);
                        countPlatCat++;

                        if (countPlatCat % 22 == 21)
                        {
                            Console.WriteLine
                                ("Press ENTER to continue...");
                            Console.ReadLine();
                        }
                    }
                }
                break;

            case '4':     // Find games containing a certain text
                string searchText;
                int    countText = 0;
                Console.Write("Text to search: ");
                searchText = Console.ReadLine().ToUpper();

                for (int i = 0; i < amount; i++)
                {
                    if (game[i].title.ToUpper().Contains(searchText) ||
                        game[i].category.ToUpper().Contains(searchText) ||
                        game[i].platform.ToUpper().Contains(searchText) ||
                        game[i].comments.ToUpper().Contains(searchText))
                    {
                        Console.Write(i + " - ");
                        Console.Write(game[i].title + " - ");
                        Console.Write(game[i].year + " - ");
                        Console.WriteLine(game[i].rating);
                        countText++;
                    }

                    if (countText % 22 == 21)
                    {
                        Console.WriteLine("Press ENTER to continue...");
                        Console.ReadLine();
                    }
                }
                break;

            case '5':     // Update a record
                string newData;
                Console.Write("Number of record: ");
                searchNumber = Convert.ToInt32(Console.ReadLine());
                if (searchNumber < 0 || searchNumber > amount)
                {
                    Console.WriteLine("No record at that number");
                }
                else
                {
                    Console.WriteLine("Old title: "
                                      + game[searchNumber].title);
                    Console.Write("New title: ");
                    newData = Console.ReadLine();
                    if (newData != "")
                    {
                        game[searchNumber].title = newData;
                    }

                    Console.WriteLine("Old category: "
                                      + game[searchNumber].category);
                    Console.Write("New category: ");
                    newData = Console.ReadLine();
                    if (newData != "")
                    {
                        game[searchNumber].category = newData;
                    }

                    Console.WriteLine("Old platform: "
                                      + game[searchNumber].platform);
                    Console.Write("New platform: ");
                    newData = Console.ReadLine();
                    if (newData != "")
                    {
                        game[searchNumber].platform = newData;
                    }

                    while (game[searchNumber].year < 1940 ||
                           game[searchNumber].year > 2100)
                    {
                        Console.WriteLine("Old year: "
                                          + game[searchNumber].year);
                        Console.Write("New year: ");
                        newData = Console.ReadLine();
                        if (newData != "")
                        {
                            game[searchNumber].year =
                                Convert.ToInt32(newData);
                        }
                    }

                    while (game[searchNumber].rating < 0 ||
                           game[searchNumber].rating > 10)
                    {
                        Console.WriteLine("Old rating: "
                                          + game[searchNumber].rating);
                        Console.Write("New rating: ");
                        newData = Console.ReadLine();
                        if (newData != "")
                        {
                            game[searchNumber].rating =
                                Convert.ToDouble(newData);
                        }
                    }

                    Console.WriteLine("Old comments: "
                                      + game[searchNumber].comments);
                    Console.Write("New comments: ");
                    newData = Console.ReadLine();
                    if (newData != "")
                    {
                        game[searchNumber].comments = newData;
                    }
                }
                break;

            case '6':     // Delete a record
                int  posToDelete;
                char confirmation;
                Console.WriteLine("Position to delete: ");
                posToDelete = Convert.ToInt32(Console.ReadLine());
                if (posToDelete < 0 || posToDelete >= amount)
                {
                    Console.WriteLine("No records at the position");
                }
                else
                {
                    Console.WriteLine
                        ("This is the game you are deleting:");
                    Console.Write(game[posToDelete].title + " - ");
                    Console.Write(game[posToDelete].category + " - ");
                    Console.Write(game[posToDelete].platform + " - ");
                    Console.Write(game[posToDelete].year + " - ");
                    Console.Write(game[posToDelete].rating + " - ");
                    Console.WriteLine(game[posToDelete].comments);
                    Console.Write("Type Y to confirm deletion... ");
                    confirmation =
                        Convert.ToChar(Console.ReadLine().ToUpper());

                    if (confirmation == 'Y')
                    {
                        for (int i = posToDelete; i < amount; i++)
                        {
                            game[i] = game[i + 1];
                        }
                        amount--;
                        Console.WriteLine("Deleted");
                    }
                    else
                    {
                        Console.WriteLine("Not deleted");
                    }
                }
                amount--;
                break;

            case '7':     // Sort data alphabetically // TO DO
                break;

            case '8':     // Eliminate redundant spaces
                for (int i = 0; i < amount; i++)
                {
                    game[i].category = game[i].category.Trim();
                    game[i].platform = game[i].platform.Trim();
                    game[i].category =
                        game[i].category.Replace("  ", " ");
                    game[i].platform =
                        game[i].platform.Replace("  ", " ");
                }
                break;

            case 'Q':     // Quit the application
                Console.WriteLine("Bye!");
                break;
            }
        }while (option != 'Q');
    }
예제 #11
0
    void FixedUpdate()
    {
        switch (active)
        {
        case games.space:
            float x = -Input.GetAxis("Horizontal") * spaceSpeed;
            Debug.Log(x);
            spacePlayer.transform.localPosition = new Vector3(Mathf.Clamp(spacePlayer.transform.localPosition.x + x, -9.7f, -2.1f), 1, -3);
            break;

        case games.pac:
            break;

        default:
            CharacterController controller = GetComponent <CharacterController>();
            moveDirection  = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            moveDirection  = transform.TransformDirection(moveDirection);
            moveDirection *= speed;
            controller.Move(moveDirection * Time.deltaTime);
            transform.position = new Vector3(transform.position.x, 3.58f, transform.position.z);
            break;
        }

        if (active == games.none)
        {
            float mouseY = Input.GetAxis("Mouse X");
            float mouseX = -Input.GetAxis("Mouse Y");

            rotY += mouseY * mouseSens * Time.deltaTime;
            rotX += mouseX * mouseSens * Time.deltaTime;

            rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle);

            Quaternion localRot = Quaternion.Euler(rotX, rotY, 0.0f);
            GetComponentInChildren <Transform>().transform.rotation = localRot;

            if (Input.GetAxis("Use") > 0)
            {
                RaycastHit hit;
                float      hitDistance;
                Vector3    forward = transform.TransformDirection(Vector3.forward) * 10;
                Debug.DrawRay(transform.position, forward, Color.green);

                if (Physics.Raycast(transform.position, (forward), out hit))
                {
                    hitDistance = hit.distance;
                    if (hitDistance < 3)
                    {
                        GameObject hitObj = hit.collider.gameObject;
                        active = hitObj.GetComponent <GameCabinet>().thisGame;
                        StartCoroutine(MoveFromTo(transform.position, new Vector3(hitObj.transform.position.x - 1.5f, 3.58f, hitObj.transform.position.z - 1.5f), transform.rotation, new Quaternion(.11f, 0f, 0f, 1f), 0.75f));
                    }
                }
            }
        }
        else
        {
            if (Input.GetAxis("Exit") > 0)
            {
                active = games.none;
            }
        }
    }
예제 #12
0
        public Turn MoveComputer(games game)
        {
            var res = new Turn();

            try
            {
                if (game == null || game.id == 0)
                {
                    return(res);
                }

                var computerMark = game.playerOneMark == "X" ? "O" : "X";
                var position     = -1;

                #region win
                for (var i = 0; i <= 2; i++)
                {
                    if (_field[i * 3] == computerMark && _field[i * 3] == _field[i * 3 + 1] && string.IsNullOrEmpty(_field[i * 3 + 2]))
                    {
                        position = i * 3 + 2;                                                                                                                                    //Horizontal
                    }
                    if (_field[i * 3] == computerMark && _field[i * 3] == _field[i * 3 + 2] && string.IsNullOrEmpty(_field[i * 3 + 1]))
                    {
                        position = i * 3 + 1;
                    }
                    if (_field[i * 3 + 1] == computerMark && _field[i * 3 + 1] == _field[i * 3 + 2] && string.IsNullOrEmpty(_field[i * 3]))
                    {
                        position = i * 3;
                    }

                    if (_field[i] == computerMark && _field[i] == _field[i + 3] && string.IsNullOrEmpty(_field[i + 6]))
                    {
                        position = i + 6;                                                                                                                    //Vertical
                    }
                    if (_field[i] == computerMark && _field[i] == _field[i + 6] && string.IsNullOrEmpty(_field[i + 3]))
                    {
                        position = i + 3;
                    }
                    if (_field[i + 3] == computerMark && _field[i + 3] == _field[i + 6] && string.IsNullOrEmpty(_field[i]))
                    {
                        position = i;
                    }
                }
                if (_field[0] == computerMark && _field[0] == _field[4] && string.IsNullOrEmpty(_field[8]))
                {
                    position = 8;                                                                                                                            //Cross
                }
                if (_field[0] == computerMark && _field[0] == _field[8] && string.IsNullOrEmpty(_field[4]))
                {
                    position = 4;
                }
                if (_field[4] == computerMark && _field[4] == _field[8] && string.IsNullOrEmpty(_field[0]))
                {
                    position = 0;
                }

                if (_field[2] == computerMark && _field[2] == _field[4] && string.IsNullOrEmpty(_field[6]))
                {
                    position = 6;
                }
                if (_field[2] == computerMark && _field[2] == _field[6] && string.IsNullOrEmpty(_field[4]))
                {
                    position = 4;
                }
                if (_field[4] == computerMark && _field[4] == _field[6] && string.IsNullOrEmpty(_field[2]))
                {
                    position = 2;
                }
                #endregion
                #region not lose
                if (position == -1)
                {
                    for (var i = 0; i <= 2; i++)
                    {
                        if (_field[i * 3] == game.playerOneMark && _field[i * 3] == _field[i * 3 + 1] && string.IsNullOrEmpty(_field[i * 3 + 2]))
                        {
                            position = i * 3 + 2;                                                                                                                                //Horizontal
                        }
                        if (_field[i * 3] == game.playerOneMark && _field[i * 3] == _field[i * 3 + 2] && string.IsNullOrEmpty(_field[i * 3 + 1]))
                        {
                            position = i * 3 + 1;
                        }
                        if (_field[i * 3 + 1] == game.playerOneMark && _field[i * 3 + 1] == _field[i * 3 + 2] && string.IsNullOrEmpty(_field[i * 3]))
                        {
                            position = i * 3;
                        }

                        if (_field[i] == game.playerOneMark && _field[i] == _field[i + 3] && string.IsNullOrEmpty(_field[i + 6]))
                        {
                            position = i + 6;                                                                                                                //Vertical
                        }
                        if (_field[i] == game.playerOneMark && _field[i] == _field[i + 6] && string.IsNullOrEmpty(_field[i + 3]))
                        {
                            position = i + 3;
                        }
                        if (_field[i + 3] == game.playerOneMark && _field[i + 3] == _field[i + 6] && string.IsNullOrEmpty(_field[i]))
                        {
                            position = i;
                        }
                    }

                    if (_field[0] == game.playerOneMark && _field[0] == _field[4] && string.IsNullOrEmpty(_field[8]))
                    {
                        position = 8;                                                                                                                        //Cross
                    }
                    if (_field[0] == game.playerOneMark && _field[0] == _field[8] && string.IsNullOrEmpty(_field[4]))
                    {
                        position = 4;
                    }
                    if (_field[4] == game.playerOneMark && _field[4] == _field[8] && string.IsNullOrEmpty(_field[0]))
                    {
                        position = 0;
                    }

                    if (_field[2] == game.playerOneMark && _field[2] == _field[4] && string.IsNullOrEmpty(_field[6]))
                    {
                        position = 6;
                    }
                    if (_field[2] == game.playerOneMark && _field[2] == _field[6] && string.IsNullOrEmpty(_field[4]))
                    {
                        position = 4;
                    }
                    if (_field[4] == game.playerOneMark && _field[4] == _field[6] && string.IsNullOrEmpty(_field[2]))
                    {
                        position = 2;
                    }
                }
                #endregion
                #region free turn
                if (position == -1)
                {
                    var freePositions = new List <int>();

                    for (var i = 0; i <= 8; i++)
                    {
                        if (string.IsNullOrEmpty(_field[i]))
                        {
                            freePositions.Add(i);
                        }
                    }
                    if (freePositions.Contains(4))
                    {
                        position = 4;
                    }
                    else if (freePositions.Contains(0))
                    {
                        position = 0;
                    }
                    else if (freePositions.Contains(2))
                    {
                        position = 2;
                    }
                    else if (freePositions.Contains(6))
                    {
                        position = 6;
                    }
                    else if (freePositions.Contains(8))
                    {
                        position = 8;
                    }
                    else if (freePositions.Contains(1))
                    {
                        position = 1;
                    }
                    else if (freePositions.Contains(3))
                    {
                        position = 3;
                    }
                    else if (freePositions.Contains(5))
                    {
                        position = 5;
                    }
                    else if (freePositions.Contains(7))
                    {
                        position = 7;
                    }
                }
                #endregion

                _field[position] = computerMark;
                AddLog(game, _turn + 1, position, "computer", computerMark);

                res = new Turn
                {
                    player   = "computer",
                    mark     = computerMark,
                    position = position
                };
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #13
0
        public GameResult CheckWinner(games game)
        {
            var res = new GameResult();

            try
            {
                if (game == null || game.id == 0)
                {
                    return(res);
                }

                var items = GetLogs(game.id);
                foreach (var item in items)
                {
                    if (item.position.HasValue)
                    {
                        _field[item.position.Value] = item.mark;
                    }
                }
                _turn = items.Count();

                if (_turn < 3)
                {
                    return(res);
                }
                if (_field[0] != null && _field[1] != null && _field[2] != null && _field[0] == _field[1] && _field[0] == _field[2])                //Horizontal
                {
                    res.winner = items.FirstOrDefault(x => x.position == 0).player;
                    res.winRow = "0,1,2";
                }
                if (_field[3] != null && _field[4] != null && _field[5] != null && _field[3] == _field[4] && _field[3] == _field[5])
                {
                    res.winner = items.FirstOrDefault(x => x.position == 3).player;
                    res.winRow = "3,4,5";
                }
                if (_field[6] != null && _field[7] != null && _field[8] != null && _field[6] == _field[7] && _field[6] == _field[8])
                {
                    res.winner = items.FirstOrDefault(x => x.position == 6).player;
                    res.winRow = "6,7,8";
                }

                if (_field[0] != null && _field[3] != null && _field[6] != null && _field[0] == _field[3] && _field[0] == _field[6])                //Vertical
                {
                    res.winner = items.FirstOrDefault(x => x.position == 0).player;
                    res.winRow = "0,3,6";
                }
                if (_field[1] != null && _field[4] != null && _field[7] != null && _field[1] == _field[4] && _field[1] == _field[7])
                {
                    res.winner = items.FirstOrDefault(x => x.position == 1).player;
                    res.winRow = "1,4,7";
                }
                if (_field[2] != null && _field[5] != null && _field[8] != null && _field[2] == _field[5] && _field[2] == _field[8])
                {
                    res.winner = items.FirstOrDefault(x => x.position == 2).player;
                    res.winRow = "2,5,8";
                }

                if (_field[0] != null && _field[4] != null && _field[8] != null && _field[0] == _field[4] && _field[0] == _field[8])                //Cross
                {
                    res.winner = items.FirstOrDefault(x => x.position == 0).player;
                    res.winRow = "0,4,8";
                }
                if (_field[2] != null && _field[4] != null && _field[6] != null && _field[2] == _field[4] && _field[2] == _field[6])
                {
                    res.winner = items.FirstOrDefault(x => x.position == 2).player;
                    res.winRow = "2,4,6";
                }

                if (!string.IsNullOrEmpty(res.winner))
                {
                    SaveGame(game, res.winner);
                }
                else
                {
                    if (_turn == 9)
                    {
                        SaveGame(game, "draw");
                        res.winner = "draw";
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
예제 #14
0
        private List <games> Creategames()
        {
            List <games> allActivities = new List <games>();
            //horror
            games h1 = new games()
            {
                Name        = "Alien Isolation",
                Description = "in search for your mother you are sent to a space colony where a hostile predator stalks you.",

                Genre1 = GameGenre.Horror
            };
            games h2 = new games()
            {
                Name        = "Outlast",
                Description = "a journalist gets a tip that something isnt right in the insane asylum in town and goes to investigate",

                Genre1 = GameGenre.Horror
            };
            //rpg
            games rpg1 = new games()
            {
                Name        = "Fire Emblem Awakening",
                Description = "strategy rpg where a mysterious character from the future appears to stop the death of a royal family memeber",
                Genre1      = GameGenre.RPG
            };
            //action
            games a1 = new games()
            {
                Name        = "Metal Gear Rising",
                Description = "after the shut down of the patriots a new threat tries to take control of the global markets for private milatary contracts",

                Genre1 = GameGenre.Action
            };
            games a2 = new games()
            {
                Name        = "Bayonetta",
                Description = "a witch who made a deal with demons has to find out where she came from while angels attack her at every turn",

                Genre1 = GameGenre.Action
            };
            //action adventure
            games AA1 = new games()
            {
                Name        = "The legend of Zelda:Breath of the wild",
                Description = "after 100 years you awaken to a land some what familiar and have to save it from a great calamity",
                Genre1      = GameGenre.Action_adventure
            };
            //strategy
            games s1 = new games()
            {
                Name        = "Fire emblem Birthright",
                Description = "a kidnapped prince returns to his kingdom and sets out a war on the kingdom that took him from his family",
                Genre1      = GameGenre.Strategy
            };
            games s2 = new games()
            {
                Name        = "Fire emblem conquest",
                Description = "a kidnapped prince goes to war with his alleged family to take over their kingdom",
                Genre1      = GameGenre.Strategy
            };



            //horror
            allgames.Add(h1);
            allgames.Add(h2);

            //action
            allgames.Add(a1);
            allgames.Add(a2);

            //action adventure
            allgames.Add(AA1);

            //rpg
            allgames.Add(rpg1);

            //strategy
            allgames.Add(s1);
            allgames.Add(s2);


            return(allgames);
        }