moved Cow.cs and Chicken.cs into Animals Folder
Chicken lays eggs now every day
This commit is contained in:
parent
4a8067d3d7
commit
2d51baacd8
10 changed files with 140 additions and 106 deletions
|
|
@ -43,6 +43,8 @@ namespace Actions {
|
|||
/// </summary>
|
||||
private void instantiateNextDayActionHandlers() {
|
||||
_nextDayActionHandlers.Add(new FarmlandTileNextDayActionHandler());
|
||||
|
||||
_nextDayActionHandlers.Add(new ChickenAnimalNextDayActionHandler());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace Actions {
|
|||
bool rv = false;
|
||||
try {
|
||||
_animal = gameObject.GetComponent<Animal>();
|
||||
rv = true;
|
||||
rv = _animal != null;
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
|
|
|||
3
Assets/Scripts/Animals.meta
Normal file
3
Assets/Scripts/Animals.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5a4be6858d3c4eed8f7ed2e541649875
|
||||
timeCreated: 1656052815
|
||||
17
Assets/Scripts/Animals/Chicken.cs
Normal file
17
Assets/Scripts/Animals/Chicken.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Actions;
|
||||
|
||||
namespace Animals {
|
||||
public class Chicken : Animal {
|
||||
void Start() {
|
||||
HouseController.NewDayEvent.AddListener(LayEgg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives a Random amount of eggs to the player
|
||||
* Directly into the Inventory
|
||||
*/
|
||||
private void LayEgg() {
|
||||
ActionManager.Instance.NextDayAction(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animals/Chicken.cs.meta
Normal file
11
Assets/Scripts/Animals/Chicken.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ca3402310a920b4a81fc0240a161965
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/Animals/Cow.cs
Normal file
31
Assets/Scripts/Animals/Cow.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Actions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animals {
|
||||
public class Cow : Animal {
|
||||
private bool _canBeMilked;
|
||||
|
||||
private void Awake() {
|
||||
_canBeMilked = true;
|
||||
HouseController.NewDayEvent.AddListener(UpdateCanBeMilked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the _canBeMilked bool
|
||||
*/
|
||||
private void UpdateCanBeMilked() {
|
||||
Debug.Log("_ca" + _canBeMilked);
|
||||
_canBeMilked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Milk if cow is able to be milked
|
||||
*/
|
||||
private void OnMouseDown() {
|
||||
if(_canBeMilked) {
|
||||
ActionManager.Instance.ClickAction(gameObject, PlayerController.instance.SelectedItem);
|
||||
_canBeMilked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using Actions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cow : Animal {
|
||||
private bool _canBeMilked;
|
||||
|
||||
private void Awake() {
|
||||
_canBeMilked = true;
|
||||
HouseController.NewDayEvent.AddListener(UpdateCanBeMilked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the _canBeMilked bool
|
||||
*/
|
||||
private void UpdateCanBeMilked() {
|
||||
Debug.Log("_ca" + _canBeMilked);
|
||||
_canBeMilked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Milk if cow is able to be milked
|
||||
*/
|
||||
private void OnMouseDown() {
|
||||
if(_canBeMilked) {
|
||||
ActionManager.Instance.ClickAction(gameObject, PlayerController.instance.SelectedItem);
|
||||
_canBeMilked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue