You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
11 years ago
|
Inventory Items and Gameplay Flags
|
||
|
==================================
|
||
|
|
||
|
# How do I manage inventory items and gameplay flags?
|
||
|
|
||
|
1. Use the [SetValue](@ref Fungus.GameController.SetValue) command to record a collected inventory item or gameplay flag.
|
||
|
2. Use the [GetValue](@ref Fungus.GameController.GetValue) command to check how many items of that type have been set.
|
||
|
3. Use the [HasValue](@ref Fungus.GameController.HasValue) command to check if any items of that type have been set.
|
||
|
4. Use the [ClearValue](@ref Fungus.GameController.HasValue) command to reset item count to 0.
|
||
|
|
||
|
## C# code example
|
||
|
~~~~~~~~~~~~~~~~~~~~
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using Fungus;
|
||
|
|
||
|
public class MyRoom : Room
|
||
|
{
|
||
|
void OnEnter()
|
||
|
{
|
||
|
// Inventory example (counting usage)
|
||
|
SetValue("rock", 2); // Pick up rocks
|
||
|
if (GetValue("rock") > 0) // Check if player has rocks
|
||
|
{
|
||
|
Say("You have some rocks");
|
||
|
}
|
||
|
SetValue("rock", 0); // Drop rocks
|
||
|
|
||
|
// Gameplay flag example (boolean flag usage)
|
||
|
SetValue("door_open"); // Sets value to 1 (to indicate True)
|
||
|
if (HasValue("door_open")) // Checks if value is non-zero (indicates True)
|
||
|
{
|
||
|
Say("The door is open");
|
||
|
}
|
||
|
ClearValue("door_open"); // Sets value to 0 (to indicate False)
|
||
|
}
|
||
|
}
|
||
|
~~~~~~~~~~~~~~~~~~~~
|