Ejemplo n.º 1
0
        //
        //  PineCone
        //

        public PineCone()
            : base(PineConeSRO.GetInstance)
        {
            classification = new Classification("pinecone",
                                                Classification.Colors.Red,
                                                Classification.Shapes.NotApplicable,
                                                Classification.Tastes.Sweet,
                                                Classification.Smells.Pleasant,
                                                Classification.Physicalities.Collectable);

            DynamicPropChassis dynChassis = new DynamicPropChassis();

            Chassis         = dynChassis;
            dynChassis.Mass = 0.2f;
            dynChassis.DefaultEditHeight        = 0.0f;
            dynChassis.CoefficientOfRestitution = 0.5f;

            collisionRadius = 0.2f;
        } // end of PineCone c'tor
        }   // end of Init()

        static public void Render(SmoothCamera camera)
        {
            // Only show these while running.
            if (InGame.inGame.CurrentUpdateMode != InGame.UpdateMode.RunSim)
            {
                return;
            }

            if (!initialized)
            {
                Init();
            }

            for (int i = 0; i < InGame.inGame.gameThingList.Count; i++)
            {
                GameActor actor = InGame.inGame.gameThingList[i] as GameActor;

                if (actor != null)
                {
                    if (actor.DisplayCurrentPage || InGame.DebugDisplayCurrentPage)
                    {
                        // Does actor have any kode?  If not, don't both with display.
                        if (actor.Brain.tasks[0].reflexes.Count > 0)
                        {
                            // Don't bother with first person actors.  We can't see the icon anyway.
                            if (!actor.FirstPerson)
                            {
                                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                                int       curPage = actor.Brain.ActiveTaskId; // Note this is 0 based.
                                Texture2D texture = GetTileForTask(curPage);
                                Debug.Assert(texture != null, "Bad id?");

                                // Use the same position as thought balloons.
                                // Orient to always face camera.
                                Vector3            position;
                                DynamicPropChassis chassis = actor.Chassis as DynamicPropChassis;
                                if (chassis != null && chassis.Tumbles)
                                {
                                    position = actor.HealthBarOffset + actor.Movement.Position + new Vector3(0, 0, -0.3f);
                                }
                                else
                                {
                                    position = actor.WorldThoughtBalloonOffset + new Vector3(0, 0, 0.5f);
                                }
                                Matrix world = Matrix.CreateBillboard(
                                    position,
                                    camera.ActualFrom,
                                    camera.ViewUp,
                                    camera.ViewDir);

                                // Borrow the thought balloon manager effect.
                                Effect effect = ThoughtBalloonManager.Effect;

                                Matrix worldViewProjMatrix = world * camera.ViewMatrix * camera.ProjectionMatrix;
                                effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix);
                                effect.Parameters["WorldMatrix"].SetValue(world);

                                effect.Parameters["ContentTexture"].SetValue(texture);

                                effect.Parameters["Size"].SetValue(size);
                                effect.Parameters["Alpha"].SetValue(1.0f);
                                effect.Parameters["BorderColor"].SetValue(Vector4.One);

                                device.SetVertexBuffer(vbuf);
                                device.Indices = UI2D.Shared.QuadIndexBuff;

                                // Render all passes.
                                for (int j = 0; j < effect.CurrentTechnique.Passes.Count; j++)
                                {
                                    EffectPass pass = effect.CurrentTechnique.Passes[j];
                                    pass.Apply();
                                    device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
                                }
                            }
                        }
                    }
                }
            }
        }   // end of Render()