// Use this for initialization
 void Awake()
 {
     BikeGameCtrl.SetPlayerLedCheTou(false, LedCheTou);
     BikeNetScript = GetComponent <bikeNetUnity>();
     BikeScript    = GetComponent <bike>();
     PlayerAni     = GetComponent <Animator>();
     PlayRootAni();
 }
    void Update()
    {
        if (Network.peerType == NetworkPeerType.Server)
        {
            return;
        }

        switch (Network.peerType)
        {
        case NetworkPeerType.Client:
            if (BikeNetScript == null || !BikeNetScript.CheckPlayerClient())
            {
                return;
            }
            break;

        case NetworkPeerType.Disconnected:
            if (BikeScript == null || BikeScript.GetIsAiNPC())
            {
                return;
            }
            break;
        }

        float playerSpeed = GlobalScript.GetInstance().player.Speed;

        if (playerSpeed <= 3)
        {
            if (PlayerAni.GetBool("root") && PlayerAni.speed != 1f)
            {
                PlayerAni.speed = 1f;
            }
            return;
        }

        float minSpeed = 0f;
        float maxSpeed = 40f;

        float minVal = BikeGameCtrl.GetInstance().AniRunSpeedMin;
        float maxVal = BikeGameCtrl.GetInstance().AniRunSpeedMax;

        float aniSpeed = 1f;

        if (playerSpeed <= maxSpeed)
        {
            float key = (maxVal - minVal) / (maxSpeed - minSpeed);
            aniSpeed = minVal + key * (playerSpeed - minSpeed);
        }

        if (PlayerAni.speed != aniSpeed)
        {
            PlayerAni.speed = aniSpeed;
        }
    }
    void Awake()
    {
        //GlobalData.GetInstance().gameMode = GameMode.SoloMode; //test.
//		bool isActiveDanJi = GlobalData.GetInstance().gameMode == GameMode.SoloMode ? true : false;
//		if (DanJiGameCtrl != null) {
//			DanJiGameCtrl.SetActive(isActiveDanJi);
//		}
//		if (LianJiGameCtrl != null) {
//			LianJiGameCtrl.SetActive(!isActiveDanJi);
//		}

        _Instance = this;
        if (GlobalData.GetInstance().gameMode == GameMode.SoloMode)
        {
            SpawnPlayer();
            bike.spawnRandPlayer();
            bike.mBikeGameCtrl = gameObject;
        }
    }