Day 18 and 19: Making a Risk Game in Unity

Jonathan Witcoski
3 min readJan 19, 2019

--

New day, new time hanging out on furlough/unemployment. Time to start fresh and new.

Lets see how far I can get in making a Risk Game.

Googled “Create a risk game”

Following a tutorial on youtube on creating a risk game.

In Inkscape, drew 2 layers, 1 for countries, and 1 the continent. Spent a solid 10 minutes downloading Inkscape.

Here are my 2 layers in inkscape
Here are the layers ready for export. The base is colored green,

Next I am going to export the lovely drawing to PNG files and then import them into a new Unity project. Im not getting superfancy since these will eventually be swapped out with mapbox sdk tiles.

Import the png file as a New asset
Change the sprite settings then click “Sprite Editor”
Hit “Slice”
So many pretty squares
Throw them into Unity
Create 2 folders and one CountryHandler Script

This is the code I added:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(PolygonCollider2D))]
public class CountryHandler : MonoBehaviour
{
private SpriteRenderer sprite;


public Color32 oldColor;
public Color32 hoverColor;
public Color32 startColor;

void Awake()
{
sprite = GetComponent<SpriteRenderer>();
sprite.color = startColor;
}
void OnMouseEnter()
{
oldColor = sprite.color;
sprite.color = hoverColor;
}

void OnMouseExit()
{
sprite.color = oldColor;
}

}

Day 19

Note. I started a new Unity Project this time saving it as a 2d game. I also created a new png files this time with the countries colored instead of hollow inside.

what results is the tile i put the collider on disappears :(

[RequireComponent(typeof(PolygonCollider2D))]
public class CountryHandler : MonoBehaviour

This part of the code is fine

Once i got to this part of the code it makes the country disappear

sprite.color = startColor;

It seems on closer inspection whenever sprite.color =xxx it makes it dissapear .

--

--