How to use the @rematch/core.dispatch.score function in @rematch/core

To help you get started, we’ve selected a few @rematch/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EvanBacon / Expo-Nitro-Roll / Game / Game.js View on Github external
onTouchesBegan = async ({ pageX: x, pageY: y }) => {
    if (this.gameEnded) {
      this.gameEnded = false;

      dispatch.score.reset();
      dispatch.game.play();
    } else if (Math.round(randomRange(0, 3)) === 0) {
      // this.takeScreenshot();
    }
    this.moveSquare();
  };
github EvanBacon / Expo-Pillar-Valley / client / src / rematch / models.js View on Github external
const cloudHighScore = data.score || 0;
          console.log('cloud score', cloudHighScore);
          if (Settings.isEveryScoreBest || highScore > cloudHighScore) {
            transaction.update(docRef, {
              score: highScore,
              timestamp: Date.now(),
              displayName: _displayName,
              photoURL: photoURL || '',
            });
          } else {
            transaction.update(docRef, {
              ...data,
              displayName: _displayName,
              photoURL: photoURL || '',
            });
            dispatch.score.setBest(cloudHighScore);
          }
        }));
        console.log('Successfully wrote score');
github EvanBacon / Expo-Pillar-Valley / client / src / Game / Game.js View on Github external
if (this.taps % 3 === 0) {
      this.animateBackgroundColor(this.taps);
    }
    if (!this.loaded) {
      return;
    }

    const distanceFromTarget = distance(
      this.balls[this.mainBall].position,
      this.targets[1].position,
    );

    if (distanceFromTarget < Settings.epsilon) {
      const perfection = 1 - distanceFromTarget / Settings.epsilon;
      dispatch.game.play();
      dispatch.score.increment();
      this.score += 1;
      this.runHapticsWithValue(perfection);
      
      if (this.particles) {
        this.particles.impulse();
      }

      this.balls[this.mainBall].x = this.targets[1].x;
      this.balls[this.mainBall].z = this.targets[1].z;

      this.generateDirection();

      const target = this.targets.shift();
      if (this.currentTarget) this.currentTarget.updateDirection(this.direction);

      target.animateOut();
github EvanBacon / Expo-Pillar-Valley / client / src / rematch / models.js View on Github external
reset: (props, { score }) => {
      if (Settings.isFirebaseEnabled) {
        if (Settings.isEveryScoreBest) {
          dispatch.score.setHighScore(score.current);
        } else if (score.isBest) {
          dispatch.score.setHighScore(score.best);
        }
      }
      dispatch.score._reset();
    },
    setHighScore: async (highScore, { user: { displayName, photoURL } }) => {
github EvanBacon / Expo-Nitro-Roll / Game / Game.js View on Github external
scorePoint = () => {
    AudioManager.sharedInstance.playAsync(
      'pop_0' + Math.round(randomRange(0, 1)),
    );
    dispatch.score.increment();
  };
github EvanBacon / Expo-Pillar-Valley / client / src / Game / Game.js View on Github external
gameOver = (animate = true) => {
    this.takeScreenshot();
    this.screenShotTaken = false;
    dispatch.score.reset();
    this.score = 0;
    dispatch.game.menu();

    this.cachedRotationVelocity = 0;

    if (animate) {
      this.balls[this.mainBall].hide({ onComplete: () => this.reset() });
      this.balls[1 - this.mainBall].hide({ duration: 0.4 });

      for (const target of this.targets) {
        target.animateOut();
      }
    } else {
      this.reset();
    }
  };