Browse Source

Added SetString and GetString commands.

master
chrisgregan 11 years ago
parent
commit
e703e3ed94
  1. 26
      Assets/Fungus/Scripts/Commands/GameCommands.cs
  2. 22
      Assets/Fungus/Scripts/GameController.cs

26
Assets/Fungus/Scripts/Commands/GameCommands.cs

@ -142,7 +142,7 @@ namespace Fungus
}
/**
* Sets a globally accessible game value
* Sets a globally accessible integer value
*/
public class SetValue : CommandQueue.Command
{
@ -164,5 +164,29 @@ namespace Fungus
}
}
}
/**
* Sets a globally accessible string value
*/
public class SetString : CommandQueue.Command
{
string key;
string value;
public SetString(string _key, string _value)
{
key = _key;
value = _value;
}
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
Game.GetInstance().stringTable.SetString(key, value);
if (onComplete != null)
{
onComplete();
}
}
}
}
}

22
Assets/Fungus/Scripts/GameController.cs

@ -464,6 +464,28 @@ namespace Fungus
return GetValue(key) != 0;
}
/**
* Sets a globally accessible string value.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param key The name of the value to set
* @param value The string value to set
*/
public static void SetString(string key, string value)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.SetString(key, value));
}
/**
* Gets a globally accessible string value.
* @param key The name of the value
* @return The string value for this key, or the empty string if not previously set.
*/
public static string GetString(string key)
{
return Game.GetInstance().stringTable.GetString(key);
}
#endregion
#region Sprite Methods

Loading…
Cancel
Save