// Use this for initialization void Start() { startTimer = timer; wander = GetComponent <WanderBehavior>(); seek = GetComponent <SeekBehavior>(); arrive = GetComponent <ArriveBehavior>(); }
// Use this for initialization void Start() { timer = transitionTime; agent = GetComponent <NavMeshAgent>(); wander = GetComponent <WanderBehavior>(); seek = GetComponent <SeekBehavior>(); flee = GetComponent <FleeBehavior>(); }
// Use this for initialization void Start() { agent = GetComponent <NavMeshAgent>(); wander = GetComponent <WanderBehavior>(); seek = GetComponent <SeekBehavior>(); flee = GetComponent <FleeBehavior>(); Energy = maxEnergy; }
// Use this for initialization void Start() { timer = transitionTime; agent = GetComponent <NavMeshAgent>(); wander = GetComponent <WanderBehavior>(); arrive = GetComponent <ArriveBehavior>(); flee = GetComponent <Flee>(); }
// Use this for initialization void Start() { currentState = new Stack <IState>(); wanderState = GetComponent <WanderBehavior>(); evadeState = GetComponent <EvadeWander>(); seekState = GetComponent <seeker>(); currentState.Push(seekState); }
void FlyAndShootUpdate() { //Movement Vector3 _acceleration = new Vector3(0.0f, 0.0f, 0.0f); //_acceleration += WanderBehavior.Calculate(gameobject, weight); _acceleration = BehaviourUpdate.BehaviourUpdated(WanderBehavior.WanderMove(this.transform, enemyData.WanderRadius, enemyData.WanderDistance, enemyData.WanderJitter, 3.0f), enemyData.WanderBehaviorWeight); //_acceleration += (Vector3)(BehaviourUpdate.BehaviourUpdated(WallAvoidance.WallAvoidanceCalculation(transform,_botLeftBound.position.x,_topRightBound.position.x,_topRightBound.position.y,_botLeftBound.position.y),enemyData.WallAvoidWeight)); _velocity += _acceleration * Time.deltaTime; if (_velocity.magnitude > enemyData.MaxSpeed) { _velocity.Normalize(); _velocity *= enemyData.MaxSpeed; } if (transform.position.x < _botLeftBound.position.x) { _velocity.x *= -1; } if (transform.position.x > _topRightBound.position.x) { _velocity.x *= -1; } if (transform.position.y < _topRightBound.position.y) { _velocity.y *= -1; } if (transform.position.y > _botLeftBound.position.y) { _velocity.y *= -1; } transform.position += _velocity * Time.deltaTime; //Shooting if (_nextAttackTime < Time.time) { animator.SetBool("Shoot", true); Invoke("unplayAnimation", 0.5f); //var targetlist = LevelManager.Instance.Train.GetTurrets(); _nextAttackTime = Time.time + enemyData.AttackDelay + Random.Range(-enemyData.AttackDelay * 0.1f, enemyData.AttackDelay * 0.1f); Invoke("delayshoot", 0.75f); } if (_nextAttackTime < (Time.time + enemyData.AttackDelay - enemyData.AttackDelay * 0.1f)) { boom.SetActive(false); } else { boom.SetActive(true); } }
void Start() { m_SteeringBehavior = new WanderBehavior(); Color color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)); foreach (Renderer renderer in gameObject.GetComponentsInChildren <Renderer>()) { renderer.materials[0].color = color; } m_CurrentCol = -1; m_CurrentRow = -1; }
public void Start() { //steerings.Add(new SeekSteering { target = seekTarget });//seeks target //steerings.Add(new FleeSteering { target = fleeTarget });//flees target wander = new WanderBehavior { radius = wanderRadius, distance = wanderDistance }; //wanders steerings.Add(wander); steerings.Add(new pursueBehavior { target = pursueTarget }); //pursue target steerings.Add(new evadeBehavior { target = evadeTarget }); }
void WanderIdle() { //Movement Vector3 _acceleration = new Vector3(0.0f, 0.0f, 0.0f); _acceleration = BehaviourUpdate.BehaviourUpdated(WanderBehavior.WanderMove(this.transform, enemyData.WanderRadius, enemyData.WanderDistance, enemyData.WanderJitter, 1.0f), enemyData.WanderBehaviorWeight); _velocity += _acceleration * Time.deltaTime; if (_velocity.magnitude > enemyData.MaxSpeed) { _velocity.Normalize(); _velocity *= enemyData.MaxSpeed; } if (transform.position.x > _botLeftBound.position.x + 1.0f) { _velocity.x *= -1; } if (transform.position.x < _topRightBound.position.x - 1.0f) { _velocity.x *= -1; } if (transform.position.y < _topRightBound.position.y - 2.0f) { _velocity.y *= -1; } if (transform.position.y > _botLeftBound.position.y + 2.0f) { _velocity.y *= -1; } transform.position += _velocity * Time.deltaTime; //Shooting if (_nextAttackTime < Time.time) { mCurrentState = State.MoveToTarget; // _nextAttackTime = enemyData.AttackDelay + Time.time; } }
public SteeringSystem(IEntity self) : base(self) { Wander = new WanderBehavior <WPP>(self) { Parameters = new WPP(1, 0.24f) }; PathFollow = new PathFollowingBehavior <WPP>(self) { Parameters = new WPP(2, 1) }; Arrive = new ArriveBehavior <WPP>(self) { Parameters = new WPP(3, 1) }; AlignTarget = new AlignTargetBehavior <WPP>(self) { Parameters = new WPP(3, 1f) }; Erratic = new ErraticOutburstBehavior <WPP>(self) { Parameters = new WPP(4, 1f) }; FlockSeparate = new FlockSeparationBehavior <WPP>(self) { Parameters = new WPP(0.42f) }; AvoidWalls = new ObstacleAvoidanceBehavior <WPP>(self) { Parameters = new WPP(0.84f) }; AlignVelocity = new AlignVelocityBehavior <WPP>(self) { Parameters = new WPP(1) }; }
// Use this for initialization void Start() { coreBlinkAnimation = GetComponentInChildren <BlinkDamageAnimation> (); currentHealth = maxHealth; difficulty = 0; wanderBehavior = GetComponent <WanderBehavior> (); wanderBehavior.setActive(true); followBehavior = GetComponent <FollowBehavior> (); wanderBehavior.setActive(false); shieldSpawner = GetComponentInChildren <ShieldSpawner> (); gunSpawner = GetComponentInChildren <GunSpawner> (); wallGunSpawner = GetComponentInChildren <WallGunSpawner> (); targetFire = GetComponent <TargettedFireBehavior> (); trapSpawner = GetComponentInChildren <TrapSpawner> (); nextBehaviorStartTime = Time.time + behaviorDelay; nextBehaviorEndTime = nextBehaviorStartTime + behaviorDuration; // targetFire.setStatus (true); // wallGunSpawner.setStatus (true); gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> (); }
private void setUpBehaviors() { //This is where you can add new behaviors, or change the ordering //Behaviors at the end of the array take precedence over earlier //behaviors WanderBehavior wb = new WanderBehavior(this, rand); GoToResourceBehavior gtrb = new GoToResourceBehavior(this); TakeResourceBehavior trb = new TakeResourceBehavior(this); GoToHQBehavior gthqb = new GoToHQBehavior(this); DepositResourcesBehavior drb = new DepositResourcesBehavior(this); GoToTowerBehavior gttb = new GoToTowerBehavior(this); RestoreTowerBehavior rtb = new RestoreTowerBehavior(this); HelpTeammateBehavior htb = new HelpTeammateBehavior(this); AttackEnemyBehavior aeb = new AttackEnemyBehavior(this, rand); bManager = new BehaviorManager(new IBehavior[]{wb, gtrb, trb, gthqb, drb, gttb, rtb, htb, aeb}); //In this example, aeb takes precedence over all other behaviors //In other words, attacking an enemy is more important than //anything else //The wandering behavior is only activated if there is nothing //else to do }
// Use this for initialization void Start() { agent = GetComponent <NavMeshAgent>(); wander = GetComponent <WanderBehavior>(); currentEnergy = maxEnergy; }
// Use this for initialization void Start() { wander = GetComponent <WanderBehavior>(); agent = GetComponent <NavMeshAgent>(); }
private void Start() { WanderBehavior = new WanderBehavior(WanderRadius, WanderDistance, Jitter); }
// Use this for initialization void Start() { wander = GetComponent <WanderBehavior>(); interpose = GetComponent <InterposeBehavior>(); rb = GetComponent <Rigidbody>(); }
public void GroupBehaviours() { Vector3 _acceleration = new Vector3(0.0f, 0.0f, 0.0f); foreach (var agent in swarmNeighbors) { if (!agent.Attacking) { _acceleration = BehaviourUpdate.BehaviourUpdated(WanderBehavior.WanderMove(agent.transform, enemyData.WanderRadius, enemyData.WanderDistance, enemyData.WanderJitter, 1.0f), enemyData.WanderBehaviorWeight); _acceleration += (Vector3)BehaviourUpdate.BehaviourUpdated(CohesionBehavior.CalculateMove(agent.transform, swarmNeighborsTrans), enemyData.CohesionBehaviorWeight); _acceleration += (Vector3)BehaviourUpdate.BehaviourUpdated(SeparationBehavior.SeparationMove(agent.transform, swarmNeighborsTrans, enemyData.SeparationBehaviorRadius), enemyData.SeparationBehaviorWeight); _acceleration += (Vector3)BehaviourUpdate.BehaviourUpdated(AlignmentBehavior.CalculateMove(agent.transform, swarmNeighborsTrans), enemyData.AlignmentBehaviorWeight); agent.Velocity += _acceleration * Time.deltaTime; if (agent.Velocity.magnitude > enemyData.MaxSpeed) { agent.Velocity.Normalize(); agent.Velocity *= enemyData.MaxSpeed; } if (agent.transform.position.x < _bottomLeft.position.x) { agent.Velocity *= -1; } if (agent.transform.position.x > _topright.position.x) { agent.Velocity *= -1; } if (agent.transform.position.y < _topright.position.y) { agent.Velocity *= -1; } if (agent.transform.position.y > _bottomLeft.position.y) { agent.Velocity *= -1; } //agent.transform.position += agent.Velocity * Time.deltaTime; } else { _acceleration = BehaviourUpdate.BehaviourUpdated(SeekBehaviour.SeekMove(agent.transform, agent.Target, enemyData.Swarm_AttackSpeed), enemyData.SeekBehaviorWeight); agent.Velocity += _acceleration * Time.deltaTime; } Vector3 deltaPos = agent.Velocity * Time.deltaTime; if (deltaPos.x == 0 && deltaPos.y == 0) { Debug.Log("Enemy is stuck!"); } agent.transform.position += agent.Velocity * Time.deltaTime; //_acceleration += (Vector3)(BehaviourUpdate.BehaviourUpdated(WallAvoidance.WallAvoidanceCalculation(agent.transform, _bottomLeft.position.x, _topright.position.x, _topright.position.y, _bottomLeft.position.y), enemyData.WallAvoidWeight)); } //transform.position += _velocity * Time.deltaTime; // { // move = BehaviourUpdate.BehaviourUpdated(CohesionBehavior.CalculateMove(agent.transform, swarmNeighbors), 5.0f); // move *= speed; // if (move.sqrMagnitude > squareMaxSpeed) // { // move = move.normalized * maxSpeed; // } // agent.transform.position += (Vector3)move * Time.deltaTime; // } }
void FlyAndShootUpdate() { //Movement Vector3 _acceleration = new Vector3(0.0f, 0.0f, 0.0f); //_acceleration += WanderBehavior.Calculate(gameobject, weight); _acceleration = BehaviourUpdate.BehaviourUpdated(WanderBehavior.WanderMove(this.transform, enemyData.WanderRadius, enemyData.WanderDistance, enemyData.WanderJitter, 3.0f), enemyData.WanderBehaviorWeight); //_acceleration += WallAvoidance.Calculate(gameobject, weight); //_acceleration += (Vector3)(BehaviourUpdate.BehaviourUpdated(WallAvoidance.WallAvoidanceCalculation(transform,_botLeftBound.position.x,_topRightBound.position.x,_topRightBound.position.y,_botLeftBound.position.y),enemyData.WallAvoidWeight)); _velocity += _acceleration * Time.deltaTime; if (_velocity.magnitude > enemyData.MaxSpeed) { _velocity.Normalize(); _velocity *= enemyData.MaxSpeed; } //if (Mathf.Abs(transform.position.x - _botLeftBound.position.x) > 1.0f) if (transform.position.x < _botLeftBound.position.x) { //_velocity = new Vector3(-_velocity.x, _velocity.y, _velocity.z); _velocity.x *= -1; } //if (Mathf.Abs(transform.position.x - _topRightBound.position.x) > 1.0f) if (transform.position.x > _topRightBound.position.x) { //_velocity = new Vector3(-_velocity.x, _velocity.y, _velocity.z); _velocity.x *= -1; } //if (Mathf.Abs(transform.position.y - _topRightBound.position.y) > 1.0f) if (transform.position.y < _topRightBound.position.y) { //_velocity = new Vector3(_velocity.x, -_velocity.y, _velocity.z); _velocity.y *= -1; } //if (Mathf.Abs(transform.position.y - _botLeftBound.position.y) > 1.0f) if (transform.position.y > _botLeftBound.position.y) { //_velocity = new Vector3(_velocity.x, -_velocity.y, _velocity.z); _velocity.y *= -1; } transform.position += _velocity * Time.deltaTime; //Shooting if (_nextAttackTime < Time.time) { var targetlist = _trainData.ListTurret; int targetSize = targetlist.Length; int randomtarget = Random.Range(0, targetSize); _nextAttackTime = Time.time + enemyData.AttackDelay + Random.Range(-enemyData.AttackDelay * 0.1f, enemyData.AttackDelay * 0.1f); GameObject projectile = _objectPoolManager.GetObjectFromPool("BasicEnemy_Projectile"); projectile.transform.position = transform.position; Vector3 targetPos = targetlist[randomtarget].gameObject.transform.position; projectile.SetActive(true); projectile.GetComponent <EnemyProjectile>().SetData(targetPos, EnemyTypeCheck.Type.Basic); } }