コード例 #1
0
    private void Awake()
    {
        LOCAL_PERSISTENT_PARTH = Application.persistentDataPath + "/";
        LOCAL_STREAMING_PARTH  = Application.streamingAssetsPath + "/";

#if UNITY_ANDROID && !UNITY_EDITOR
        //AndroidJavaClass javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        //javaObject = javaClass.GetStatic<AndroidJavaObject>("currentActivity");
        LOCAL_VERSION_URL = "file://" + LOCAL_PERSISTENT_PARTH;
        PLATFORM_FILE     = "Android/";
#endif

#if UNITY_EDITOR                                     //&&!UNITY_ANDROID && !UNITY_IPHONE
        LOCAL_VERSION_URL = "file:///" + LOCAL_PERSISTENT_PARTH;
        PLATFORM_FILE     = "Editor/";
#endif

#if UNITY_IPHONE && !UNITY_EDITOR
        LOCAL_VERSION_URL = "file://" + LOCAL_PERSISTENT_PARTH;
        PLATFORM_FILE     = "IOS/";
#endif

        MoveFilesFromStreamingToPersistent();

        StartCoroutine(DownLoad(SERVER_VERSION_URL + VERSION_FILE, delegate(WWW serverVersion)
        {
            HandleVersionFile(serverVersion.text, serverVersionDic);
            StartCoroutine(DownLoad(LOCAL_VERSION_URL + VERSION_FILE, delegate(WWW localVersion)
            {
                HandleVersionFile(localVersion.text, localVertsionDic);


#if UNITY_ANDROID && !UNITY_EDITO
                //javaObject.Call("unityInitialized");
#endif

#if UNITY_IPHONE && !UNITY_EDITOR
                IOSNativeInitCenter(this.gameObject.name, "InitializePet");
#endif
                currentPet = Instantiate(Resources.Load <GameObject>("Pets/" + RandomUtil.Array(new int[3] {
                    2, 6, 14
                })));
                currentPet.transform.SetParent(transform.GetChild(0).GetChild(0));
                currentPet.transform.localPosition = Vector3.zero;
                currentPet.transform.localRotation = Quaternion.identity;
            }));
        }));
    }
コード例 #2
0
ファイル: RotateAround.cs プロジェクト: WSHSHIWBB/DLL
    private IEnumerator GameHelper(int petNum)
    {
        if (petNum < 0 || petNum > 30)
        {
            Debug.LogError("The petNum is illegal");
            yield break;
        }

        double[] duration  = null;
        double[] outOfFOV  = null;
        double[] moveSpeed = null;
        double[] moveDis   = null;
        if (petNum >= 0 && petNum <= 25)
        {
            duration = new double[3] {
                configModule.dllConfig.captureDuration.Tx1, configModule.dllConfig.captureDuration.Tx2, configModule.dllConfig.captureDuration.Tx3
            };
            outOfFOV = new double[2] {
                configModule.dllConfig.longestOutOfFOV.T1, configModule.dllConfig.longestOutOfFOV.T2
            };
            moveSpeed = new double[2] {
                configModule.dllConfig.petMoveSpeed.V1, configModule.dllConfig.petMoveSpeed.V2
            };
            moveDis = new double[3] {
                configModule.dllConfig.petMoveDistance.L1, configModule.dllConfig.petMoveDistance.L2, configModule.dllConfig.petMoveDistance.L3
            };
        }
        else if (petNum >= 26 && petNum <= 30)
        {
            duration = new double[3] {
                configModule.dllConfig.captureDuration.Tx3, configModule.dllConfig.captureDuration.Tx4, configModule.dllConfig.captureDuration.Tx5
            };
            outOfFOV = new double[2] {
                configModule.dllConfig.longestOutOfFOV.T2, configModule.dllConfig.longestOutOfFOV.T3
            };
            moveSpeed = new double[2] {
                configModule.dllConfig.petMoveSpeed.V3, configModule.dllConfig.petMoveSpeed.V4
            };
            moveDis = new double[3] {
                configModule.dllConfig.petMoveDistance.L3, configModule.dllConfig.petMoveDistance.L4, configModule.dllConfig.petMoveDistance.L5
            };
        }
        float captureDuration = (float)RandomUtil.Array(duration);
        float longestOutOfFov = (float)RandomUtil.Array(outOfFOV);
        float petMoveSpeed    = (float)RandomUtil.Array(moveSpeed);
        float petMoveDistance = (float)RandomUtil.Array(moveDis);
        float durationCounter = captureDuration;
        float outOfFOVCounter = longestOutOfFov;

        while (true)
        {
            while (durationCounter > 0)
            {
                yield return(null);

                if (!isCapturePaused)
                {
                    durationCounter -= Time.deltaTime;

                    if (outOfFOVCounter > 0)
                    {
                        outOfFOVCounter -= Time.deltaTime;
                    }
                    else
                    {
                        outOfFOVCounter = longestOutOfFov;
                        //ToDo OutFOV
                        ForceIntoFOV();
                    }
                }
            }

            if (!isCapturePaused)
            {
                durationCounter = captureDuration;
                //ToBe CaptureDuration
                ForceCapture();
            }
        }
    }