Esempio n. 1
0
    private void _RefreshGOB()
    {
        // Call modify here?
        // After any changes, current item state.
        // Created directly from asset, then additions added depending on type.
        // Take view direction into account.

        CUtility.DestroyChildren(_itemRoot);
        GameObject gob = _asset.CreateVisuals(EViewDirection.VD_FRONT);

        gob.transform.SetParent(_itemRoot.transform);

        // Create usage slot visuals
        // Create specific visuals for items that use extended models?

        if (_asset.mItemType == EItemType.DESK || _asset.mItemType == EItemType.REST)
        {
            for (int i = 0; i < _asset.mUsageSlots.Count; ++i)
            {
                GameObject unit = GameObject.Instantiate(CGame.PrimaryResources.Prefabs[7] as GameObject);
                unit.transform.SetParent(_itemRoot.transform);
                unit.transform.localPosition = _asset.mUsageSlots[i].mUsePosition;
                unit.transform.rotation      = Quaternion.Euler(_asset.mUsageSlots[i].mUseRotation);
                Animator _animator = unit.transform.GetChild(0).GetComponent <Animator>();
                _animator.Play("work_working_action_2");
            }
        }

        _RebuildTileIcons();
    }
    private void _Init(EPlaceType Type, Transform Parent, PlacementDelegate PlacementDelegate)
    {
        mType          = Type;
        _placeable     = false;
        _placeDelegate = PlacementDelegate;

        if (mType == EPlaceType.ITEM)
        {
            _gob = mAsset.CreateVisuals(EViewDirection.VD_FRONT);
            _gob.transform.SetParent(Parent);
            CItemView.SetItemSurfaceColour(mAsset.mItemType, _gob, CGame.COLOR_BLUEPRRINT);
        }
        else if (mType == EPlaceType.UNIT)
        {
            mRotation = 225;
            _gob      = GameObject.Instantiate(CGame.PrimaryResources.Prefabs[7] as GameObject);
            _gob.transform.SetParent(Parent);
            _gob.transform.rotation = Quaternion.AngleAxis(mRotation, Vector3.up);
        }
    }
Esempio n. 3
0
    protected override void _New(CUserSession UserSession)
    {
        _Gob      = mAsset.CreateVisuals((EViewDirection)mRotation);
        _Gob.name = mAsset.mName;
        _Gob.transform.SetParent(UserSession.mPrimaryScene.transform);

        if (mBlueprint)
        {
            CUtility.SetLayerRecursively(_Gob.transform, 9);
            _currentSurfaceColor = Color.white;
        }
        else
        {
            if (mAsset.mItemType == EItemType.DESK)
            {
                _briedcaseGOB = GameObject.CreatePrimitive(PrimitiveType.Cube);
                _briedcaseGOB.GetComponent <MeshRenderer>().material = CGame.PrimaryResources.FlatMat;
                _briedcaseGOB.transform.SetParent(_Gob.transform);
                _briedcaseGOB.transform.localScale    = new Vector3(0.15f, 0.3f, 0.45f);
                _briedcaseGOB.transform.localPosition = new Vector3(0.626f, 0.69f, 1.473f);
                _briedcaseGOB.transform.rotation      = Quaternion.Euler(0.0f, -10.0f, 270.0f);

                _briedcaseGOB.SetActive(false);
            }
            else if (mAsset.mItemType == EItemType.SAFE)
            {
                /*
                 * _textGob = new GameObject("sceneText");
                 * _textGob.transform.SetParent(_Gob.transform);
                 *
                 * _textMesh = _textGob.AddComponent<TextMesh>();
                 * _textMesh.text = mValue.ToString();
                 * _textMesh.characterSize = 0.09f;
                 * _textMesh.fontSize = 32;
                 * _textMesh.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                 * _textMesh.anchor = TextAnchor.MiddleCenter;
                 * //text.font = CGame.ToolkitUI.SceneTextFont;
                 *
                 * _textGob.transform.localPosition = new Vector3(0.5f, 0.0f, 0.0f);
                 * _textGob.transform.rotation = Quaternion.Euler(90, 0, 0);
                 */
            }
            else if (mAsset.mItemType == EItemType.START)
            {
                if (mOwnerID == UserSession.mPlayerIndex)
                {
                    _punchOut = CPunchOut.Create(out _punchOutMesh);
                    _punchOut.transform.SetParent(_Gob.transform);
                }
            }
            else if (mAsset.mItemType == EItemType.DOOR)
            {
                _briedcaseGOB = (GameObject)GameObject.Instantiate(CGame.WorldResources.PadlockPrefab, new Vector3(0.5f, 2.25f, 1.0f), Quaternion.identity);
                _briedcaseGOB.transform.SetParent(_Gob.transform);
            }

            _audioSource = _Gob.AddComponent <AudioSource>();
            _audioSource.outputAudioMixerGroup = CGame.UIResources.SoundsMixer;
            _audioSource.spatialBlend          = 1.0f;
        }
    }