Skip to content

Commit

Permalink
The new adaptive design is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
pacatum committed Oct 3, 2017
1 parent 336fb49 commit 6b46dc4
Show file tree
Hide file tree
Showing 70 changed files with 550 additions and 375 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Prefabs/UI/Copy_Paste_view.prefab
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions Assets/Prefabs/UI/Create_new_tournament_button.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Prefabs/UI/RPS_Game/Opponent_step.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/RPS_Game/Round_item_view.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/RPS_Game/Round_over_item_view.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/RPS_Game/Step.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/Tournament_history_item_view.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/choose_hand_button.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/UI/scedule_tournament_item_view.prefab
Binary file not shown.
Binary file modified Assets/Scenes/Main.unity
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/Scripts/ChangeScreenResolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ChangeScreenResolution : MonoBehaviour {
[SerializeField] float maxScreenSettingsLeft;

void OnRectTransformDimensionsChange() {
if ( Screen.height <= 800 || Screen.width <= 1100 ) {
if ( Screen.height <= 800 || Screen.width <= 1000 ) {
SetMinScreenView();
} else {
SetMaxScreenView();
Expand Down
90 changes: 50 additions & 40 deletions Assets/Scripts/Management/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Base.Data;
using Base.Data.Accounts;
using Base.Data.Tournaments;
using Promises;
using Tools;
using Gesture = Base.Config.ChainTypes.RockPaperScissorsGesture;

Expand Down Expand Up @@ -88,46 +89,55 @@ void AuthorizationManager_OnAuthorizationChanged( AuthorizationManager.Authoriza
Repository.OnObjectUpdate += Repository_OnObjectUpdate;
}

public void UpdateMetches( TournamentObject info ) {
SetCurrentTournament( info.Id );

TournamentManager.Instance.GetDetailsTournamentObject( info.TournamentDetails.Id ).Then( detail => {
ApiManager.Instance.Database.GetMatches( Array.ConvertAll( detail.Matches, match => match.Id ) ).Then( matches => {
var myMatch = Array.Find( matches, match => match.State.Equals( ChainTypes.MatchState.InProgress ) && match.Players.Contains( me.Id ) );
ApiManager.Instance.Database.GetGames( Array.ConvertAll( myMatch.Games, game => game.Id ) ).Then( games => {
var existTournament = IsTournamentExist( myMatch.Tournament );
var existMatch = existTournament && myTournaments[ myMatch.Tournament ].StartedMatches.Contains( myMatch.Id );
if ( !existTournament ) {
myTournaments[ myMatch.Tournament ] = new TournamentContainer( match => OnNewMatch.Invoke( match ), match => OnMatchComplete.Invoke( match ) );
}
myTournaments[ myMatch.Tournament ].UpdateTournamentInfo( info, detail );
var opponent = Array.Find( myMatch.Players, account => !me.Id.Equals( account ) );
Repository.GetInPromise( opponent, () => ApiManager.Instance.Database.GetAccount( opponent.Id ) ).Then( account => {
if ( !existMatch ) {
myTournaments[ myMatch.Tournament ].NewMatch( myMatch, me, account,
( match, game ) => OnNewGame.Invoke( match, game ),
( match, game ) => OnGameComplete.Invoke( match, game ),
( match, game ) => OnGameExpectedMove.Invoke( match, game ) );
}
var completedGames = myTournaments[ myMatch.Tournament ].CurrentMatch.CompletedGames;
foreach ( var game in games ) {
if ( !completedGames.ContainsKey( game.Id ) ) {
if ( game.State.Equals( ChainTypes.GameState.Complete ) ) {
( completedGames[game.Id] = new GameContainer( completedGames.Count + 1, game, me, account ) )
.CheckState();
} else {
myTournaments[myMatch.Tournament].CurrentMatch.NewGame( game ).CheckState();
}
}
}
} );
} );
} );
} );
}

void Repository_OnObjectUpdate( IdObject idObject ) {
public Promise UpdateMetches( TournamentObject info ) {
return new Promise( ( action, exeption ) => {
SetCurrentTournament( info.Id );
TournamentManager.Instance.GetDetailsTournamentObject( info.TournamentDetails.Id )
.Then( detail => {
ApiManager.Instance.Database.GetMatches( Array.ConvertAll( detail.Matches, match => match.Id ) )
.Then( matches => {
var myMatch = Array.Find( matches, match => match.State.Equals( ChainTypes.MatchState.InProgress ) && match.Players.Contains( me.Id ) );
ApiManager.Instance.Database.GetGames( Array.ConvertAll( myMatch.Games, game => game.Id ) )
.Then( games => {
var existTournament = IsTournamentExist( myMatch.Tournament );
var existMatch = existTournament && myTournaments[myMatch.Tournament].StartedMatches.Contains( myMatch.Id );
if ( !existTournament ) {
myTournaments[myMatch.Tournament] = new TournamentContainer( match => OnNewMatch.Invoke( match ), match => OnMatchComplete.Invoke( match ) );
}
myTournaments[myMatch.Tournament].UpdateTournamentInfo( info, detail );
var opponent = Array.Find( myMatch.Players, account => !me.Id.Equals( account ) );
Repository.GetInPromise( opponent, () => ApiManager.Instance.Database.GetAccount( opponent.Id ) )
.Then( account => {
if ( !existMatch ) {
myTournaments[myMatch.Tournament]
.NewMatch( myMatch, me, account,
( match, game ) => OnNewGame.Invoke( match, game ),
( match, game ) => OnGameComplete.Invoke( match, game ),
( match, game ) => OnGameExpectedMove.Invoke( match, game ) );
}
var completedGames = myTournaments[myMatch.Tournament].CurrentMatch.CompletedGames;
foreach ( var game in games ) {
if ( !completedGames.ContainsKey( game.Id ) ) {
if ( game.State.Equals( ChainTypes.GameState.Complete ) ) {
( completedGames[game.Id] = new GameContainer( completedGames.Count + 1, game, me, account ) )
.CheckState();
} else {
myTournaments[myMatch.Tournament].CurrentMatch.NewGame( game ).CheckState();
}
}
}
action();
} );
} );
} );
} );
} );

}

void Repository_OnObjectUpdate( IdObject idObject ) {
if ( !idObject.SpaceType.Equals( SpaceType.Match ) ) {
return;
}
Expand Down
17 changes: 17 additions & 0 deletions Assets/Scripts/Management/TournamentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ public IEnumerator GetMatcheObjects(uint[] matchesId, List<MatchObject> result)
result.AddRange(matchList);
}

public IEnumerator GetAccount(SpaceTypeId accountId, List<AccountObject> accountResult) {
List<AccountObject> account = null;
ApiManager.Instance.Database.GetAccount(accountId.Id ).Then( result => {
account = new List<AccountObject>();
account.Add( result );
} ).Catch(exeption => account = new List<AccountObject>() );

while ( account == null ) {
yield return null;
}

if ( account.Count > 0 ) {
accountResult.AddRange(account);
}

}

public IEnumerator GetMatcheWinnerAccountsObjects( uint tournamentId, List<AccountObject> accountWinners ) {
List<AccountObject> loadedAccounts = null;
GetDetailsTournamentObject( tournamentId ).Then( details => {
Expand Down
14 changes: 12 additions & 2 deletions Assets/Scripts/UI/Controllers/UIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class UIController : SingletonMonoBehaviour<UIController> {
[SerializeField] NoticesView noticesView;

private TournamentObject currenTournamentObject;
[Header( "Popups" ), SerializeField] private MessagePopupView messagePopupView;
[Header( "Popups" ), SerializeField] MessagePopupView messagePopupView;
public string bufferString;


Expand Down Expand Up @@ -216,7 +216,8 @@ void ShowTournamentDetailsView() {
}

void ShowGameScreenView() {
SwitchCanvas( gameScreenView );
//SwitchCanvas( gameScreenView );
gameScreenView.Show();
}

public void SwitchCursorState( CursorState state ) {
Expand Down Expand Up @@ -249,4 +250,13 @@ public void HidePopups() {
messagePopupView.HideAll();
}

public void CloseNotGamingPanels() {
foreach ( var canvas in allCanvases ) {
if ( !canvas.Equals( gameScreenView ) ) {
canvas.Hide();
}
}
ScreenLoader_OnLoad( false );
}

}
6 changes: 3 additions & 3 deletions Assets/Scripts/UI/CreateNewSettings/BuyInSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void SelectDropdownValue( int value ) {

ApiManager.Instance.Database
.GetAccountBalance( AuthorizationManager.Instance.UserData.FullAccount.Account.Id.Id, selectAssetObject.Id.Id )
.Then( result => SetAvailableBalanceText( ( result.Amount / Mathf.Pow( 10, selectAssetObject.Precision ) ) + selectAssetObject.Symbol ) );
.Then( result => SetAvailableBalanceText( ( result.Amount / Mathf.Pow( 10, selectAssetObject.Precision ) ) + " " + selectAssetObject.Symbol ) );
}

void SetAvailableBalanceText( string amount ) {
Expand All @@ -74,7 +74,7 @@ void UpdateBalances( AuthorizationManager.AuthorizationData data ) {
TournamentManager.Instance.GetAssetObject()
.Then( asset => {
selectAssetObject = asset;
SetAvailableBalanceText( 0 + selectAssetObject.Symbol );
SetAvailableBalanceText( 0 + " " + selectAssetObject.Symbol );
assetsData.Add( asset );
} );
} else {
Expand All @@ -87,7 +87,7 @@ void UpdateBalances( AuthorizationManager.AuthorizationData data ) {
}
balanceDropdown.AddOptions( options );
selectAssetObject = objects[0];
SetAvailableBalanceText( ( AuthorizationController.Instance.accountBalances[0].Amount / Mathf.Pow( 10, selectAssetObject.Precision ) ) + selectAssetObject.Symbol );
SetAvailableBalanceText( ( AuthorizationController.Instance.accountBalances[0].Amount / Mathf.Pow( 10, selectAssetObject.Precision ) ) +" " + selectAssetObject.Symbol );
} );
}
}
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/UI/CreateNewView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public uint NumberOfPlayers {
public double BuyIn {
get { return buyInSetting.BuyInAmount; }
}


public override void Show() {
base.Show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void Item_OnCancelClick( SceduleTournamentItemView item ) {
}

void Item_OnOperationSuccess() {
StartCoroutine( currentJoinItem.UpdateItem( currentJoinItem.CurrentTournament) );
leaveTournamentConfirmation.OnOperationSuccess -= Item_OnOperationSuccess;
joinTournamentConfirmation.OnOperationSuccess -= Item_OnOperationSuccess;
LoadTournaments();
}


Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/UI/DashboardScreen/DashboardTabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected virtual void AddPage() {

}


#region Sorting

public SortType CurrentSortingType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,4 @@ protected override void AddPage() {
addPage = true;
LoadTournaments();
}

}
16 changes: 5 additions & 11 deletions Assets/Scripts/UI/FilterGames/FilterGamesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ List<TournamentObject> FilterTournaments( List<TournamentObject> tournaments, As


var search = IsTournamentContains( tournaments[i], assets[i], searchFilter, accounts[i]==null? null : accounts[i] );


if ( buyIn && numberOfPlayers && symbol && gameName && search ) {

if ( participate.SelectChoise.Equals( "ONLY ME" ) ) {
if ( IsPlayerJoined( details[i] ) ) {
resultList.Add( tournaments[i] );
Expand All @@ -184,15 +181,13 @@ bool IsTournamentContains( TournamentObject tournament, AssetObject asset,
var jackpot = ( ( tournament.Options.BuyIn.Amount / Math.Pow( 10, asset.Precision ) * tournament.Options.NumberOfPlayers ) + asset.Symbol ).ToLower().Contains( search );
var time = tournament.Options.RegistrationDeadline - DateTime.UtcNow;
var registerDeadline = false;
if (time.TotalMinutes < 60)
{
registerDeadline = ("Register: <" + (int)time.TotalMinutes + "m").Contains(searchText);
}
else if ( time.TotalHours > 0 ) {
if ( time.TotalMinutes < 60 ) {
registerDeadline = ( "Register: <" + (int) time.TotalMinutes + "m" ).Contains( searchText );
} else if ( time.TotalHours > 0 ) {
registerDeadline = ( "Register: ~" + (int) time.TotalHours + "h" ).Contains( searchText );
}
//var startTime = ( "Start: " + Convert.ToDateTime( time.ToString() ).ToString( "hh:mm:ss" ) ).Contains( searchText );
var startDelay = "2 minutes after full".Contains(search);
var startDelay = "2 minutes after full".Contains( search );
var gameName = "rps".Contains( search );
if ( tournament.State.Equals( ChainTypes.TournamentState.Concluded ) ) {
var result = account.Id.Equals( AuthorizationManager.Instance.UserData.FullAccount.Account.Id )
Expand All @@ -204,7 +199,7 @@ bool IsTournamentContains( TournamentObject tournament, AssetObject asset,
var winner = account.Name.ToLower().Contains( search );
return buyIn || gameName || tournamentId || winner || result;
}
return buyIn || jackpot || registerDeadline || gameName || tournamentId || startDelay;
return buyIn || jackpot || registerDeadline || gameName || tournamentId || startDelay;
}


Expand All @@ -216,7 +211,6 @@ bool IsPlayerJoined( TournamentDetailsObject tournamentDetails ) {
}
return false;
}


void FilterRestoreValuesToDefault() {
Restore();
Expand Down
8 changes: 5 additions & 3 deletions Assets/Scripts/UI/FilterGames/SearchView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ void Update() {
startInsertIndex = input.selectionAnchorPosition;
}

if ( Input.GetKeyUp( KeyCode.Return )) {
if ( Input.GetKeyUp( KeyCode.Return ) ) {
Value_OnChange();
}

gameObject.SetActive(false);
if ( Input.GetKeyUp( KeyCode.Escape ) ) {
Hide();
}

}

protected void Copy( InputField target ) {
Expand Down
19 changes: 10 additions & 9 deletions Assets/Scripts/UI/GameInfoView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public override void Awake() {
aboutGameButton.GetComponent<Button>().onClick.AddListener( ScrollToAboutGameText );
creatingTournamentButton.GetComponent<Button>().onClick.AddListener( ScrollToCreatingTournamentText );
howToPlayButton.GetComponent<Button>().onClick.AddListener( ScrollToHowToPlayText );
payoutsButton.GetComponent<Button>().onClick.AddListener( ScrollToTheEnd );
tournamentHistoryButton.GetComponent<Button>().onClick.AddListener( ScrollToTheEnd );
settingButton.GetComponent<Button>().onClick.AddListener( ScrollToTheEnd );
payoutsButton.GetComponent<Button>().onClick.AddListener(delegate {ScrollToTheEnd( payoutsButton );});
tournamentHistoryButton.GetComponent<Button>().onClick.AddListener(delegate { ScrollToTheEnd(tournamentHistoryButton); });
settingButton.GetComponent<Button>().onClick.AddListener( delegate {ScrollToTheEnd(settingButton);} );

scrollView.onValueChanged.AddListener(UpdateScrollPosition);
Clear();
Expand Down Expand Up @@ -82,26 +82,27 @@ void ScrollToHowToPlayText() {
scrollView.content.anchoredPosition = new Vector2(scrollView.content.anchoredPosition.x, thirdScrollYPosition );
}

void ScrollToTheEnd() {
void ScrollToTheEnd(ButtonView button) {
scrollView.content.anchoredPosition = new Vector2(scrollView.content.anchoredPosition.x, fourthScrollYPosition );
SwitchButton( button );
}

void UpdateScrollPosition(Vector2 position) {
void UpdateScrollPosition( Vector2 position ) {
var contentPosition = scrollView.content.anchoredPosition.y;
if (contentPosition >= fisrtScrollYPosition && contentPosition < secondScrollYPosition ) {
if ( contentPosition >= fisrtScrollYPosition && contentPosition < secondScrollYPosition ) {
SwitchButton( aboutGameButton );
}else if (contentPosition >= secondScrollYPosition && contentPosition < thirdScrollYPosition ) {
} else if ( contentPosition >= secondScrollYPosition && contentPosition < thirdScrollYPosition ) {
SwitchButton( creatingTournamentButton );
} else if (contentPosition >= thirdScrollYPosition && contentPosition < fourthScrollYPosition ) {
} else if ( contentPosition >= thirdScrollYPosition && contentPosition < fourthScrollYPosition ) {
SwitchButton( howToPlayButton );
} else {
if(settingButton.Currentstate != ButtonState.Pressed && tournamentHistoryButton.Currentstate!= ButtonState.Pressed)
SwitchButton( payoutsButton );
}
}


void Clear() {

SwitchButton(aboutGameButton);
ScrollToAboutGameText();
}
Expand Down
Loading

0 comments on commit 6b46dc4

Please sign in to comment.