Skip to content

Instantly share code, notes, and snippets.

View TheMehranKhan's full-sized avatar

Mehran TheMehranKhan

View GitHub Profile
@TheMehranKhan
TheMehranKhan / UIManager.cs
Created October 27, 2023 20:51
This code block provides a UI manager functionality in Unity. It manages UI elements and triggers events on button clicks.
/*
Author: themehrankhan
License: MIT License
Description:
This code block provides a UI manager functionality in Unity. It manages UI elements and triggers events on button clicks.
Usage:
1. Create an empty game object in Unity and attach this script to it.
2. Set the UI elements and button click events in the inspector.
@TheMehranKhan
TheMehranKhan / PowerUp.cs
Created October 27, 2023 20:51
This code block provides a power-up system functionality in Unity. It allows the player to collect power-ups and apply their effects.
/*
Author: themehrankhan
License: MIT License
Description:
This code block provides a power-up system functionality in Unity. It allows the player to collect power-ups and apply their effects.
Usage:
1. Attach this script to the power-up object in Unity.
2. Set the power-up effect and duration in the inspector.
@TheMehranKhan
TheMehranKhan / EnemyAI.cs
Created October 27, 2023 20:51
This code block provides a basic enemy AI functionality in Unity. It allows the enemy to follow and attack the player.
/*
Author: themehrankhan
License: MIT License
Description:
This code block provides a basic enemy AI functionality in Unity. It allows the enemy to follow and attack the player.
Usage:
1. Attach this script to the enemy object in Unity.
2. Set the player object in the inspector.
@TheMehranKhan
TheMehranKhan / PlayerMovement.cs
Created October 27, 2023 20:51
This code block provides a basic player movement functionality in Unity. It allows the player to move forward, backward, left, and right using the arrow keys or WASD keys.
/*
Author: themehrankhan
License: MIT License
Description:
This code block provides a basic player movement functionality in Unity. It allows the player to move forward, backward, left, and right using the arrow keys or WASD keys.
Usage:
1. Attach this script to the player object in Unity.
2. Ensure the player object has a Rigidbody component attached.
@TheMehranKhan
TheMehranKhan / CameraFollow.cs
Created October 27, 2023 20:50
This code block provides a camera follow functionality in Unity. It allows the camera to smoothly follow the player object.
/*
Author: themehrankhan
License: MIT License
Description:
This code block provides a camera follow functionality in Unity. It allows the camera to smoothly follow the player object.
Usage:
1. Attach this script to the camera object in Unity.
2. Set the target object (player object) in the inspector.
@TheMehranKhan
TheMehranKhan / ScoreManager.cs
Created October 27, 2023 20:47
Keeps track of the player's score and updates a score text UI element.
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Keeps track of the player's score and updates a score text UI element.
///
/// This script can be used to centralize the game's score logic, making it easier to maintain and update.
///
/// To use the score manager, simply attach this script to a game object in your scene
/// and assign the score text UI element to the `scoreText` public property.
@TheMehranKhan
TheMehranKhan / CollectibleItem.cs
Created October 27, 2023 20:38
A collectible item that gives points to the player's score when the player collides with it.
// Author: themehrankhan
using UnityEngine;
/// <summary>
/// A collectible item that gives points to the player's score when the player collides with it.
/// </summary>
public class CollectibleItem : MonoBehaviour
{
/// <summary>
@TheMehranKhan
TheMehranKhan / GameOverManager.cs
Created October 27, 2023 20:37
A game over manager that is responsible for showing the game over UI and handling game restart.
// Author: themehrankhan
using UnityEngine;
using UnityEngine.SceneManagement;
/// <summary>
/// A game over manager that is responsible for showing the game over UI and handling game restart.
///
/// This manager can be used to centralize the game's game over logic, making it easier to maintain and update.
///
@TheMehranKhan
TheMehranKhan / LocationBasedGame.cs
Created October 27, 2023 20:36
A location-based game that uses Mapbox to check if the player is within a target radius.
using UnityEngine;
using Mapbox.Unity.Map;
using Mapbox.Unity.Location;
/// <summary>
/// A location-based game that uses Mapbox to check if the player is within a target radius.
/// </summary>
public class LocationBasedGame : MonoBehaviour
{
/// <summary>
@TheMehranKhan
TheMehranKhan / HealthBar.cs
Created October 27, 2023 20:34
A health bar that is represented by a slider UI element.
// Author: themehrankhan
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// A health bar that is represented by a slider UI element.
/// It can be used to display the player's current health in the game.
///
/// To use the health bar, simply attach this script to a game object in your scene