Skip to content

Instantly share code, notes, and snippets.

View mutoo's full-sized avatar

Lingjia Liu mutoo

View GitHub Profile
@mutoo
mutoo / CycleBuffer.cs
Last active March 6, 2017 11:10
NetworkMgr
public class CycleBuffer
{
public static byte GetByte(byte[] buffer, int index) {
int size = buffer.Length;
return buffer[(index % size + size) % size];
}
}
@mutoo
mutoo / FixAssemblys
Created November 13, 2015 08:04 — forked from horsman/FixAssemblys
FixUnityAssemblys
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.Text.RegularExpressions;
using System.IO;
using System.Text;
public class ReimportUnityEngineUI
{
[MenuItem( "Assets/Reimport UI Assemblies", false, 100 )]
@mutoo
mutoo / CircleText.cs
Last active December 4, 2024 13:14
the code is based on Unity3d 4.6.x, the api may changed.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class CircleText : BaseVertexEffect
{
public int radius = 50;
public float spaceCoff = 1f;
function class(super)
local cls
if super == nil then
-- table with a dumb ctor
cls = { ctor = function() end }
else
cls = setmetatable({}, super)
cls.super = super
end
function isa(instance, Class)
local metatable = getmetatable(instance)
while metatable ~= nil do
if metatable == Class then
return true
else
metatable = getmetatable(metatable)
end
end
-- would not handle userdata, function, thread
function clone(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
var ExpTable = function () {
this.table = [];
};
ExpTable.prototype.addRow = function (row) {
this.table.push(row);
};
ExpTable.prototype.getConfigFromExp = function(total_exp) {
var row;
@mutoo
mutoo / The-Red-Heart.markdown
Created April 22, 2015 09:22
The Red Heart
@mutoo
mutoo / guid.js
Created April 18, 2015 02:54
simple guid generator
/**
* @return {string}
*/
S4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
/**
* @return {string}
@mutoo
mutoo / alias.js
Last active August 29, 2015 14:19
convenience of use of cocos2d-js
uiReader = ccs.uiReader.widgetFromJsonFile.bind(ccs.uiReader);
getWidget = ccui.helper.seekWidgetByName.bind(ccui.helper);
on = cc.eventManager.addCustomListener.bind(cc.eventManager);
off = cc.eventManager.removeCustomListeners.bind(cc.eventManager);
send = cc.eventManager.dispatchCustomEvent.bind(cc.eventManager);