Пример #1
0
        public void Start()
        {
            Seed = System.Guid.NewGuid().ToString().Substring(0, 8).ToUpper();
            Random.InitState(Seed.GetHashCode());

            lt           = GameObject.Find("Directional Light");
            textures1[0] = Resources.Load("dirt stones") as Texture;
            textures2[0] = Resources.Load("leafs dark") as Texture;
            textures1[1] = Resources.Load("dirt stones eary yellow") as Texture;
            textures2[1] = Resources.Load("dirt stones leafs more") as Texture;
            textures1[2] = Resources.Load("grey dirt stones") as Texture;
            textures2[2] = Resources.Load("granit grass") as Texture;
            textures1[3] = Resources.Load("dirt stones") as Texture;
            textures2[3] = Resources.Load("sand stones") as Texture;

            LoadSkyBoxMaterials();

            int rnd = (int)(Random.Range(0f, 0.3f) * 10);

            Ground.texture1 = textures1[rnd];
            Ground.texture2 = textures2[rnd];

            #region LevelProcessor

            GameObject levelProcessor = new GameObject();
            lpObj = levelProcessor.AddComponent <LevelProcessor>();
            lpObj.ProcessLevel(bunnyPrefab, ghostPrefab);

            #endregion

            transform.position = lpObj.startingPosition;

            #region Character

            characterTransform = Instantiate(characterPrefab, transform.position, transform.rotation);
            SimpleCharacterControl sCC = characterTransform.GetComponent <SimpleCharacterControl>();
            sCC.m_jumpForce             = lpObj.maxJumpHeight * 3; // TODO: Find right multiply and maybe addition
            sCC.m_moveSpeed             = 5;
            characterTransform.position = lpObj.startingPosition;
            characterTransform.rotation = Quaternion.AngleAxis(90, new Vector3(0, 1, 0));
            Debug.Log("starting position = " + lpObj.startingPosition);

            Camera camera = this.GetComponent <Camera>();

            camera.transform.parent = characterTransform.transform;
            Vector3 localPosition = camera.transform.localPosition;
            localPosition.x = 10;
            camera.transform.localPosition = localPosition;

            #endregion

            #region Skybox and Music

            Material m = Resources.Load("CloudyCrownMidday", typeof(Material)) as Material;
            Debug.Log("Matieral-Name: " + m.name);
            RenderSettings.skybox = m;

            audio     = gameObject.AddComponent <AudioSource>();
            acMorning = Resources.Load("Songs/Morning") as AudioClip;
            acSundown = Resources.Load("Songs/Sundown") as AudioClip;
            acDoD     = Resources.Load("Songs/Dance Of Death") as AudioClip;
            acOutcast = Resources.Load("Songs/Outcast") as AudioClip;

            audio.clip   = acMorning;
            audio.loop   = true;
            audio.volume = 0.1f;
            audio.Play();
            #endregion
        }
Пример #2
0
 private void Awake()
 {
     _processor = GetComponent <LevelProcessor>();
 }