public Script_Wolf(Vector3 p_position, Script_GameManager p_gameManager, Script_Grid p_grid, Quaternion p_rotation) { _wolfObject = GameObject.CreatePrimitive(PrimitiveType.Cube); _wolfObject.name = "WolfObject"; _wolfObject.transform.position = p_position; _wolfObject.transform.rotation = p_rotation; _material = _wolfObject.GetComponent <Renderer>().material; _material.color = Color.black; _speed = 0.033f; _size = 0.5f; _movementDecay = 0.01f; _actionDecay = 0.1f; _sensingRange = 2; _sheepBeingEaten = null; _maxHealth = 10.0f; _health = 5.0f; _healthNeededToReproduce = _maxHealth * 0.75f; _decidedAction = DecidedAction.Wandering; _actDelegate = null; _tilesWithinRange = new List <Script_Tile> (); _sheepWithinRange = new List <Script_Sheep> (); _surroundingTiles = new List <Script_Tile> (); _grid = p_grid; _occupiedLocation = GetCurrentGridPosition(); _targetLocation = GetCurrentGridPosition(); OccupyNewLocation(GetCurrentGridPosition()); }
public void Decide() { _grassBeingEaten = null; if (DecideToDie()) { _decidedAction = DecidedAction.dying; _actDelegate = new ActDelegate(Die); } if (DecideToEvade() && !DecideToDie()) { if (AtTargetLocation() || _decidedAction != DecidedAction.Evading) { DecideDirectionToEvade(); } _decidedAction = DecidedAction.Evading; _actDelegate = new ActDelegate(EvadeToLocation); } else if (DecideToReproduce() && !DecideToDie() && !DecideToEvade()) { _reproductionLocation = DecideReproductionTile(); Script_Tile currentlyOccupiedTile = _grid.AccessGridTile(_reproductionLocation.x, _reproductionLocation.z); currentlyOccupiedTile.SetOccupiedBySheep(false); _decidedAction = DecidedAction.Reproducing; _actDelegate = new ActDelegate(Reproduce); } else if (DecideToEatGrass() && !DecideToDie() && !DecideToReproduce() && !DecideToEvade()) { OccupyNewLocation(GetCurrentGridPosition()); _decidedAction = DecidedAction.Eating; _actDelegate = new ActDelegate(EatGrass); } else if (DecideToSeekGrass() && !DecideToEatGrass() && !DecideToReproduce() && !DecideToDie() && !DecideToEvade()) { if (AtTargetLocation() || _decidedAction != DecidedAction.Seeking) { DecideGrassToSeek(); } _decidedAction = DecidedAction.Seeking; _actDelegate = new ActDelegate(MoveToLocation); } else if (DecideToWander() && !DecideToSeekGrass() && !DecideToEatGrass() && !DecideToReproduce() && !DecideToDie() && !DecideToEvade()) { if (AtTargetLocation() || _decidedAction != DecidedAction.Wandering) { DecideWanderingLocation(); } _decidedAction = DecidedAction.Wandering; _actDelegate = new ActDelegate(MoveToLocation); } }