Skip to content

Instantly share code, notes, and snippets.

LP grofit

  • UK
Block or report user

Report or block grofit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@grofit
grofit / validate-property-attribute.js
Created Aug 4, 2016
CommonJS test for validation group failure
View validate-property-attribute.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ValidateProperty = undefined;
var _dec, _dec2, _class;
var _aureliaFramework = require("aurelia-framework");
@grofit
grofit / app.html
Created Apr 8, 2016 — forked from jdanyow/app.html
Aurelia Gist
View app.html
<template>
<h1>${message}</h1>
</template>
@grofit
grofit / NoCompositionOrSeparationItem.cs
Last active Nov 21, 2016
Example of view separation with composition
View NoCompositionOrSeparationItem.cs
public class NoCompositionOrSeparationItem
{
public Sprite ItemImage;
public Vector3 InventoryPosition;
public Image ItemOverlay;
public string Name {get;set;}
public ItemType Type {get;set;}
public int Value {get;set;}
}
@grofit
grofit / SceneExtensions.cs
Created Oct 1, 2015
uFrame MVVM View Instantiation Helpers
View SceneExtensions.cs
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
{
@grofit
grofit / Objective.cs
Last active Jun 25, 2018
Quick RPG Quest System Example
View Objective.cs
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
}
@grofit
grofit / ExistingApproach.cs
Created Jun 12, 2015
A hybrid Strategy/Chain Of Responsibility style approach
View ExistingApproach.cs
public class Character
{
public EntityStates CurrentState { get; }
public void Update()
{
switch(CurrentState)
{
case EntityStates.Idle
{
@grofit
grofit / AttackAction.cs
Last active Apr 22, 2016
Example of interacting with uFrame from NodeCanvas
View AttackAction.cs
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
@grofit
grofit / CompositionExample.cs
Created May 31, 2015
An example of inheritance woes
View CompositionExample.cs
/* 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
{
@grofit
grofit / create-user-view-model.js
Created Apr 16, 2015
Some MVVM class based approach thing
View create-user-view-model.js
// 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);
@grofit
grofit / NotUsingIoC.cs
Last active Nov 21, 2016
What is Inversion of Control
View NotUsingIoC.cs
/*
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;
You can’t perform that action at this time.