Exemplo n.º 1
0
        public ShootingTarget(Vector3 position, Vector3 rotation, ShootingTargetType type,
                              SoundEffect shotSFX, SoundEffect knockdownSFX)
        {
            isActive   = true;
            targetType = type;

            this.shotSFX      = shotSFX;
            this.knockdownSFX = knockdownSFX;
            sfxVolume         = 0.75f;

            slidingDirection  = new Vector3(maxMovement, 0.0f, 0.0f);
            shiftingDirection = new Vector3(0.0f, 0.0f, maxMovement);

            initialPosition  = position;
            initialRotation  = rotation;
            animationSpeed   = 3.0f;
            runFallAnimation = false;

            // Skew starting time for randomized animations
            totalTime = (float)rand.NextDouble() * 10.0f;

            // Load the target mesh
            targetMesh                = MeshManager.LoadMesh("target.m3d");
            targetMesh.Position       = position;
            targetMesh.RotationAngles = rotation;
            targetMesh.Scale          = 3.0f;
        }
Exemplo n.º 2
0
        private void ConvertToShooterLevel()
        {
            // Get all targets in the mesh list and create shooting target objects
            // from them
            Predicate <Mesh> isSecretItem = (Mesh m) => m.MeshFileName == SECRET_ITEM_MESH_NAME;
            Predicate <Mesh> isTarget     = (Mesh m) => m.MeshFileName == SHOOTING_TARGET_MESH_NAME;
            List <Mesh>      targets      = new List <Mesh>();

            foreach (Mesh mesh in meshList)
            {
                if (isTarget(mesh))
                {
                    targets.Add(mesh);
                }
                else if (isSecretItem(mesh))
                {
                    secretItem = mesh;
                }
            }

            // Add shooting targets for each target mesh
            foreach (Mesh target in targets)
            {
                // Target type is determined by mesh size in file
                ShootingTargetType targetType = ShootingTargetType.Stationary;
                if (target.Scale == TARGET_TYPE_SCALE_STATIONARY)
                {
                    targetType = ShootingTargetType.Stationary;
                }
                else if (target.Scale == TARGET_TYPE_SCALE_SLIDING)
                {
                    targetType = ShootingTargetType.Sliding;
                }
                else if (target.Scale == TARGET_TYPE_SCALE_SHIFTING)
                {
                    targetType = ShootingTargetType.Shifting;
                }

                ShootingTarget shootingTarget = new ShootingTarget(target.Position,
                                                                   target.RotationAngles, targetType, targetHitSFX, targetKnockdownSFX);

                // Add the new shooting target
                shootingTargetList.Add(shootingTarget);
            }

            // Remove the targets from the mesh list
            List <Mesh> copyMeshList = new List <Mesh>(meshList);

            foreach (Mesh mesh in copyMeshList)
            {
                if (isTarget(mesh))
                {
                    meshList.Remove(mesh);
                }
            }
        }