// Connect two variables to create parts of rules
    // TODO: now this should be done by the FuzzyGUIRule
    public static void addConnection(FuzzyGUIElement a, FuzzyGUIElement b)
    {
        if (b.canAttachTo[(int)a.typeId]) {
            GameObject connectionGo = new GameObject();
            connectionGo.name = "Connection";
            FuzzyGUIConnection c = connectionGo.AddComponent<FuzzyGUIConnection>();
            c.connect(a,b);
            connections.Add(c);

            // Build the text of the rule!
            if (textMesh.text == "If..."){
                textMesh.text = "If " + a.vName;
            }

            if (b is FuzzyGUIComplement) {
                textMesh.text += "'s " + b.vName + " is ";
            } else if (b is FuzzyGUIAdjective) {
                textMesh.text += b.vName;
            }
            else if (b is FuzzyGUIAdverb){
                textMesh.text += b.vName;
            }

        }
    }
 public void connect(FuzzyGUIElement a, FuzzyGUIElement b)
 {
     line = gameObject.AddComponent<LineRenderer>();
     line.SetVertexCount(2);
     this.a = a;
     this.b = b;
 }
Beispiel #3
0
    public void fillSlot(FuzzyGUIElement el)
    {
        el.transform.parent = transform;
        el.transform.position = transform.position; // Place on the slot (this goes against snapping?)

        this.element = el;
        this.setName("");
        //updateName();

        if (listener) listener.slotWasFilled(id,el); // This was here to notice the rule that its slot has been filled! MUST FIND A BETTER WAY!

        print("Slot filled with element " + element.vName);
    }
 public virtual void slotWasFilled(int slotId, FuzzyGUIElement element)
 {
     // Abstract
 }
Beispiel #5
0
 /*void OnTriggerExit(Collider other){
     FuzzyGUIElementMov tmpEl = other.gameObject.GetComponent<FuzzyGUIElementMov>();
     if (tmpEl) {
         tmpEl.onSlot(null);
         //if (tmpEl.dropped == true) tmpEl.setTarget(transform.position);
     //	snap(other.transform);
         element = null;
     }
 }*/
 public void removeElement()
 {
     this.element = null;
 }
Beispiel #6
0
    FuzzyGUIElement listener; // The listener will be notified when the slot gets filled

    #endregion Fields

    #region Methods

    // When this slot is filled, this will notice the listener
    public void addListener(int id, FuzzyGUIElement listener)
    {
        this.listener = listener;
        this.id = id;
    }
Beispiel #7
0
 // Listen for slot events
 public void slotWasFilled(int slotId, FuzzyGUIElement element)
 {
     parseRule();
 }