Exemplo n.º 1
0
 public override void OnInteract()
 {
     base.OnInteract();
     PlayerScreen playerScreen = PlayerScreen.GetInst();
     if (playerScreen.HasFuel)
     {
         if (trex == null)
         {
             new Sound3D("PlaneEngine", scene.FindEntity("Plane").Transformation.GetPosition());
             playerScreen.AddJournalEntry("It won't start. Search outside for a tool.");
             playerScreen.RemoveMarker(scene.FindEntity("Plane").Transformation);
             trex = (AnimatedModel)scene.FindEntity("TRex");
             trex.SetVisible(true);
             trex.Model.GetAnimationLayer().SetActiveAnimation("TRexIdle", false);
             trexSound = new Sound3D("TRexIdle", trex.Transformation.GetPosition());
             trexSound.Looped = true;
             //cameraLerpTime = -0.25f;
         }
     }
     else
     {
         playerScreen.AddJournalEntry("It's out of fuel. If only there were a gas station here.");
         if (!playerScreen.HasAlertedGasStation)
         {
             playerScreen.RemoveMarker(scene.FindEntity("Plane").Transformation);
             playerScreen.AddMarker(scene.FindEntity("GasStation").Transformation);
             playerScreen.HasAlertedGasStation = true;
         }
     }
 }
Exemplo n.º 2
0
        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));
            }
        }