grassynull33 / project2-game

Companion web app for VR game (made with Unity) that features real-time updates based on what happens in-game
https://equilibrium-game.herokuapp.com/
MIT License
4 stars 5 forks source link
express handlebars mvc mysql node-js project sequelize unity-3d

equili-logo-black-bg

Equilibrium is a first person virtual reality adventure game with real-time database connection and a companion web app. Our Firebase connection is integrated with a MySQL database and Sequelize, an object relational mapper for MySQL. The functionality of the web app works closely with encrypted C# data.

Getting Started

How to Play the Game:

Prerequisities for Game:

For Windows/Mac OS X/Linux (Minimum Requirements)

VR (Minimum Requirements)

Prerequisities for Web App:

Dependencies

Screenshots

Low Polycount Version (Game):

Low_Poly_FPS_View Morning Low_Poly_FPS_View Night Low_Poly_Overview

HD Version (Game):

HD_FPS_View Morning HD_FPS_View Night HD_Overview

Map of Game Environment (Web App):

screenshot 2017-05-23 13 25 23

Achievements (Web App):

screenshot 2017-05-23 13 12 29

Technologies Used

Core Game:

Databases:

Web App:

Code Walkthroughs

Model-View-Controller:

Separating our code into modules made our code much more readable and easy to work with. Although there is some initial investment in planning, the payoff of isolating chunks of code was significant as we can identify errors and, often times, re-use code almost effortlessly.

router.get('/',
  itemController.checkItemsList,
  minigameController.checkMinigame,
  wikiController.checkWiki,
  achievementController.checkAchievements,
  storeItemController.checkStoreItems
);

Game Real-Time Firebase Updates:

For the preliminary building stage of our game, we wanted to make sure we could get information from the game to Firebase in real-time or close to it. Getting Firebase SDK to update with organized data objects took a lot of tinkering, and eventually we scrapped .Push() method for Firebase, which was our initial method to get information from the game. Thanks to the Transaction class and list used to create objects in unique nodes, we were able to organize big chunks of relevent data that auto-sorts based on the time the data was created (when an interaction happens in game with a GameObject).

    TransactionResult InventoryUpdate(MutableData mutableData) {
        List<object> inventory = mutableData.Value as List<object>;
        Dictionary<string, object> inventorySetup = new Dictionary<string, object>();
        inventory.Add(inventorySetup);
        mutableData.Value = inventory;
    return TransactionResult.Success(mutableData);
  }

    public void PickupItemEvent(GameObject item, int slotID, bool wasStacked, string desc, string name, bool hasDurability, bool isCraftable, bool isBlueprint, int itemID) //This event will be triggered when you pick up an item.
    {
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("Inventory");

        reference.RunTransaction(mutableData => {
            List<object> inventory = mutableData.Value as List<object>;

            if (inventory == null)
            {
                inventory = new List<object>();
            }

            Dictionary<string, object> itemData =
                             new Dictionary<string, object>();
            itemData["Item ID"] = itemID;
            itemData["ItemName"] = name;
            itemData["Description"] = desc;
            itemData["SlotID"] = slotID;
            itemData["GreaterThanOne"] = wasStacked;
            itemData["HasDurability"] = hasDurability;
            itemData["IsCraftable"] = isCraftable;
            itemData["IsBlueprint"] = isBlueprint;
            inventory.Add(itemData);
            mutableData.Value = inventory;
            return TransactionResult.Success(mutableData);
        });

Game VR-Controls:

Using only Unity Engine and System Collections dependencies, used the input keys of a mouse(0) keycode, that has been overhauled into the inventory management system in scripts to emulate the 'tap' functionality on VR's headset controls on the side for the particular peripheral we used (Samsung Gear VR), while also having it track the angle of the device to control the movement within the open-world game. Can also be controlled via WASD, or the arrow keys in their respective platforms.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Update() {
        if (Input.GetMouseButton(0))
    }
}
...
    void Update () {
        if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f) {
            // Move forward
            moveForward = true;
        }
        else {
            // Stop moving
            moveForward = false;
        }

Team BNYY (Contributors)

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments