Exemplo n.º 1
0
    //加载WayPoint相关
    public static GameObject LoadWayPoint(string PrefabName)
    {
        int        hash = PrefabName.GetHashCode();
        GameObject obj  = null;

        if (!EffectCache.TryGetValue(hash, out obj))
        {
            obj = Resources.Load <GameObject>(cfg_WayPointPath + PrefabName);
            EffectCache[hash] = obj;
        }
        if (obj == null)
        {
            Debugger.LogError("路点不存在:" + PrefabName);
            return(null);
        }
        return(GameObject.Instantiate(obj));
    }
Exemplo n.º 2
0
        public Effect(GraphicsDevice graphicsDevice, byte[] effectCode)
            : this(graphicsDevice)
        {
            // By default we currently cache all unique byte streams
            // and use cloning to populate the effect with parameters,
            // techniques, and passes.
            //
            // This means all the immutable types in an effect:
            //
            //  - Shaders
            //  - Annotations
            //  - Names
            //  - State Objects
            //
            // Are shared for every instance of an effect while the
            // parameter values and constant buffers are copied.
            //
            // This might need to change slightly if/when we support
            // shared constant buffers as 'new' should return unique
            // effects without any shared instance state.

            //Read the header
            MGFXHeader header = ReadHeader(effectCode);
            // First look for it in the cache.
            //
            Effect cloneSource;
            if (!EffectCache.TryGetValue(header.EffectKey, out cloneSource))
            {
                using (var stream = new MemoryStream(effectCode, header.HeaderSize, effectCode.Length - header.HeaderSize, false))
                    using (var reader = new BinaryReader(stream))
                    {
                        // Create one.
                        cloneSource = new Effect(graphicsDevice);
                        cloneSource.ReadEffect(reader);

                        // Cache the effect for later in its original unmodified state.
                        EffectCache.Add(header.EffectKey, cloneSource);
                    }
            }

            // Clone it.
            _isClone = true;
            Clone(cloneSource);
        }
Exemplo n.º 3
0
        public override void UnloadContent()
        {
            BokuGame.Release(ref faceEyesOpen);
            BokuGame.Release(ref faceEyesSquint);
            BokuGame.Release(ref faceEyesPupils);
            BokuGame.Release(ref faceEyesPupilsCross);
            BokuGame.Release(ref faceBrowsUp);
            BokuGame.Release(ref faceBrowsNormal);
            BokuGame.Release(ref faceBrowsDown);


            if (effectCache != null)
            {
                effectCache.UnLoad();
                effectCache = null;
            }

            base.UnloadContent();
        }
        public static void InitDeviceResources(GraphicsDevice device)
        {
            effectCache = new EffectCache <EffectParams>();
            effectCache.Load(Effect);

            // Scale background frame to be of length one on the long side (width).
            kBackSize = new Vector2(BackTexture.Width, BackTexture.Height) / (float)BackTexture.Width;

            // Scale life bar image to fit inside the background frame (original images are of equal size).
            kLifeSize = new Vector2(kBackSize.X * kLifeBarScalarX, kBackSize.Y * kLifeBarScalarY);

            vertexBuf = new VertexBuffer(device, typeof(VertexPositionTexture), 4, BufferUsage.WriteOnly);
            VertexPositionTexture[] verts = new VertexPositionTexture[4] {
                new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(1, 1)),
                new VertexPositionTexture(new Vector3(0, 0, 0), new Vector2(0, 1)),
            };
            vertexBuf.SetData <VertexPositionTexture>(verts);
        }
Exemplo n.º 5
0
        private T AdjustNewAsset <T>(T asset, string assetName)
        {
#if FRB_XNA
            if (asset is Microsoft.Xna.Framework.Graphics.Texture)
            {
                (asset as Microsoft.Xna.Framework.Graphics.Texture).Name = assetName;
            }

#if WINDOWS_PHONE || WINDOWS_8 || MONOGAME
            // do nothing???
#else
            else if (mFirstEffect == null && asset is Effect)
            {
                lock (Renderer.GraphicsDevice)
                {
                    mFirstEffect      = asset as Effect;
                    mFirstEffectCache = new EffectCache(mFirstEffect, true);
                }
            }
#endif
#elif SILVERLIGHT
            if (asset is Texture2D)
            {
                (asset as Texture2D).Name = assetName;
            }
#endif

            if (asset is FlatRedBall.Scene)
            {
                return((T)(object)((asset as FlatRedBall.Scene).Clone()));
            }
            else if (asset is FlatRedBall.Graphics.Particle.EmitterList)
            {
                return((T)(object)(asset as FlatRedBall.Graphics.Particle.EmitterList).Clone());
            }
            else
            {
                return(asset);
            }
        }
Exemplo n.º 6
0
 internal virtual void SetupEffectValues(EffectCache cache)
 {
 }
Exemplo n.º 7
0
        internal override void SetupEffectValues(EffectCache cache)
        {
            if (cache.CacheShared)
            {

                #region Calculate center point

                Vector3 cp = mMapCenterPoint;
                Vector3 offset = (BoundingBox.Max + BoundingBox.Min) * 0.5f;
                cp -= offset;

                #endregion

                // Set parameters
                List<EffectParameter> paramList;
                #region ShadowMapTexture
                paramList = cache[EffectCache.EffectParameterNamesEnum.ShadowMapTexture];
                if (!mInShadowCreationPass && paramList != null)
                {
                    foreach (EffectParameter param in paramList)
                    {
                        param.SetValue(ShadowDepthTexture);
                    }
                }
                #endregion
                #region ShadowCameraMatrix
                paramList = cache[EffectCache.EffectParameterNamesEnum.ShadowCameraMatrix];
                if (paramList != null)
                {
                    foreach (EffectParameter param in paramList)
                    {
                        param.SetValue(ShadowCameraMatrix);
                    }
                }
                #endregion
                #region ShadowLightDirection
                paramList = cache[EffectCache.EffectParameterNamesEnum.ShadowLightDirection];
                if (paramList != null)
                {
                    foreach (EffectParameter param in paramList)
                    {
                        param.SetValue(mLightDirection);
                    }
                }
                #endregion
                #region ShadowLightDist
                paramList = cache[EffectCache.EffectParameterNamesEnum.ShadowLightDist];
                if (paramList != null)
                {
                    foreach (EffectParameter param in paramList)
                    {
                        param.SetValue(mLightDist);
                    }
                }
                #endregion
                #region ShadowCameraAt
                paramList = cache[EffectCache.EffectParameterNamesEnum.ShadowCameraAt];
                if (paramList != null)
                {
                    foreach (EffectParameter param in paramList)
                    {
                        param.SetValue(cp);
                    }
                }
                #endregion

            }
        }
Exemplo n.º 8
0
    private void Awake()
    {
        var effectsObj = new GameObject("Effects");

        effects = effectsObj.AddComponent <EffectCache>();
    }
Exemplo n.º 9
0
 public CreateQueueHandler(PhotonApplication application, FightManager fightManager, EffectCache effectCache)
     : base(application)
 {
     _fightManager = fightManager;
 }