コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            DebugShapeRenderer.Initialize(GraphicsDevice);
            listaTanques = new List <Tank>();
            Create3DAxis.Initialize(GraphicsDevice);
            base.Initialize();
        }
コード例 #2
0
        public void Draw(Matrix cameraView, Matrix cameraProjection)
        {
            bulletModel.Root.Transform = world;
            DebugShapeRenderer.AddBoundingSphere(boundingSphere, Color.Red);
            view       = cameraView;
            projection = cameraProjection;

            // Draw the model.
            foreach (ModelMesh mesh in bulletModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World      = bulletModel.Root.Transform;
                    effect.View       = view;
                    effect.Projection = projection;

                    effect.EnableDefaultLighting();
                }
                mesh.Draw();
            }
        }
コード例 #3
0
        private void IAControl(Vector3 playerPosition, List <Tank> listaParceiros)
        {
            verificarLimites(posicaoAnterior);

            Vector3 desvioDeParceiro = IA.GerirDistancia(listaParceiros, this);

            desvioDeParceiro = desvioDeParceiro * velocidade;
            Vector3 acelaracaoDesvioParceiro = (desvioDeParceiro - direcao) * velocidadeMaxima;

            Vector3 direcaoPlayer = playerPosition - position;

            direcaoPlayer = direcaoPlayer * velocidade;
            acelaracao    = (direcaoPlayer - direcao) * velocidadeMaxima;

            //se a direcao desejada for o player
            if (desvioDeParceiro == Vector3.Zero)
            {
                direcao = direcao + acelaracao;
            }
            //se a direcao desejada for fugir do parceiro
            else
            {
                direcao = direcao + acelaracaoDesvioParceiro;
            }

            //DebugShapeRenderer.AddLine(this.position, this.position + desvioDeParceiro,Color.Yellow);
            position += Vector3.Normalize(direcao) * velocidade;

            position.Y = newAltura;
            world      = Matrix.CreateScale(scale) * Matrix.CreateTranslation(position);
            Vector3 newRigth  = Vector3.Cross(newNormal, direcao);
            Matrix  rotacaoUp = Matrix.CreateWorld(position, Vector3.Cross(newNormal, newRigth), newNormal);

            world = Matrix.CreateScale(scale) * rotacaoUp;
            DebugShapeRenderer.AddLine(this.position + new Vector3(0, 1, 0), (this.position + new Vector3(0, 1, 0)) + this.direcao * 4, Color.Red);
            posicaoAnterior = this.position;
        }