Exemplo n.º 1
0
    private void Start()
    {
        if (_instance == null)
        {
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(this.gameObject);
        }

        this.transform.LookAt(_target);
    }
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        /// RTS camera init
        CameraComponent camera       = new CameraComponent(this.gameObject);
        ZoomCamera      zoomCamera   = new ZoomCamera(camera, zoomMin, zoomMax, zoomSpeed);
        RotateCamera    rotateCamera = new RotateCamera(zoomCamera, rotateSpeed);
        FreeCamera      freeCamera   = new FreeCamera(rotateCamera, minX, minZ, maxX, maxZ, movementSpeed);

        rtsCamera = new SelectionFrameCamera(freeCamera, selection_frame);

        /// Follow camera init
        orbitalCamera = new OrbitalCamera(zoomCamera, rotateSpeed);
        followCamera  = new FollowCamera(orbitalCamera, followDampTime);

        currentCamera = rtsCamera;
    }
Exemplo n.º 3
0
    // Use this for initialization
    private void Start()
    {
        boat = this.GetComponent <Rigidbody>();

        //Only perform the following for THIS player's boat
        if (!isLocalPlayer)
        {
            return;
        }

        //Make orbital and boat camera follow boat
        boatCam       = Camera.main.GetComponent <BoatCameraNetworked>();
        orbCam        = Camera.main.GetComponent <OrbitalCamera>();
        orbCam.target = this.gameObject;
        Camera.main.GetComponent <OrbitalCamera>().enabled = false;
        boatCam.boatToFollow = this.gameObject;

        //Get cannon scripts from all cannons
        cannonScripts    = new List <BroadsideCannonFireNetworked>(this.GetComponentsInChildren <BroadsideCannonFireNetworked>().Where(t => t.GetType() != typeof(SwivelGun)));
        swivelGunScripts = new List <SwivelGun>(this.GetComponentsInChildren <SwivelGun>());
    }
Exemplo n.º 4
0
        public override void Load()
        {
            // Engine components.
            RessourceManager ressourceManager = Engine.GetComponent <RessourceManager>();


            // Setup the scene
            Entities              = new List <Entity>();
            camera                = new OrbitalCamera(Engine.GraphicDevice.GetBufferSize().X / Engine.GraphicDevice.GetBufferSize().Y, 90);
            render                = new RenderBatch();
            testSun               = new Sun(new Point3D(-150f, 150f, -150f), new Color3(255, 255, 255));
            testScene             = new Scene(camera, testSun);
            testScene.Fog.Density = 0f;

            // Dragon
            Model    dragonModel    = ressourceManager.ImportRessource <Model>("model:dragon.obj");
            Material dragonMaterial = new Material(ressourceManager.ImportRessource <Texture2D>("texture2D:blue.png"));

            dragonMaterial.Reflectivity = 1f;
            dragonMaterial.ShineDamper  = 10f;
            ressourceManager.ImportRessource <ShaderProgram>("shader:material.json");
            Entities.Add(new Entity(new Transform(new Vector3(0, 0, 0), new Vector3(), 0.1f), dragonModel, dragonMaterial));

            // Terrain
            Material GrassMaterial = new Material(ressourceManager.ImportRessource <Texture2D>("texture2D:grass.png"))
            {
                Reflectivity = 0f,
                ShineDamper  = 10f
            };

            terrain = new Entity(new Transform(0, -10f, 0), ModelFactorie.GeneratePlane(640f, 256, 64, new PerlinHeightMap()), GrassMaterial);
            water   = new Entity(new Transform(0, 0, 0), ModelFactorie.GeneratePlane(640f, 16, 64, new FlatHeightMap()), dragonMaterial);


            // Show the inspector.
            new Inspector.InspectorUI(Engine, testScene).ShowInspector();
        }
Exemplo n.º 5
0
 void Start()
 {
     orbit = GetComponent <OrbitalCamera>();
 }