Exemplo n.º 1
0
    public void cleanUpSpider(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript)
    {
        string existingSpider = PlayerPrefs.GetString(spiderSpawnerName + ".mySpider", "");

        availableSpiders[existingSpider] = true;
        spiderSpawnerScript.SendMessage("cleanUpSpider");
    }
Exemplo n.º 2
0
 public void spawnNewSpiderFromBait(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript)
 {
     if (spiderSpawnerScript.mySpider == null && spiderSpawnerScript.myBait != null)
     {
         Bait       baitScript           = spiderSpawnerScript.myBait.GetComponent <Bait>();
         int        min                  = baitScript.spiderMin;
         int        max                  = baitScript.spiderMax;
         GameObject selectedSpiderPrefab = spiderPrefabs[UnityEngine.Random.Range(min, max)];
         if ((PlayerPrefs.GetInt("totalSpidersKilled") == 0 && PlayerPrefs.GetInt("uniqueSpiderVisits") >= 24 && PlayerPrefs.GetInt("anansiHasVisited") == 0) ||
             (PlayerPrefs.GetInt("anansiHasVisited") == 1 && UnityEngine.Random.Range(0, 25) == 0))
         {
             PlayerPrefs.SetInt("anansiHasVisited", 1);
             selectedSpiderPrefab = spiderPrefabDictionary["Anansi"];
         }
         if (availableSpiders[selectedSpiderPrefab.name] && specialSpiderConditions(selectedSpiderPrefab.name))
         {
             int newNumberOfVisits = PlayerPrefs.GetInt(selectedSpiderPrefab.name + ".numberOfVisits") + 1;
             PlayerPrefs.SetInt(selectedSpiderPrefab.name + ".numberOfVisits", newNumberOfVisits);
             if (newNumberOfVisits >= 3)
             {
                 maybeKillSpider(selectedSpiderPrefab.name);
             }
             spiderSpawnerScript.SendMessage("cleanUpSpider");
             availableSpiders[selectedSpiderPrefab.name] = false;
             spiderSpawnerScript.spiderPrefab            = selectedSpiderPrefab;
             spiderSpawnerScript.SendMessage("spawnSpider");
         }
     }
 }
Exemplo n.º 3
0
 public void SetDirt(GameObject dirt, SpiderSpawner.Area area)
 {
     if (dirt == null)
     {
         Destroy(gameObject);
     }
     this.dirt = dirt;
     Dirt = this.dirt.name;
     this.area = area;
 }
Exemplo n.º 4
0
    public void spawnBait(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript)
    {
        string existingBait = PlayerPrefs.GetString(spiderSpawnerName + ".myBait", "");

        if (existingBait != "")           //there should only ever *not* be bait if a spider's already chlling
        {
            spiderSpawnerScript.SendMessage("placeBait", existingBait);
//			PlayerPrefs.DeleteKey(spiderSpawners[i].gameObject.name+".myBait"); //was this line necessary?
        }
    }
Exemplo n.º 5
0
    public void killSpider(SpiderSpawner spiderSpawner, string killerSpiderName)
    {
        int spidersKilled = PlayerPrefs.GetInt("totalSpidersKilled");

        PlayerPrefs.SetInt("totalSpidersKilled", spidersKilled + 1);
        string killedSpiderName = spiderSpawner.mySpider.GetComponent <Spider>().simpleName;

        PlayerPrefs.SetString(killedSpiderName + ".killedBy", killerSpiderName);
        cleanUpBait(spiderSpawner);
        cleanUpSpider(spiderSpawner.gameObject.name, spiderSpawner);
        availableSpiders[killedSpiderName] = false;
        canvasHandler.GetComponent <CanvasHandler>().displaySpiderPresent(killedSpiderName, killerSpiderName);
    }
Exemplo n.º 6
0
    public void spawnSpider(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript)
    {
        string existingSpider = PlayerPrefs.GetString(spiderSpawnerName + ".mySpider", "");

        if (existingSpider != "")
        {
            spiderSpawnerScript.spiderPrefab = spiderPrefabDictionary[existingSpider];
            availableSpiders[existingSpider] = false;
            spiderSpawnerScript.SendMessage("spawnSpider");
        }
        else
        {
            spawnNewSpiderFromBait(spiderSpawnerName, spiderSpawnerScript);
        }
    }
Exemplo n.º 7
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");
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
	public void spawnSpider(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript) {
		string existingSpider = PlayerPrefs.GetString (spiderSpawnerName+".mySpider","");
		if (existingSpider != "") {
			spiderSpawnerScript.spiderPrefab = spiderPrefabDictionary[existingSpider];
			availableSpiders[existingSpider] = false;
			spiderSpawnerScript.SendMessage("spawnSpider");
		} else {
			spawnNewSpiderFromBait(spiderSpawnerName, spiderSpawnerScript);
		}
	}
Exemplo n.º 9
0
 private void Start()
 {
     _camera        = FindObjectOfType <Camera>();
     _spiderSpawner = FindObjectOfType <SpiderSpawner>();
 }
Exemplo n.º 10
0
    // Wind power is determined by a value from 0 to 1.
    // Edges of the wind (y1 and y2) are generated randomly.
    // The slope coefficient of the first inclined line: k = 1 / y1.
    // The slope coefficient of the second inclined line: k = -1 / (y2 - 2).
    //
    // Power
    //  |
    // 1|    /¯¯¯¯¯¯¯\
    //  |   /         \
    //  |  /           \
    //  | /             \
    //  |/_______________\___
    //  0     y1    y2   2   y

    // Start is called before the first frame update
    void Start()
    {
        _spiderSpawner = FindObjectOfType <SpiderSpawner>();
        _spiderSpawner.SpiderCreated += this.StartTrackingSpider;
    }
Exemplo n.º 11
0
 void Awake()
 {
     singleton = this;
 }
Exemplo n.º 12
0
	public void killSpider(SpiderSpawner spiderSpawner, string killerSpiderName) {
		int spidersKilled = PlayerPrefs.GetInt("totalSpidersKilled");
		PlayerPrefs.SetInt("totalSpidersKilled", spidersKilled+1);
		string killedSpiderName = spiderSpawner.mySpider.GetComponent<Spider>().simpleName;
		PlayerPrefs.SetString(killedSpiderName+".killedBy", killerSpiderName);
		cleanUpBait(spiderSpawner);
		cleanUpSpider(spiderSpawner.gameObject.name, spiderSpawner);
		availableSpiders[killedSpiderName] = false;
		canvasHandler.GetComponent<CanvasHandler>().displaySpiderPresent(killedSpiderName, killerSpiderName);
	}
Exemplo n.º 13
0
 public void cleanUpBait(SpiderSpawner spiderSpawnerScript)
 {
     spiderSpawnerScript.cleanUpBait();
 }
Exemplo n.º 14
0
	public void spawnNewSpiderFromBait(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript) {
		if (spiderSpawnerScript.mySpider == null && spiderSpawnerScript.myBait != null) {
			Bait baitScript = spiderSpawnerScript.myBait.GetComponent<Bait>();
			int min = baitScript.spiderMin;
			int max = baitScript.spiderMax;
			GameObject selectedSpiderPrefab = spiderPrefabs[UnityEngine.Random.Range(min, max)];
			if ((PlayerPrefs.GetInt("totalSpidersKilled") == 0 && PlayerPrefs.GetInt("uniqueSpiderVisits") >= 24 && PlayerPrefs.GetInt("anansiHasVisited") == 0)
				|| (PlayerPrefs.GetInt("anansiHasVisited") == 1 && UnityEngine.Random.Range(0,25) == 0)) {
					PlayerPrefs.SetInt("anansiHasVisited", 1);
					selectedSpiderPrefab = spiderPrefabDictionary["Anansi"];
			}
			if (availableSpiders[selectedSpiderPrefab.name] && specialSpiderConditions(selectedSpiderPrefab.name)){
				int newNumberOfVisits = PlayerPrefs.GetInt(selectedSpiderPrefab.name+".numberOfVisits") + 1;
				PlayerPrefs.SetInt (selectedSpiderPrefab.name+".numberOfVisits", newNumberOfVisits);
				if (newNumberOfVisits >= 3) {
					maybeKillSpider(selectedSpiderPrefab.name);
				}
				spiderSpawnerScript.SendMessage("cleanUpSpider");
				availableSpiders[selectedSpiderPrefab.name] = false;
				spiderSpawnerScript.spiderPrefab = selectedSpiderPrefab;
				spiderSpawnerScript.SendMessage("spawnSpider");
			}
		} 
	}
Exemplo n.º 15
0
	public void spawnBait(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript) {
		string existingBait = PlayerPrefs.GetString (spiderSpawnerName+".myBait","");
		if (existingBait != "") { //there should only ever *not* be bait if a spider's already chlling
			spiderSpawnerScript.SendMessage("placeBait", existingBait);
//			PlayerPrefs.DeleteKey(spiderSpawners[i].gameObject.name+".myBait"); //was this line necessary?
		} 
	}
Exemplo n.º 16
0
	public void cleanUpSpider(string spiderSpawnerName, SpiderSpawner spiderSpawnerScript) {
		string existingSpider = PlayerPrefs.GetString(spiderSpawnerName+".mySpider","");
		availableSpiders[existingSpider] = true;
		spiderSpawnerScript.SendMessage("cleanUpSpider");
	}
Exemplo n.º 17
0
	public void cleanUpBait(SpiderSpawner spiderSpawnerScript) {
		spiderSpawnerScript.cleanUpBait();
	}