This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Taken from StackOverflow: | |
| https://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon */ | |
| public bool IsPointInPolygon( Point p, Point[] polygon ) | |
| { | |
| double minX = polygon[ 0 ].X; | |
| double maxX = polygon[ 0 ].X; | |
| double minY = polygon[ 0 ].Y; | |
| double maxY = polygon[ 0 ].Y; | |
| for ( int i = 1 ; i < polygon.Length ; i++ ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From 'BeauWorlds' on Unity Answers: | |
| // https://answers.unity.com/questions/685656/rotate-an-image-by-modifying-texture2dgetpixels32.html | |
| using System; | |
| public class ImageRotator { | |
| public static Texture2D RotateImage(Texture2D originTexture, int angle){ | |
| Texture2D result; | |
| result = new Texture2D(originTexture.width, originTexture.height); | |
| Color32[] pix1 = result.GetPixels32(); | |
| Color32[] pix2 = originTexture.GetPixels32(); | |
| int W = originTexture.width; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //From: https://schier.co/blog/2014/12/08/wait-for-user-to-stop-typing-using-javascript.html | |
| // Get the input box | |
| var textInput = document.getElementById('test-input'); | |
| // Init a timeout variable to be used below | |
| var timeout = null; | |
| // Listen for keystroke events | |
| textInput.onkeyup = function (e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var coords = Enumerable.Range(0, width) | |
| .SelectMany(x => Enumerable.Range(0, height) | |
| .Select(y => new Vector2(x, y))) | |
| .OrderBy(x => random.Next()); | |
| foreach (var c in coords) | |
| { | |
| var i = (int)c.x; | |
| var j = (int)c.y; | |
| //blah blah blah |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Adapted from Programming in Lua (first edition) | |
| -- by Roberto Ierusalimschy | |
| -- Lua.org, December 2003 | |
| -- ISBN 8590379817 | |
| Queue={} | |
| function Queue:new() | |
| local o = {first=0, last=-1, size=0} | |
| o.keys={} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| namespace CommonTimeGames | |
| { | |
| public class CollisionWatcher : MonoBehaviour | |
| { | |
| public delegate void CollisionEventHandler(Collision collision); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEngine.UI; | |
| namespace CommonTimeGames.NekoMaze.UI | |
| { | |
| public class CameraFader : MonoBehaviour | |
| { | |
| public Color FadeOutColor = Color.black; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM microsoft/aspnetcore-build:2.0 AS build-env | |
| WORKDIR /app | |
| # Copy csproj and restore as distinct layers | |
| COPY *.csproj ./ | |
| RUN dotnet restore | |
| # Copy everything else and build | |
| COPY . ./ | |
| RUN dotnet publish -c Release -o out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class CharacterCamera : MonoBehaviour { | |
| public GameObject Character; | |
| //0, 1, -4 | |
| //15 0 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static T Random<T>(this IEnumerable<T> enumerable, Func<T, int> weightFunc) | |
| { | |
| int totalWeight = 0; // this stores sum of weights of all elements before current | |
| T selected = default(T); // currently selected element | |
| foreach (var data in enumerable) | |
| { | |
| int weight = weightFunc(data); // weight of current element | |
| int r = Random.Next(totalWeight + weight); // random value | |
| if (r >= totalWeight) // probability of this is weight/(totalWeight+weight) | |
| selected = data; // it is the probability of discarding last selected element and selecting current one instead |
NewerOlder