/**
     * Create my own info box
     */
    void CreateMyPlayerInfoBox(Player pPlayer)
    {
        GameObject playerInfo = (GameObject)Instantiate(mMyPlayerInfoPrefab, Vector3.zero, Quaternion.identity);

        playerInfo.transform.parent = mPlayersList.gameObject.transform;

        dfTextbox myNameTextBox = (dfTextbox)playerInfo.GetComponentInChildren(typeof(dfTextbox));

        myNameTextBox.Text = pPlayer.uName;
        dfPropertyBinding.Bind(myNameTextBox.gameObject, myNameTextBox, "Text", pPlayer, "uName");

        dfDropdown myStation = (dfDropdown)playerInfo.GetComponentInChildren(typeof(dfDropdown));

        dfEventDrivenPropertyBinding.Bind(myStation.gameObject, pPlayer, "uAvailableStationNames", "AvailableStationsHaveChanged", myStation, "Items", null);

        dfPropertyBinding.Bind(myStation.gameObject, myStation, "SelectedIndex", pPlayer, "uSelectedStationIndex");

        dfTextureSprite stationLogo = playerInfo.transform.FindChild("StationLogo").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(stationLogo.gameObject, pPlayer, "uStationLogo", stationLogo, "Texture");

        dfTextureSprite d = playerInfo.transform.FindChild("IsPlayerReady").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(d.gameObject, pPlayer, "uReadyTexture", d, "Texture");
    }
 void Awake()
 {
     mProps = (Props)FindObjectOfType(typeof(Props));
     uImage = (dfTextureSprite)GetComponentInChildren(typeof(dfTextureSprite));
     mRecordingPropPrefab = (GameObject)Resources.Load("Afternoon/Prefabs/RecordingProp");
     mScreen = GameObject.FindGameObjectWithTag("Screen");
 }
Esempio n. 3
0
    /**
     * Subtract to our viewer score for the given need
     * pDay = the need's day NOT the current day
     */
    void LoseScore(int pDay, string pNeed, dfControl source, int pNumber = 1)
    {
        dfTextureSprite target = mMam.GetComponent <dfTextureSprite>();

        if (pDay == 1)
        {
            target = mDaughter.GetComponent <dfTextureSprite>();
        }

        for (int i = 0; i < pNumber; i++)
        {
            GameObject           g = (GameObject)Instantiate(mPointGainedIndicatorPrefab, Vector3.zero, Quaternion.identity);
            PointGainedIndicator p = g.GetComponent <PointGainedIndicator>();
            p.transform.parent = mUIRoot.transform;
            if (source == null)
            {
                g.GetComponent <dfTextureSprite>().Position = new Vector3(mScreenControl.Position.x + (mScreenControl.Width / 2), mScreenControl.Position.y - (mScreenControl.Height / 2));
            }
            else
            {
                g.GetComponent <dfTextureSprite>().Position = new Vector3(mScreenControl.Position.x + source.Position.x + (source.Width / 2), mScreenControl.Position.y + source.Position.y - (source.Height / 2));
            }
            p.SetNegative();
            p.MoveTo(target);
        }

        mNetworkManager.myPlayer.networkView.RPC("LoseWatchingScore", RPCMode.All, pNeed, pNumber);
    }
    /**
     * Create an info box for another player
     */
    void CreatePlayerInfoBox(Player pPlayer)
    {
        GameObject playerInfo = (GameObject)Instantiate(mPlayerInfoPrefab, Vector3.zero, Quaternion.identity);

        playerInfo.transform.parent = mPlayersList.gameObject.transform;

        dfLabel nameLabel = (dfLabel)playerInfo.GetComponentsInChildren(typeof(dfLabel))[0];

        dfPropertyBinding.Bind(nameLabel.gameObject, pPlayer, "uName", nameLabel, "Text");

        dfLabel stationLabel = (dfLabel)playerInfo.GetComponentsInChildren(typeof(dfLabel))[1];

        dfPropertyBinding.Bind(stationLabel.gameObject, pPlayer, "uStationName", stationLabel, "Text");

        dfTextureSprite stationLogo = playerInfo.transform.FindChild("StationLogo").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(stationLogo.gameObject, pPlayer, "uStationLogo", stationLogo, "Texture");

        PlayerInfoBox p = (PlayerInfoBox)playerInfo.GetComponent(typeof(PlayerInfoBox));

        p.uID = pPlayer.uID;

        dfTextureSprite d = playerInfo.transform.FindChild("IsPlayerReady").GetComponent <dfTextureSprite>();

        dfPropertyBinding.Bind(d.gameObject, pPlayer, "uReadyTexture", d, "Texture");
    }
Esempio n. 5
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(mPlayingPropPrefab, Vector3.zero, Quaternion.identity);

        g.transform.parent = pScreen.transform;

        dfTextureSprite sprite = (dfTextureSprite)g.GetComponent(typeof(dfTextureSprite));

        sprite.Texture  = (Texture2D)Resources.Load("Props/" + mPropID);
        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 = (PlayingProp)g.GetComponent(typeof(PlayingProp));

        r.uID = uID;
        Game mGame = GameObject.FindObjectOfType <Game>();

        if (mGame.uProps.ContainsKey(mPropID))
        {
            r.uProp = mGame.uProps[mPropID];
        }
        else if (mGame.uBackdrops.ContainsKey(mPropID))
        {
            r.uProp = mGame.uBackdrops[mPropID];
        }
        sprite.enabled = true;
    }
    void OnMouseDown()
    {
        GameObject g = (GameObject)Instantiate(mRecordingPropPrefab, Vector3.zero, Quaternion.identity);

        g.transform.parent = mScreen.transform;

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

        dfTextureSprite sprite = (dfTextureSprite)g.GetComponent(typeof(dfTextureSprite));
        // 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.Texture  = (Texture2D)Resources.Load("Props/" + uPurchasedProp.uProp.uID);
        sprite.Size     = new Vector2(sprite.Texture.width, sprite.Texture.height);

        RecordingProp r = (RecordingProp)g.GetComponent(typeof(RecordingProp));

        r.uPurchasedProp = uPurchasedProp;

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

        p.OnMouseDown();

        mProps.Remove(uPurchasedProp);
    }
 /**
  * Move to the target and then destroy ourself
  */
 public void MoveTo(dfTextureSprite pTarget)
 {
     dfTweenVector3 v = GetComponent<dfTweenVector3>();
     mTexture.BringToFront();
     v.StartValue = mTexture.Position;
     v.EndValue = new Vector3(pTarget.Position.x + (pTarget.Width/2), pTarget.Position.y - (pTarget.Height/2));
     v.Play();
 }
Esempio n. 8
0
    /**
     * Move to the target and then destroy ourself
     */
    public void MoveTo(dfTextureSprite pTarget)
    {
        dfTweenVector3 v = GetComponent <dfTweenVector3>();

        mTexture.BringToFront();
        v.StartValue = mTexture.Position;
        v.EndValue   = new Vector3(pTarget.Position.x + (pTarget.Width / 2), pTarget.Position.y - (pTarget.Height / 2));
        v.Play();
    }
Esempio n. 9
0
 protected override void OnEnableLate()
 {
     sprite = GetComponent <dfTextureSprite>();
     if (sprite == null)
     {
         Debug.LogError("Can not find dfTextureSprite.");
         OnlineMapsUtils.DestroyImmediate(this);
     }
 }
 // ReSharper disable once UnusedMember.Local
 protected override void OnEnableLate()
 {
     sprite = GetComponent<dfTextureSprite>();
     if (sprite == null)
     {
         Debug.LogError("Can not find dfTextureSprite.");
         Destroy(this);
     }
 }
Esempio n. 11
0
    public void Start()
    {
        // Obtain a reference to the dfTextureSprite instance attached to this object
        this.control = GetComponent<dfTextureSprite>();

        this.hue = HSBColor.GetHue( control.Color );
        this.color = control.Color;

        updateHotspot();
    }
Esempio n. 12
0
    public void Start()
    {
        // Obtain a reference to the dfTextureSprite instance attached to this object
        this.control = GetComponent <dfTextureSprite>();

        this.hue   = HSBColor.GetHue(control.Color);
        this.color = control.Color;

        updateHotspot();
    }
Esempio n. 13
0
    void AddBrains(List <Brain> brains)
    {
        AddedBrains = 0;
        var children = new List <GameObject>();

        foreach (Transform child in transform)
        {
            children.Add(child.gameObject);
        }
        children.ForEach(child => Destroy(child));

        //  GameObject.Find("MainPanel").GetComponent<dfPanel>().Enable();

        //   GameObject.Find("LoadingLabel").GetComponent<dfLabel>().IsVisible = false;
        DataLoaded = false;
        int   level = 0;
        int   idx   = 0;
        float ratio = 1.0f / brains.Count;



        LevelCount   = new Dictionary <int, int>();
        CurrentCount = new Dictionary <int, int>();
        foreach (Brain b in brains)
        {
            countLevels(b, 0);
        }
        printLevels();

        int numBrains = brains.Count;

        foreach (Brain b in brains)
        {
            Color32 color = hsvToRgb(idx / (float)numBrains, 1, 0.5f);
            // print("Hello");
            recurseAdd(b, level, ratio, idx, idx * ratio, 0, color);
            idx++;
        }

        //    print("Count: " + allBrains.Count());
        // print("Number of brains: " + numberOfBrains);
        if (AddedBrains < 2)
        {
            // print("Joe");
            dfTextureSprite sprite = _panel.AddPrefab(Tutorial) as dfTextureSprite;

            var center_x = _panel.Width / 2;
            sprite.RelativePosition = new Vector3(center_x - sprite.Width / 2, 7, 0);
            sprite.ZOrder           = 0;
            // print("Joe 2");
        }
    }
Esempio n. 14
0
    private void updateSelectedColor()
    {
        if (control == null)
        {
            this.control = GetComponent <dfTextureSprite>();
        }

        var relativePos = indicator.RelativePosition + (Vector3)indicator.Size * 0.5f;

        this.color = getColor(
            relativePos.x,
            relativePos.y,
            control.Width,
            control.Height,
            this.Hue
            );
    }
    [RPC] void StartPreparing()
    {
        if (Network.isServer)
        {
            // Set everyone to "not ready" so we can wait again after the recording stage
            foreach (Player player in mNetworkManager.players)
            {
                player.networkView.RPC("SetReady", RPCMode.All, false);
            }
        }

        mDialogueManager.EndDialogue();


        // First, instatiate all of the backdrops
        foreach (PurchasedBackdrop purchasedBackdrop in uPurchasedBackdrops)
        {
            GameObject g = (GameObject)Instantiate(mBackdropPrefab, Vector3.zero, Quaternion.identity);
            g.transform.parent = mScreen.transform;

            dfTextureSprite sprite = (dfTextureSprite)g.GetComponent(typeof(dfTextureSprite));
            sprite.Position = new Vector2(0, 550);
            sprite.Texture  = (Texture2D)Resources.Load("Props/" + purchasedBackdrop.uProp.uID);

            RecordingProp r = (RecordingProp)g.GetComponent(typeof(RecordingProp));
            r.uPurchasedProp = purchasedBackdrop;

            mBackdropMap.Add(purchasedBackdrop, g.GetComponent <AfternoonBackdrop>());
        }


        uRecording = false;
        Action finishedPreparing =
            () => {
            StartRecording();
        };

        mCountdown.StartCountdown(Game.PREPARING_COUNTDOWN, finishedPreparing);
    }
Esempio n. 16
0
    private void updateSelectedColor()
    {
        if( control == null )
        {
            this.control = GetComponent<dfTextureSprite>();
        }

        var relativePos = indicator.RelativePosition + (Vector3)indicator.Size * 0.5f;

        this.color = getColor(
            relativePos.x,
            relativePos.y,
            control.Width,
            control.Height,
            this.Hue
        );
    }
 void Awake()
 {
     mSprite = GetComponent <dfTextureSprite>();
 }
 void Awake()
 {
     mMyProps = (MyProps)FindObjectOfType(typeof(MyProps));
     uImage   = (dfTextureSprite)GetComponentInChildren(typeof(dfTextureSprite));
 }
Esempio n. 19
0
 public void Start()
 {
     this.control = GetComponent<dfTextureSprite>();
 }
Esempio n. 20
0
 public void OnEnable()
 {
     myImage = GetComponent <dfTextureSprite>();
 }
 void Awake()
 {
     mNegativeTexture = (Texture2D)Resources.Load ("Evening/Images/unhappy");
     mTexture = gameObject.GetComponent<dfTextureSprite>();
 }
Esempio n. 22
0
    private void CreateMap()
    {
        OnlineMaps map = CreateMapGameObject();
        GameObject go  = map.gameObject;

        if (use3DControl == 0)
        {
            Texture2D texture = CreateTexture(map);

            if (mapControl2D == 0)
            {
                go.AddComponent <OnlineMapsGUITextureControl>();
                GUITexture guiTexture = go.GetComponent <GUITexture>();
                guiTexture.texture         = texture;
                go.transform.localPosition = new Vector3(0.5f, 0.5f);
                go.transform.localScale    = Vector3.zero;
                guiTexture.pixelInset      = new Rect(textureWidth / -2, textureHeight / -2, textureWidth, textureHeight);
            }
            else if (mapControl2D == 1)
            {
                go.AddComponent <OnlineMapsSpriteRendererControl>();
                SpriteRenderer spriteRenderer = go.GetComponent <SpriteRenderer>();
                spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, textureWidth, textureHeight), Vector2.zero);
                go.AddComponent <BoxCollider>();
            }
#if !UNITY_4_3 && !UNITY_4_5
            else if (mapControl2D == 2 || mapControl2D == 3)
            {
                RectTransform rectTransform = go.AddComponent <RectTransform>();
                rectTransform.SetParent(uGUIParent.transform as RectTransform);
                go.AddComponent <CanvasRenderer>();
                rectTransform.localPosition = Vector3.zero;
                rectTransform.anchorMax     = rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
                rectTransform.pivot         = new Vector2(0.5f, 0.5f);
                rectTransform.sizeDelta     = new Vector2(textureWidth, textureHeight);

                if (mapControl2D == 2)
                {
                    go.AddComponent <OnlineMapsUIImageControl>();
                    Image image = go.AddComponent <Image>();
                    image.sprite = Sprite.Create(texture, new Rect(0, 0, textureWidth, textureHeight), Vector2.zero);
                }
                else
                {
                    go.AddComponent <OnlineMapsUIRawImageControl>();
                    RawImage image = go.AddComponent <RawImage>();
                    image.texture = texture;
                }
            }
#endif
#if NGUI
            else if (mapControl2D == 4)
            {
                go.layer = NGUIParent.layer;
                UITexture uiTexture = go.AddComponent <UITexture>();
                uiTexture.mainTexture      = texture;
                uiTexture.width            = textureWidth;
                uiTexture.height           = textureHeight;
                go.transform.parent        = NGUIParent.transform;
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale    = Vector3.one;
                go.transform.localRotation = Quaternion.Euler(Vector3.zero);
                BoxCollider boxCollider = go.AddComponent <BoxCollider>();
                boxCollider.size = new Vector3(textureWidth, textureHeight, 0);
                go.AddComponent <OnlineMapsNGUITextureControl>();
            }
#endif
#if DFGUI
            else if (mapControl2D == 5)
            {
                go.transform.parent = DFGUIParent.transform;

                dfTextureSprite textureSprite = go.AddComponent <dfTextureSprite>();
                textureSprite.Texture = texture;
                textureSprite.Width   = textureWidth;
                textureSprite.Height  = textureHeight;
                textureSprite.Pivot   = dfPivotPoint.MiddleCenter;
                textureSprite.transform.localPosition = Vector3.zero;

                go.AddComponent <OnlineMapsDFGUITextureControl>();
            }
#endif
#if IGUI
            else if (mapControl2D == 6)
            {
                go.transform.parent = IGUIParent.transform;

                iGUIImage image = go.AddComponent <iGUIImage>();
                image.image           = texture;
                image.positionAndSize = new Rect(0, 0, 1, 1);

                go.AddComponent <OnlineMapsIGUITextureControl>();
            }
#endif

            map.useSmartTexture = smartTexture;
            map.redrawOnPlay    = true;
        }
        else
        {
            OnlineMapsControlBase3D control3D = null;

            if (mapControl3D == 0)
            {
                map.target        = OnlineMapsTarget.tileset;
                map.tilesetWidth  = tilesetWidth;
                map.tilesetHeight = tilesetHeight;
                map.tilesetSize   = tilesetSize;

                OnlineMapsTileSetControl ts = go.AddComponent <OnlineMapsTileSetControl>();
                control3D         = ts;
                ts.useElevation   = useElevation;
                ts.bingAPI        = bingAPI;
                ts.smoothZoom     = smoothZoom;
                ts.tileMaterial   = tileMaterial;
                ts.markerMaterial = markerMaterial;
                ts.tilesetShader  = tilesetShader;
                ts.drawingShader  = drawingShader;
                ts.markerShader   = markerShader;

                if (moveCameraToTileset)
                {
                    GameObject cameraGO = activeCamera.gameObject;
                    float      minSide  = Mathf.Min(tilesetSize.x, tilesetSize.y);
                    Vector3    position = new Vector3(tilesetSize.x / -2, minSide, tilesetSize.y / 2);
                    cameraGO.transform.position = position;
                    cameraGO.transform.rotation = Quaternion.Euler(90, 180, 0);
                }

                if (useBuildings)
                {
                    go.AddComponent <OnlineMapsBuildings>();
                }
            }
            else if (mapControl3D == 1)
            {
                control3D           = go.AddComponent <OnlineMapsTextureControl>();
                map.useSmartTexture = smartTexture;
                map.redrawOnPlay    = true;
            }

            if (control3D != null)
            {
                control3D.activeCamera       = activeCamera;
                control3D.allowCameraControl = allowCameraControl;
            }
        }

        if (useLocationService)
        {
            go.AddComponent <OnlineMapsLocationService>();
        }
        if (useRWT)
        {
            go.AddComponent <OnlineMapsRWTConnector>();
        }

        EditorGUIUtility.PingObject(go);
        Selection.activeGameObject = go;
    }
	public void OnEnable()
	{
		myImage = GetComponent<dfTextureSprite>();
	}
 void Awake()
 {
     uImage = (dfTextureSprite) GetComponentInChildren(typeof(dfTextureSprite));
     mDialoguePrefab = (GameObject)Resources.Load ("Afternoon/Prefabs/Dialogue");
     mScreen = GameObject.FindGameObjectWithTag("Screen");
 }
Esempio n. 25
0
 void Awake()
 {
     uImage          = (dfTextureSprite)GetComponentInChildren(typeof(dfTextureSprite));
     mDialoguePrefab = (GameObject)Resources.Load("Afternoon/Prefabs/Dialogue");
     mScreen         = GameObject.FindGameObjectWithTag("Screen");
 }
    void RecordProps()
    {
        // First loop through all of the recordable objects in screen to check if any have been added/removed
        RecordingProp[] currentRecordingProps = FindObjectsOfType <RecordingProp>().Where(rp => rp.GetType() != typeof(RecordingDialogue)).ToArray();

        // Get the IDs from all current props
        string[] currentIDs = (from prop in currentRecordingProps select prop.uPurchasedProp.uID).ToArray();

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

                // Get the full prop information
                RecordingProp   p      = currentRecordingProps.Where(prop => prop.uPurchasedProp.uID == ID).First();
                dfTextureSprite sprite = (dfTextureSprite)p.gameObject.GetComponent(typeof(dfTextureSprite));

                float x_pos = sprite.Position.x;                // - (sprite.Width / 2);
                float y_pos = sprite.Position.y;                // + (sprite.Height / 2);
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "InstantiationChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uPurchasedProp.uProp.uID, p.uPurchasedProp.uID, x_pos.ToString(), y_pos.ToString(), sprite.Size.x.ToString(), sprite.Size.y.ToString(), sprite.ZOrder.ToString() }) });
                mKnownPositions[ID] = sprite.Position;
                mKnownZOrders[ID]   = sprite.ZOrder;
                mKnownSizes[ID]     = sprite.Size;
            }
        }

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

        mKnownPropIDs = currentIDs;

        // Then check if any have moved position
        foreach (RecordingProp p in currentRecordingProps)
        {
            dfTextureSprite sprite = (dfTextureSprite)p.gameObject.GetComponent(typeof(dfTextureSprite));
            if (sprite.Position != mKnownPositions[p.uPurchasedProp.uID])
            {
                // The prop has moved
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "PositionChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uPurchasedProp.uID, sprite.Position.x.ToString(), sprite.Position.y.ToString() }) });
                mKnownPositions[p.uPurchasedProp.uID] = sprite.Position;
            }

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

            if (sprite.Size != mKnownSizes[p.uPurchasedProp.uID])
            {
                // The prop has changed size
                mRecordingPlayer.networkView.RPC("RecordAction", RPCMode.All, new object[] { "SizeChange", RPCEncoder.Encode(new string[] { mTime.ToString(), p.uPurchasedProp.uID, sprite.Size.x.ToString(), sprite.Size.y.ToString() }) });
                mKnownSizes[p.uPurchasedProp.uID] = sprite.Size;
            }
        }
    }
Esempio n. 27
0
 void Awake()
 {
     mNegativeTexture = (Texture2D)Resources.Load("Evening/Images/unhappy");
     mTexture         = gameObject.GetComponent <dfTextureSprite>();
 }
 public void Start()
 {
     this.control = GetComponent <dfTextureSprite>();
 }