Skip to content

Instantly share code, notes, and snippets.

View DevEarley's full-sized avatar
🎯
Focusing

Alex Earley DevEarley

🎯
Focusing
View GitHub Profile
@DevEarley
DevEarley / ScreenResolutionUtility.cs
Last active March 25, 2024 10:52
Static Screen Resolution Utility for Unity 3D with Common Resolutions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum CommonScreenResolutions
{
gameConsole_16bit_pocket_10x9, //160 × 144 160∶144 10:9 1∶1
gameConsole_16bit_low_4x3, //256 × 224 256∶224 4∶3 7∶6
gameConsole_16bit_super_4x3, //400 × 300 4∶3 4∶3 1∶1
gameConsole_32bit_low_4x3, //256 × 224 256∶224 4∶3 7∶6
@DevEarley
DevEarley / CharacterMotionAndAnimation.cs
Last active March 3, 2024 08:30
Character Motion And Animation script for Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterMotionAndAnimation : MonoBehaviour
{
public Animator animator;
public GameObject camera;
public CharacterController controller;
public Vector3 playerVelocity;
@DevEarley
DevEarley / RNGController.cs
Created December 2, 2023 17:47
C# RNG implementation for Unity3D
public class RNGController : MonoBehaviour
{
private int index = 0;
private int lastLargestIndex = 0;
private int max_index = 1000;
private List <int> values = new List<int>();
public int Next(int RNG_ID)
{
var offsetIndex = RNG_ID + index;
@DevEarley
DevEarley / unity3d-basic-classes.md
Last active July 3, 2023 15:45
Unity3D basic classes

Behaviours

  • Attached to a GO. Many GOs may have this script.
  • A MonoBehaviour.
  • Can be used multiple times in a scene.
  • Can implement interfaces.
  • Great for enemy behaviour, trigger & door logic, reacting to OnTrigger events.

Controllers

  • Attached to a GO like a Behaviour
  • Single instance of this may exist in a scene at once.
@DevEarley
DevEarley / InputController.cs
Created April 28, 2023 19:01
Unity Input Controller & Service
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public enum InputControllerState
{
NO_INPUT_DEVICE_CONNECTED,
NO_CONTROLLER_CONNECTED,
NO_KEYBOARD_CONNECTED,
BOTH_KEYBOARD_AND_CONTROLLER_CONNECTED
@DevEarley
DevEarley / dotnet-core-angular-quickstart.md
Last active March 26, 2023 23:40
.NET Core WebAPI and Angular Quick Start Guide

.NET Core WebAPI and Angular Quick Start Guide

Why Angular and .NET Core?

Angular is a well established frontend framework. With Angular, you can quickly bind input fields to logic that calls the .NET Core WebAPI backend. WebAPI is simple to set up and can host our angular app without MVC.

Installation

  • Download VS Code
  • Download .NET Core CLI for your OS.
  • Download Node.JS
@DevEarley
DevEarley / angular-js-best-practices.md
Last active January 28, 2023 02:08
AngularJS (1.X) Best Practices and Naming Conventions

Angular Naming Convention

TYPE CONVENTION EXAMPLE
App Module UpperCamel MyApp
Controller UpperCamel SomeController
Service UpperCamel SomeDataService
Factory UpperCamel SomeFactory
Directive lowerCamel someDirective
Filter lowerCamel someFilter
@DevEarley
DevEarley / A-Delegate-pattern-in-Uniy3D.md
Last active October 10, 2022 20:46
Delegate pattern in Uniy3D

Delegate pattern in Uniy3D

  • A delegate is something that acts on another thing's behalf.

  • So if Thing A needed something, Thing B to Thing Z could deliver that to Thing A. This makes Things B to Z all delegates to Thing A. Thing A invokes a delegate function. Thing A doesn't care who runs the errand. Thing A doesn't care how it happens. As long as it happens.

Delegate Invoker

@DevEarley
DevEarley / A-service-locator-in-unity.md
Last active October 10, 2022 20:13
Service Locator pattern in Unity3D

Service Locator pattern in Unity3D

Using the Service Locator pattern in Unity allows you connect various services together to a single source. When a script needs access to something on the Service Locator, it just needs to access the Service Locators's Instance. This instance will have any service the invoker may need.

To setup, the service must be referenced in the script and the script must find these services on Awake. You can look them up by the GameObject they are attached to or attach them to the Service Locator's GO. In this example, I use GetComponentInChildren<T>(). Alternatively you can search for the GameObject by name and then get the component, PlayerController = GameObject.Find("PlayerController").GetComponent<PlayerController>();

  • Contains references to all Controllers and all Services.
  • Attached to a GO.
  • Must reference all controllers and services automatically.
@DevEarley
DevEarley / fe-testing.md
Last active April 1, 2022 15:24
Notes on front end testing

Notes on Frontend Testing

Use Data Attributes Rather Than CSS Selectors.

... choose selectors less prone to change. My favorite type of selector is the data attribute. A developer is less likely to change data attributes while refactoring, making them perfect for locating elements in tests. I recommend naming them in a meaningful way to clearly convey their purpose to any developers working on the source code.

* Frontend Testing Pitfalls

Don't Use AAA, Use BDD!

AAA refers to Arrange, Act, Assert. This is a tried and true pattern for unit testing things like APIS. But does that work for something like integration testing with the DOM? Consider another approach, behavioral-driven development (BDD).