/// <summary>
        /// Method called when new sessions are created.  Override to change behavior.
        /// </summary>
        /// <returns>New session instance.</returns>
        protected virtual TSession CreateSession(System.Net.Sockets.Socket socket)
        {
            var session = SocketSession <TSession, TConfig> .Create(socket, AsyncPool, Config, this);

            SessionSetup?.Invoke(this, new SessionEventArgs <TSession, TConfig>(session));
            session.Closed += (sender, args) => OnClose(session, args.CloseReason);
            return(session);
        }
        public HttpResponseMessage Delete()
        {
            if (!Convert.ToBoolean(_appSettings.GetSetting(AppSettingKey.AllowDatabaseDelete)))
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            string connectionString = ConfigurationManager.ConnectionStrings["SpeedyDonkeyDbContext"].ConnectionString;

            var sessionSetup = new SessionSetup(connectionString);

            sessionSetup.BuildSchema();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
            public static bool Prefix(SessionSetup __instance, ref SessionPitstop ___mSessionPitStop, ref Driver ___mDriver, ref RacingVehicle ___mVehicle)
            {
                SessionDetails.SessionType sessionType = Game.instance.sessionManager.eventDetails.currentSession.sessionType;
                bool qualifyingBasedActive             = ___mDriver.contract.GetTeam().championship.rules.qualifyingBasedActive;
                bool flag  = false;
                bool flag2 = false;

                if (___mVehicle.practiceKnowledge.practiceReport != null)
                {
                    PracticeReportKnowledgeData knowledgeOfType  = ___mVehicle.practiceKnowledge.practiceReport.GetKnowledgeOfType(PracticeReportSessionData.KnowledgeType.QualifyingTrim);
                    PracticeReportKnowledgeData knowledgeOfType2 = ___mVehicle.practiceKnowledge.practiceReport.GetKnowledgeOfType(PracticeReportSessionData.KnowledgeType.RaceTrim);
                    flag  = (knowledgeOfType.normalizedKnowledge >= 1f);
                    flag2 = (knowledgeOfType2.normalizedKnowledge >= 1f);
                }
                switch (sessionType)
                {
                case SessionDetails.SessionType.Practice:
                    if (qualifyingBasedActive && !flag && flag2)
                    {
                        ___mSessionPitStop.currentSetup.trim        = SessionSetup.Trim.Qualifying;
                        ___mSessionPitStop.targetSetup.trim         = SessionSetup.Trim.Qualifying;
                        ___mVehicle.practiceKnowledge.knowledgeType = PracticeReportSessionData.KnowledgeType.QualifyingTrim;
                    }
                    else
                    {
                        ___mSessionPitStop.currentSetup.trim        = SessionSetup.Trim.Race;
                        ___mSessionPitStop.targetSetup.trim         = SessionSetup.Trim.Race;
                        ___mVehicle.practiceKnowledge.knowledgeType = PracticeReportSessionData.KnowledgeType.RaceTrim;
                    }
                    break;

                case SessionDetails.SessionType.Qualifying:
                    ___mSessionPitStop.currentSetup.trim = SessionSetup.Trim.Qualifying;
                    ___mSessionPitStop.targetSetup.trim  = SessionSetup.Trim.Qualifying;
                    break;

                case SessionDetails.SessionType.Race:
                    ___mSessionPitStop.currentSetup.trim = SessionSetup.Trim.Race;
                    ___mSessionPitStop.targetSetup.trim  = SessionSetup.Trim.Race;
                    break;
                }
                return(false);
            }
Esempio n. 4
0
    public void StartGame()
    {
        SessionSetup setup = GameObject.FindGameObjectWithTag("GameState").GetComponent <SessionSetup>();

        setup.playAreaSize = new Vector2Int(GetIntInputValue("(I) FieldX"), GetIntInputValue("(I) FieldY"));
        setup.piecesToWin  = GetIntInputValue("(I) Pieces to win");

        setup.players.Clear();

        Transform verticalLayout = GameObject.Find("(P) Players").transform.GetChild(0);

        for (int i = 0; i < verticalLayout.childCount - 1; i++)
        {
            string name    = verticalLayout.GetChild(i).Find("(I) Player Name").GetComponent <InputField>().text;
            int    control = verticalLayout.GetChild(i).Find("(D) Control").GetComponent <Dropdown>().value;
            setup.players.Add(new Player(new MarkType(), control == 1, name));
        }

        TicTacToeGlobal.views.ActivateGameView();
    }