Skip to content

Instantly share code, notes, and snippets.

View dyguests's full-sized avatar
:octocat:
٩(˃̶͈̀௰˂̶͈́)و

fanhl dyguests

:octocat:
٩(˃̶͈̀௰˂̶͈́)و
  • ChengDu.China
View GitHub Profile
@dyguests
dyguests / BinaryIndexedTree.kt
Created November 18, 2021 07:53
BinaryIndexedTree, 数状数组
class BinaryIndexedTree(private var nums: IntArray) {
var size: Int = nums.size
private val _bit = IntArray(size + 1)
init {
for (i in 0 until size) init(i, nums[i])
}
private fun init(index: Int, value: Int) {
var i = index + 1
@dyguests
dyguests / GroundHelper.cs
Last active February 9, 2022 14:15
GroundHelper, PhysicsObject, grounded checker.
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Utils
{
public class GroundHelper
{
private const float minMoveDistance = 0.001f;
private const float shellRadius = 0.01f;
@dyguests
dyguests / SceneStacker.cs
Last active October 7, 2022 02:38
Scene Manager
using System.Collections.Generic;
using UnityEngine.SceneManagement;
namespace Tools
{
public static class SceneStacker
{
private static readonly Stack<string> SceneStack = new();
private static bool sIsInitialization;
@dyguests
dyguests / Touchable.cs
Created July 31, 2021 15:33
Unity Button without Image.
// https://stackoverflow.com/questions/36888780/how-to-make-an-invisible-transparent-button-work
// file Touchable.cs
// Correctly backfills the missing Touchable concept in Unity.UI's OO chain.
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(Touchable))]
public class Touchable_Editor : Editor
@dyguests
dyguests / AnimationCurveEx.cs
Created June 6, 2021 02:50
AnimationCurve PlayEvaluate
using System;
using System.Collections;
using UnityEngine;
namespace Util
{
public static class AnimationCurveEx
{
public static IEnumerator PlayEvaluate(this AnimationCurve curve, float time, Action<float> action, params Tuple<float, Action>[] animationEvents)
{
@dyguests
dyguests / FillScreen.cs
Created March 28, 2021 09:39
fill screen.
using UnityEngine;
namespace Game
{
public class FillScreen : MonoBehaviour
{
public SpriteRenderer sr;
private void Awake()
{
@dyguests
dyguests / InputCtlr.cs
Created March 6, 2021 13:47
Mouse To World
using Common;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Game
{
public class InputCtlr : MonoBehaviour
{
private InputActions inputActions;
@dyguests
dyguests / Kotlin DSL Tree.kt
Last active December 13, 2022 06:23
Kotlin DSL Tree
fun main() {
val root = NodeBuilder {
"Ali"{
"Bob"{
"Candy"()
"Dave"()
}
"Egg"{
"Fold"()
}
@dyguests
dyguests / Inputer2DHelper.cs
Created March 5, 2020 14:54
Unity Inputer2DHelper
using System;
using UnityEngine;
namespace Lina.Scripts
{
public struct Inputer2DHelper
{
private Vector2 move;
private bool fire1;
@dyguests
dyguests / PhysicsObject.cs
Created January 30, 2020 13:36
Unity PhysicsObject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PhysicsObject : MonoBehaviour {
public float minGroundNormalY = .65f;
public float gravityModifier = 1f;
protected Vector2 targetVelocity;