Exemple #1
0
    /// <summary>
    /// Toggles the camera from top to follow
    /// </summary>
    public void ToggleCamera()
    {
        int enumL = System.Enum.GetValues(typeof(CamMode)).Length - 1;

        Camy         = (Camy != (CamMode)enumL ? Camy += 1 : (CamMode)0);
        camButt.text = Camy.ToString();
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))         // OVRInput.GetDown(OVRInput.RawButton.B)
        {
            prevCamMode = (prevCamMode + 1) % numOfCamModes;
            currCamMode = (CamMode)prevCamMode;
        }

        switch (currCamMode)
        {
        case CamMode.FirstPerson:
            Debug.Log("Cam mode is now: " + currCamMode.ToString());
            avatar.ShowFirstPerson = true;
            avatar.ShowThirdPerson = false;
            transform.position     = focus.transform.position +
                                     focus.transform.TransformDirection(new Vector3(len, h2, d2));
            transform.rotation = focus.transform.rotation;
            break;

        case CamMode.ThirdPerson:
            Debug.Log("Cam mode is now: " + currCamMode.ToString());
            avatar.ShowFirstPerson = false;
            avatar.ShowThirdPerson = true;
            transform.position     = Vector3.Lerp(transform.position, focus.transform.position +
                                                  focus.transform.TransformDirection(new Vector3(0f, height, -distance)),
                                                  dampening * Time.deltaTime);
            //StartCoroutine(WaitToLookAt());
            break;

        default:
            Debug.Log("Cam mode is now: " + currCamMode.ToString());
            transform.position = Vector3.Lerp(transform.position, focus.transform.position +
                                              focus.transform.TransformDirection(new Vector3(0f, height, -distance)),
                                              dampening * Time.deltaTime);
            //StartCoroutine(WaitToLookAt());
            break;
        }
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        menuParams.Check4MenuParam();

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        campAdd = true;

        //
        if (GameObject.Find("menuParams"))
        {
            mP = GameObject.Find("menuParams").GetComponent <menuParams>();

            if (mP.sesh)
            {
                StreamReader sr   = new StreamReader(Path.Combine(Application.dataPath, "sesh.txt"));
                string[]     load = sr.ReadToEnd().Split('\n');
                sr.Close();

                mP.seshMark.y = load.Length;

                if (mP.seshMark.x > mP.seshMark.y)
                {
                    Application.Quit();
                    if (Application.isEditor)
                    {
                        GoToMenu();
                    }
                }

                string[] load2 = load[(int)mP.seshMark.x - 1].Split(',');

                // laps, days, course, CO, Mode, attempts, ini
                mP.laps             = int.Parse(load2[0]);
                mP.maxDays          = int.Parse(load2[1]);
                mP.lvlName          = load2[2];
                mP.lvlData          = menu.ReturnLvlData(load2[2]);
                mP.CO               = (COMode)int.Parse(load2[3]);
                mP.mode             = (GameMode)int.Parse(load2[4]);
                mP.attempts         = int.Parse(load2[5]);
                mP.randomizeWeights = bool.Parse(load2[6]);
                mP.storedName       = load2[7];
            }

            mode                = mP.mode;
            CrossOver           = mP.CO;
            selMode             = mP.SEL;
            randomizeIniWeights = mP.randomizeWeights;
            attempt.y           = mP.attempts;
            mLaps               = mP.laps;
            slowMode            = mP.slowMode;

            //
            if (mode == GameMode.Test)
            {
                attempt.y = mP.brains.Count;
            }
            else if (mode == GameMode.Campaign)
            {
                attempt.y = 1;
            }
            //
            if (mP.brains.Count > 0)
            {
                //
                for (int i = 0; i < mP.brains.Count; i++)
                {
                    loadedBrains.Add(mP.brains[i].Split('\n')[1]);
                }
            }


            //
            lvlBuilder lb = gameObject.AddComponent <lvlBuilder>();

            //
            if (mode == GameMode.Test || mode == GameMode.Train)
            {
                lb.saveFile = mP.lvlData;
                lb.reverse  = mP.reverse;
            }
            else
            {
                mP.lvlName  = "Campaign Course #" + (mP.campaignProgress + 1);
                lb.saveFile = (mP.campaignProgress < 4) ? mP.campaign[(int)Mathf.Floor(mP.campaignProgress)] : "FINAL";
                lb.reverse  = (mP.campaignProgress % 1) != 0;
            }
        }

        //
        graphs[0] = GameObject.Find("FitnessGraph");
        graphs[1] = GameObject.Find("AverageGraph");

        // This will disable the UI if in race mode
        rT[0].gameObject.SetActive(mode == GameMode.Test || mode == GameMode.Campaign);
        rT[1].gameObject.SetActive(mode == GameMode.Train);

        // Set the appropriate version number on the top left of screen
        vT.text = "v" + Application.version;

        // Set all of the input texts to "?" instead of the default "New Text" :)
        for (int i = 0; i < inp.Length; i++)
        {
            inp[i].text = "?";
        }

        // This will hide the starting marker
        startSp.GetComponent <Renderer>().enabled = false;

        // This grabs a ref to the camera's starting position & rotation
        camStarts[0] = Camera.main.transform.position;
        camStarts[1] = Camera.main.transform.eulerAngles;

        // This sets the text for the control & camera mode buttons
        //ctButt.text = intelli.ToString();
        camButt.text = Camy.ToString();

        // attIniData is Attempt Initializer, we first need to define how many brains this ini will hold, it will hold our max attempt count
        attIniData = new float[(int)attempt.y][];

        //
        attIniString = new string[(int)attempt.y];

        // then every brian will hold 29 values, in our case floats, so we'll loop through every brain & set their value size to hold 29 floats, which will be a fully randomized brain
        for (int i = 0; i < attIniData.Length; i++)
        {
            attIniData[i] = new float[29];
        }

        //
        if (loadedBrains == null || loadedBrains.Count < 1)
        {
            //
            if (randomizeIniWeights)
            {
                RandomizeWholeDay();
            }
        }
        else
        {
            SetWholeDay();
        }
    }