void Start()
    {
        // Set up the binding between the highlight and isSelected
        dfSlicedSprite highlight = (dfSlicedSprite)GetComponentInChildren(typeof(dfSlicedSprite));

        dfPropertyBinding.Bind(this, "uIsSelected", highlight, "IsVisible");
    }
예제 #2
0
    public override void run(GameObject pScreen)
    {
        // First we destroy the object if it already exists
        foreach (PlayingProp p in pScreen.GetComponentsInChildren <PlayingProp>().Where(p => p.uID == uID))
        {
            GameObject.Destroy(p.gameObject);
        }

        GameObject g = (GameObject)GameObject.Instantiate(mPlayingDialoguePrefab, Vector3.zero, Quaternion.identity);

        g.transform.parent = pScreen.transform;

        dfSlicedSprite sprite = g.GetComponent <dfSlicedSprite>();

        sprite.SpriteName = mSpriteName;
        sprite.Size       = new Vector2(float.Parse(mSizeX), float.Parse(mSizeY));
        sprite.Position   = new Vector2(float.Parse(mNewX), float.Parse(mNewY));
        sprite.ZOrder     = int.Parse(mZOrder);

        PlayingProp r = g.GetComponent <PlayingProp>();

        r.uID = uID;

        dfLabel l = g.GetComponentInChildren <dfLabel>();

        l.Text      = mText;
        l.TextScale = float.Parse(mTextScale);

        sprite.enabled = true;
    }
예제 #3
0
    void OnMouseDown()
    {
        GameObject g = (GameObject)Instantiate(mDialoguePrefab, Vector3.zero, Quaternion.identity);

        g.transform.parent = mScreen.transform;

        Vector2 mousePosition = uImage.GetManager().ScreenToGui(new Vector2(Input.mousePosition.x, Input.mousePosition.y));

        dfSlicedSprite sprite = g.GetComponent <dfSlicedSprite>();
        // TODO: these numbers are hardcoded - copied from the unity gui - figure out how to get this programatically
        Vector2 top_left = new Vector2(mousePosition.x - 183, (0 - mousePosition.y) + 123);

        sprite.Position   = new Vector2(top_left.x - (sprite.Size.x / 2), top_left.y + (sprite.Size.y / 2));
        sprite.SpriteName = uBackgroundSpriteName;
        sprite.Size       = new Vector2(300, 300);

        MovingArea p = g.GetComponentInChildren <MovingArea>();

        p.OnMouseDown();
    }
예제 #4
0
 public void Start()
 {
     this.control = GetComponent<dfSlicedSprite>();
 }
예제 #5
0
 public void Start()
 {
     this.control = GetComponent<dfSlicedSprite>();
     this.useGUILayout = false;
 }
    void RecordDialogue()
    {
        // First loop through all of the recordable objects in screen to check if any have been added/removed
        RecordingDialogue[] currentDialogues = FindObjectsOfType <RecordingDialogue>();

        // Get the IDs from all current text
        string[] currentIDs = (from dialogue in currentDialogues select dialogue.uID).ToArray();

        // Check if any have been added
        foreach (string ID in currentIDs)
        {
            if (!mKnownDialogueIDs.Contains(ID))
            {
                // This is a new dialogue

                RecordingDialogue d      = currentDialogues.Where(dialogue => dialogue.uID == ID).First();
                dfSlicedSprite    sprite = d.gameObject.GetComponent <dfSlicedSprite>();
                dfLabel           label  = sprite.GetComponentInChildren <dfLabel>();
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "DialogueInstantiationChange", RPCEncoder.Encode(new string[] { mTime.ToString(), d.uID, sprite.SpriteName, label.Text, label.TextScale.ToString(), sprite.Position.x.ToString(), sprite.Position.y.ToString(), sprite.Size.x.ToString(), sprite.Size.y.ToString(), sprite.ZOrder.ToString() }) });
                mKnownDialogueTexts[ID]      = label.Text;
                mKnownDialogueTextScales[ID] = label.TextScale;
                mKnownPositions[ID]          = sprite.Position;
                mKnownZOrders[ID]            = sprite.ZOrder;
                mKnownSizes[ID] = sprite.Size;
            }
        }

        // Check if any have been removed
        foreach (string ID in mKnownDialogueIDs)
        {
            if (!currentIDs.Contains(ID))
            {
                // This dialogue has been removed
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "DestroyChange", RPCEncoder.Encode(new string[] { mTime.ToString(), ID }) });
            }
        }

        mKnownDialogueIDs = currentIDs;

        // Then check if any have moved position
        foreach (RecordingDialogue p in currentDialogues)
        {
            dfSlicedSprite sprite = p.gameObject.GetComponent <dfSlicedSprite>();
            dfLabel        label  = sprite.GetComponentInChildren <dfLabel>();
            if (sprite.Position != mKnownPositions[p.uID])
            {
                // The prop has moved
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "PositionChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uID, sprite.Position.x.ToString(), sprite.Position.y.ToString() }) });
                mKnownPositions[p.uID] = sprite.Position;
            }

            if (sprite.ZOrder != mKnownZOrders[p.uID])
            {
                // The prop has moved ZOrder
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "ZOrderChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uID, sprite.ZOrder.ToString() }) });
                mKnownZOrders[p.uID] = sprite.ZOrder;
            }

            if (sprite.Size != mKnownSizes[p.uID])
            {
                // The prop has changed size
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "SizeChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uID, sprite.Size.x.ToString(), sprite.Size.y.ToString() }) });
                mKnownSizes[p.uID] = sprite.Size;
            }

            if (label.Text != mKnownDialogueTexts[p.uID])
            {
                // The prop has changed size
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "DialogueTextChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uID, label.Text }) });
                mKnownDialogueTexts[p.uID] = label.Text;
            }

            if (label.TextScale != mKnownDialogueTextScales[p.uID])
            {
                // The prop has changed size
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "DialogueTextScaleChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uID, label.TextScale.ToString() }) });
                mKnownDialogueTextScales[p.uID] = label.TextScale;
            }
        }
    }
예제 #7
0
 public void Start()
 {
     this.control      = GetComponent <dfSlicedSprite>();
     this.useGUILayout = false;
 }