Skip to content

Instantly share code, notes, and snippets.


Gabriel Maldonado iamgabrielma

View GitHub Profile
iamgabrielma / CalculateEntityClosestFOV.cs
Created Jun 23, 2019
Calculates the closest FOV of an entity list
View CalculateEntityClosestFOV.cs
void CalculateEntityClosestFOV(List<Entity> _listOfEntities) {
// We iterate through each item of the Entity list that was passed as an argument
foreach (var enemy in _listOfEntities)
// If entity != null, proceed
if (enemy != null)
// Get its position and set some constants that will create the quadrant around the entity:
Vector3 _entityLocation = new Vector3(enemy.entityLocation.x, enemy.entityLocation.y, 0);
iamgabrielma / h_msMethodAnalysis.cs
Created Jun 19, 2019
Helper function to calculate how many milliseconds takes a method from start to finish
View h_msMethodAnalysis.cs
using System.Diagnostics; // enables System.Diagnostics.StopWatch
using System; // enables System.TimeSPan
Stopwatch stopwatch = new Stopwatch();
// Your function here
TimeSpan ts = stopwatch.Elapsed;
iamgabrielma / functions.php
Created Jun 17, 2019
Disables WPCOM masterbar
View functions.php
function disable_wpcomtoolbar ( $modules ) {
if ( isset( $modules['masterbar'] ) ) {
unset( $modules['masterbar'] );
return $modules;
add_filter( 'jetpack_get_available_modules', 'disable_wpcomtoolbar' );
iamgabrielma / RoguelikeCameraController.cs
Created Jun 16, 2019
Attaches the main camera to the player so it moves with the player.
View RoguelikeCameraController.cs
/* The main problem we try to solve here is that the Main Camera is a game object that is already in place before the Player Entity is generated, so it cannot be assigned as the Player instance is null */
using UnityEngine;
public class CameraController : MonoBehaviour
public Transform target; // The Player Transform
private bool isPlayerFound;
void Start()
iamgabrielma / _debug_helper_functions.cs
Created Jun 12, 2019
Debug function example: When enabled, 100% chance to create a certain item each time x is triggered
View _debug_helper_functions.cs
private bool _debug_create_specific_item = true;
// DEBUG: When enabled, 100% chance to create a certain item each time x is triggered
if (_debug_create_specific_item)
Debug.Log("###############------+ DEBUG MODE +-----###############");
pickupItemObject = new GameObject("itemName");
itemTag = "itemTag";
SetupPickupItem(pickupItemObject, itemTag, itemSprite);
View PlayerReceivesDamage.cs
## in PlayerCollisions.cs , attached to the player game object:
public bool isPlayerTakingDamage;
public void Start(){
isPlayerTakingDamage = false;
iamgabrielma / FloatingTextController.cs
Created May 30, 2019
Creates floating text on events
View FloatingTextController.cs
/* FloatingTextController.cs*/
public class FloatingTextController : MonoBehaviour
private static FloatingText popupText;
private static GameObject canvas;
public static void Initialize()
iamgabrielma / MapColorPulse.cs
Created May 29, 2019
Modifies the alpha value of a GameObject following a pulse rhythm, creating the effect of appear/disappear gradually.
View MapColorPulse.cs
IEnumerator MapColorPulse()
bool isLimitReached = false;
map = GameObject.Find("Map");
SpriteRenderer mapRendererComponent = map.GetComponent<SpriteRenderer>();
initialMapAlphaValue = mapRendererComponent.color.a; // 1
//Debug.Log("Initial alpha: " + initialMapAlphaValue); // 1
// Test: Using Find() + new Color for setting up the alpha value:
iamgabrielma / AdManager.cs
Created May 26, 2019
Ad Manager that deals with Unity Ads between gameplays
View AdManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
namespace Ngu
public class AdManager : MonoBehaviour
View functions.php
/* Atomic V1 & V2 */
if( ( defined( 'PRESSABLE_PROXY' ) && PRESSABLE_PROXY ) || ( defined( 'ATOMIC_PROXY' ) && ATOMIC_PROXY ) ) {
// Your code here