Day 18 and 19: Making a Risk Game in Unity
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.
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.
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 .