This file contains 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 class Account | |
{ | |
Guid Id {get;set;} | |
string Name {get;set;} | |
} |
This file contains 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
/* | |
This is a Path calculator which uses an A* approach | |
*/ | |
public class AStarPathCalculator : IPathCalculator | |
{ | |
IEnumerable<Vector3> FindPathTo(Vector3 startPosition, Vector3 endPosition) | |
{ | |
var path = ABPath.Construct(startPosition, endPosition); | |
return path.vectorList; | |
} |
This file contains 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
/* | |
This is just a hacky approach to get things moving, as passport-socketio library | |
does not support cookie-sessions. | |
*/ | |
var Promise = require("bluebird"); | |
var passport = require("passport"); | |
var session = require("cookie-session"); | |
var sessionConfig = { |
This file contains 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
/* | |
This is worst case scenario | |
- You are unable to control the dependency or swap it for another without changing the NotUsingIoC source code. | |
- You are also going to have difficulties testing this as you cannot easily mock _someDependency. | |
*/ | |
public class NotUsingIoC | |
{ | |
private ISomeDependency _someDependency; | |
This file contains 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
// Imagine this is a starting page where the user creates their account | |
function CreateUserViewModel() | |
{ | |
// could be done via IoC to improve testability and reuseability | |
var someAjaxService = {}; // Imagine it does something | |
this.user = new User(); | |
var saveDataToServer = function() { | |
var data = ko.toJS(this.user); | |
someAjaxService.Post("/users", data); |
This file contains 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
/* Ok lets start by expressing the intent for a vehicle to move */ | |
public interface IVehicleMovement | |
{ | |
public float Speed {get; set;} | |
public void Move(Vector2 direction); | |
} | |
/* This will implement the most common form of movement */ | |
public class SimpleWheelMovement : IVehicleMovement | |
{ |
This file contains 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 NodeCanvas; | |
using NodeCanvas.Variables; | |
using UnityEngine; | |
/* | |
Let us assume you have a uFrame Entity which can attack | |
and when it does it needs to play an animation in the view layer | |
and also needs to tell the controller to trigger an attack |
This file contains 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 class Character | |
{ | |
public EntityStates CurrentState { get; } | |
public void Update() | |
{ | |
switch(CurrentState) | |
{ | |
case EntityStates.Idle | |
{ |
This file contains 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 class Objective | |
{ | |
public ObjectiveType Type {get;set;} | |
public int ObjectiveInt {get;set;} | |
public float ObjectiveFloat {get;set;} | |
public Vector3 ObjectiveVector {get;set;} | |
// could possibly use Dictionary instead | |
} |
This file contains 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 class SceneExtensions | |
{ | |
public static TView InstantiatePrefabView<TView>(this IScene scene, ViewModel viewModel, string prefabName, string instanceName = null, Transform parent = null) | |
where TView : ViewBase, new() | |
{ | |
var prefab = Resources.Load(prefabName) as GameObject; | |
if (prefab == null) | |
{ throw new Exception(string.Format("Cannot locate prefab [{0}]", prefabName)); } | |
var createViewCommand = new InstantiateViewCommand | |
{ |
OlderNewer