示例#1
0
        /// <summary>
        /// Takes care of drawing shadows and additional FX when needed (like in forest). [WIP]
        /// </summary>
        public static void DrawCharacterShadowSpecialEffects()
        {
            Module_world_debug.worldCharacterInstances[Module_world_debug.currentControllableEntity].bDraw = true; //always draw and later test the cases
            if (Module_world_debug.activeCollidePolygon == null)
            {
                return;
            }

            if ((Module_world_debug.activeCollidePolygon.Value.vertFlags & Module_world_debug.TRIFLAGS_FORESTTEST) > 0 && Module_world_debug.activeCollidePolygon.Value.groundtype > 5) //shadow
            {
                var shadowGeom = Extended.GetShadowPlane(Module_world_debug.playerPosition + new Vector3(-2.2f, .1f, -2.2f), 4f);
                Module_world_debug.ate.Texture = (Texture2D)Module_world_debug.wmset.GetWorldMapTexture(Wmset.Section38_textures.shadowBig, 0);
                Module_world_debug.ate.Alpha   = .25f;
                foreach (var pass in Module_world_debug.ate.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    Module_world_debug.ate.GraphicsDevice.DepthStencilState = DepthStencilState.None;
                    Memory.Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, shadowGeom, 0, shadowGeom.Length / 3);
                }
                Module_world_debug.ate.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                Module_world_debug.ate.Alpha = 1f;
            }


            else if ((Module_world_debug.activeCollidePolygon.Value.vertFlags & Module_world_debug.TRIFLAGS_FORESTTEST) == 0 && Module_world_debug.activeCollidePolygon.Value.texFlags == 0 &&
                     Module_world_debug.activeCollidePolygon.Value.groundtype <= 5) //forest
            {
                Module_world_debug.ate.Alpha = 1f;
                Module_world_debug.worldCharacterInstances[Module_world_debug.currentControllableEntity].bDraw = false;
                if (Module_world_debug.bHasMoved && fxWalkDuration > 0.25f)
                {
                    fxWalkDuration      = 0f;
                    lastFxBushSpriteId %= 4;
                    worldEffects.Add(new worldFx()
                    {
                        fxLocation = Module_world_debug.playerPosition,
                        scale      = 1.00f, atlasId = lastFxBushSpriteId++
                    });
                }
                else
                {
                    fxWalkDuration += 0.05f;
                }
            }

            for (int i = worldEffects.Count - 1; i > 0; i--)
            {
                VertexPositionTexture[] shadowGeom = Extended.GetShadowPlane(worldEffects[i].fxLocation +
                                                                             new Vector3(-2.2f, .1f, -2.2f), 12f * worldEffects[i].scale);

                Extended.ConvertToSprite(ref shadowGeom, 4, worldEffects[i].atlasId);

                Module_world_debug.ate.Texture = (Texture2D)Module_world_debug.wmset.GetWorldMapTexture(Wmset.Section38_textures.wmfx_bush,
                                                                                                        MathHelper.Clamp(GetLeavesFxClut(Module_world_debug.activeCollidePolygon), 0, 5)); //this is wrong
                Module_world_debug.ate.Alpha = 0.75f;
                foreach (EffectPass pass in Module_world_debug.ate.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    Module_world_debug.ate.GraphicsDevice.DepthStencilState = DepthStencilState.None;
                    Memory.Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, shadowGeom, 0, shadowGeom.Length / 3);
                }
                //ate.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                worldFx currentFx = worldEffects[i];
                currentFx.scale -= 0.005f;
                if (currentFx.scale < 0.8)
                {
                    worldEffects.RemoveAt(i);
                }
                else
                {
                    worldEffects[i] = currentFx;
                }
            }
        }