/// <summary>
    /// Initializes the primary structure and sub-components.
    /// </summary>
    public void Initialize()
    {
        Time     = new TimeHolder();
        Graphics = new GraphicsHolder();
        Settings = new SettingHolder();
        Input    = new InputHolder();

        Input.Initialize(this);
        Time.Initialize();
        Graphics.Initialize(this);
    }
Esempio n. 2
0
        private void UpdateImage()
        {
            _image = null;

            _barEngine = _barEngine ?? new BarEngine();

            // setup options affecting size of barcode
            _barEngine.IsAutoModuleSize = false;
            _barEngine.FixedModuleSize  = (float)SymbolSize;

            // common options
            _barEngine.CodeType   = BarStyle.cbsQRCode;
            _barEngine.CaptionPos = BarCodeCaptionPosition.None;

            // QRCode
            _barEngine.QRCodeModel    = 2;                                   //Model2
            _barEngine.QRCodeMask     = -1;                                  //-1 means auto
            _barEngine.QRVersion      = CodeVersion == 0 ? -1 : CodeVersion; //-1 means auto
            _barEngine.QRConnection   = false;
            _barEngine.QRConnectionNo = 0;
            _barEngine.QRErrorLevel   = ErrorLevelMapping[ErrorCorrectionLevel];
            _barEngine.QRCodeEncoding = System.Text.Encoding.UTF8;// old Custom QRCode use UTF8 to encode text.

            using (GraphicsHolder gh = GraphicsHolder.FromScreen())
            {
                NSD.Size size;
                using (DrawDevice dd = new DrawDevice(this, gh.Graphics))
                    size = _barEngine.CalculateSize2(dd, Text);
                bool      isBarcodeEmpty = size.Width == 0 || size.Height == 0;
                Rectangle rcImage        = isBarcodeEmpty ? new Rectangle(0, 0, 1, 1)
                    : new Rectangle(0, 0, (int)(size.Width + 0.5), (int)(size.Height + 0.5));

                IntPtr dc = gh.Graphics.GetHdc();
                _image = new Metafile(dc, rcImage, MetafileFrameUnit.Pixel);
                gh.Graphics.ReleaseHdc(dc);
                using (var gDraw = Graphics.FromImage(_image))
                    using (var bBack = new SolidBrush(Color.Transparent))
                    {
                        gDraw.FillRectangle(bBack, rcImage);
                        if (!isBarcodeEmpty)
                        {
                            using (DrawDevice dd = new DrawDevice(this, gDraw))
                            {
                                _barEngine.DrawEx(dd, rcImage, _text);
                            }
                        }
                    }
            }
        }
    public void RpcAssignObject(NetworkIdentity id, int spawnableIndex)
    {
        //	if(!isLocalPlayer)return;

        //Debug.Log(id.netId.Value);
        GameObject spawnHolder     = id.gameObject;
        GameObject graphics        = buildingGroups.buildings[spawnableIndex].graphics;
        Vector3    grapihicsOffset = new Vector3(0, graphics.transform.localScale.y / 2, 0);

        graphics = Instantiate(graphics, spawnHolder.transform.position + grapihicsOffset, spawnHolder.transform.rotation, spawnHolder.transform);
        graphics.GetComponent <GraphicsHolder> ().colorize(LobbyManager.singleton.GetComponent <LobbyManager> ().gameColors.gameColorList() [PO.colorIndex]);
        BuildingUnit buildingUnit        = spawnHolder.GetComponent <BuildingUnit> ();
        Vector3      navMeshObstacleSize = spawnHolder.GetComponent <BoxCollider> ().size;

        AssignData(spawnHolder, spawnableIndex, buildingUnit, navMeshObstacleSize);

        if (spawnHolder.transform.childCount <= 0)
        {
            Debug.LogError("No graphics");
        }
        NavMeshObstacle navMeshObstacle = spawnHolder.AddComponent(typeof(NavMeshObstacle)) as NavMeshObstacle;

        navMeshObstacleSize.x  -= obstacleSizeCut;
        navMeshObstacleSize.y  -= obstacleSizeCut;
        navMeshObstacleSize.z  += obstacleHeightAdd;
        navMeshObstacle.size    = navMeshObstacleSize;
        navMeshObstacle.carving = true;
        spawnHolder.name        = PO.team + " - bldg - " + id.netId;

        spawnHolder.GetComponent <BuildingStats> ().netPlayer = PO;
        GraphicsHolder graphicsHolder = spawnHolder.GetComponentInChildren <GraphicsHolder> ();

        buildingUnit.team = PO.team;
        if (graphicsHolder != null)
        {
            graphicsHolder.colorize(LobbyManager.singleton.GetComponent <LobbyManager> ().gameColors.gameColorList() [PO.colorIndex]);
        }
        PO.myBuildings.Add(spawnHolder);
    }