コード例 #1
0
ファイル: GasStation.cs プロジェクト: MattVitelli/Nosferatu
        public GasStation(Scene scene)
        {
            Model gasStation = new Model("GasStation");

            (scene.MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.GasStation, gasStation.Transformation, gasStation.GetMesh().GetBounds());
            //powerPlant.Transformation.SetPosition(powerPlant.Transformation.GetPosition()-Vector3.Up*94);
            Vector3 pos = gasStation.Transformation.GetPosition();
            gasStationTransform = gasStation.Transformation;
            AnimationNode[] nodes = gasStation.GetMesh().GetNodes();
            Matrix worldMatrix = gasStation.Transformation.GetTransform();

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(gasStation.Transformation.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            scene.AddEntity("SafeTrigger", campTrigger);

            //Vector3 meshCenter = 0.5f * (gasStation.GetMesh().GetBounds().Max + gasStation.GetMesh().GetBounds().Min);
            for (int i = 0; i < nodes.Length; i++)
            {
                InteractObject gasTank = new InteractObject(null, "GasTank");
                gasTank.SetInteractNode(new GasTankNode(gasTank));
                Vector3 gasTankPos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                gasTank.Transformation.SetPosition(gasTankPos);
                gasTank.Transformation.SetRotation(gasStation.Transformation.GetRotation());
                scene.AddEntity("GasTank", gasTank);
            }
            scene.AddEntity("GasStation", gasStation);
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: MattVitelli/Nosferatu
        void CreateStartZone()
        {
            Model tent = new Model("MilitaryTent");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Camp, tent.Transformation, tent.GetMesh().GetBounds());
            AddEntity("Tent", tent);

            AnimationNode[] nodes = tent.GetMesh().GetNodes();
            Matrix worldMatrix = tent.Transformation.GetTransform();
            //Vector3 meshCenter = 0.5f * (gasStation.GetMesh().GetBounds().Max + gasStation.GetMesh().GetBounds().Min);
            for (int i = 0; i < nodes.Length; i++)
            {
                Vector3 nodePos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                if (nodes[i].Name == "Bed")
                {
                    InteractObject bed = new InteractObject(new BedNode(this), "Bed");
                    bed.Transformation.SetPosition(nodePos);
                    bed.Transformation.SetRotation(tent.Transformation.GetRotation());
                    AddEntity("Bed", bed);
                }
                if(nodes[i].Name == "Ammo")
                {
                    InteractObject weaponBox = new InteractObject(new WeaponBoxNode(this), "AmmoBox");
                    weaponBox.Transformation.SetPosition(nodePos);
                    weaponBox.Transformation.SetRotation(tent.Transformation.GetRotation());
                    AddEntity("WeaponBox", weaponBox);
                }
            }

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(tent.Transformation.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 15);
            AddEntity("CampTrigger", campTrigger);

            /*
            Model campfire = new Model("Campfire");
            campfire.Transformation = tent.Transformation;
            AddEntity("CampFire", campfire);

            ParticleEmitter flameEmitter = new ParticleEmitter(ResourceManager.Inst.GetParticleEffect("Fire0"), 300);
            flameEmitter.Transformation.SetPosition(campfire.Transformation.GetPosition() + Vector3.Up * 1.5f);
            AddEntity("FireEffect", flameEmitter);

            ParticleEmitter smokeEmitter = new ParticleEmitter(ResourceManager.Inst.GetParticleEffect("Smoke4"), 300);
            smokeEmitter.Transformation.SetPosition(campfire.Transformation.GetPosition() + Vector3.Up * 3.0f);
            AddEntity("SmokeEffect", smokeEmitter);
            */
        }
コード例 #3
0
ファイル: Scene.cs プロジェクト: MattVitelli/Nosferatu
        void CreateLandmarks()
        {
            plant = new PowerPlant(this);
            gasStation = new GasStation(this);

            CreateHangar();

            Model shack = new Model("Shack");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Docks, shack.Transformation, shack.GetMesh().GetBounds());
            AddEntity("Shack", shack);

            InteractObject key = new InteractObject(null, "Key");
            key.SetInteractNode(new PickupNode(key, PickupName.Key, "Key"));
            key.Transformation.SetPosition(shack.Transformation.GetPosition());
            key.Transformation.SetRotation(shack.Transformation.GetRotation());
            AddEntity("Key", key);

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(shack.Transformation.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            AddEntity("SafeTrigger", campTrigger);

            Model arena = new Model("Arena");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Meadow, arena.Transformation, arena.GetMesh().GetBounds());
            AddEntity("Arena", arena);

            Model windmill = new Model("Windmill");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Windmill, windmill.Transformation, windmill.GetMesh().GetBounds());
            AddEntity("Windmill", windmill);

            Model well = new Model("Well");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Well, well.Transformation, well.GetMesh().GetBounds());
            AddEntity("Well", well);

            Model tower = new Model("RadioTower");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.RadioTower, tower.Transformation, tower.GetMesh().GetBounds());
            AddEntity("RadioTower", tower);

            CreateStartZone();

            BoundingBox sandBounds = MainTerrain.Transformation.GetBounds();
            sandBounds.Max.Y = 0;
            (MainTerrain as TerrainVoxel).SetUnavailableRegion(sandBounds);

            for (int i = 0; i < 50; i++)
            {
                Vector3 normalWeapon;
                Vector3 posWeapon;
                (MainTerrain as TerrainVoxel).GenerateRandomTransform(RandomHelper.RandomGen, out posWeapon, out normalWeapon);
                InteractObject weaponBox = new InteractObject(new WeaponBoxNode(this), "AmmoBox");
                NormalTransform transform = new NormalTransform();
                weaponBox.Transformation = transform;
                transform.ConformToNormal(normalWeapon);
                transform.SetPosition(posWeapon);
                AddEntity("WeaponBox", weaponBox);
            }

            sandBounds = MainTerrain.Transformation.GetBounds();
            sandBounds.Max.Y = 16;
            (MainTerrain as TerrainVoxel).SetUnavailableRegion(sandBounds);
        }
コード例 #4
0
ファイル: Scene.cs プロジェクト: MattVitelli/Nosferatu
        void CreateHangar()
        {
            Model hangar = new Model("Hangar");
            (MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.Hangar, hangar.Transformation, hangar.GetMesh().GetBounds());
            AddEntity("Hangar", hangar);

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(hangar.Transformation.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            AddEntity("SafeTrigger", campTrigger);

            AnimationNode[] nodes = hangar.GetMesh().GetNodes();
            Matrix worldMatrix = hangar.Transformation.GetTransform();
            Vector3 rot = hangar.Transformation.GetRotation();
            Vector3 camNodePos = Vector3.Zero;
            for (int i = 0; i < nodes.Length; i++)
            {
                Vector3 nodePos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                switch (nodes[i].Name)
                {
                    case "Plane":
                        InteractObject plane = new InteractObject(new AirplaneNode(this), "Plane");
                        plane.Transformation.SetPosition(nodePos);
                        plane.Transformation.SetRotation(rot);
                        AddEntity("Plane", plane);
                        break;
                    case "Door":
                        InteractObject door = new InteractObject(null, "HangarDoor", true);
                        Vector3 dispVec = Vector3.TransformNormal(Vector3.Right, worldMatrix)*-4f;
                        door.Transformation.SetPosition(nodePos);
                        door.Transformation.SetRotation(rot);
                        door.SetInteractNode(new HangarDoorNode(door, Vector3.Zero, dispVec));
                        AddEntity("HangarDoor", door);
                        break;
                    case "Garage":
                        InteractObject garage = new InteractObject(null, "HangarGarage", true);
                        garage.Transformation.SetPosition(nodePos);
                        garage.Transformation.SetRotation(rot);
                        garage.SetInteractNode(new HangarDoorNode(garage, new Vector3(0, 0, -MathHelper.PiOver2), Vector3.Zero));
                        AddEntity("HangarGarage", garage);
                        break;
                    case "DinoSpawn":
                        AnimatedModel trex = new AnimatedModel("TRex");
                        trex.SetCulling(false);
                        trex.Transformation.SetPosition(nodePos);
                        trex.Model.GetAnimationLayer().SetActiveAnimation("TRexIdle", true);//.SetAnimationLayer("AlphaRaptorIdle", 1.0f);
                        trex.Model.SetCustomMatrix(Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(-MathHelper.PiOver2));
                        //model.UpdateAnimation();
                        AddEntity("TRex", trex);
                        trex.SetVisible(false);
                        break;
                    case "CameraNode":
                        camNodePos = nodePos;
                        break;
                }

                InteractObject tempPlane = (InteractObject)FindEntity("Plane");
                AirplaneNode planeNode = (AirplaneNode)tempPlane.GetInteractNode();
                planeNode.SetEndCameraPosition(camNodePos, Vector3.TransformNormal(Vector3.Forward, worldMatrix));
                //InteractObject gasTank = new InteractObject(null, "GasTank");
                //gasTank.SetInteractNode(new GasTankNode(gasTank));
            }
        }
コード例 #5
0
ファイル: PowerPlant.cs プロジェクト: MattVitelli/Nosferatu
        public PowerPlant(Scene scene)
        {
            Model powerPlant = new Model("PowerPlant");
            Model powerPlantFence = new Model("PowerPlantFence");
            InteractObject switchA = new InteractObject(new SwitchNode(this, 0x1), "PowerPlantSwitchA");
            InteractObject switchB = new InteractObject(new SwitchNode(this, 0x2), "PowerPlantSwitchB");
            InteractObject switchC = new InteractObject(new SwitchNode(this, 0x4), "PowerPlantSwitchC");
            InteractObject switchD = new InteractObject(new SwitchNode(this, 0x8), "PowerPlantSwitchD");

            (scene.MainTerrain as TerrainVoxel).GetLandmarkTransform(MapLandmark.PowerPlant, powerPlant.Transformation, powerPlantFence.GetMesh().GetBounds());
            //powerPlant.Transformation.SetPosition(powerPlant.Transformation.GetPosition()-Vector3.Up*94);
            Vector3 pos = powerPlant.Transformation.GetPosition();
            Vector3 rot = powerPlant.Transformation.GetRotation();
            powerPlantTransform = powerPlant.Transformation;
            (switchA.GetInteractNode() as SwitchNode).SetInteractObject(switchA);
            (switchB.GetInteractNode() as SwitchNode).SetInteractObject(switchB);
            (switchC.GetInteractNode() as SwitchNode).SetInteractObject(switchC);
            (switchD.GetInteractNode() as SwitchNode).SetInteractObject(switchD);

            powerPlantFence.Transformation = powerPlant.Transformation;

            SafeTrigger campTrigger = new SafeTrigger();
            campTrigger.Transformation.SetPosition(powerPlantTransform.GetPosition());
            campTrigger.Transformation.SetScale(Vector3.One * 30);
            scene.AddEntity("SafeTrigger", campTrigger);

            switchA.Transformation.SetPosition(pos);
            switchA.Transformation.SetRotation(rot);

            switchB.Transformation.SetPosition(pos);
            switchB.Transformation.SetRotation(rot);

            switchC.Transformation.SetPosition(pos);
            switchC.Transformation.SetRotation(rot);

            switchD.Transformation.SetPosition(pos);
            switchD.Transformation.SetRotation(rot);

            AnimationNode[] nodes = powerPlantFence.GetMesh().GetNodes();
            Matrix worldMatrix = powerPlantFence.Transformation.GetTransform();
            //Vector3 meshCenter = 0.5f * (gasStation.GetMesh().GetBounds().Max + gasStation.GetMesh().GetBounds().Min);
            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].Name == "DoorHinge")
                {
                    InteractObject door = new InteractObject(null, "PowerPlantDoor", true);
                    Vector3 doorPos = Vector3.Transform(nodes[i].Translation, worldMatrix);
                    door.Transformation.SetPosition(doorPos);
                    door.Transformation.SetRotation(powerPlantFence.Transformation.GetRotation());
                    door.SetInteractNode(new PowerPlantDoorNode(door, new Vector3(0, MathHelper.PiOver2, 0), Vector3.Zero));
                    scene.AddEntity("PowerPlantDoor", door);
                }
            }

            //switchA.interactNode.OnInteract();
            //switchD.interactNode.OnInteract();

            scene.AddEntity("PowerPlant", powerPlant);
            scene.AddEntity("PowerPlantFence", powerPlantFence);

            scene.AddEntity("SwitchA", switchA);
            scene.AddEntity("SwitchB", switchB);
            scene.AddEntity("SwitchC", switchC);
            scene.AddEntity("SwitchD", switchD);

            List<int> potentialPuzzles = new List<int>();
            for (int i = 0; i < (1 << 7); i++)
            {
                if (IsValidPuzzle(i))
                {
                    potentialPuzzles.Add(i);
                }
            }
            Puzzle = potentialPuzzles[RandomHelper.RandomGen.Next(potentialPuzzles.Count)];
            int randInput = RandomHelper.RandomGen.Next(16);
            while (AttemptPuzzle(Puzzle, randInput))
                randInput = RandomHelper.RandomGen.Next(16);
            IsEnabled = false;
            if ((randInput & 0x01) > 0)
                switchA.GetInteractNode().OnInteract();
            if ((randInput & 0x02) > 0)
                switchB.GetInteractNode().OnInteract();
            if ((randInput & 0x04) > 0)
                switchC.GetInteractNode().OnInteract();
            if ((randInput & 0x08) > 0)
                switchD.GetInteractNode().OnInteract();
            IsEnabled = true;
        }