Inserting Values Mid-Chain and Finding Specific Values

Last time we covered establishing the foundations for a doubly linked list class: namely, the ability to create nodes of data with references to previous or successive nodes to form a series. Right now we can add to either end of the chain with our AddFirst(T t) and AddLast(T t) methods. Today we’ll look at inserting data into the middle of the chain based on some reference point.

A quick reminder of two things. First: I’m using Unity to develop and test this system. If you’re following along in a different development environment, you may need to adjust how errors…


A fun exercise for practice juggling variable references

I have written about the usefulness of Linked Lists in the past. Today, I want to get into the mechanics of how a linked list works by creating my own implementation of linked list functionality.

NOTE: Linked Lists are already implemented in C#. This exercise will duplicate that functionality, but it is not at all necessary for you to implement your own version of this for your work. I did this as an exercise in understanding how some features might work, for educational purposes not for practical purposes.

What is a Linked List?

The title image gives the gist of how a linked list operates…


Using Class Inheritance to Pull The Wool Over Unity’s Eyes

I recently watched a brilliant presentation on Game Architecture with Scriptable Objects from Ryan Hipple, where he demonstrated a useful pattern he calls the Runtime Set. It’s a useful way to keep track of all of the active objects of a given type in the scene. If you’ve ever needed to keep track of how many enemies remain in a wave, or which buildings have been built in a player’s warcamp, this is a great way to have that information tracked and available to any class or method that wants it without hard dependencies or extra code.

The tricky part…


Creating reliable, reusable tests to aid rapid development

Recently I completed a challenge to rotate the elements of a matrix clockwise or counter-clockwise by 45 degrees. In other words, I needed to be able to make this:


From Brute Force to Formal Elegance

Here’s the situation: you’ve been hammering away at a complicated coding problem for a day or so and you’ve iterated your way into a working system. Mission complete, right?


Leveraging Linked Lists for Lightweight Loops

Welcome to part 2. The objective before us: take all the information we collected in the previous four articles (the initiative list, the turn list, the action lists) and use that data to move the proper pieces on the map in the proper sequence.

The bulk of the process happens here, in the ProcessRoundRoutine coroutine:


A Brute Force Solution to a Complicated System

Here’s the objective for today: create a system for recording and replaying multiple commands from multiple actors, where all actors first declare their moves in ascending initiative order, and afterward all moves are played in descending initiative order.

There is a more elegant solution than the one I’m presenting here. This is the initial brute force implementation to get the mechanics working. We’ll be shaping this all up into something more polished in the next article.

We’re gonna take this one in two parts. Today’s article will focus on actors declaring their actions. Tomorrow I’ll cover executing the action queue.

Actors Declare Actions


Handling Tactical Initiative Data Using Linked Lists

Today, the objective is to sort a C# Dictionary by the value property of each key/value pair, and then load that information into a LinkedList. This list will allow us to easily control who may act and keep the UI updated in the process.

We’ll begin by declaring a LinkedList<KeyValuePair<Actor, int>> to match the data from the dictionary. Then in the RoundStart() method we made in the previous article we’ll remove the debug loop and replace it with another loop that is specifically targeting the key/value pairs in the dictionary:


Creating An Event Driven System for Ordering Actors in Turn-Based Tactical Play with Unity 3D and C#

Here’s the objective: using Unity 3D and C# we want to build a system that can alert any number of actors to roll a random number, and report back their name and initiative number to be stored in a dictionary as key/value pairs.

For the first part of this, we’ll be using the Func<TResult> Delegate. This is a kind of delegate that can accept any function that returns the type designated by TResult. In this case, we want a delegate method that will return an integer value — the actor’s initiative roll.

The delegate declaration looks like this:


Today we visit the scene of an emergent urban tragedy: a tremor has collapsed some pedestrian walkways, leaving a bystander trapped beneath the rubble! Luckily, we have a pair of heroes on the scene, ready to save the day.

Thus the stage is set for today’s demonstration.

From a gameplay perspective, we need to be able to interact with objects on the scene that can be moved, but we also need those objects to prevent NavMesh agents from walking through them.

These two goals are in conflict. If we bake these objects into the NavMesh in the editor, then moving…

Michael Davis

Unity Developer / Game Developer / Artist / Problem Solver

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store