Inheritance: Component
示例#1
0
        public override void Update(GameTime gameTime)
        {
            _input.Update();
            gunPrimary.Update(gameTime);
            gunSecondary.Update(gameTime);

            Spheres = Collider3D.UpdateBoundingSphere(this);

            if (gameTime.TotalGameTime > (_shieldrefreshdelay.Add(TimeSpan.FromSeconds(3))))
            {
                if (shield == _shieldpast)
                {
                    _wasDamaged = false;
                }
                _shieldpast         = shield;
                _shieldrefreshdelay = gameTime.TotalGameTime;
            }
            if (_wasDamaged == false && shield < maxShield)
            {
                shield += 1;
            }

            if (health <= 0 || Vector2.Distance(new Vector2(Position.X, Position.Z), Vector2.Zero) > maxRange)
            {
                IsNotDead = false;
            }
        }
示例#2
0
        public virtual void Draw(Color entityColor)
        {
            if (Collider3D.BoundingFrustumIntersection(this))
            {
                foreach (var mesh in Model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();

                        effect.DiffuseColor  = entityColor.ToVector3();
                        effect.SpecularColor = entityColor.ToVector3();

                        effect.DirectionalLight0.Enabled       = true;
                        effect.DirectionalLight0.DiffuseColor  = Color.LightGoldenrodYellow.ToVector3();                // a light
                        effect.DirectionalLight0.Direction     = Vector3.Normalize(Position - new Vector3(0, 1000, 0)); // coming along the x-axis
                        effect.DirectionalLight0.SpecularColor = Color.DarkGoldenrod.ToVector3();                       // with highlights

                        effect.PreferPerPixelLighting = true;

                        RotationMatrix    = Matrix.CreateWorld(Position, RotationMatrix.Forward, Vector3.Up);
                        effect.World      = RotationMatrix * Matrix.CreateScale(Scale);
                        effect.View       = Global.Camera.ViewMatrix;
                        effect.Projection = Global.Camera.ProjectionMatrix;

                        World = effect.World;
                    }
                    mesh.Draw();
                }
            }
        }
示例#3
0
 void OnTriggerEnter3D(Collider3D trigger)
 {
     if (trigger.gameObject.CompareTag("obstacle"))
     {
         col = true;
     }
 }
示例#4
0
        public Bullet(BulletType bulletType, Model model, float moveSpeed, bool canDamageStation, int damage, Vector3 position, Vector3 direction)
        {
            Model          = model;
            Position       = position;
            Spheres        = Collider3D.UpdateBoundingSphere(this);
            RotationMatrix = Matrix.CreateWorld(position, direction, Vector3.Up);

            _bulletType     = bulletType;
            _makeDmg        = damage;
            _canDmgStation  = canDamageStation;
            _bulletLifeTime = 25000;
            _moveDirection  = direction;
            _moveSpeed      = moveSpeed;
            if (bulletType == BulletType.BigJoe)
            {
                _trail = new Trail(new BombTrailSettings());
            }
            if (bulletType == BulletType.PhotonBomb)
            {
                _trail = new Trail(new BomberBombTrailSettings());
            }
            if (bulletType == BulletType.BossGun)
            {
                _trail = new Trail(new BomberBombTrailSettings());
            }
        }
示例#5
0
 public override void LoadContent()
 {
     Model   = Global.ContentManager.Load <Model>("Models/drone");
     Spheres = Collider3D.UpdateBoundingSphere(this);
     gunPrimary.LoadContent();
     gunSecondary.LoadContent();
     //RotationMatrix = Matrix.CreateRotationX();
 }
示例#6
0
 public override void Update(GameTime gameTime)
 {
     Spheres = Collider3D.UpdateBoundingSphere(this);
     Gun.Update(gameTime);
     if (Health <= 0)
     {
         IsDead = true;
     }
 }
示例#7
0
 public override void LoadContent(Model model)
 {
     Model   = model;
     Spheres = Collider3D.UpdateBoundingSphere(this);
     Gun.LoadContent();
     foreach (var tower in towerList)
     {
         tower.LoadContent();
     }
 }
示例#8
0
 public override void LoadContent()
 {
     Model   = Global.ContentManager.Load <Model>("Models/station");
     Spheres = Collider3D.UpdateBoundingSphere(this);
     Gun.LoadContent();
     for (int i = 0; i < Spheres.Length; i++)
     {
         Spheres[i].Radius = Spheres[i].Radius * 0.75f;
     }
 }
示例#9
0
 public override void Update(GameTime gameTime)
 {
     if (Health <= 0)
     {
         IsDead = true;
     }
     Gun.Update(gameTime);
     Spheres = Collider3D.UpdateBoundingSphere(this);
     //TODO: health, armor update
 }
示例#10
0
 public override void Update(GameTime gameTime)
 {
     _angle        += 0.005f;
     RotationMatrix = Matrix.CreateRotationY(_angle);
     Spheres        = Collider3D.UpdateBoundingSphere(this);
     for (int i = 0; i < Spheres.Length; i++)
     {
         Spheres[i].Radius = Spheres[i].Radius * 0.8f;
     }
     Position += _direction * _speed;
 }
示例#11
0
        /// <summary>
        /// Creates a new Model
        /// </summary>
        /// <param name="position">model initial position</param>
        /// <param name="model">the model mesh</param>
        /// <param name="collider">the model collider</param>
        private void CreateModel(Vector3 position, Model model, Collider3D collider)
        {
            Entity primitive = new Entity()
               .AddComponent(new Transform3D() { Position = position })
               .AddComponent(collider)
               .AddComponent(model)
               .AddComponent(new RigidBody3D())
               .AddComponent(new MaterialsMap() { DefaultMaterialPath = WaveContent.Assets.basicMaterial })
               .AddComponent(new ModelRenderer());

            this.EntityManager.Add(primitive);
        }
示例#12
0
        /// <summary>
        /// Update method
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(TimeSpan gameTime)
        {
            touchPanelState = WaveServices.Input.TouchPanelState;
            bestValue       = float.MaxValue;
            if (touchPanelState.IsConnected && touchPanelState.Count > 0)
            {
                // Calculate the ray
                CalculateRay();

                // Look for all entities in the game...
                for (int i = 0; i < EntityManager.Count; i++)
                {
                    currentEntity = EntityManager.EntityGraph.ElementAt(i);;

                    entityCollider = currentEntity.FindComponent <Collider3D>(false);
                    // ... but only a collidable entities ( entities which have a boxCollider component)
                    if (entityCollider != null)
                    {
                        if (entityCollider is BoxCollider3D)
                        {
                            // Intersect our calculated ray with the entity's boxCollider
                            collisionResult = (entityCollider as BoxCollider3D).Intersects(ref ray);
                        }
                        else if (entityCollider is SphereCollider3D)
                        {
                            collisionResult = (entityCollider as SphereCollider3D).Intersects(ref ray);
                        }

                        // If any collision
                        if (collisionResult.HasValue)
                        {
                            // Check the distance. We want to have the closer to the screen entity, so we want to get the low collisionResult value
                            if (collisionResult.Value < bestValue)
                            {
                                // Send to the scene the new entity picked name
                                if (this.myScene != null)
                                {
                                    this.myScene.ShowPickedEntity(currentEntity.Name);
                                }
                                bestValue = collisionResult.Value;
                            }
                        }
                    }
                }
            }
            else
            {
                if (this.myScene != null)
                {
                    this.myScene.ShowPickedEntity("None");
                }
            }
        }
示例#13
0
 public override void Update(GameTime gameTime)
 {
     if (Health <= 0)
     {
         IsDead = true;
     }
     if (_boss.IsDead)
     {
         this.IsDead = true;
     }
     Spheres = Collider3D.UpdateBoundingSphere(this);
 }
示例#14
0
        /// <summary>
        /// Creates a new Model
        /// </summary>
        /// <param name="position">model initial position</param>
        /// <param name="model">the model mesh</param>
        /// <param name="collider">the model collider</param>
        private void CreateModel(Vector3 position, Model model, Collider3D collider)
        {
            Entity primitive = new Entity()
                               .AddComponent(new Transform3D()
            {
                Position = position
            })
                               .AddComponent(collider)
                               .AddComponent(model)
                               .AddComponent(new RigidBody3D())
                               .AddComponent(new MaterialsMap())
                               .AddComponent(new ModelRenderer());

            this.EntityManager.Add(primitive);
        }
示例#15
0
        private void Collide(GameTime gameTime)
        {
            var aremoveList = new List <Asteroid>();
            var bremoveList = new List <Projectile>();

            foreach (var asteroid in _asteroids.AsteroidList)
            {
                foreach (var bullet in _bulletList)
                {
                    if (bullet.Position.X < -200)
                    {
                        bremoveList.Add(bullet);
                        continue;
                    }

                    if (asteroid.Model != null)
                    {
                        if (Collider3D.Intersection(bullet, asteroid))
                        {
                            aremoveList.Add(asteroid);
                            bremoveList.Add(bullet);
                            _score += 1;
                        }
                    }
                }
            }
            foreach (var asteroid in _asteroids.AsteroidList)
            {
                if (Collider3D.Intersection(_ship, asteroid))
                {
                    aremoveList.Add(asteroid);
                    _health -= 5;
                    _hit.Play(0.2f, 0f, 0);
                }
            }

            foreach (var ast in aremoveList)
            {
                _asteroids.AsteroidList.Remove(ast);
            }
            foreach (var bullet in bremoveList)
            {
                _bulletList.Remove(bullet);
            }
        }
        /// <inheritdoc/>
        protected override bool OnAttached()
        {
            if (!Application.Current.IsEditor)
            {
                if (this.physicBody3D == null)
                {
                    this.physicBody3D = new StaticBody3D();
                    this.Owner.AddComponent(this.physicBody3D);
                }

                if (this.collider == null)
                {
                    this.collider = new BoxCollider3D();
                    this.Owner.AddComponent(this.collider);
                }
            }

            return(base.OnAttached());
        }
示例#17
0
        public override void Update(GameTime gameTime)
        {
            if (Health <= 0)
            {
                IsDead = true;
            }
            Spheres = Collider3D.UpdateBoundingSphere(this);
            Gun.Update(gameTime);
            _compositionRec.Center = Position;
            towerList[0].Position  = _compositionRec.EdgeBottomLeft;
            towerList[1].Position  = _compositionRec.EdgeBottomRight;
            towerList[2].Position  = _compositionRec.EdgeTopLeft;
            towerList[3].Position  = _compositionRec.EdgeTopRight;

            foreach (AttackTower tower in towerList)
            {
                tower.RotateTowards(tower.Position - Global.Camera.Position);
                tower.Gun.Update(gameTime);
            }
        }
        /// <inheritdoc/>
        protected override void Start()
        {
            var assetsService = Application.Current.Container.Resolve <AssetsService>();

            if (!Application.Current.IsEditor)
            {
                this.gazePointerTransform = new Transform3D();
                this.gazePointerCollider  = new SphereCollider3D()
                {
                    Radius = this.Radius
                };
                var gazePointerEntity = new Entity("GazePointer")
                                        .AddComponent(this.gazePointerTransform)
                                        .AddComponent(this.gazePointerCollider);

                if (this.HasHoverLight)
                {
                    gazePointerEntity.AddComponent(new HoverLight()
                    {
                        Radius = this.Radius, Color = this.Color
                    });
                }

                this.Managers.EntityManager.Add(gazePointerEntity);

                this.xrPlatform = Application.Current.Container.Resolve <XRPlatform>();
                if (this.xrPlatform != null)
                {
                    IVoiceCommandService voiceCommandService = Application.Current.Container.Resolve <IVoiceCommandService>();
                    if (voiceCommandService != null)
                    {
                        voiceCommandService.CommandRecognized += this.VoiceCommandService_CommandRecognized;
                    }
                }
            }
        }
示例#19
0
 public override void Update(GameTime gameTime)
 {
     Spheres          = Collider3D.UpdateBoundingSphere(this);
     Position        -= _moveDirection * _moveSpeed;
     _bulletLifeTime -= gameTime.ElapsedGameTime.Milliseconds;
 }
示例#20
0
        //#################################
        // Collision
        //#################################
        void CollisionHandling(GameTime gameTime)
        {
            //remove lists for collisions etc
            List <Asteroid>       _removeAsteroid          = new List <Asteroid>();
            List <Bullet>         _removeBullets           = new List <Bullet>();
            List <BoundingSphere> explosionBoundingSpheres = new List <BoundingSphere>();

            /* bullet of drone with enemy ships */
            foreach (var bullet in _droneFleet._bulletList)
            {
                foreach (var ship in _waveBuilder.ShipList)
                {
                    if (Collider3D.IntersectionSphere(bullet, ship))
                    {
                        if (bullet._bulletType == Bullet.BulletType.BigJoe)
                        {
                            explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), ship.Position, 0.4, 50, true));
                            BoundingSphere curBoundingSphere = new BoundingSphere();
                            curBoundingSphere.Center = bullet.Position;
                            curBoundingSphere.Radius = 45;
                            explosionBoundingSpheres.Add(curBoundingSphere);
                        }
                        ship.getHit(bullet.makeDmg);
                        _removeBullets.Add(bullet);
                        Global.HighScorePoints += 20;
                        if (ship.Health > 0)
                        {
                            PlayShipHitSound(new Vector3D(ship.Position.X, ship.Position.Y, ship.Position.Z));
                            hitmarkerParticles.AddParticle(bullet.Position, Vector3.Zero);
                        }
                        else if (ship.Health <= 0)
                        {
                            if (ship.GetType() == typeof(EnemyBomber))
                            {
                                explosionList.Add(new ExplosionSystem(new ShipBigExplosionSettings(), new ShipRingExplosionSettings(), ship.Position, 0.4, 50, true));
                            }
                            else
                            {
                                explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), new ShipRingExplosionSettings(), ship.Position, 0.4, 30));
                            }
                            PlayExplosionSound(new Vector3D(bullet.Position.X, bullet.Position.Y, bullet.Position.Z));
                        }
                        break;
                    }
                }
            }



            /* bullet of enemy ships with drone and station */
            foreach (var bullet in _waveBuilder.BulletList)
            {
                if (Collider3D.IntersectionSphere(bullet, _droneFleet.GetActiveDrone()))
                {
                    _droneFleet.GetActiveDrone().getHit(bullet.makeDmg);
                    if (bullet._bulletType == Bullet.BulletType.BossGun)
                    {
                        explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), bullet.Position, 0.6, 50, true));
                    }
                    _removeBullets.Add(bullet);
                }

                if (bullet.CanDamageStation && Collider3D.IntersectionSphere(bullet, _station))
                {
                    _sphereAlpha = 0.2f;
                    explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), bullet.Position, 0.4));
                    _station.getHit(bullet.makeDmg);
                    if (bullet._bulletType == Bullet.BulletType.BossGun)
                    {
                        explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), bullet.Position, 0.6, 50, true));
                    }
                    _removeBullets.Add(bullet);
                }
            }

            /* asteroids with drone(& its bullets) & station & other asteroids & enemy ships (& its bullets)*/
            foreach (var ast in _asteroidField._asteroidList)
            {
                if (Vector3.Distance(ast.Position, _station.Position) > Global.MapDespawnRadius)
                {
                    explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, 0.4));
                    _removeAsteroid.Add(ast);
                    continue;
                }
                if (Collider3D.IntersectionSphere(ast, _droneFleet.GetActiveDrone()))
                {
                    _droneFleet.GetActiveDrone().getHit(5);
                    dustParticles.AddParticle(ast.Position, Vector3.Zero);
                    _removeAsteroid.Add(ast);
                    Global.HighScorePoints -= 50;
                    PlayAstExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));
                    continue;
                }
                if (Collider3D.IntersectionSphere(_station, ast))
                {
                    _sphereAlpha = 0.2f;
                    explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, 0.4));
                    ast.IsDead = true;
                    _removeAsteroid.Add(ast);
                    _station.getHit(100);
                    PlayAstExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));
                    continue;
                }
                foreach (var ast2 in _asteroidField._asteroidList)
                {
                    if (ast != ast2 && Collider3D.IntersectionSphere(ast2, ast))
                    {
                        var newDirection = new Vector3();
                        ast.Reflect(ast2.Direction, ast2.Spheres[0].Center, out newDirection);
                        ast2.Direction = newDirection;
                        dustParticles.AddParticle(ast.Position, Vector3.Zero);
                    }
                }
                foreach (var ship in _waveBuilder.ShipList)
                {
                    if (Collider3D.IntersectionSphere(ast, ship))
                    {
                        dustParticles.AddParticle(ship.Position, Vector3.Zero);
                        _removeAsteroid.Add(ast);
                    }
                }
                foreach (var bullet in _waveBuilder.BulletList)
                {
                    if (Collider3D.IntersectionSphere(bullet, ast))
                    {
                        explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, 0.35));
                        _removeAsteroid.Add(ast);
                        _removeBullets.Add(bullet);
                        break;
                    }
                }
                foreach (var bullet in _droneFleet._bulletList)
                {
                    if (Collider3D.IntersectionSphere(bullet, ast))
                    {
                        explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, 0.35));
                        _removeAsteroid.Add(ast);
                        _removeBullets.Add(bullet);
                        Global.HighScorePoints += 50;
                        PlayAstExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));

                        if (bullet._bulletType == Bullet.BulletType.BigJoe)
                        {
                            explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), ast.Position, 0.6, 50, true));
                            BoundingSphere curBoundingSphere = new BoundingSphere();
                            curBoundingSphere.Center = bullet.Position;
                            curBoundingSphere.Radius = 45;
                            explosionBoundingSpheres.Add(curBoundingSphere);
                        }
                        if (ast.IsShiny)
                        {
                            Global.Money += 200;
                        }
                        break;
                    }
                }
            }

            /* AoE explosions */
            foreach (var explosion in explosionBoundingSpheres)
            {
                foreach (var ast in _asteroidField._asteroidList)
                {
                    if (Collider3D.IntersectionSphere(ast, explosion))
                    {
                        explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, 0.35));
                        _removeAsteroid.Add(ast);
                        Global.HighScorePoints += 50;
                        PlayAstExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));

                        if (ast.IsShiny)
                        {
                            Global.Money += 200;
                        }
                    }
                }

                foreach (var ship in _waveBuilder.ShipList)
                {
                    if (Collider3D.IntersectionSphere(ship, explosion))
                    {
                        ship.getHit(80 * (_droneFleet.GetActiveDrone().makeDmg / 10));
                        Global.HighScorePoints += 20;
                        if (ship.Health > 0)
                        {
                            PlayShipHitSound(new Vector3D(ship.Position.X, ship.Position.Y, ship.Position.Z));
                            hitmarkerParticles.AddParticle(ship.Position, Vector3.Zero);
                        }
                        else if (ship.Health <= 0)
                        {
                            if (ship.GetType() == typeof(EnemyBomber))
                            {
                                explosionList.Add(new ExplosionSystem(new ShipBigExplosionSettings(), new ShipRingExplosionSettings(), ship.Position, 0.4, 50, true));
                            }
                            else
                            {
                                explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), new ShipRingExplosionSettings(), ship.Position, 0.4, 30));
                            }
                            PlayExplosionSound(new Vector3D(ship.Position.X, ship.Position.Y, ship.Position.Z));
                        }
                    }
                }
            }
            foreach (var ast in _removeAsteroid)
            {
                _asteroidField._asteroidList.Remove(ast);
            }

            foreach (var bullet in _removeBullets)
            {
                _droneFleet._bulletList.Remove(bullet);
                _waveBuilder.BulletList.Remove(bullet);
            }
        }
示例#21
0
 public virtual void LoadContent(Model model)
 {
     Model   = model;
     Spheres = Collider3D.UpdateBoundingSphere(this);
     Gun.LoadContent();
 }
示例#22
0
        //#################################
        // Collision
        //#################################
        void CollisionHandling(GameTime gameTime)
        {
            //remove lists for collisions etc
            List <Asteroid> _removeAsteroid = new List <Asteroid>();
            List <Bullet>   _removeBullets  = new List <Bullet>();

            /* asteroids with drone(& its bullets) & station & other asteroids & enemy ships (& its bullets)*/
            foreach (var ast in _asteroidField._asteroidList)
            {
                if (Vector3.Distance(ast.Position, _station.Position) > Global.MapDespawnRadius)
                {
                    explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, _duration));
                    _removeAsteroid.Add(ast);
                    continue;
                }

                if (Collider3D.IntersectionSphere(ast, _droneFleet.GetActiveDrone()))
                {
                    _droneFleet.GetActiveDrone().getHit(5);
                    dustParticles.AddParticle(ast.Position, Vector3.Zero);
                    _removeAsteroid.Add(ast);

                    PlayExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));
                    continue;
                }

                if (Collider3D.IntersectionSphere(_station, ast))
                {
                    explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, _duration));
                    ast.IsDead = true;
                    _removeAsteroid.Add(ast);
                    _station.getHit(10);
                    continue;
                }

                foreach (var ast2 in _asteroidField._asteroidList)
                {
                    if (ast != ast2 && Collider3D.IntersectionSphere(ast2, ast))
                    {
                        var newDirection = new Vector3();
                        ast.Reflect(ast2.Direction, ast2.Spheres[0].Center, out newDirection);
                        ast2.Direction = newDirection;
                        dustParticles.AddParticle(ast.Position, Vector3.Zero);
                        //ast.Position += ast.Direction * (2 * ((float)random.NextDouble()) * ast.MaxRadius() + ast.MaxRadius());
                    }
                }
                foreach (var bullet in _droneFleet._bulletList)
                {
                    if (Collider3D.IntersectionSphere(bullet, ast))
                    {
                        explosionList.Add(new ExplosionSystem(new AsteroidExplosionSettings(), ast.Position, _duration));
                        _removeAsteroid.Add(ast);
                        _removeBullets.Add(bullet);

                        PlayExplosionSound(new Vector3D(ast.Position.X, ast.Position.Y, ast.Position.Z));
                        if (bullet._bulletType == Bullet.BulletType.BigJoe)
                        {
                            explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), ast.Position, _duration, 50, true));
                        }
                        if (ast.IsShiny)
                        {
                            Global.Money += 200;
                        }
                        break;
                    }
                }
            }

            foreach (var ast in _removeAsteroid)
            {
                _asteroidField._asteroidList.Remove(ast);
            }

            foreach (var bullet in _removeBullets)
            {
                _droneFleet._bulletList.Remove(bullet);
            }
        }
示例#23
0
 public override void LoadContent()
 {
     Spheres = Collider3D.UpdateBoundingSphere(this);
 }
示例#24
0
 public override void LoadContent()
 {
     Model   = Global.ContentManager.Load <Model>("Models/laser");
     Spheres = Collider3D.UpdateBoundingSphere(this);
     Gun.LoadContent();
 }