Exemple #1
0
    //if baitSetAt < 60 seconds, spawn the bait
    //else if baitSetAt < 15 minutes, spawn the bait plus the spider
    //if there's already a spider saved, spawn that one
    //if not, pick one and save it
    //else if baitSetAt < 2 hours, spawn just the spider
    //if there is bait but no spider, spawn the bait, then the spider, then clean up the bait
    //if there is spider, spawn it and clean up the bait
    //else clean up
    //delete baitSetAt
    //clear mybait + playerpref
    //clear myspider + playerpref

    void LoadSpiderSpawners()
    {
        if (spiderSpawners != null)
        {
            for (int i = 0; i < spiderSpawners.Length; i++)
            {
                TimeSpan timeSinceBaitSet = DataKeeper.getTimeSinceStamp(spiderSpawners[i].gameObject.name + ".baitSetAt");
                if (timeSinceBaitSet.TotalSeconds > 0)                    // Should only ever be 0 if the stamp isn't set
                {
                    SpiderSpawner spiderSpawnerScript = spiderSpawners[i].GetComponent <SpiderSpawner>();
                    string        spiderSpawnerName   = spiderSpawners[i].gameObject.name;
                    if (timeSinceBaitSet.TotalSeconds < secondsBetweenBaitPlacingAndEating)                        // bait sitting out
                    {
                        spawnBait(spiderSpawnerName, spiderSpawnerScript);
                    }
                    else if (timeSinceBaitSet.TotalSeconds < secondsBetweenEatingAndChilling)                           // spider nomming bait
                    {
                        spawnBait(spiderSpawnerName, spiderSpawnerScript);
                        spawnSpider(spiderSpawnerName, spiderSpawnerScript);
                    }
                    else if (timeSinceBaitSet.TotalSeconds < secondsBetweenChillingAndLeaving)                         // spider chilling
                    {
                        spawnBait(spiderSpawnerName, spiderSpawnerScript);
                        spawnSpider(spiderSpawnerName, spiderSpawnerScript);
                        cleanUpBait(spiderSpawnerScript);
                    }
                    else                          // clean up and note how many times it has visited
                    {
                        spawnBait(spiderSpawnerName, spiderSpawnerScript);
                        spawnSpider(spiderSpawnerName, spiderSpawnerScript);
                        updateSpiderVisits(spiderSpawnerName);
                        cleanUpBait(spiderSpawnerScript);
                        cleanUpSpider(spiderSpawnerName, spiderSpawnerScript);
                        PlayerPrefs.DeleteKey(spiderSpawnerName + ".baitSetAt");
                    }
                }
            }
        }
    }