// Load the cat from a previous save public void Load() { // Load personality, stats and style personality = CatPersonality.Load(); stats = CatStats.Load(); style = CatStyle.Load(); achievements = CatAchievements.Load(); // Load cat pose Quaternion r = new Quaternion(PlayerPrefs.GetFloat("pose.r.x"), PlayerPrefs.GetFloat("pose.r.y"), PlayerPrefs.GetFloat("pose.r.z"), PlayerPrefs.GetFloat("pose.r.w")); Vector3 p = new Vector3(PlayerPrefs.GetFloat("pose.p.x"), PlayerPrefs.GetFloat("pose.p.y"), PlayerPrefs.GetFloat("pose.p.z")); gameObject.transform.SetPositionAndRotation(p, r); // TODO: color, other info Debug.Log("--- LOADED --"); Debug.Log(personality); Debug.Log(stats); Debug.Log(style); Debug.Log("-------------"); }
public void catsEvacuated(IList <GameObject> cats) { foreach (GameObject cat in cats) { CatStyle catStyle = cat.GetComponent <CatStyle>(); playerMoney = playerMoney + catStyle.breedData.value; } }
// Called when there is no save to generate a new random cat public void CreateNew() { // Initialize stats for a completely content cat stats = new CatStats(); // Initialize personality to random values personality = CatPersonality.RandomPersonality(); // Initialize the style to random color style = CatStyle.RandomStyle(); // Initialize no achievements achievements = new CatAchievements(); }
public void SpawnCatsRandom(int howManyCats) { Bounds bounds = spawnArea.bounds; Vector2 center = bounds.center; for (int i = 0; i < howManyCats; i++) { float x = 0; float y = 0; do { x = Random.Range(center.x - bounds.extents.x, center.x + bounds.extents.x); y = Random.Range(center.y - bounds.extents.y, center.x + bounds.extents.y); } while (!spawnArea.OverlapPoint(new Vector2 { x = x, y = y })); GameObject cat = Instantiate(catPrefab, new Vector3 { x = 0f, y = 0f, z = 0f }, Quaternion.identity); cat.transform.SetParent(catWrapper.transform, false); //place cat at random point cat.transform.localPosition = new Vector3 { x = x, y = y, z = 0f }; // Set the breed of the cat to a random breed from the breed dictionary CatStyle catStyle = catPrefab.GetComponent <CatStyle>(); // TEMPORARY CODE TO LIMIT BREEDS TO BELLYCAT CatBreed breedInfo = breedArray[(int)Random.Range(0f, breedArray.Length - 1)]; while (breedInfo.variantSprite != bellyCat) { breedInfo = breedArray[(int)Random.Range(0f, breedArray.Length - 1)]; } catStyle.breedData = breedInfo; cat.GetComponent <CatBehavior>().fondness = breedInfo.breedFondnessMult; } }