Exemple #1
0
        public override void DoCollide(bool x, bool y, bool z, Vector3 checkPosition, Hero gameHero, VoxelWorld gameWorld, bool withPlayer)
        {
            gameWorld.Explode(checkPosition, 5f);

            Die();

            base.DoCollide(x, y, z, checkPosition, gameHero, gameWorld, withPlayer);
        }
Exemple #2
0
        public override void DoCollide(bool x, bool y, bool z, Vector3 checkPosition, Hero gameHero, VoxelWorld gameWorld, bool withPlayer)
        {
            gameWorld.Explode(checkPosition, 5f);

            Die();

            base.DoCollide(x, y, z, checkPosition, gameHero, gameWorld, withPlayer);
        }
Exemple #3
0
        void CheckCollisions(Hero gameHero, VoxelWorld gameWorld)
        {
            Vector3 worldSpace;

            switch (Type)
            {
            case ProjectileType.Laser1:
            case ProjectileType.Laser2:
            case ProjectileType.Laser3:
            case ProjectileType.Laser4:
            case ProjectileType.Rocket:
                for (float d = 0f; d < 1f; d += 0.1f)
                {
                    if (!Active)
                    {
                        continue;
                    }

                    worldSpace = gameWorld.FromScreenSpace(Position + (d * ((Position + Speed) - Position)));
                    Voxel v = gameWorld.GetVoxel(Position + (d * ((Position + Speed) - Position)));

                    if (v.Active && Active)
                    {
                        if (v.Destructable >= 1 && Owner is Hero)
                        {
                            gameWorld.Explode(Position + (d * ((Position + Speed) - Position)), Type != ProjectileType.Rocket?3f:5f);
                            gameWorld.Explode((Position + (d * ((Position + Speed) - Position))) + new Vector3(0f, 0f, -3f), Type != ProjectileType.Rocket ? 3f : 5f);
                            gameWorld.Explode((Position + (d * ((Position + Speed) - Position))) + new Vector3(0f, 0f, 3f), Type != ProjectileType.Rocket ? 3f : 5f);

                            //gameWorld.SetVoxelActive((int)worldSpace.X, (int)worldSpace.Y, (int)worldSpace.Z, false);
                            //for (int i = 0; i < 4; i++) ParticleController.Instance.Spawn(Position, new Vector3(-0.05f + ((float)Helper.Random.NextDouble() * 0.1f), -0.05f + ((float)Helper.Random.NextDouble() * 0.1f), -((float)Helper.Random.NextDouble() * 0.5f)), 0.25f, new Color(v.SR, v.SG, v.SB), 1000, true);
                        }
                        Active = false;
                    }

                    if (Owner is Enemy)
                    {
                        if (!gameHero.Dead && gameHero.CollisionBox.Contains(Position + (d * ((Position + Speed) - Position))) == ContainmentType.Contains)
                        {
                            gameHero.DoHit(Position + (d * ((Position + Speed) - Position)), this);
                            Active = false;
                            if (Type == ProjectileType.Rocket)
                            {
                                ParticleController.Instance.SpawnExplosion(Position);
                            }
                        }
                    }

                    if (Owner is Hero)
                    {
                        foreach (Enemy e in EnemyController.Instance.Enemies.Where(en => en.Active))
                        {
                            if (e.boundingSphere.Contains(Position + (d * ((Position + Speed) - Position))) == ContainmentType.Contains)
                            {
                                e.DoHit(Position + (d * ((Position + Speed) - Position)), Speed, Damage); Active = false; if (Type == ProjectileType.Rocket)
                                {
                                    ParticleController.Instance.SpawnExplosion(Position);
                                }
                            }
                        }
                    }
                }
                break;
            }
        }
Exemple #4
0
        void CheckCollisions(Hero gameHero, VoxelWorld gameWorld)
        {
            Vector3 worldSpace;
            switch (Type)
            {
                case ProjectileType.Laser1:
                case ProjectileType.Laser2:
                case ProjectileType.Laser3:
                case ProjectileType.Laser4:
                case ProjectileType.Rocket:
                    for (float d = 0f; d < 1f; d += 0.1f)
                    {
                        if (!Active) continue;

                        worldSpace = gameWorld.FromScreenSpace(Position + (d * ((Position + Speed) - Position)));
                        Voxel v = gameWorld.GetVoxel(Position + (d * ((Position + Speed) - Position)));

                        if (v.Active && Active)
                        {
                            if (v.Destructable >= 1 && Owner is Hero)
                            {
                                gameWorld.Explode(Position + (d * ((Position + Speed) - Position)), Type!= ProjectileType.Rocket?3f:5f);
                                gameWorld.Explode((Position + (d * ((Position + Speed) - Position))) + new Vector3(0f, 0f, -3f), Type != ProjectileType.Rocket ? 3f : 5f);
                                gameWorld.Explode((Position + (d * ((Position + Speed) - Position))) + new Vector3(0f, 0f, 3f), Type != ProjectileType.Rocket ? 3f : 5f);

                                //gameWorld.SetVoxelActive((int)worldSpace.X, (int)worldSpace.Y, (int)worldSpace.Z, false);
                                //for (int i = 0; i < 4; i++) ParticleController.Instance.Spawn(Position, new Vector3(-0.05f + ((float)Helper.Random.NextDouble() * 0.1f), -0.05f + ((float)Helper.Random.NextDouble() * 0.1f), -((float)Helper.Random.NextDouble() * 0.5f)), 0.25f, new Color(v.SR, v.SG, v.SB), 1000, true);

                            }
                            Active = false;
                        }

                        if(Owner is Enemy)
                            if (!gameHero.Dead && gameHero.CollisionBox.Contains(Position + (d * ((Position + Speed) - Position))) == ContainmentType.Contains)
                            {
                                gameHero.DoHit(Position + (d * ((Position + Speed) - Position)), this);
                                Active = false;
                                if(Type== ProjectileType.Rocket) ParticleController.Instance.SpawnExplosion(Position);
                            }

                        if(Owner is Hero)
                            foreach (Enemy e in EnemyController.Instance.Enemies.Where(en => en.Active)) { if (e.boundingSphere.Contains(Position + (d * ((Position + Speed) - Position))) == ContainmentType.Contains) { e.DoHit(Position + (d * ((Position + Speed) - Position)), Speed, Damage); Active = false; if (Type == ProjectileType.Rocket) ParticleController.Instance.SpawnExplosion(Position); } }

                    }
                    break;
            }
        }