Esempio n. 1
0
    public string SetContent(int idx, double value)
    {
        if (idx < 0 || idx >= GameManager.gameOptions.memoryCellCount)
        {
            return("subIndex out of bounds");
        }

        // Interpret
        cells[idx].value = value;
        if (value.ToString().Length <= GameManager.gameOptions.dataLength)
        {
            cells[idx].isBase26 = false;
            cells[idx].content  = value.ToString();
        }
        else
        {
            // Number too large = switch to base-26
            cells[idx].isBase26 = true;
            string converted = AlphaNumeral.DblToString(value);
            if (converted.Length > GameManager.gameOptions.dataLength)
            {
                return("'" + converted + "' number larger than data size");
            }
            cells[idx].content = converted;
        }

        return(null);
    }
    protected string EvalStatic(string input, out string result)
    {
        result = input;

        // Evaluate Labels
        Regex           labelPattern = new Regex(@"\|(" + P.DATA + @")\|");
        MatchCollection matches      = labelPattern.Matches(input);

        foreach (Match label in matches)
        {
            // Validate label
            string label_lower = label.Groups[1].Value.ToLower();
            double value       = 0;
            if (!player.GetStatic().TryGetValue(label_lower, out value))
            {
                return("Static address '" + label.Value + "' not found");
            }

            // Substitute label
            int pos = input.IndexOf(label.Value);
            input = input.Remove(pos, label.Value.Length);
            input = input.Insert(pos, AlphaNumeral.DblToString(value));
        }

        result = input;
        return(null);
    }
Esempio n. 3
0
    string GetActiveCommand(string input, out bool success)
    {
        success = true;
        // XXX: consider moving logic to NodeManager
        Dictionary <double, NodeScript> nodes = NodeManager.GetNodes();

        double address = 0;

        int rand = UnityEngine.Random.Range(0, nodes.Count);
        int i    = 0;

        foreach (KeyValuePair <double, NodeScript> nodePair in nodes)
        {
            address = nodePair.Key;
            if (i == rand)
            {
                break;
            }
            i++;
        }

        return(AlphaNumeral.DblToString(address));
    }
Esempio n. 4
0
 public string GetIdString()
 {
     return(AlphaNumeral.DblToString(id));
 }
Esempio n. 5
0
 string GetAnyCommand(string input, out bool success)
 {
     success = true;
     return(AlphaNumeral.DblToString(NodeManager.GetRandomAddress()));
 }