Esempio n. 1
0
    // On collision with something
    void OnCollisionEnter(Collision collision)
    {
        if (instanceInit == false)
        {
            print("Contact Mars !");
            //GameObject overExplo = Instantiate (mRoverInit);

            roverInit rover = mRoverInit.GetComponent <roverInit>();
            rover.target = GameObject.Find("map_point_target");
            instanceInit = true;
        }
    }
Esempio n. 2
0
    public new void OnSelection(GameObject oldSelection)
    {
        if (oldSelection != null)
        {
            print("target selected, ancien objet : " + oldSelection.name);

            if (oldSelection.name == "rover_exploration(Clone)")
            {
                roverInit rover = oldSelection.GetComponent <roverInit>();
                rover.target = GameObject.Find(this.name);
            }
        }
    }
    void Update()
    {
        // Sun rotation
        //float rotx = mSunRotation.Evaluate(Time.fixedTime) * 360;
        //mSun.transform.rotation = Quaternion.Euler (new Vector3 (rotx, 0, 0));
        mSun.transform.Rotate(new Vector3(0.1f, 0, 0));

        if (Input.GetKeyDown(KeyCode.R) && currentRoverNb > 0)
        {
            GameObject rover    = Instantiate(mRoverInit, mSpawnPoint.transform.position, mSpawnPoint.transform.rotation) as GameObject;
            roverInit  roverCmp = rover.GetComponent <roverInit> ();
            roverCmp.target = mTarget;
            currentRoverNb -= 1;
        }
    }
Esempio n. 4
0
    // Upd ate is called once per frame
    void Update()
    {
        float forwardSpeed = Input.GetAxis("Vertical") * Time.deltaTime * camSpeed;
        float sideSpeed    = Input.GetAxis("Horizontal") * Time.deltaTime * camSpeed;
        float zoomSpeed    = Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * scrollSpeed;

        transform.position += new Vector3(sideSpeed, forwardSpeed, -zoomSpeed);

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hitInfo = new RaycastHit();
            Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);

            // first use
            if (lastObject == null)
            {
                print("lastObject est null");
                lastObject = hitInfo.collider.transform.root.gameObject;
            }

            print("OnSelection " + lastObject.name);
            print("OnDeSelection " + hitInfo.collider.transform.root.gameObject.name);
            hitInfo.collider.transform.root.SendMessage("OnSelection", lastObject);
            lastObject.SendMessage("OnDeSelection", hitInfo.collider.transform.root.gameObject);
            lastObject = hitInfo.collider.transform.root.gameObject;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (lastObject != null)
            {
                print("New Rover to " + lastObject.name);
                GameObject roverExplo = Instantiate(mRoverInit);
                roverInit  rover      = roverExplo.GetComponent <roverInit> ();
                rover.target = lastObject;
            }
        }
    }