private void Initialize() { BackgroundColor = Color.White; Size = new Size(NUIApplication.GetDefaultWindow().WindowSize); Position = new Position(NUIApplication.GetDefaultWindow().WindowSize.Width, 0); Layout = new AbsoluteLayout() { SetPositionByLayout = false }; showAnimation = new Animation(300); showAnimation.AnimateTo(this, "PositionX", 0, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine)); showAnimation.Finished += (object source, EventArgs args) => { OnShowFinished.Invoke(this, new EventArgs()); }; hideAnimation = new Animation(300); hideAnimation.AnimateTo(this, "PositionX", Size.Width, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine)); hideAnimation.Finished += (object source, EventArgs args) => { OnHideFinished.Invoke(this, new EventArgs()); }; }
/// <summary> /// A Unity Animation event hook /// Is called when the hide animation is finished. /// Instantiates a new match and converts player setting UI values /// into new Side instances and re-assigns the ruleset from the /// dialog to the match. /// Finally, <see cref="OnNewMatch"/> is invoked /// </summary> public void HideFinished() { OnHideFinished?.Invoke(); GameObject matchInstance = Object.Instantiate <GameObject>(matchPrefab); Match m = matchInstance.GetComponent <Match>(); foreach (PlayerSettings playerSetting in playerSettings) { Side s = new Side(); s.color = playerSetting.SelectedColor(); s.role = playerSetting.SelectedRole(); s.iconName = playerSetting.SelectedIcon(); s.pieceResource = playerSetting.SelectedPieceResource(); s.name = playerSetting.SelectedName(); s.aiStrategy = playerSetting.SelectedAIRoleStrategy(); m.RegisterSide(s); } r.SetMatch(m); m.ruleset = r; OnNewMatch?.Invoke(m); }