public void SpawnClothesOnAnimal(GameObject animal, Animal.AnimalType animalType, int clothingID) { /*---Spawns clothing according to what animal type the item is intended for---*/ if (animalType == Animal.AnimalType.Alpaca) { GameObject newOutfitItem = Instantiate(ClothingManager.instance.clothes[clothingID].item); newOutfitItem.transform.localScale = ClothingManager.instance.clothes[clothingID].spawnScaleAlpaca; newOutfitItem.transform.parent = animal.transform; newOutfitItem.transform.localPosition = ClothingManager.instance.clothes[clothingID].spawnPositionAlpaca; newOutfitItem.transform.localRotation = Quaternion.Euler(ClothingManager.instance.clothes[clothingID].spawnRotationAlpaca); } else if (animalType == Animal.AnimalType.Sheep) { GameObject newOutfitItem = Instantiate(ClothingManager.instance.clothes[clothingID].item); newOutfitItem.transform.localScale = ClothingManager.instance.clothes[clothingID].spawnScaleSheep; newOutfitItem.transform.parent = animal.transform; newOutfitItem.transform.localPosition = ClothingManager.instance.clothes[clothingID].spawnPositionSheep; newOutfitItem.transform.localRotation = Quaternion.Euler(ClothingManager.instance.clothes[clothingID].spawnRotationSheep); } else if (animalType == Animal.AnimalType.Rabbit) { GameObject newOutfitItem = Instantiate(ClothingManager.instance.clothes[clothingID].item); newOutfitItem.transform.localScale = ClothingManager.instance.clothes[clothingID].spawnScaleRabbit; newOutfitItem.transform.parent = animal.transform; newOutfitItem.transform.localPosition = ClothingManager.instance.clothes[clothingID].spawnPositionRabbit; newOutfitItem.transform.localRotation = Quaternion.Euler(0, 0, 0); } }
public void CheckForChallenge(Animal.AnimalType animalType, Player player) { bool challengeMatched = false; foreach (Player _player in GameManager.Instance.AllPlayers) { if (_player == player) { foreach (Challenge challenge in _player.PlayerChallenges) { if (challenge.AnimalToKillOrTrap == animalType) { challenge.AmountCollectedKilledTrapped++; challengeMatched = true; break; } } break; // Not sure } } if (challengeMatched) { UpdateShopChallenges(player); } }
/*----------------Animal Creation------------------------------------------------------*/ public GameObject SpawnAnimalType(Animal.AnimalType animalType) { /* Returns an animal prefab based on a enum parameter * instantiates animal with placeholder position and rotation */ GameObject newAnimal; if (animalType == Animal.AnimalType.Alpaca) { newAnimal = Instantiate(alpacaPrefab, new Vector3(0, 0, 0), Quaternion.identity); } else if (animalType == Animal.AnimalType.Sheep) { newAnimal = Instantiate(sheepPrefab, new Vector3(0, 0, 0), Quaternion.identity); } else if (animalType == Animal.AnimalType.Rabbit) { newAnimal = Instantiate(rabbitPrefab, new Vector3(0, 0, 0), Quaternion.identity); } else { newAnimal = null; } return(newAnimal); }
public void SpawnAnimalTypeWithLocation(Animal.AnimalType animalType, GameObject location) { /* Returns an animal prefab based on a enum parameter * instantiates animal with placeholder position and rotation */ GameObject newAnimal; if (animalType == Animal.AnimalType.Alpaca) { newAnimal = Instantiate(alpacaPrefab, location.transform.position, Quaternion.identity); } else if (animalType == Animal.AnimalType.Sheep) { newAnimal = Instantiate(sheepPrefab, location.transform.position, Quaternion.identity); } else if (animalType == Animal.AnimalType.Rabbit) { newAnimal = Instantiate(rabbitPrefab, location.transform.position, Quaternion.identity); } else { newAnimal = null; } Animal animalInfo = newAnimal.GetComponent <Animal>(); InitializeNewAnimal(animalInfo, animalType); //have to adjust MeshRenderer to SKinnedMeshRenderer for Alpaca if (animalType == Animal.AnimalType.Alpaca) { animalInfo.wool.GetComponent <SkinnedMeshRenderer>().material = FurManager.instance.furs[animalInfo.fur.furID].furMaterial; } else { animalInfo.wool.GetComponent <MeshRenderer>().material = FurManager.instance.furs[animalInfo.fur.furID].furMaterial; } SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot01.clothingID); SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot02.clothingID); SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot03.clothingID); animalInfo.pen = location.gameObject.name; animals.Add(animalInfo); }
public void SpawnNewAnimal(Animal.AnimalType animalType) { /* Spawns a new animal based on a enum parameter * initializes new animal with starting traits * and adds the new animals info to the animals List to be saved and loaded */ GameObject newAnimal = null; if (animalType == Animal.AnimalType.Alpaca) { newAnimal = SpawnAnimalType(Animal.AnimalType.Alpaca); FindObjectOfType <AudioManager>().Play("Alpaca"); } else if (animalType == Animal.AnimalType.Sheep) { newAnimal = SpawnAnimalType(Animal.AnimalType.Sheep); FindObjectOfType <AudioManager>().Play("Sheep"); } else if (animalType == Animal.AnimalType.Rabbit) { newAnimal = SpawnAnimalType(Animal.AnimalType.Rabbit); FindObjectOfType <AudioManager>().Play("Rabbit"); } Animal animalInfo = newAnimal.GetComponent <Animal>(); InitializeNewAnimal(animalInfo, animalType); if (animalInfo.animalType == Animal.AnimalType.Alpaca) { animalInfo.wool.GetComponent <SkinnedMeshRenderer>().material = FurManager.instance.furs[animalInfo.fur.furID].furMaterial; } else { animalInfo.wool.GetComponent <MeshRenderer>().material = FurManager.instance.furs[animalInfo.fur.furID].furMaterial; } SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot01.clothingID); SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot02.clothingID); SpawnClothesOnAnimal(newAnimal, animalInfo.animalType, animalInfo.slot03.clothingID); animals.Add(animalInfo); //other animals to be added later(sheep, rabbit) }
public void InitializeNewAnimal(Animal animalInfo, Animal.AnimalType animalType) { /* Initializes a new animal with un-upgraded starting traits * assigns them a unique ID * assigns their type */ animalInfo.animalID = saves.Count; while (saves.ContainsKey(animalInfo.animalID)) { animalInfo.animalID += 1; } animalInfo.name = GenerateRandomName(); animalInfo.animalType = animalType; animalInfo.fur = startingFurItem; animalInfo.slot01 = startingAccessory; animalInfo.slot02 = startingTorso; animalInfo.slot03 = startingShoe; saves.Add(animalInfo.animalID, animalInfo.GetAnimalSave()); return; }
/// <summary> /// left click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void animalClick(object sender, EventArgs e) { Button btn = sender as Button; // achieve animal animal a = btn.Tag as animal; //if status is not start, then return if (status != "start") { return; } string color = this_user == 1 ? user1_color : user2_color; if (!a.isUse) { //Version 1: display text // btn.Text = AnimalType.getText(a.animal_type); //set blank background is white btn.BackColor = Color.White; if (a.user_type == "blue") { //version 1: change text color //btn.ForeColor = Color.Blue; //version 2:add picture btn.BackgroundImage = Image.FromFile(AnimalType.getImageBlue(a.animal_type)); btn.BackgroundImageLayout = ImageLayout.Stretch; } else { //version 1: change text color //btn.ForeColor = Color.Red; //version 2:add picture btn.BackgroundImage = Image.FromFile(AnimalType.getImageRed(a.animal_type)); btn.BackgroundImageLayout = ImageLayout.Stretch; } //change status to uncovered a.isUse = true; //initial click to determine which color is next if (user1_color == null) { user1_color = a.user_type; if (user1_color == "blue") { user2_color = "red"; //switch color this.this_user = 2; displayUser(); } else { user2_color = "blue"; //switch color this.this_user = 2; displayUser(); } } else { //switch this.this_user = this_user == 1 ? 2 : 1; displayUser(); } selectButton = null; } else if (color == a.user_type) { //select button this.selectButton = btn; } else if (selectButton != null) { //attack //determine distance Point p1 = (btn.Parent as Panel).Location; Point p2 = (selectButton.Parent as Panel).Location; //can only move up down left or right if (p1.X != p2.X && p1.Y != p2.Y) { return; } if (p1.Y == p2.Y) { if (Math.Abs(p1.X - p2.X) > this.edge) { return; } } else { if (Math.Abs(p1.Y - p2.Y) > this.edge) { return; } } //compare animal a2 = this.selectButton.Tag as animal; //cannot beat your own animals if (a2.user_type == a.user_type) { return; } if (!AnimalType.canEat(a2.animal_type, a.animal_type)) { //cannot beat return; } //can beat selectButton.Controls.Remove(selectButton); btn.Parent.Controls.Add(selectButton); btn.Parent.Controls.Remove(btn); //remove beaten ones if (a.user_type == "blue") { Blue_buttons.Remove(btn); } else { Red_buttons.Remove(btn); } bool ove = isOver(); if (ove) { MessageBox.Show("Congrats! You Won!"); status = "over"; return; } else { //switch player this.this_user = this_user == 1 ? 2 : 1; displayUser(); } this.selectButton = null; } }