Beispiel #1
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // Is this a packet?
        PacketScript packg = otherCollider.gameObject.GetComponent <PacketScript>();

        if (packg != null && pick)
        {
            transform.localScale *= 0.7f;
            //new Vector3(0.25f, 0.25f, 1);
            Destroy(packg.gameObject); // Remember to always target the game object, otherwise you will just remove the script
        }
    }
    public static string CreatePacket(NodeScript source, NodeScript target, string contents)
    {
        // Create and validate packet
        PacketScript script = new PacketScript(source, target, contents);
        string       errors = commands.Interpret(source, script);

        if (errors != null)
        {
            return(errors);
        }
        packets.Add(script);

        PacketGraphicManager.DisplayPacket(source, target);

        return(null);
    }
Beispiel #3
0
    // XXX: Dare I say I do not like how I am handling Packets
    public string Interpret(NodeScript node, PacketScript in_packet)
    {
        localNode = node;
        packet    = in_packet;

        // Divide input
        Regex pattern = new Regex(@"^([^ ]+)(?:\s+(.+))?");
        Match match   = pattern.Match(packet.GetContents());

        if (!match.Success)
        {
            return("'" + packet.GetContents() + "' invalid command format");
        }
        string command    = match.Groups[1].Value;
        string parameters = match.Groups[2].Value;

        // Interpret command across all command lists
        Command cmd = null;

        if (!commands.TryGetValue(command.ToLower(), out cmd))
        {
            return("'" + command + "' in '" + packet.GetContents() + "' command not found");
        }

        /*if( packet.GetTarget() != null ) {
         *      string error = EvalLabels( parameters, out parameters, packet.GetTarget() );
         *      if( error != null ) {
         *              return error;
         *      }
         * }*/

        // Run command
        bool   success;
        string output = cmd(parameters, out success);

        if (!success)
        {
            return(output);
        }

        return(null);
    }