Hello all, this is an update to this project. That post contains a link to both the up to date engineering manifest of this project, as well as context to this post. But if you’re not here for the code talk then… it doesn’t matter I guess! I hope who ever may be reading this is having a great day and all is right in their world. Today I bring with me what will likely be the final build of Imponderabilia. The game has been extremely fun to work on, and really has taught me so much about architecture that I really look forward to applying to future projects.
Final build? But this is Version 0.7? Great observation! I wouldn’t feel comfortable dubbing this build as a completed version as we have not worked much (or at all) on the aesthetic of the game. So, as I’ve said in the previous build postings, I’m not an artist, this build is simply a proof of mechanics and architecture.
What has changed from previous build? Version 0.3 was largely an implementation of independent features which utilized the “InputGrouping” class I wrote and posted here.
- Feedback
- Emphasis on letting player know when an action has been completed
- Indicators of when an interaction is available and how engage
- Features
- Implemented Rice Prep interaction
- Implemented dependency between interactions
- Player must cook rice first, then roll rice with fish, then cut roll.
- Player can hold as many rice or uncut rolls as desired
- Score system
- Simple score system which considers the amount of sushi and quality/completion of required interactions
- Added a timer which will end game after count down.
- Bug Fixes
- Key Sprite Manager (check engineering manifest in link at top of page)
- Added FlipSprite method which fixed the irregularity in key sprite “pressing” animation
- Sushi Roller
- Countdown animation no longer misfiring when checking for input
- Player Animator
- Small bug fixes, added front and back walk animations
- Key Sprite Manager (check engineering manifest in link at top of page)
Here you go! Please enjoy, and direct any feed back you have to aidantakami@gmail.com
For those of you seeking a little more meat, below is my RiceMeter Game Object script. The product of this script can be seen when you approach the diamond colored grill in my build above. It consists of 2 sliders, and is meant to simulate the act of making rice.
By pressing space bar before the game start, the player adds rice to the pot which they will begin to cool once they “Interact”. The interaction begins once the player presses the indicated keys “AWDS” in that order. The player will now have begun the interaction. Players repeat that same motion of AWDS repeatedly to add water and clean the rice. however, once the water is full, the player can no longer add water, nor clean the rice. But players can drain the water by holding down space, which will allow room for more water to be added. But watch out, if you drain too much water, you will lose some rice. The 2 sliders represent the amount of rice, and the amount of water currently in the pot.
By adding rice, the player ends the interaction with more rice and can make more sushi from this rice, however the more rice added, the more tedious it is for the player to balance between adding water and draining it once the pot is full.
This script is only the half of the overall game, the other half is where all specific key strokes are registered, and where the outcome of the game is handled. However, this game object stores and deals with the values pertaining to how much rice and water are present, added, lost/drained, and all the above, making it (hopefully) a more enjoyable script to read. Here’s some code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class RiceMeterGO : MonoBehaviour
{
//Sliders for the rice and water level
public Slider riceLevel;
public Slider waterLevel;
//TMP used to indicate how much rice is in the pot
public TextMeshProUGUI riceText;
//float used to determine how much the rice must be washed
// before the slider image, below, is lerped to green
public float requiredWashes;
//Slider image
public Image waterFill;
//How fast water is added and drained
public float waterAddIncrement;
public float waterDrainIncrement;
//Used to progressively lerp slider image
private float lerpInt = 0;
private float timesWashed = 0;
//Color32 used for lerping slider image
private Color32 unwashedColor;
private Color32 washedColor;
//Enter key used to tell player when finished
public SpriteRenderer enterKey;
public SpriteRenderer enterKeyHighlighted;
//float used to increment the key sprite switcher
private float keySwitchIncrementer;
public void Start()
{
//Set slider max and min
riceLevel.minValue = 0;
riceLevel.maxValue = 10;
waterLevel.minValue = 0;
waterLevel.maxValue = 10;
//Instantiate colors
unwashedColor = new Color32(255, 0, 38, 255);
washedColor = new Color32(0, 255, 47, 150);
//reset
ResetMeter();
}
//Will add rice to the rice level slider.
//Max rice that can be added is 5
//Tis will be start of the game for UI
public void AddRice()
{
//Adds rice if under or equal to 5 cups
if(riceLevel.value <= 5)
{
//Increments
riceLevel.value += 1;
//If this is the first increment
if(waterLevel.value == 0)
{
//set to 0.5 higher
waterLevel.value = 1.5f;
}
else
{
//else just increase
waterLevel.value += 1;
}
}
//Else increment
else
{
riceLevel.value = 1;
waterLevel.value = 1.5f;
Debug.Log("Rice reset");
}
//Sets Rice Text UI to rice level
riceText.text = riceLevel.value.ToString();
}
//Will return the number of rice in meter
public float GetNumberOfRice()
{
return riceLevel.value;
}
//Will add water to the Water slider
public void AddWater()
{
//If water level is okay add water
if (!isWaterFull())
{
waterLevel.value += waterAddIncrement;
lerpInt += waterAddIncrement;
//Change color & value of water
waterFill.color = Color32.Lerp(unwashedColor, washedColor, lerpInt * 0.04f);
//increments times washeds
timesWashed++;
}
else Debug.Log("Full");
}
public void DrainWater()
{
//If water level okey drain water
if (isRiceLevelOkay())
{
waterLevel.value -= waterDrainIncrement;
}
else LoseRice();
}
//Used to check if water level is acceptable
private bool isWaterFull()
{
//If water is higher than rice
if (waterLevel.value == waterLevel.maxValue) return true;
else return false;
}
private bool isRiceLevelOkay()
{
if (waterLevel.value > riceLevel.value) return true;
else return false;
}
//Will return int representing the quality of the rice
/*
* Retrun 0: bad rice, no cookie
* Retrun 1: okay rice... still no cookie for now
* Retrun 2: good rice, cookie
* Return 3: Master rice, cookies
*
*/
public int RiceQualityCheck()
{
if(timesWashed <= 49)
{
return 0;
}
else if(timesWashed <= 64)
{
return 1;
}
else if(timesWashed <= 79)
{
return 2;
}
else if(timesWashed > 80)
{
return 3;
}
else
{
return 0;
}
}
private void Update()
{
//Will indicate to player when they have washed rice enough, triggers right before lerp is finished
if(timesWashed > 80)
{
//Triggers enter key flashing
if (keySwitchIncrementer < 1f)
{
enterKeyHighlighted.gameObject.SetActive(false);
enterKey.gameObject.SetActive(true);
enterKey.transform.position = new Vector2(gameObject.transform.position.x + 0.2f, gameObject.transform.position.y - 0.2f);
}
else if(keySwitchIncrementer < 2f)
{
enterKeyHighlighted.gameObject.SetActive(true);
enterKey.gameObject.SetActive(false);
enterKeyHighlighted.transform.position = new Vector2(gameObject.transform.position.x + 0.2f, gameObject.transform.position.y - 0.2f);
}
else
{
keySwitchIncrementer = 0;
}
keySwitchIncrementer += Time.deltaTime;
}
}
public void LoseRice()
{
if(riceLevel.value >= 2)
{
riceLevel.value--;
//Sets Rice Text UI to rice level
riceText.text = riceLevel.value.ToString();
}
else
{
//Game End
}
}
public void ResetRiceValue()
{
riceLevel.value = 1;
}
public void ResetWaterValue()
{
waterLevel.value = 1.5f;
}
public void ResetMeter()
{
ResetRiceValue();
ResetWaterValue();
lerpInt = 0;
timesWashed = 0;
waterFill.color = unwashedColor;
enterKey.gameObject.SetActive(false);
enterKeyHighlighted.gameObject.SetActive(false);
riceText.text = "1";
}
//Used to set slider active or not
public void SetRMActive(bool setActive)
{
waterLevel.gameObject.SetActive(setActive);
riceLevel.gameObject.SetActive(setActive);
riceText.gameObject.SetActive(setActive);
}
}
