Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
        }