void Start() { _isRunningSimulation = false; _entityList = new List <Script_IEntity> (); cameraXPosition = width * 0.5f - tileSize * 0.5f; cameraZPosition = height * 0.5f - tileSize * 0.5f; cameraYPosition = 15.0f; cameraForward = new Vector3(0, -1, 0); cameraUp = new Vector3(0, 0, 1); Camera.main.transform.position = new Vector3(cameraXPosition, cameraYPosition, cameraZPosition); Camera.main.transform.rotation = Quaternion.LookRotation(cameraForward, cameraUp); _grid = new Script_Grid(this); _grid.InstantiateGrid(10, 10, 0); InstantiateEntityAtRandomLocation <Script_TradingPost> (); InstantiateEntityAtRandomLocation <Script_FallenStar> (); InstantiateEntityAtRandomLocation <Script_SpaceShip> (); InstantiateEntityAtRandomLocation <Script_StarChaser>(); _ui = new Script_UI(_grid, this); }
void Awake() { _tileHeight = -1.0f; _senseTimerFrequency = 1.0f; _decideTimerFrequency = 1.0f / 2.0f; _actTimerFrequency = 1.0f / 30.0f; senseTimer = 0.0f; decideTimer = 0.0f; actTimer = 0.0f; cameraXPosition = width * 0.5f - tileSize * 0.5f; cameraZPosition = height * 0.5f - tileSize * 0.5f; cameraYPosition = 10.0f; cameraForward = new Vector3(0, -1, 0); cameraUp = new Vector3(0, 0, 1); Camera.main.transform.position = new Vector3(cameraXPosition, cameraYPosition, cameraZPosition); Camera.main.transform.rotation = Quaternion.LookRotation(cameraForward, cameraUp); GridTile = Resources.Load("Prefab_GridTile") as GameObject; Grid = new Script_Grid(this); Grid.InstantiateGrid(GridTile, 10, 10, _tileHeight, transform.rotation); GameObject sheep = Resources.Load("Prefab_Sheep") as GameObject; Grid.CreateSheep(sheep, 10, 10, 0, transform.rotation, 10); GameObject wolf = Resources.Load("Prefab_Wolf") as GameObject; Grid.CreateWolves(wolf, 10, 10, 0, transform.rotation, 3); }
public Script_Action_MoveTowardsEntity(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_entityFlag, Script_IEntity p_entityToMove) { _tree = p_tree; _grid = p_grid; _entityFlag = p_entityFlag; _entityToMove = p_entityToMove; }
public Script_Enemy(Script_GameManager p_manager, Script_Grid p_grid, Vector3Int p_gridLocation) { _attackRange = 1; _engageTargetRange = 3; _threatMultiplier = 1; _stats = new EntityStats(10, 0, 100, 1.5f); _targetToAttack = null; _threatDictionary = new Dictionary <Script_IFriendly, int> (); _health = _stats._maxHealth; _manager = p_manager; _grid = p_grid; _gridLocation = p_gridLocation; _position = p_gridLocation; _gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); _gameObject.name = "EnemyObject"; _objectMaterial = _gameObject.GetComponent <Renderer>().material; _objectMaterial.color = Color.red; _gameObject.transform.position = p_gridLocation; InitializeThreatList(); InitializeBehaviourTree(); }
public Script_AStar(Script_Grid p_grid) { _openDictionary = new Dictionary <int, Script_Node> (); _closedDictionary = new Dictionary <int, Script_Node> (); _grid = p_grid; }
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()); }
void Start() { _cameraXPosition = _width * 0.5f - _tileSize * 0.5f; _cameraZPosition = _height * 0.5f - _tileSize * 0.5f; _cameraYPosition = 10.0f; _cameraForward = new Vector3(0, -1, 0); _cameraUp = new Vector3(0, 0, 1); _camera = Camera.main; _camera.transform.position = new Vector3(_cameraXPosition, _cameraYPosition, _cameraZPosition); _camera.transform.rotation = Quaternion.LookRotation(_cameraForward, _cameraUp); _grid = new Script_Grid(); _grid.InstantiateGrid(10, 10, 0); _friendlyList = new List <Script_IEntity> (); _enemyList = new List <Script_IEntity> (); _projectileList = new List <Script_IProjectile>(); _visualEffectsList = new List <Script_IVisual> (); _damageDealer = new Script_DamageDealer(this, _grid, new Vector3Int(6, 0, 5)); _friendlyList.Add(_damageDealer); _healer = new Script_Healer(this, _grid, new Vector3Int(4, 0, 5)); _friendlyList.Add(_healer); _tank = new Script_Tank(this, _grid, new Vector3Int(5, 0, 5)); _friendlyList.Add(_tank); _tank.InitializeBehaviourTree(); _healer.InitializeBehaviourTree(); _damageDealer.InitializeBehaviourTree(); _enemySpawner = new Script_EnemySpawner(this, _grid); }
public Script_Action_SetNearestLocationSurroundingEntity(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_entityToGetLocationAround, Script_IEntity p_fromEntity, blackboard_flags p_locationToMoveTowardsFlag) { _tree = p_tree; _grid = p_grid; _fromEntity = p_fromEntity; _locationToMoveTowardsFlag = p_locationToMoveTowardsFlag; _entityToGetLocationAround = p_entityToGetLocationAround; }
public Script_Action_SetRandomLocationWithinRange(Script_BehaviourTree p_tree, blackboard_flags p_locationFlag, Script_IEntity p_entityToCalculateFrom, Script_Grid p_grid, int p_range) { _tree = p_tree; _entity = p_entityToCalculateFrom; _locationFlag = p_locationFlag; _grid = p_grid; _range = p_range; }
public Script_Action_SetNearestEntityFromEntityWithinRange(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_entityListFlag, int p_range, Script_IEntity p_fromEntity, blackboard_flags p_returnedEntityFlag) { _grid = p_grid; _tree = p_tree; _entityListFlag = p_entityListFlag; _range = p_range; _fromEntity = p_fromEntity; _returnedNearestEntityFlag = p_returnedEntityFlag; }
public Script_Condition_IsEntityNearby(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_entityFlag, Script_IEntity p_measuredFromEntity, int p_range) { _tree = p_tree; _entityFlag = p_entityFlag; _grid = p_grid; _measuredFromEntity = p_measuredFromEntity; _range = p_range; }
public Script_Action_SetEntitiesWithinRange(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_listOfEntitiesFlag, blackboard_flags p_listOfEntitiesWithinRangeFlag, Script_IEntity p_entityToCalculateRangeFrom, int p_range) { _tree = p_tree; _range = p_range; _entityToCalculateRangeFrom = p_entityToCalculateRangeFrom; _listOfEntitiesFlag = p_listOfEntitiesFlag; _listOfEntitiesWithinRangeFlag = p_listOfEntitiesWithinRangeFlag; _grid = p_grid; }
public Script_Condition_IsEntityTypeNearby(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_entityListFlag, Script_IEntity p_targetEntity, int p_range) { _tree = p_tree; _entityListFlag = p_entityListFlag; _grid = p_grid; _targetEntity = p_targetEntity; _range = p_range; }
public Script_TileGrass(Script_GameManager p_gameManager, Script_Grid p_grid, Vector3Int p_position) { _meshObjectName = "ObjectSpaceGrass"; _meshObjectColor = new Color(0.0f, 1.0f, 0.0f); _meshObjectScale = new Vector3(0.1f, 0.1f, 0.1f); _isWalkable = true; _position = p_position; _gameManager = p_gameManager; CreateGameObject(); }
public Script_TradingPost(Script_GameManager p_gameManager, Script_Grid p_grid, Vector3Int p_gridPosition) { _meshObjectName = "ObjectTradingPost"; _meshObjectColor = new Color(1.0f, 0.2f, 0.0f); _meshObjectScale = new Vector3(0.8f, 0.8f, 0.8f); _startLocation = p_gridPosition; _gridPosition = p_gridPosition; _gameManager = p_gameManager; CreateGameObject(); }
public Script_Tile(Script_Grid p_grid, GrassStates p_state, int p_gridXCoordinate, int p_y, int p_gridZCoordinate, Quaternion p_rotation) { _position = new Vector3Int(p_gridXCoordinate, -1, p_gridZCoordinate); _tileObject = GameObject.CreatePrimitive(PrimitiveType.Cube); _tileObject.name = "TileObject"; _tileObject.transform.position = _position; _tileObject.transform.rotation = p_rotation; _material = _tileObject.GetComponent <Renderer>().material; _material.color = Color.white; _nearbySheep = new List <Script_Sheep> (); _isOccupiedBySheep = false; _isOccupiedByWolf = false; _grid = p_grid; _gridXCoordinate = p_gridXCoordinate; _gridZCoordinate = p_gridZCoordinate; _sheepSensingRange = 2; _isOld = false; _actDelegate = null; _matureTimerMax = 5.0f; _matureTimerCurrent = 0.0f; _isMature = false; _maxHealth = 10.0f; _state = p_state; _colorDirt = new Color(1, 1, 0, 1); _colorGrass = new Color(0, 1, 1, 1); _colorDecayingGrass = new Color(0.5f, 0.5f, 0, 1); _isTrampledUpon = false; _isEatenUpon = false; if (_state == GrassStates.Dirt) { _health = 0.0f; _colorCurrent = _colorDirt; } else if (_state == GrassStates.Grass) { _health = 8.0f; _colorCurrent = Color.Lerp(_colorDecayingGrass, _colorGrass, _health / _maxHealth); } SetColor(_colorCurrent); }
public Script_StarChaser(Script_GameManager p_manager, Script_Grid p_grid, Vector3Int p_position) { _meshObjectName = "ObjectStarChaser"; _meshObjectColor = new Color(1.0f, 1.0f, 1.0f); _meshObjectScale = new Vector3(1.0f, 1.0f, 1.0f); _nodeCollisionRange = 0.1f; _targetNode = null; _pathList = new List <Script_Node> (); _gridPosition = p_position; _manager = p_manager; _grid = p_grid; _speed = 1.0f; _position = (Vector3)p_position; _startLocation = p_position; _chasingState = new Script_StateChasingStar(_grid, _manager, this); _sellingState = new Script_StateSellStar(_grid, _manager, this); _restingState = new Script_StateRest(_grid, _manager, this); _doNothingState = new Script_StateDoNothing(_manager, this); _stateManager = new Script_Statemachine(); _doNothingState.SetNextState(StateIDs.CHASINGFALLENSTAR); _chasingState.SetNextState(StateIDs.SELLINGFALLENSTAR); _sellingState.SetNextState(StateIDs.RESTING); _restingState.SetNextState(StateIDs.DOINGNOTHING); _stateManager.AddState(StateIDs.CHASINGFALLENSTAR, _chasingState); _stateManager.AddState(StateIDs.SELLINGFALLENSTAR, _sellingState); _stateManager.AddState(StateIDs.RESTING, _restingState); _stateManager.AddState(StateIDs.DOINGNOTHING, _doNothingState); _stateManager.SetState(StateIDs.DOINGNOTHING); _nextState = StateIDs.DOINGNOTHING; CreateGameObject(); }
public Script_StateRest(Script_Grid p_grid, Script_GameManager p_manager, Script_StarChaser p_creator) { _pathObjectScale = new Vector3(0.1f, 0.1f, 0.1f); _pathObjectColor = Color.yellow; _pathObjectString = "PathObject"; _manager = p_manager; _pathObjects = new List <GameObject> (); _pathObjectsMaterials = new List <Material> (); _pathfinding = new Script_AStar(p_grid); _gridPosition = p_creator.GetGridPosition(); _pathList = new List <Script_Node> (); _grid = p_grid; _pathfinding = new Script_AStar(_grid); _creator = p_creator; _nextState = StateIDs.DOINGNOTHING; }
public Script_DamageDealer(Script_GameManager p_manager, Script_Grid p_grid, Vector3Int p_gridLocation) { _attackRange = 3; _engageTargetRange = 3; _threatMultiplier = 1; _stats = new EntityStats(10, 0, 100, 1.5f); _health = _stats._maxHealth; _manager = p_manager; _grid = p_grid; _gridLocation = p_gridLocation; _position = p_gridLocation; _gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); _gameObject.name = "DamageDealerObject"; _objectMaterial = _gameObject.GetComponent <Renderer>().material; _objectMaterial.color = Color.cyan; _gameObject.transform.position = p_gridLocation; }
public Script_Action_OccupyTile(Script_BehaviourTree p_tree, Script_Grid p_grid, blackboard_flags p_flag) { _tree = p_tree; _grid = p_grid; _flag = p_flag; }
public Script_EnemySpawner(Script_GameManager p_manager, Script_Grid p_grid) { _maxEnemyAmount = 3; _manager = p_manager; _grid = p_grid; }