Exemplo n.º 1
0
        void MakeHealthManaGumps()
        {
            mUIMats = new MatLib(mGD, mSKeeper);
            mUIMats.CreateMaterial("Text");
            mUIMats.SetMaterialEffect("Text", "2D.fx");
            mUIMats.SetMaterialTechnique("Text", "Text");

            mUI = new ScreenUI(mGD.GD, mUIMats, 16);

            Vector4 healthColour = Vector4.UnitX + Vector4.UnitW;
            Vector4 manaColour   = Vector4.UnitZ + Vector4.UnitW;

            mUI.AddGump("UI\\HMBubble", "HealthBubble", healthColour,
                        Vector2.UnitX * 20f + Vector2.UnitY * 520f,
                        Vector2.One * 1.5f);

            mUI.AddGump("UI\\HMBubble", "ManaBubble", manaColour,
                        Vector2.UnitX * 1070f + Vector2.UnitY * 520f,
                        Vector2.One * 1.5f);
        }
Exemplo n.º 2
0
        internal LightExplorer(GraphicsDevice gd, StuffKeeper sk)
        {
            mGD = gd;
            mSK = sk;

            mResX = gd.RendForm.ClientRectangle.Width;
            mResY = gd.RendForm.ClientRectangle.Height;

            mGD.eDeviceLost += OnDeviceLost;

            mEForm.Visible = true;
            mOForm.Visible = true;

            mEForm.eOpenGBSP += OnOpenGBSP;

            mFontMats = new MatLib(gd, sk);

            mFontMats.CreateMaterial("Text");
            mFontMats.SetMaterialEffect("Text", "2D.fx");
            mFontMats.SetMaterialTechnique("Text", "Text");

            mFonts = sk.GetFontList();

            mST  = new ScreenText(gd.GD, mFontMats, mFonts[0], 1000);
            mSUI = new ScreenUI(gd.GD, mFontMats, 100);

            mTextProj = Matrix.OrthoOffCenterLH(0, mResX, mResY, 0, 0.1f, 5f);

            Vector4 color = Vector4.UnitY + (Vector4.UnitW * 0.15f);

            mSUI.AddGump("UI\\CrossHair", "CrossHair", Vector4.One,
                         Vector2.UnitX * ((mResX / 2) - 16)
                         + Vector2.UnitY * ((mResY / 2) - 16),
                         Vector2.One);

            mST.AddString(mFonts[0], "Face Index: " + mFaceIndex, "FaceIndex",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 400f, Vector2.One);
            mST.AddString(mFonts[0], "Face aimed at: " + mFaceAimedAt, "FaceAimedAt",
                          color, Vector2.UnitX * 20f + Vector2.UnitY * 420f, Vector2.One);
        }
Exemplo n.º 3
0
        const float InvertIncrement = 0.01f;            //10ms


        internal Game(GraphicsDevice gd, string gameRootDir)
        {
            mGD          = gd;
            mGameRootDir = gameRootDir;
            mResX        = gd.RendForm.ClientRectangle.Width;
            mResY        = gd.RendForm.ClientRectangle.Height;

            mSKeeper = new StuffKeeper();

            mSKeeper.eCompileNeeded += SharedForms.ShaderCompileHelper.CompileNeededHandler;
            mSKeeper.eCompileDone   += SharedForms.ShaderCompileHelper.CompileDoneHandler;

            mSKeeper.Init(mGD, gameRootDir);

            mFontMats = new MatLib(gd, mSKeeper);
            mCPrims   = new CommonPrims(gd, mSKeeper);

            mFonts = mSKeeper.GetFontList();

            mFontMats.CreateMaterial("Text");
            mFontMats.SetMaterialEffect("Text", "2D.fx");
            mFontMats.SetMaterialTechnique("Text", "Text");

            mST  = new ScreenText(gd.GD, mFontMats, mFonts[0], 1000);
            mSUI = new ScreenUI(gd.GD, mFontMats, 100);

            mTextProj = Matrix.OrthoOffCenterLH(0, mResX, mResY, 0, 0.1f, 5f);

            //load avail static stuff
            if (Directory.Exists(mGameRootDir + "/Statics"))
            {
                DirectoryInfo di = new DirectoryInfo(mGameRootDir + "/Statics");

                FileInfo[] fi = di.GetFiles("*.MatLib", SearchOption.TopDirectoryOnly);

                if (fi.Length > 0)
                {
                    mStaticMats = new MatLib(gd, mSKeeper);
                    mStaticMats.ReadFromFile(fi[0].DirectoryName + "\\" + fi[0].Name);

                    mStaticMats.InitCelShading(1);
                    mStaticMats.GenerateCelTexturePreset(gd.GD,
                                                         (gd.GD.FeatureLevel == FeatureLevel.Level_9_3),
                                                         false, 0);
                    mStaticMats.SetCelTexture(0);
                    mKeeper.AddLib(mStaticMats);
                }

                mStatics = Mesh.LoadAllStaticMeshes(mGameRootDir + "\\Statics", gd.GD);

                foreach (KeyValuePair <string, IArch> arch in mStatics)
                {
                    arch.Value.UpdateBounds();
                }

                fi = di.GetFiles("*.StaticInstance", SearchOption.TopDirectoryOnly);
                foreach (FileInfo f in fi)
                {
                    string archName = FileUtil.StripExtension(f.Name);
                    if (archName.Contains('_'))
                    {
                        archName = archName.Substring(0, f.Name.IndexOf('_'));
                    }

                    archName += ".Static";

                    if (!mStatics.ContainsKey(archName))
                    {
                        continue;
                    }

                    StaticMesh sm = new StaticMesh(mStatics[archName]);

                    sm.ReadFromFile(f.DirectoryName + "\\" + f.Name);

                    mMeshes.Add(sm);

                    sm.UpdateBounds();
                    sm.SetMatLib(mStaticMats);
                    Vector3 randPos = Mathery.RandomPosition(mRand,
                                                             Vector3.UnitX * 100f +
                                                             Vector3.UnitZ * 100f);
                    mMeshPositions.Add(randPos);
                    mMeshRotations.Add(Vector3.Zero);
                    mMeshScales.Add(Vector3.One);
                    UpdateStaticTransform(mMeshes.Count - 1);
                }
                AddStaticCollision();
            }

            //skip hair stuff when computing bone bounds
            //hits to hair usually wouldn't activate much
            List <string> skipMats = new List <string>();

            skipMats.Add("Hair");

            //load character stuff if any around
            if (Directory.Exists(mGameRootDir + "/Characters"))
            {
                DirectoryInfo di = new DirectoryInfo(mGameRootDir + "/Characters");

                FileInfo[] fi = di.GetFiles("*.AnimLib", SearchOption.TopDirectoryOnly);
                if (fi.Length > 0)
                {
                    mCharAnims = new AnimLib();
                    mCharAnims.ReadFromFile(fi[0].DirectoryName + "\\" + fi[0].Name);

                    List <Anim> anims = mCharAnims.GetAnims();
                    foreach (Anim a in anims)
                    {
                        mAnims.Add(a.Name);
                    }
                }

                fi = di.GetFiles("*.MatLib", SearchOption.TopDirectoryOnly);
                if (fi.Length > 0)
                {
                    mCharMats = new MatLib(mGD, mSKeeper);
                    mCharMats.ReadFromFile(fi[0].DirectoryName + "\\" + fi[0].Name);
                    mCharMats.InitCelShading(1);
                    mCharMats.GenerateCelTexturePreset(gd.GD,
                                                       gd.GD.FeatureLevel == FeatureLevel.Level_9_3, false, 0);
                    mCharMats.SetCelTexture(0);
                    mKeeper.AddLib(mCharMats);
                }

                fi = di.GetFiles("*.Character", SearchOption.TopDirectoryOnly);
                foreach (FileInfo f in fi)
                {
                    IArch arch = new CharacterArch();
                    arch.ReadFromFile(f.DirectoryName + "\\" + f.Name, mGD.GD, true);

                    mCharArchs.Add(FileUtil.StripExtension(f.Name), arch);
                }

                fi = di.GetFiles("*.CharacterInstance", SearchOption.TopDirectoryOnly);
                foreach (FileInfo f in fi)
                {
                    string archName = f.Name;
                    if (archName.Contains('_'))
                    {
                        archName = f.Name.Substring(0, f.Name.IndexOf('_'));
                    }

                    if (!mCharArchs.ContainsKey(archName))
                    {
                        continue;
                    }

                    Character c = new Character(mCharArchs[archName], mCharAnims);

                    //map this to an arch
                    mCharToArch.Add(c, mCharArchs[archName]);

                    c.ReadFromFile(f.DirectoryName + "\\" + f.Name);

                    c.SetMatLib(mCharMats);

                    c.SetTransform(Matrix.Translation(
                                       Mathery.RandomPosition(mRand,
                                                              Vector3.UnitX * 100f +
                                                              Vector3.UnitZ * 100f)));

                    c.ComputeBoneBounds(skipMats);

                    c.AutoInvert(true, mInvertInterval);

                    mCharacters.Add(c);
                }

                if (mCharacters.Count > 0)
                {
                    mAnimTimes = new float[mCharacters.Count];
                    mCurAnims  = new int[mCharacters.Count];
                    mCBone     = new int[mCharacters.Count];
                    mCBones    = new Dictionary <int, Matrix> [mCharacters.Count];
                }

                foreach (KeyValuePair <string, IArch> arch in mCharArchs)
                {
                    //build draw data for bone bounds
                    (arch.Value as CharacterArch).BuildDebugBoundDrawData(mGD.GD, mCPrims);
                }
            }

            //typical material group for characters
            //or at least it works with the ones
            //I have right now
            //TODO: way to define these in the asset?
            List <string> skinMats = new List <string>();

            skinMats.Add("Face");
            skinMats.Add("Skin");
            skinMats.Add("EyeWhite");
            skinMats.Add("EyeLiner");
            skinMats.Add("IrisLeft");
            skinMats.Add("PupilLeft");
            skinMats.Add("IrisRight");
            skinMats.Add("PupilRight");
            skinMats.Add("Nails");
            mKeeper.AddMaterialGroup("SkinGroup", skinMats);

            mTextColor  = Vector4.UnitY + (Vector4.UnitW * 0.15f);
            mHitColor   = Vector4.One * 0.9f;
            mHitColor.Y = mHitColor.Z = 0f;

            mSUI.AddGump("UI\\CrossHair", "CrossHair", Vector4.One,
                         Vector2.UnitX * ((mResX / 2) - 16)
                         + Vector2.UnitY * ((mResY / 2) - 16),
                         Vector2.One);

            //string indicators for various statusy things
            mST.AddString(mFonts[0], "", "StaticStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 460f, Vector2.One);
            mST.AddString(mFonts[0], "", "InvertStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 480f, Vector2.One);
            mST.AddString(mFonts[0], "", "AnimStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 500f, Vector2.One);
            mST.AddString(mFonts[0], "", "CharStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 520f, Vector2.One);
            mST.AddString(mFonts[0], "", "PosStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 540f, Vector2.One);
            mST.AddString(mFonts[0], "", "HitStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 560f, Vector2.One);
            mST.AddString(mFonts[0], "", "ThreadStatus",
                          mTextColor, Vector2.UnitX * 20f + Vector2.UnitY * 580f, Vector2.One);

            UpdateCAStatus();
            UpdateInvertStatus();
            UpdateStaticStatus();
        }