示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (playCont.fast)
        {
            targSpeedMultiplier = 2.5f;
        }
        else
        {
            targSpeedMultiplier = 1;
        }
        speedMultiplier = /*tmpSpeedMultiplier;*/ Mathf.SmoothDamp(speedMultiplier, targSpeedMultiplier, ref speedDampVel, speedDampTime);

        if (Time.time >= timestamp)
        {
            FloorConfig targetConfig = floorConfigs[(int)Random.Range(0, floorConfigs.Length)];
            for (int i = 0; i < targetConfig.info.Length; i++)
            {
                GameObject spawnObj = null;
                switch (targetConfig.info[i].type)
                {
                case FloorConfig.ObjTypes.Pole:
                    spawnObj = Instantiate(obstaclePrfb, tunnelTran) as GameObject;
                    break;

                case FloorConfig.ObjTypes.Board:
                    spawnObj = Instantiate(boardPrfb, tunnelTran) as GameObject;
                    break;

                case FloorConfig.ObjTypes.Coin:
                    spawnObj = Instantiate(coinPrefab, tunnelTran) as GameObject;
                    break;
                }

                spawnObj.transform.position    = new Vector3(targetConfig.info[i].position.x, spawnDepth, targetConfig.info[i].position.z);
                spawnObj.transform.eulerAngles = targetConfig.info[i].eulers;
            }
            timestamp = Time.time + delay / speedMultiplier;
        }


        if (tunnelTran.childCount > 0)
        {
            for (int i = 0; i < tunnelTran.childCount; i++)
            {
                Transform ob    = tunnelTran.GetChild(i);
                float     speed = fallSpeed * speedMultiplier;
                ob.transform.Translate(Vector3.up * speed * Time.deltaTime, Space.World);

                if (ob.position.y > player.position.y + 10)
                {
                    Destroy(ob.gameObject);
                }
            }
        }

        if (!dead)
        {
            progressedDepth += Time.deltaTime * fallSpeed * speedMultiplier;
            depthUI.text     = progressedDepth.ToString("(0m)");
        }

        Camera.main.fieldOfView = Mathf.Clamp(60 * speedMultiplier, 60, 80);

        float scrollSpeed = Time.time * fallSpeed * speedMultiplier;

        scrollingMat.SetFloat("Vector1_79A07576", 0.016f * scrollSpeed);
    }
示例#2
0
 public static T ToModel <T>(this FloorConfig entity) where T : class
 {
     return(Mapper.Map <FloorConfig, T>(entity));
 }