Coder Social home page Coder Social logo

hats_sample_game's Introduction

Details: Beamable Sample Project

This sample project demonstrates specific Beamable features and services.

Project Configuration

Beamable HATS

HATS is a turn based game multiplayer built on Beamable technology. Up to 4 players can battle on a hexagonial grid, compete on the leaderboard, earn rewards, and customize their characters. HATS demonstrates the following Beamable features.

This project is meant to be a sample for your own multiplayer turn based game. You should fork this project and do whatever you like with it. You could change out the assets, modify the game rules, flip the game upside-down, or use the source code as inspiration for a brand new game. Its completely up to you.

At the moment, there are some simple rules...

  • 4 players start the match
  • You get 10 seconds to commit a move
  • You can move in any open direction. If you step in lava, you'll die. If you step on ice, you'll slide across it.
  • You can cast a fireball in any open direction
  • You can throw an arrow in any open direction
  • You can cast a shield around yourself for a turn. Shields reflect fireball attacks back to their caster.
  • If you get hit with a fireball or an arrow, you'll die.
  • Eventually, tiles under players start to turn to lava! Keep on the move!
  • Last player left alive gets the most points.

Hats Screenshots

Getting Started

Follow these steps to build the game and run it locally.

  • Open the root folder as a Unity Project. Unity 2020.3.11 (LTS) is recommended.
  • Create a new Beamable Customer account. HATS already has the Beamable package installed, but no customer account has been set up. Use the Beamable Docs to learn how to create a new account.
  • You may need to rebuild the Addressable Asset Groups.

    To build content in the Editor, open the Addressables Groups window, then select Build > New Build > Default Build Script

  • Run the Matchmaking scene.

Making it your own

You can use HATS however you'd like to create your own game. Here are some ideas to get you going...

  • Change out the game assets to create a scifi or fantasy theme.
  • Add more characters, hats, or tile types
  • Add in-game pickups that give your player powerups and new attacks
  • Make the game 3D!

If you want to learn how various social features are implemented in HATS, check out the sections below.

Multiplayer

HATS uses a deterministic simulation networking model. All network messages get sent to a GameSimulation class. The code runs on every player's machine, and produces the same game outputs. The simulation code creates a set of Game Events. That sequence of events can be consumed with MonoBehaviours or other classes to create rich onscreen visuals and sounds. A design diagram for HATS

A player's input move is sent to a central Beamable Game Relay server, where it is then rebroadcast to all connected players. If you submit a move, you can expect to see your own move show up as a network message. Those network messages are sent to the GameSimulation, and converted into a sequence of GameEvents. Check out the PlayerMoveBuilder if you want to change how network messages are created for each player.

The GameEvents are handled by GameEventHandlers, which are subclasses of MonoBehaviours. You can create your own subclass of a GameEventHandler, and implement the methods you care about. Check out the PlayerController for an example. Each event that you want to repond to runs inside of a Unity Coroutine. You can play animations, sounds, or add pauses into the game. The Game Simulation won't continue until you invoke the completeCallback argument on each event method.

If you want to change how the GameSimulation works in general, you can create new GameEvents, or change how the logic works. Anytime the PlayGame() method yield returns a GameEvent, the GameProcessor has a chance to broadcast it to any listening GameEventHandlers.

Leaderboards

The LeaderboardScreenController class is where you should look to see Beamable's leaderboard SDK. Scores on the leaderboard set via the Multiplayer Game Relay server. The Beamable server awards scores to players based on their scores. Scores are calculated in the GameSimulation.CalcualteScore() method

Checkout the Beamable Leaderboard Docs to learn more.

Inventory

In HATS, players can spend earned gems to buy new characters and hats. In this game, the characters and hats don't have any effect on the gameplay. Characters and Hats are subtypes of Beamable's ItemContent. You can take a look at the CharacterContent and HatContent classes. The Content is managed through the Beamable Content Manager.

In the game, there is one scene that shows what characters and hats a player has in their inventory, and what items are still available for purchase. Check out the Character Panel Controller class for details.

Development Requirements

If you clone this repository, you may want to get Git LFS installed before you make any commits. It isn't required.

hats_sample_game's People

Contributors

cdhanna avatar verticallongboard avatar jeff0rosenberg avatar srivellobeamable avatar wisniewski915 avatar nightrise avatar hashbangjonathan avatar mhijazib avatar

Stargazers

a avatar

Watchers

Marco Williams avatar James Cloos avatar  avatar Justin LeFebvre avatar  avatar Drazen Patekar avatar Łukasz Kundys avatar  avatar MevLyshkin avatar Artur Mankowski avatar Mohammed Agboola avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.