Skip to content

Instantly share code, notes, and snippets.

View xdegtyarev's full-sized avatar
🧊

Alexander Degtyarev xdegtyarev

🧊
View GitHub Profile
@xdegtyarev
xdegtyarev / robotAI
Created August 5, 2014 12:40
FSM Example 1
enum State {
CHARGING,
SEARCH_HUMANS,
KILL_ALL_HUMANS
}
State myState = State.CHARGING;
float charge = 0f;
void Update() {
@xdegtyarev
xdegtyarev / State
Created August 5, 2014 13:47
FSM example: State
public class State {
public virtual void Enter( Robot entity );
public virtual void Execute( Robot entity );
public virtual void Exit( Robot entity );
}
@xdegtyarev
xdegtyarev / fsm
Created August 5, 2014 13:47
FSM example: FSM
public class FSM {
public Robot entity;
public State currentState;
public FSM( Robot entity ) {
this.entity = entity;
}
public void Update() {
@xdegtyarev
xdegtyarev / robot
Created August 5, 2014 13:49
FSM example: robot states
public class Charging : State {
public override void Execute( Robot entity ) {
if ( entity.charge == 100f ) {
entity.fsm.ChangeState( SearchHumans.Instance );
} else {
entity.DoCharge();
}
}
@xdegtyarev
xdegtyarev / launch
Created August 5, 2014 13:49
FSM example: launching fsm
public class Robot {
public FSM fsm;
void Start() {
fsm = new FSM( this );
}
void Update() {
fsm.Update();
Shader "xdegtyarev/InvertedFog"
{
Properties
{
_FogTexture ("Alpha8", 2D) = "white" {}
_FogIntencity("Intencity", Float) = 0.5
}
SubShader
{
Shader "xdegtyarev/Alpha8MaxBlended"
{
Properties
{
_MainTex ("Alpha8", 2D) = "white" {}
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
@xdegtyarev
xdegtyarev / sublimeRunner
Created September 27, 2012 14:08
Unity Sublime Runner
//
// main.cpp
// SublimeRunner
//
// Created by Alexander Degtyarev on 9/27/12.
// Copyright (c) 2012 Alexander Degtyarev. All rights reserved.
//
#include <iostream>
#include <sstream>
@xdegtyarev
xdegtyarev / CompleteSharp.sublime-settings
Created November 10, 2012 19:44
CompleteSharp Unity3d config
{
// You probably want to configure this to something of your own.
// ${home}, ${env:<variable>}, ${project_path:} and ${folder:} tokens can be used in the completesharp_assemblies option.
//
// ${home} is replaced with the value of the HOME environment variable.
//
// ${env:<variable>} is replaced with the "variable" environment variable.
//
// ${project_path:} tries to find a file with the given name in all the registered project folders and
// returns the first file found, or the original file name if none is found.
@xdegtyarev
xdegtyarev / Get currency ios code from currency symbol
Created December 4, 2012 11:24
Get Currency Code From Currency Symbol
public string GetCurrencyCodeFromSymbol(string symbol)
{
Debug.Log("Retrieving symbol" + symbol);
RegionInfo regionalInfo;
foreach(CultureInfo o in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
regionalInfo = new RegionInfo(o.LCID);
Debug.Log("Regional Symbol" + regionalInfo.CurrencySymbol);
if(regionalInfo.CurrencySymbol == symbol)
{