Ejemplo n.º 1
0
    void SpawnObstacle()
    {
        spawnObstacleTimer += Time.deltaTime;
        if (spawnObstacleTimer > spawnObstacleInterval)
        {
            spawnObstacleTimer = 0;
            float amount = obstacleAmountBegin + (Time.timeSinceLevelLoad / 60.0f) * (obstacleAmountFinal - obstacleAmountBegin);
            if (Time.timeSinceLevelLoad > 60.0f)
            {
                amount = obstacleAmountFinal;
            }
            spawnObstacleInterval = 1.0f + TFMath.GaussRand() * 60 / amount;


            //int pt = GetSpawnPoint();
            int pt = UnityEngine.Random.Range(0, spawnObstaclePoints.Length);
            if (pt > -1)
            {
                int        id            = UnityEngine.Random.Range(0, 5);
                GameObject obj           = (GameObject)Resources.Load("Prefabs/Rock/rock" + (id + 1).ToString());
                Vector3    spawnPosition = spawnObstaclePoints[pt].point;
                Instantiate(obj, spawnPosition, Quaternion.identity);
            }
        }
    }
Ejemplo n.º 2
0
 void SpawnWharf()
 {
     spawnWharfTimer += Time.deltaTime;
     if (spawnWharfTimer > spawnWharfInterval)
     {
         spawnWharfTimer    = 0;
         spawnWharfInterval = TFMath.GaussRand() * 60 / (float)dockAmount;
         //Debug.Log(BGScroller.currentID + "xx"+ BGScroller.nextID);
         //OnSentSpawnMessage.Invoke(this, EventArgs.Empty);
         BGScroller.spawnTimes++;
     }
 }
Ejemplo n.º 3
0
    void SpawnFishByID(int fishID, int spawnPointID)
    {
        FishData   tempData = fishDataList.fish[fishID];
        GameObject obj      = (GameObject)Resources.Load("Prefabs/Fish/" + tempData.modelID);
        float      LRange   = tempData.maxLength - tempData.minLength;
        float      WRange   = tempData.maxWeight - tempData.minWeight;
        float      length   = tempData.minLength + LRange * TFMath.GaussRand();
        float      weight   = tempData.minWeight + WRange * TFMath.GaussRand();

        obj.GetComponent <Fish>().SetFish(tempData.speed, tempData.score, length, weight, spawnPointID, fishID);
        Vector3 spawnPosition = spawnPoints[spawnPointID].point;

        Instantiate(obj, spawnPosition, Quaternion.Euler(-35, 180, 0));
        // Debug.Log("生成了一条" + length.ToString("f2") + "cm," + weight.ToString("f2") + "kg的" + tempData.name);
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        transform.rotation = new Quaternion(-0.1f, transform.rotation.y, transform.rotation.z, transform.rotation.w);
        switch (state)
        {
        case FishState.idle: {
            timer += Time.deltaTime;
            if (timer > m_idleTime)
            {
                timer      = 0;
                m_idleTime = idleTime + TFMath.GaussRand() * idleTime;
                anim.speed = 1.0f;
                state      = FishState.move;
                path.DOPlay();
            }


            break;
        }

        case FishState.move:
        {
            timer += Time.deltaTime;
            if (timer > m_waitTime)
            {
                timer      = 0;
                m_waitTime = waitTime + TFMath.GaussRand() * waitTime;
                anim.speed = 0.1f;
                state      = FishState.idle;
                path.DOPause();
            }
            break;
        }

        case FishState.show:
        {
            break;
        }

        default: break;
        }
    }
Ejemplo n.º 5
0
    void SpawnFish()
    {
        spawnFishTimer += Time.deltaTime;
        if (spawnFishTimer > spawnFishInterval)
        {
            spawnFishTimer    = 0;
            spawnFishInterval = TFMath.GaussRand() * 60 / (float)fishAmount;

            int pt = GetSpawnPoint();
            if (pt > -1)
            {
                //spawnPoints[pt].occupied = true;
                SpawnFishByID(GetRandomFishID(), pt);
            }
            else
            {
                return;
            }

            //if (Random.Range(0, 8) == 0)
            //StartCoroutine(Spawnshoal());
        }
    }
Ejemplo n.º 6
0
    void Start()
    {
        spawnFishInterval     = 0.5f + TFMath.GaussRand() * 5f;
        spawnWharfInterval    = firstDockTime;
        spawnObstacleInterval = firstObstacleTime;
        AssetBundle ab;

#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        ab = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/data.ab");
#endif
#if UNITY_ANDROID
        ab = AssetBundle.LoadFromFile(Application.dataPath + "!assets/data.ab");
#endif
        TextAsset ta = ab.LoadAsset <TextAsset>("Fish");
        fishDataList = JsonUtility.FromJson <FishDataList>(ta.text);
        ab.Unload(true);
        int length = fishDataList.fish.Count;

        foreach (var item in fishDataList.fish)
        {
            toatlRarity += item.rarity[mapID];
        }
    }