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…
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.
The title image gives the gist of how a linked list operates…
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…
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:
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:
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.
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:
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…