Exemplo n.º 1
0
        private static void GetUploadDetails(
            IDatabaseCommandFactory databaseCommandFactory,
            int uploadId,
            out string uploadContent,
            out string userId,
            out PlayStyle playStyle)
        {
            const string CommandText       = @"
	            SELECT UploadContent, UserId, PlayStyle
	            FROM Uploads
	            WHERE Id = @UploadId"    ;
            var          commandParameters = new Dictionary <string, object>
            {
                { "@UploadId", uploadId },
            };

            using (var command = databaseCommandFactory.Create(
                       CommandText,
                       commandParameters))
                using (var reader = command.ExecuteReader())
                {
                    reader.Read();
                    uploadContent = reader["UploadContent"].ToString();
                    userId        = reader["UserId"].ToString();

                    if (!Enum.TryParse(reader["PlayStyle"].ToString(), out playStyle))
                    {
                        playStyle = default(PlayStyle);
                    }
                }
        }
Exemplo n.º 2
0
        void load_profile()
        {
            String       line;
            StreamReader reader = new StreamReader(filepath + "Player Profile\\Profile.txt");

            while ((line = reader.ReadLine()) != null)
            {
                string[] comps = line.Split(' ');
                switch (comps[0])
                {
                case "Rank:":
                    this.rank = parseRank(comps[1]);
                    break;

                case "SkillLevel:":
                    this.skill_level = parseRank(comps[1]);
                    break;

                case "PlayStyle:":
                    this.style = parsePlayStyle(comps[1]);
                    break;

                case "ExperimentType:":
                    this.exp_type = parseType(comps[1]);
                    break;
                }
            }
        }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        if (!PlayerPrefs.HasKey("PlayStyle"))
        {
        #if UNITY_STANDALONE
            PlayerPrefs.SetString("PlayStyle", PlayStyle.FirstPerson.ToString());
            Debug.Log("Playstyle is set to first person");
        #else
            PlayerPrefs.SetString("PlayStyle", PlayStyle.TopDown.ToString());
            Debug.Log("Playstyle is set to top down");
        #endif
        }

        var style        = PlayerPrefs.GetString("PlayStyle");
        var successParse = PlayStyle.TryParse(style, true, out styleOfPlay);
        if (!successParse)
        {
            Debug.Log($"Couldn't parse playstyle {style}");
            styleOfPlay = PlayStyle.TopDown;
        }

        TopDownCamera.SetActive(styleOfPlay == PlayStyle.TopDown);
        TopDownCamera.GetComponent <Camera>().enabled = styleOfPlay == PlayStyle.TopDown;

        FirstPersonCamera.SetActive(styleOfPlay == PlayStyle.FirstPerson);
        FirstPersonCamera.GetComponent <Camera>().enabled = styleOfPlay == PlayStyle.FirstPerson;
    }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Computer"/> class through random fighter selection.
        /// </summary>
        public Computer()
        {
            int rnd = Rnd.Next(1, 4);

            switch (rnd)
            {
            case 1:
                Fighter   = new Attacker();
                playStyle = PlayAttacker;
                break;

            case 2:
                Fighter   = new Swarmer();
                playStyle = PlaySwarmer;
                break;

            case 3:
                Fighter   = new Defender();
                playStyle = PlayDefender;
                break;

            default:
                throw new Exception("Failed to generate computer oponent.");
            }
            WriteLine($"Computer has chosen {Fighter.Style.ToString().ToLower()}.");
        }
Exemplo n.º 5
0
        public void SscFile_Parses_Steps_Type(string sscFilePath, PlayStyle expectedPlayStyle)
        {
            var sscFile = new SmFile(sscFilePath);

            var actualPlayStyle = sscFile.ChartMetadata.StepCharts.Single().PlayStyle;

            Assert.Equal(expectedPlayStyle, actualPlayStyle);
        }
Exemplo n.º 6
0
 public SongDifficulty GetHighestChartedDifficulty(PlayStyle style)
 {
     return
         (StepCharts
          .Where(c => c.PlayStyle == style)
          .OrderByDescending(c => c.Difficulty)
          .Select(d => d.Difficulty)
          .FirstOrDefault());
 }
Exemplo n.º 7
0
        [InlineData(TEST_DATA_ARABIAN_NIGHTS, PlayStyle.Double, SongDifficulty.Challenge)] //Doubles Only chart
        public void SmFile_GenerateLightsChart_Maintains_Reference_Chart_Data(string smFilePath,
                                                                              PlayStyle referenceChartStyle, SongDifficulty referenceChartDifficulty)
        {
            var smFile = new SmFile(smFilePath);

            var lightsData = StepChartBuilder.GenerateLightsChart(smFile);

            Assert.Equal(referenceChartStyle, lightsData.ReferenceChart.PlayStyle);
            Assert.Equal(referenceChartDifficulty, lightsData.ReferenceChart.Difficulty);
        }
Exemplo n.º 8
0
    //此函数将一个特效属性值与子元素属性值拷贝给自身。
    //此函数只允许编辑器调用,外界不许调用
    //前置条件:脚本所挂接的gameObject除特效之外的其他属性必需相等
    public bool _CopyValues(SpecialEffect o)
    {
#if UNITY_EDITOR
        if (o == null)
        {
            return(false);
        }

        if (o == this)
        {
            return(true);
        }

        if (GetType() != o.GetType())
        {
            return(false);
        }

        if (elems.Count != o.elems.Count)
        {
            return(false);
        }

        //检查底下的元素类型是否完全一样
        for (int i = 0; i < elems.Count; i++)
        {
            if (elems[i].GetType() != o.elems[i].GetType())
            {
                return(false);
            }
        }

        totalTime  = o.totalTime;
        style      = o.style;
        speedScale = o.speedScale;

        playOnAwake       = o.playOnAwake;
        bindingTargetPath = o.bindingTargetPath;

        for (int i = 0; i < elems.Count; i++)
        {
            if (!elems[i]._CopyValues(o.elems[i]))
            {//此种情况禁止出现
                Debug.LogError("注意!" + "子元素拷贝失败!出现不同步的特效!拷贝操作从\"" + o.gameObject.name + "\"到\"" + gameObject.name + "\"");
                return(false);
            }
        }

        return(true);
#else
        //客户端版,此函数永远运行失败
        return(false);
#endif
    }
Exemplo n.º 9
0
    public void Init()
    {
        style = PlayStyle.FOLLOW_BALL;
        WantPosition = transform.position;
        MoveThreshold = 0.5f;
        aiTimer = 0;
        BaseX = transform.position.x;
        
        bAllowTurn = false;
        
        Speed = 11;
        SprintSpeed = 11;
        
        avatar.SetRandomAvatar();
        network.SendAvatar(avatar.CurrentHairColour, avatar.CurrentHair, avatar.CurrentBrow, avatar.CurrentSkinColour);

        bIsInitialized = true;
    }
Exemplo n.º 10
0
    public void Init()
    {
        style         = PlayStyle.FOLLOW_BALL;
        WantPosition  = transform.position;
        MoveThreshold = 0.5f;
        aiTimer       = 0;
        BaseX         = transform.position.x;

        bAllowTurn = false;

        Speed       = 11;
        SprintSpeed = 11;

        avatar.SetRandomAvatar();
        network.SendAvatar(avatar.CurrentHairColour, avatar.CurrentHair, avatar.CurrentBrow, avatar.CurrentSkinColour);

        bIsInitialized = true;
    }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Computer"/> class using a specified style.
        /// </summary>
        /// <param name="style">The type of fighter that the computer will play.</param>
        public Computer(FightingStyle style)
        {
            switch (style)
            {
            case FightingStyle.Attacker:
                Fighter   = new Attacker();
                playStyle = PlayAttacker;
                break;

            case FightingStyle.Swarmer:
                Fighter   = new Swarmer();
                playStyle = PlaySwarmer;
                break;

            case FightingStyle.Defender:
                Fighter   = new Defender();
                playStyle = PlayDefender;
                break;

            default:
                throw new ArgumentException("Invalid style.");
            }
            WriteLine($"Computer is {Fighter.Style.ToString().ToLower()}.");
        }
Exemplo n.º 12
0
    /* ******************************************************** */
    //! Start playing the animation

    /*!
     * @param	No
     *      Animation's Index<br>
     *      -1 == Now-Setting Index is not changed<br>
     *      default: -1
     * @param	PlayTimes
     *      -1 == Now-Setting "CountLoopRemain" is not changed
     *      0 == Infinite-looping <br>
     *      1 == Not looping <br>
     *      2 <= Number of Plays<br>
     *      default: -1
     * @param	FrameInitial
     *      Offset frame-number of starting Play in animation (0 origins). <br>
     *      At the time of the first play-loop, Animation is started "LabelStart + FrameOffsetStart + FrameInitial".
     *      -1 == use "FrameNoInitial" Value<br>
     *      default: -1
     * @param	RateTime
     *      Coefficient of time-passage of animation.<br>
     *      Minus Value is given, Animation is played backwards.<br>
     *      0.0f is given, the now-setting is not changed) <br>
     *      default: 0.0f (Setting is not changed)
     * @param	KindStylePlay
     *      PlayStyle.NOMAL == Animation is played One-Way.<br>
     *      PlayStyle.PINGPONG == Animation is played Wrap-Around.<br>
     *      PlayStyle.NO_CHANGE == use "Play-Pingpong" Setting.
     *      default: PlayStyle.NO_CHANGE
     * @param	LabelStart
     *      Label-name of starting Play in animation.
     *      "_start" == Top-frame of Animation (reserved label-name)<br>
     *      "" == use "NameLabelStart"<br>
     *      default: ""
     * @param	FrameOffsetStart
     *      Offset frame-number from LabelStart
     *      Animation's Top-frame is "LabelStart + FrameOffsetStart".<br>
     *      int.MinValue == use "OffsetFrameStart"
     *      default: int.MinValue
     * @param	LabelEnd
     *      Label-name of the terminal in animation.
     *      "_end" == Last-frame of Animation (reserved label-name)<br>
     *      "" == use "NameLabelEnd"<br>
     *      default: ""
     * @param	FrameOffsetEnd
     *      Offset frame-number from LabelEnd
     *      Animation's Last-frame is "LabelEnd + FrameOffsetEnd".<br>
     *      int.MaxValue == use "OffsetFrameEnd"
     *      default: int.MaxValue
     * @retval	Return-Value
     *      true == Success <br>
     *      false == Failure (Error)
     *
     * The playing of animation begins. <br>
     * <br>
     * "No" is the Animation's Index (Get the Index in the "AnimationGetIndexNo" function.). <br>
     * Give "0" to "No" when the animation included in (imported "ssae") data is one. <br>
     * When the Animation's Index not existing is given, this function returns false. <br>
     * <br>
     * The update speed of animation quickens when you give a value that is bigger than 1.0f to "RateTime".
     */
    public bool AnimationPlay(int No                  = -1,
                              int TimesPlay           = -1,
                              int FrameInitial        = -1,
                              float RateTime          = 0.0f,
                              PlayStyle KindStylePlay = PlayStyle.NO_CHANGE,
                              string LabelStart       = "",
                              int FrameOffsetStart    = int.MinValue,
                              string LabelEnd         = "",
                              int FrameOffsetEnd      = int.MaxValue
                              )
    {
        /* Error-Check */
        animationNo = (-1 != No) ? No : animationNo;            /* Don't Use "AnimationNo" (occur "Stack-Overflow") */
        if ((0 > animationNo) || (ListInformationPlay.Length <= animationNo))
        {
            return(false);
        }

        /* Set Playing-Datas */
        Status &= ~BitStatus.MASK_INITIAL;
        Status |= BitStatus.PLAYING;
        Status |= BitStatus.DECODE_USERDATA;
        switch (KindStylePlay)
        {
        case PlayStyle.NO_CHANGE:
            break;

        case PlayStyle.NORMAL:
            FlagStylePingpong = false;
            break;

        case PlayStyle.PINGPONG:
            FlagStylePingpong = true;
            break;

        default:
            goto case PlayStyle.NO_CHANGE;
        }

        /* Set Animation Information */
        int FrameNo;

        Library_SpriteStudio.AnimationInformationPlay InformationAnimation = ListInformationPlay[animationNo];
        string Label = "";

        Label = string.Copy((true == string.IsNullOrEmpty(LabelStart)) ? NameLabelStart : LabelStart);
        if (true == string.IsNullOrEmpty(Label))
        {
            Label = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultStart);
        }
        FrameNo = InformationAnimation.FrameNoGetLabel(Label);
        if (-1 == FrameNo)
        {               /* Label Not Found */
            FrameNo = InformationAnimation.FrameStart;
        }
        FrameNo += (int.MinValue == FrameOffsetStart) ? OffsetFrameStart : FrameOffsetStart;
        if ((InformationAnimation.FrameStart > FrameNo) || (InformationAnimation.FrameEnd < FrameNo))
        {
            FrameNo = InformationAnimation.FrameStart;
        }
        frameNoStart = FrameNo;

        Label = string.Copy((true == string.IsNullOrEmpty(LabelEnd)) ? NameLabelEnd : LabelEnd);
        if (true == string.IsNullOrEmpty(Label))
        {
            Label = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultEnd);
        }
        FrameNo = InformationAnimation.FrameNoGetLabel(Label);
        if (-1 == FrameNo)
        {               /* Label Not Found */
            FrameNo = InformationAnimation.FrameEnd;
        }
        FrameNo += (int.MaxValue == FrameOffsetEnd) ? OffsetFrameEnd : FrameOffsetEnd;
        if ((InformationAnimation.FrameStart > FrameNo) || (InformationAnimation.FrameEnd < FrameNo))
        {
            FrameNo = InformationAnimation.FrameEnd;
        }
        frameNoEnd = FrameNo;

        framePerSecond = (null == partsRootOrigin) ? InformationAnimation.FramePerSecond : partsRootOrigin.FramePerSecond;

        int CountFrame = (frameNoEnd - frameNoStart) + 1;

        if (-1 == FrameInitial)
        {               /* Use "FrameNoInitial" */
            FrameInitial = ((0 <= FrameNoInitial) && (CountFrame > FrameNoInitial)) ? FrameNoInitial : 0;
        }
        else
        {               /* Direct-Frame */
            FrameInitial = ((0 <= FrameInitial) && (CountFrame > FrameInitial)) ? FrameInitial : 0;
        }
//		frameNoNow = FrameInitial;
        frameNoNow      = FrameInitial + frameNoStart;
        frameNoPrevious = -1;

        RateTime = (0.0f == RateTime) ? RateTimeAnimation : RateTime;
        if (0.0f > RateTime)
        {
            Status    = (0 == (Status & BitStatus.STYLE_REVERSE)) ? (Status | BitStatus.STYLE_REVERSE) : (Status & ~BitStatus.STYLE_REVERSE);
            RateTime *= -1.0f;
        }
        rateTimePlay = RateTime;

        Status |= (0 != (Status & BitStatus.STYLE_REVERSE)) ? BitStatus.PLAYING_REVERSE : 0;
        if (0 != (Status & BitStatus.PLAYING_REVERSE))
        {               /* Play-Reverse & Start Top-Frame */
            frameNoNow = (frameNoNow <= frameNoStart) ? frameNoEnd : frameNoNow;
        }
        else
        {               /* Play-Normal & Start End-Frame */
            frameNoNow = (frameNoNow >= frameNoEnd) ? frameNoStart : frameNoNow;
        }
//		TimeAnimation = frameNoNow * TimeFramePerSecond;
        TimeAnimation = (frameNoNow - frameNoStart) * TimeFramePerSecond;

        if (-1 != TimesPlay)
        {
            /* MEMO: TimesPlay is Invalid, Force Play-Once */
            CountLoopRemain = (0 > TimesPlay) ? 0 : (TimesPlay - 1);
        }

        /* UserData-CallBack Buffer Create */
        if (null == ListCallBackUserData)
        {
            ListCallBackUserData = new ArrayList();
        }
        ListCallBackUserData.Clear();

        return(true);
    }
Exemplo n.º 13
0
 public Settings(PlayStyle playStyle, float volume, float pan)
 {
     this.playStyle = playStyle;
     this.volume = volume;
     this.pan = pan;
 }
Exemplo n.º 14
0
        public static void CalculateSurvival(IWebDriver driver, Gender gender, int birthYear, int weeklyPlaytime, PlayStyle playStyle)
        {
            DialogHelper.TestDialog(driver, SiteConstants.SurvivalCalculatorAnchorId, SiteConstants.SurvivalModalId, () =>
            {
                Console.WriteLine("Populating calculator settings...");
                driver.SelectValue(By.Id(SiteConstants.SurvivalGenderSelectId), gender.ToString());
                driver.SelectValue(By.Id(SiteConstants.SurvivalBirthYearSelectId), birthYear.ToString(CultureInfo.InvariantCulture));
                driver.SelectValue(By.Id(SiteConstants.SurvivalWeeklyPlaytimeSelectId), weeklyPlaytime.ToString(CultureInfo.InvariantCulture));
                driver.SelectValue(By.Id(SiteConstants.SurvivalPlayStyleSelectId), playStyle.ToString());

                Console.WriteLine("Starting calculation...");
                driver.FindElement(By.Id(SiteConstants.SurvivalCalculatorButtonId)).Click();

                Console.WriteLine("Waiting for calculation to complete...");
                driver.WaitUntilElementCondition(By.Id(SiteConstants.SurvivalBacklogCompletionLabelId), e => e.Text != SiteConstants.SurvivalNotCalculatedText,
                                                 "Could not verify survival calculation completion");
            }, false);
        }
Exemplo n.º 15
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="Style"></param>
 /// <param name="Difficulty"></param>
 public StepPlayType(PlayStyle Style, PlayDifficulty Difficulty) => (this.Style, this.Difficulty) = (Style, Difficulty);
Exemplo n.º 16
0
        public void CreatePreviewWindow(GUIFrame frame)
        {
            frame.ClearChildren();

            if (frame == null)
            {
                return;
            }

            var previewContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.98f), frame.RectTransform, Anchor.Center))
            {
                Stretch = true
            };

            var title = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), previewContainer.RectTransform, Anchor.CenterLeft), ServerName, font: GUI.LargeFont)
            {
                ToolTip = ServerName
            };

            title.Text = ToolBox.LimitString(title.Text, title.Font, (int)(title.Rect.Width * 0.85f));

            GUITickBox favoriteTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.8f), title.RectTransform, Anchor.CenterRight),
                                                        "", null, "GUIServerListFavoriteTickBox")
            {
                Selected   = Favorite,
                ToolTip    = TextManager.Get(Favorite ? "removefromfavorites" : "addtofavorites"),
                OnSelected = (tickbox) =>
                {
                    if (tickbox.Selected)
                    {
                        GameMain.ServerListScreen.AddToFavoriteServers(this);
                    }
                    else
                    {
                        GameMain.ServerListScreen.RemoveFromFavoriteServers(this);
                    }
                    tickbox.ToolTip = TextManager.Get(tickbox.Selected ? "removefromfavorites" : "addtofavorites");
                    return(true);
                }
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), previewContainer.RectTransform),
                             TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"), string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion));

            bool hidePlaystyleBanner = previewContainer.Rect.Height < 380 || !PlayStyle.HasValue;

            if (!hidePlaystyleBanner)
            {
                PlayStyle playStyle                  = PlayStyle ?? Networking.PlayStyle.Serious;
                Sprite    playStyleBannerSprite      = ServerListScreen.PlayStyleBanners[(int)playStyle];
                float     playStyleBannerAspectRatio = playStyleBannerSprite.SourceRect.Width / playStyleBannerSprite.SourceRect.Height;
                var       playStyleBanner            = new GUIImage(new RectTransform(new Point(previewContainer.Rect.Width, (int)(previewContainer.Rect.Width / playStyleBannerAspectRatio)), previewContainer.RectTransform),
                                                                    playStyleBannerSprite, null, true);

                var playStyleName = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.0f), playStyleBanner.RectTransform)
                {
                    RelativeOffset = new Vector2(0.01f, 0.06f)
                },
                                                     TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"), TextManager.Get("servertag." + playStyle)), textColor: Color.White,
                                                     font: GUI.SmallFont, textAlignment: Alignment.Center,
                                                     color: ServerListScreen.PlayStyleColors[(int)playStyle], style: "GUISlopedHeader");
                playStyleName.RectTransform.NonScaledSize = (playStyleName.Font.MeasureString(playStyleName.Text) + new Vector2(20, 5) * GUI.Scale).ToPoint();
                playStyleName.RectTransform.IsFixedSize   = true;

                var serverTypeContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.2f), playStyleBanner.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft),
                                                       "MainMenuNotifBackground", Color.Black)
                {
                    CanBeFocused = false,
                };

                var serverType = new GUITextBlock(new RectTransform(Vector2.One, serverTypeContainer.RectTransform, Anchor.CenterLeft),
                                                  TextManager.Get((OwnerID != 0 || LobbyID != 0) ? "SteamP2PServer" : "DedicatedServer"), textAlignment: Alignment.CenterLeft);
            }
            else
            {
                var serverType = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), previewContainer.RectTransform, Anchor.CenterLeft),
                                                  TextManager.Get((OwnerID != 0 || LobbyID != 0) ? "SteamP2PServer" : "DedicatedServer"), textAlignment: Alignment.CenterLeft);
            }

            var content = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), previewContainer.RectTransform))
            {
                Stretch = true
            };
            // playstyle tags -----------------------------------------------------------------------------

            var playStyleContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), content.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f,
                CanBeFocused    = true
            };

            var playStyleTags = GetPlayStyleTags();

            foreach (string tag in playStyleTags)
            {
                if (!ServerListScreen.PlayStyleIcons.ContainsKey(tag))
                {
                    continue;
                }

                new GUIImage(new RectTransform(Vector2.One, playStyleContainer.RectTransform),
                             ServerListScreen.PlayStyleIcons[tag], scaleToFit: true)
                {
                    ToolTip = TextManager.Get("servertagdescription." + tag),
                    Color   = ServerListScreen.PlayStyleIconColors[tag]
                };
            }

            playStyleContainer.Recalculate();

            // -----------------------------------------------------------------------------

            float elementHeight = 0.075f;

            // Spacing
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.025f), content.RectTransform), style: null);

            var serverMsg = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform))
            {
                ScrollBarVisible = true
            };
            var msgText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverMsg.Content.RectTransform), ServerMessage, font: GUI.SmallFont, wrap: true)
            {
                CanBeFocused = false
            };

            serverMsg.Content.RectTransform.SizeChanged += () => { msgText.CalculateHeightFromText(); };
            msgText.RectTransform.SizeChanged           += () => { serverMsg.UpdateScrollBarSize(); };

            var gameMode = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("GameMode"));

            new GUITextBlock(new RectTransform(Vector2.One, gameMode.RectTransform),
                             TextManager.Get(string.IsNullOrEmpty(GameMode) ? "Unknown" : "GameMode." + GameMode, returnNull: true) ?? GameMode,
                             textAlignment: Alignment.Right);

            GUITextBlock playStyleText = null;

            if (hidePlaystyleBanner && PlayStyle.HasValue)
            {
                PlayStyle playStyle = PlayStyle.Value;
                playStyleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("serverplaystyle"));
                new GUITextBlock(new RectTransform(Vector2.One, playStyleText.RectTransform), TextManager.Get("servertag." + playStyle), textAlignment: Alignment.Right);
            }

            var subSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("ServerListSubSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, subSelection.RectTransform), TextManager.Get(!SubSelectionMode.HasValue ? "Unknown" : SubSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            var modeSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("ServerListModeSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, modeSelection.RectTransform), TextManager.Get(!ModeSelectionMode.HasValue ? "Unknown" : ModeSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            if (gameMode.TextSize.X + gameMode.GetChild <GUITextBlock>().TextSize.X > gameMode.Rect.Width ||
                subSelection.TextSize.X + subSelection.GetChild <GUITextBlock>().TextSize.X > subSelection.Rect.Width ||
                modeSelection.TextSize.X + modeSelection.GetChild <GUITextBlock>().TextSize.X > modeSelection.Rect.Width)
            {
                gameMode.Font = subSelection.Font = modeSelection.Font = GUI.SmallFont;
                gameMode.GetChild <GUITextBlock>().Font = subSelection.GetChild <GUITextBlock>().Font = modeSelection.GetChild <GUITextBlock>().Font = GUI.SmallFont;
                if (playStyleText != null)
                {
                    playStyleText.Font = playStyleText.GetChild <GUITextBlock>().Font = GUI.SmallFont;
                }
            }

            var allowSpectating = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerListAllowSpectating"))
            {
                CanBeFocused = false
            };

            if (!AllowSpectating.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowSpectating.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowSpectating.Selected = AllowSpectating.Value;
            }

            var allowRespawn = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerSettingsAllowRespawning"))
            {
                CanBeFocused = false
            };

            if (!AllowRespawn.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowRespawn.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowRespawn.Selected = AllowRespawn.Value;
            }

            /*var voipEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), bodyContainer.RectTransform), TextManager.Get("serversettingsvoicechatenabled"))
             * {
             *  CanBeFocused = false
             * };
             * if (!VoipEnabled.HasValue)
             *  new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), voipEnabledTickBox.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
             * else
             *  voipEnabledTickBox.Selected = VoipEnabled.Value;*/

            var usingWhiteList = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerListUsingWhitelist"))
            {
                CanBeFocused = false
            };

            if (!UsingWhiteList.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), usingWhiteList.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                usingWhiteList.Selected = UsingWhiteList.Value;
            }


            content.RectTransform.SizeChanged += () =>
            {
                GUITextBlock.AutoScaleAndNormalize(allowSpectating.TextBlock, allowRespawn.TextBlock, usingWhiteList.TextBlock);
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform),
                             TextManager.Get("ServerListContentPackages"), textAlignment: Alignment.Center, font: GUI.SubHeadingFont);

            var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), content.RectTransform))
            {
                ScrollBarVisible = true
            };

            if (ContentPackageNames.Count == 0)
            {
                new GUITextBlock(new RectTransform(Vector2.One, contentPackageList.Content.RectTransform), TextManager.Get("Unknown"), textAlignment: Alignment.Center)
                {
                    CanBeFocused = false
                };
            }
            else
            {
                for (int i = 0; i < ContentPackageNames.Count; i++)
                {
                    var packageText = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform)
                    {
                        MinSize = new Point(0, 15)
                    },
                                                     ContentPackageNames[i])
                    {
                        Enabled = false
                    };
                    if (i < ContentPackageHashes.Count)
                    {
                        if (ContentPackage.AllPackages.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.Selected = true;
                            continue;
                        }

                        //workshop download link found
                        if (i < ContentPackageWorkshopIds.Count && ContentPackageWorkshopIds[i] != 0)
                        {
                            packageText.TextColor = Color.Yellow;
                            packageText.ToolTip   = TextManager.GetWithVariable("ServerListIncompatibleContentPackageWorkshopAvailable", "[contentpackage]", ContentPackageNames[i]);
                        }
                        else //no package or workshop download link found, tough luck
                        {
                            packageText.TextColor = GUI.Style.Red;
                            packageText.ToolTip   = TextManager.GetWithVariables("ServerListIncompatibleContentPackage",
                                                                                 new string[2] {
                                "[contentpackage]", "[hash]"
                            }, new string[2] {
                                ContentPackageNames[i], ContentPackageHashes[i]
                            });
                        }
                    }
                }
            }

            // -----------------------------------------------------------------------------

            foreach (GUIComponent c in content.Children)
            {
                if (c is GUITextBlock textBlock)
                {
                    textBlock.Padding = Vector4.Zero;
                }
            }
        }
Exemplo n.º 17
0
 public void EventRemove(PlayStyle style)
 {
     if (Events.ContainsKey(style))
     {
         Events.Remove(style);
     }
 }
Exemplo n.º 18
0
 public void EventAdd(PlayStyle style, Eventer e)
 {
     if (Events.ContainsKey(style))
     {
         Events[style] = e;
     }
     else
     {
         Events.Add(style, e);
     }
 }
Exemplo n.º 19
0
 public ArchetypeStyle(string name, PlayStyle style)
 {
     Name  = name;
     Style = style;
 }
Exemplo n.º 20
0
        private static void AssertSurvival(IWebDriver driver, Gender gender, int birthYear, int weeklyPlaytime, PlayStyle playStyle, bool expectSurvival)
        {
            SignInHelper.SignInWithId(driver, UserConstants.SampleSteamId);
            SurvivalHelper.CalculateSurvival(driver, gender, birthYear, weeklyPlaytime, playStyle);

            Console.WriteLine("Parsing backlog completion date...");
            var backlogCompletion = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalBacklogCompletionLabelId)).Text);

            Console.WriteLine("Parsing time of death date...");
            var timeOfDeath = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalTimeOfDeathLabelId)).Text);

            Console.WriteLine("Asserting expected results...");
            bool survival = timeOfDeath >= backlogCompletion;

            if (expectSurvival)
            {
                Assert.IsTrue(survival, "Expected time of death to come after backlog completion");
                Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalSuccessImgId)).Displayed, "Expected backlog completion success");
            }
            else
            {
                Assert.IsFalse(survival, "Expected time of death to come before backlog completion");
                Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalFailureImgId)).Displayed, "Expected backlog completion failure");
            }
        }
Exemplo n.º 21
0
        public void CreatePreviewWindow(GUIFrame frame)
        {
            frame.ClearChildren();

            if (frame == null)
            {
                return;
            }

            var previewContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), frame.RectTransform, Anchor.Center))
            {
                Stretch = true
            };

            var titleContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.035f), previewContainer.RectTransform), true)
            {
                Color = Color.White * 0.2f
            };

            var title = new GUITextBlock(new RectTransform(new Vector2(0.9f, 0.0f), titleContainer.RectTransform, Anchor.CenterLeft), ServerName, font: GUI.LargeFont)
            {
                ToolTip = ServerName
            };

            title.Text = ToolBox.LimitString(title.Text, title.Font, title.Rect.Width);

            title.Padding = new Vector4(10, 0, 0, 10);

            GUITickBox favoriteTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.85f), titleContainer.RectTransform, Anchor.CenterRight, scaleBasis: ScaleBasis.BothHeight)
            {
                RelativeOffset = new Vector2(0.0f, 0.1f)
            }, "", null, "GUIServerListFavoriteTickBox")
            {
                Selected   = Favorite,
                ToolTip    = TextManager.Get(Favorite ? "removefromfavorites" : "addtofavorites"),
                OnSelected = (tickbox) =>
                {
                    if (tickbox.Selected)
                    {
                        GameMain.ServerListScreen.AddToFavoriteServers(this);
                    }
                    else
                    {
                        GameMain.ServerListScreen.RemoveFromFavoriteServers(this);
                    }
                    tickbox.ToolTip = TextManager.Get(tickbox.Selected ? "removefromfavorites" : "addtofavorites");
                    return(true);
                }
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), previewContainer.RectTransform),
                             TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"), string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion));

            PlayStyle playStyle = PlayStyle ?? Networking.PlayStyle.Serious;

            Sprite playStyleBannerSprite      = GameMain.ServerListScreen.PlayStyleBanners[(int)playStyle];
            float  playStyleBannerAspectRatio = playStyleBannerSprite.SourceRect.Width / (playStyleBannerSprite.SourceRect.Height * 0.65f);
            var    playStyleBanner            = new GUIImage(new RectTransform(new Vector2(1.0f, 1.0f / playStyleBannerAspectRatio), previewContainer.RectTransform, Anchor.TopCenter, scaleBasis: ScaleBasis.BothWidth),
                                                             playStyleBannerSprite, null, true);

            var playStyleName = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.0f), playStyleBanner.RectTransform)
            {
                RelativeOffset = new Vector2(0.01f, 0.06f)
            },
                                                 TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"), TextManager.Get("servertag." + playStyle)), textColor: Color.White,
                                                 font: GUI.SmallFont, textAlignment: Alignment.Center,
                                                 color: GameMain.ServerListScreen.PlayStyleColors[(int)playStyle], style: "GUISlopedHeader");

            playStyleName.RectTransform.NonScaledSize = (playStyleName.Font.MeasureString(playStyleName.Text) + new Vector2(20, 5) * GUI.Scale).ToPoint();
            playStyleName.RectTransform.IsFixedSize   = true;


            var columnContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.45f), previewContainer.RectTransform), isHorizontal: true)
            {
                Stretch = true
            };

            // Left column -------------------------------------------------------------------------------
            var leftColumnHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 1.0f), columnContainer.RectTransform), childAnchor: Anchor.Center)
            {
                Stretch = true
            };

            var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 1.0f), leftColumnHolder.RectTransform))
            {
                Stretch = true
            };

            float elementHeight = 0.075f;

            // Spacing
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.025f), leftColumn.RectTransform), style: null);

            var serverMsg = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), leftColumn.RectTransform))
            {
                ScrollBarVisible = true
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverMsg.Content.RectTransform), ServerMessage, font: GUI.SmallFont, wrap: true)
            {
                CanBeFocused = false
            };

            var gameMode = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), leftColumn.RectTransform), TextManager.Get("GameMode"));

            new GUITextBlock(new RectTransform(Vector2.One, gameMode.RectTransform),
                             TextManager.Get(string.IsNullOrEmpty(GameMode) ? "Unknown" : "GameMode." + GameMode, returnNull: true) ?? GameMode,
                             textAlignment: Alignment.Right);

            /*var traitors = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), bodyContainer.RectTransform), TextManager.Get("Traitors"));
             * new GUITextBlock(new RectTransform(Vector2.One, traitors.RectTransform), TextManager.Get(!TraitorsEnabled.HasValue ? "Unknown" : TraitorsEnabled.Value.ToString()), textAlignment: Alignment.Right);*/

            var subSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), leftColumn.RectTransform), TextManager.Get("ServerListSubSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, subSelection.RectTransform), TextManager.Get(!SubSelectionMode.HasValue ? "Unknown" : SubSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            var modeSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), leftColumn.RectTransform), TextManager.Get("ServerListModeSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, modeSelection.RectTransform), TextManager.Get(!ModeSelectionMode.HasValue ? "Unknown" : ModeSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            var allowSpectating = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), leftColumn.RectTransform), TextManager.Get("ServerListAllowSpectating"))
            {
                CanBeFocused = false
            };

            if (!AllowSpectating.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowSpectating.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowSpectating.Selected = AllowSpectating.Value;
            }

            var allowRespawn = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), leftColumn.RectTransform), TextManager.Get("ServerSettingsAllowRespawning"))
            {
                CanBeFocused = false
            };

            if (!AllowRespawn.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowRespawn.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowRespawn.Selected = AllowRespawn.Value;
            }

            /*var voipEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), bodyContainer.RectTransform), TextManager.Get("serversettingsvoicechatenabled"))
             * {
             *  CanBeFocused = false
             * };
             * if (!VoipEnabled.HasValue)
             *  new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), voipEnabledTickBox.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
             * else
             *  voipEnabledTickBox.Selected = VoipEnabled.Value;*/

            var usingWhiteList = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), leftColumn.RectTransform), TextManager.Get("ServerListUsingWhitelist"))
            {
                CanBeFocused = false
            };

            if (!UsingWhiteList.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), usingWhiteList.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                usingWhiteList.Selected = UsingWhiteList.Value;
            }


            leftColumn.RectTransform.SizeChanged += () =>
            {
                GUITextBlock.AutoScaleAndNormalize(allowSpectating.TextBlock, allowRespawn.TextBlock, usingWhiteList.TextBlock);
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), leftColumn.RectTransform),
                             TextManager.Get("ServerListContentPackages"));

            var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), leftColumn.RectTransform))
            {
                ScrollBarVisible = true
            };

            if (ContentPackageNames.Count == 0)
            {
                new GUITextBlock(new RectTransform(Vector2.One, contentPackageList.Content.RectTransform), TextManager.Get("Unknown"), textAlignment: Alignment.Center)
                {
                    CanBeFocused = false
                };
            }
            else
            {
                List <string> availableWorkshopUrls = new List <string>();
                for (int i = 0; i < ContentPackageNames.Count; i++)
                {
                    var packageText = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform)
                    {
                        MinSize = new Point(0, 15)
                    },
                                                     ContentPackageNames[i])
                    {
                        Enabled = false
                    };
                    if (i < ContentPackageHashes.Count)
                    {
                        if (GameMain.Config.SelectedContentPackages.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.Selected = true;
                            continue;
                        }

                        //matching content package found, but it hasn't been enabled
                        if (ContentPackage.List.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.TextColor = Color.Orange;
                            packageText.ToolTip   = TextManager.GetWithVariable("ServerListContentPackageNotEnabled", "[contentpackage]", ContentPackageNames[i]);
                        }
                        //workshop download link found
                        else if (i < ContentPackageWorkshopUrls.Count && !string.IsNullOrEmpty(ContentPackageWorkshopUrls[i]))
                        {
                            availableWorkshopUrls.Add(ContentPackageWorkshopUrls[i]);
                            packageText.TextColor = Color.Yellow;
                            packageText.ToolTip   = TextManager.GetWithVariable("ServerListIncompatibleContentPackageWorkshopAvailable", "[contentpackage]", ContentPackageNames[i]);
                        }
                        else //no package or workshop download link found, tough luck
                        {
                            packageText.TextColor = Color.Red;
                            packageText.ToolTip   = TextManager.GetWithVariables("ServerListIncompatibleContentPackage",
                                                                                 new string[2] {
                                "[contentpackage]", "[hash]"
                            }, new string[2] {
                                ContentPackageNames[i], ContentPackageHashes[i]
                            });
                        }
                    }
                }
                if (availableWorkshopUrls.Count > 0)
                {
                    var workshopBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), leftColumn.RectTransform), TextManager.Get("ServerListSubscribeMissingPackages"))
                    {
                        ToolTip   = TextManager.Get(SteamManager.IsInitialized ? "ServerListSubscribeMissingPackagesTooltip" : "ServerListSubscribeMissingPackagesTooltipNoSteam"),
                        Enabled   = SteamManager.IsInitialized,
                        OnClicked = (btn, userdata) =>
                        {
                            GameMain.SteamWorkshopScreen.SubscribeToPackages(availableWorkshopUrls);
                            GameMain.SteamWorkshopScreen.Select();
                            return(true);
                        }
                    };
                    workshopBtn.TextBlock.AutoScale = true;
                }
            }

            // Spacing
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform), style: null);

            // Right column ------------------------------------------------------------------------------

            var rightColumnBackground = new GUIFrame(new RectTransform(new Vector2(0.2f, 1.0f), columnContainer.RectTransform), style: null)
            {
                Color = Color.Black * 0.25f
            };

            var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 1.0f), rightColumnBackground.RectTransform, Anchor.Center));

            // playstyle tags -----------------------------------------------------------------------------

            var playStyleTags = GetPlayStyleTags();

            foreach (string tag in playStyleTags)
            {
                if (!GameMain.ServerListScreen.PlayStyleIcons.ContainsKey(tag))
                {
                    continue;
                }

                new GUIImage(new RectTransform(Vector2.One, rightColumn.RectTransform, scaleBasis: ScaleBasis.BothWidth),
                             GameMain.ServerListScreen.PlayStyleIcons[tag], scaleToFit: true)
                {
                    ToolTip = TextManager.Get("servertagdescription." + tag),
                    Color   = GameMain.ServerListScreen.PlayStyleIconColors[tag]
                };
            }


            /*var playerCount = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListPlayers"));
             * new GUITextBlock(new RectTransform(Vector2.One, playerCount.RectTransform), PlayerCount + "/" + MaxPlayers, textAlignment: Alignment.Right);
             *
             *
             * new GUITickBox(new RectTransform(new Vector2(1, elementHeight), columnRight.RectTransform), "Round running")
             * {
             *  Selected = GameStarted,
             *  CanBeFocused = false
             * };*/


            // -----------------------------------------------------------------------------

            foreach (GUIComponent c in leftColumn.Children)
            {
                if (c is GUITextBlock textBlock)
                {
                    textBlock.Padding = Vector4.Zero;
                }
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// get <see cref="EnumMemberAttribute"/> of <see cref="PlayStyle"/>
 /// </summary>
 /// <param name="PlayStyle"></param>
 /// <returns></returns>
 public static string ToMemberName(this PlayStyle PlayStyle)
 => PlayStyle.GetAttribute <EnumMemberAttribute>(ThrowNotFoundFiled: false)?.Value ?? "Unkown";
Exemplo n.º 23
0
 public Eventer GetEvents(PlayStyle style)
 {
     if (Events.ContainsKey(style))
         return Events[style];
     return Events[PlayStyle.Null];
 }
Exemplo n.º 24
0
 public PlayerHelper()
 {
     PlayList      = new List <string>();
     PlayListIndex = -1;
     PlayStyle     = PlayStyle.list;
 }
Exemplo n.º 25
0
 public void ChangeEvent(PlayStyle style)
 {
     if (Events.ContainsKey(Mode))
     {
         Events[Mode].Final();
     }
     Mode = style;
     if (Events.ContainsKey(style))
     {
         Events[Mode].Init();
         Start();
     }
 }
Exemplo n.º 26
0
 public Settings(PlayStyle playStyle, float volume, float pan)
 {
     this.playStyle = playStyle;
     this.volume    = volume;
     this.pan       = pan;
 }
Exemplo n.º 27
0
 public StepMetadata GetSteps(PlayStyle style, SongDifficulty difficulty)
 {
     return(StepCharts.FirstOrDefault(c => c.PlayStyle == style && c.Difficulty == difficulty));
 }