UNO Scratch-Off Lottery Ticket Game

Technologies Used: Unity, C#, Custom Shaders, Texture2D Manipulation, Weighted Random Algorithms, Input Handling, Coroutine Management, WebGL, Service Locator Design Pattern

Description:
This interactive simulator replicates the experience of a scratch-off lottery ticket using Unity, C#, and custom shaders. It allows users to "scratch" off a dynamic surface, revealing hidden prizes based on a weighted random system. The scratch-off effect is powered by real-time texture manipulation, where users control the scratch area with intuitive input actions. The system dynamically updates the mask as the user interacts with the game, creating a visually engaging and responsive experience. The weighted random system ensures that smaller prizes are more frequent, mirroring real-world lottery dynamics. Available on WebGL, the game runs directly in a web browser without the need for any installations.

Key Features:

  • Custom Scratch-Off Effect:
    Implements a dynamic texture manipulation system using Unity’s Texture2D class and custom shaders. As users "scratch" the surface, a mask is gradually removed to reveal the prize underneath. The effect simulates the tactile feel of real-world scratch-off tickets.

  • Weighted Random Reward System:
    The game features a weighted random algorithm that favors lower rewards. By applying an exponential function to the distribution, the system makes smaller prizes more frequent, while still leaving the possibility of a high-value win. This adds an element of surprise and excitement akin to real lottery tickets.

  • Interactive Input Handling:
    The scratch-off area is fully interactive, with user input detected using Unity’s InputSystem. The left mouse button (or touch input on mobile) is used to reveal areas of the scratch-off surface. This provides users with an intuitive and engaging experience.

  • Service Locator Design Pattern:
    The project uses the Service Locator design pattern to manage and access core game services, such as the prize calculation system, input handling, and UI updates. This pattern improves the flexibility and maintainability of the code, allowing different game components to easily interact with essential services without direct dependencies, facilitating a more modular and scalable architecture.

  • Modular and Extensible Code:
    The codebase is designed to be modular, with components that can easily be extended for future updates. The UI is responsive, and the game structure supports the addition of animations, sound effects, or even multiplayer features if desired.

  • Dynamic Texture Updates:
    Utilizes real-time texture updates to create a seamless scratching experience. As the user interacts with the ticket, the texture is updated dynamically, providing an immersive, responsive effect. This approach demonstrates advanced understanding of Unity's rendering and Texture2D class.

  • Optimized Performance:
    The system efficiently handles real-time texture changes and interactions, ensuring smooth performance even as the scratch area grows larger. The use of coroutines allows for efficient input handling without blocking the main game loop.

  • User Feedback and Reward Display:
    The user is notified of their rewards through a dynamic UI system that updates in real time. The prize amount is presented with formatting (e.g., $1,000 or $5k) to enhance the user experience.

  • WebGL Deployment:
    The game is fully playable in the browser via WebGL, enabling cross-platform accessibility. It runs seamlessly without requiring any installations or additional plugins, making it easy for users to access and enjoy the game from anywhere with an internet connection.

Why It’s Special:
This project is a unique fusion of creative game design and advanced technical implementation, incorporating custom shader effects, real-time texture manipulation, and a probabilistic reward system. By developing the scratch-off effect and integrating a weighted random system, I've deepened my understanding of Unity's rendering system, texture management, and input handling. Additionally, this project showcases my ability to blend artistic design with technical execution, creating an interactive, fun experience while demonstrating skills in programming, graphics, and game mechanics. The integration of the Service Locator design pattern also demonstrates my proficiency in creating maintainable and scalable game architectures. This project not only highlights my expertise in Unity but also showcases my ability to implement complex systems and turn creative concepts into working prototypes. With its WebGL deployment, the game is accessible directly from the browser, showcasing my ability to create cross-platform games.

Inspiration: