From 4f911ce32ded943cf9b7d903dc759f1cd33cb337 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Mon, 20 Jul 2020 18:26:27 +0200 Subject: [PATCH] Improved game start screen --- locales/en.json | 3 + locales/fr.json | 5 +- src/screens/Game/screens/GameStartScreen.js | 119 ++++++++++++++++++-- 3 files changed, 119 insertions(+), 8 deletions(-) diff --git a/locales/en.json b/locales/en.json index 83ecee6..aada7d0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -363,6 +363,9 @@ }, "game": { "title": "Game", + "welcomeTitle": "Welcome !", + "welcomeMessage": "Stuck on the toilet? The teacher is late?\nThis game is for you!\n\nTry to get the best score and beat your friends.", + "play": "Play!", "score": "Score : %{score}", "time": "Time :", "level": "Level :", diff --git a/locales/fr.json b/locales/fr.json index bdf848c..a744a7d 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -361,7 +361,10 @@ "homeButtonSubtitle": "Contacte le développeur de l'appli" }, "game": { - "title": "Le Jeu trop ouf", + "title": "Jeu trop ouf", + "welcomeTitle": "Bienvenue !", + "welcomeMessage": "Coincé sur les WC ? Le prof est pas là ?\nCe jeu est fait pour toi !\n\nEssaie d'avoir le meilleur score et de battre tes amis.", + "play": "Jouer !", "score": "Score : %{score}", "time": "Temps :", "level": "Niveau :", diff --git a/src/screens/Game/screens/GameStartScreen.js b/src/screens/Game/screens/GameStartScreen.js index 4d6e45e..f48c822 100644 --- a/src/screens/Game/screens/GameStartScreen.js +++ b/src/screens/Game/screens/GameStartScreen.js @@ -3,12 +3,17 @@ import * as React from "react"; import {StackNavigationProp} from "@react-navigation/stack"; import type {CustomTheme} from "../../../managers/ThemeManager"; -import {Button, Headline, withTheme} from "react-native-paper"; +import {Button, Card, Divider, Headline, Paragraph, withTheme} from "react-native-paper"; import {View} from "react-native"; import i18n from "i18n-js"; import Mascot, {MASCOT_STYLE} from "../../../components/Mascot/Mascot"; import MascotPopup from "../../../components/Mascot/MascotPopup"; import AsyncStorageManager from "../../../managers/AsyncStorageManager"; +import type {Grid} from "../components/GridComponent"; +import GridComponent from "../components/GridComponent"; +import GridManager from "../logic/GridManager"; +import Piece from "../logic/Piece"; +import * as Animatable from "react-native-animatable"; type Props = { navigation: StackNavigationProp, @@ -21,10 +26,17 @@ type State = { class GameStartScreen extends React.Component { + gridManager: GridManager; + state = { mascotDialogVisible: AsyncStorageManager.getInstance().preferences.gameStartShowBanner.current === "1", } + constructor(props: Props) { + super(props); + this.gridManager = new GridManager(4, 4, props.theme); + } + hideMascotDialog = () => { AsyncStorageManager.getInstance().savePref( AsyncStorageManager.getInstance().preferences.gameStartShowBanner.key, @@ -33,20 +45,113 @@ class GameStartScreen extends React.Component { this.setState({mascotDialogVisible: false}) }; - render() { + getPiecesBackground() { + let gridList = []; + for (let i = 0; i < 18; i++) { + gridList.push(this.gridManager.getEmptyGrid(4, 4)); + const piece = new Piece(this.props.theme); + piece.toGrid(gridList[i], true); + } return ( - - + {gridList.map((item: Grid, index: number) => { + const size = 10 + Math.floor(Math.random() * 30); + const top = Math.floor(Math.random() * 100); + const rot = Math.floor(Math.random() * 360); + const left = (index % 6) * 20; + const animDelay = size * 20; + const animDuration = 2 * (2000 - (size * 30)); + return ( + + + + + + + ); + })} + + + ); + } + + getWelcomeText() { + return ( + + - Coucou + + + + {i18n.t("screens.game.welcomeTitle")} + + + + {i18n.t("screens.game.welcomeMessage")} + + + + + + ); + } + + render() { + return ( + + {this.getPiecesBackground()} + {this.getWelcomeText()}