public override void Enter() { updateRefresh = 0.5f; Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> (); if (wanderBehaviour != null) { wanderBehaviour.enabled = true; wanderBehaviour.weight = 0.25f; } offsetPursueBehaviour = ship.boid.GetBehaviour <OffsetPursue> (); if ((offsetPursueBehaviour == null) || (escortingShip == null)) { AttackEmporer(); } else { offsetPursueBehaviour.enabled = true; offsetPursueBehaviour.leader = escortingShip; offsetPursueBehaviour.RefreshOffset(); } ship.StartCoroutine(IUpdate()); }
public override void Enter() { pursueBehaviour = ship.boid.GetBehaviour <Pursue> (); if (pursueBehaviour != null) { pursueBehaviour.enabled = true; pursueBehaviour.target = target.boid; pursueBehaviour.desiredDistance = desiredDistance; } Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> (); if (wanderBehaviour != null) { wanderBehaviour.enabled = true; wanderBehaviour.weight = 10f; } Flee targetFlee = target.boid.GetBehaviour <Flee> (); if (targetFlee != null) { targetFlee.avoidingBoids.Add(ship.transform); } target.pursuers++; ship.pursuing = target; ship.guns[0].enabled = true; ship.StartCoroutine(IUpdate()); }
// Use this for initialization protected override void Start() { Sight = GetComponent <FieldOfView>(); Search = GetComponent <AStarSearch>(); Path = GetComponent <ASPathFollower>(); Wander = GetComponent <Wander>(); Seek = GetComponent <Seek>(); Flee = GetComponent <Flee>(); Arrive = GetComponent <Arrive>(); Terrain = GameObject.Find("Terrain"); Animator = GetComponent <Animator>(); SearchAgent = GetComponent <ASAgent>(); State = new FiniteStateMachine <Velociraptor>(this); State.Change(V_Idle.Instance); Path.enabled = true; Path.path = new ASPath(); Path.enabled = false; collision_ticks = 0.0f; health_time = 0.0f; hunger_time = 0.0f; thirst_time = 0.0f; base.Start(); }
private void Awake() { if (gameObject.activeSelf == true) { idle = new Idle(this); rest = new Rest(this); eat = new Eat(this); wander = new Wander(this); chase = new Chase(this); flee = new Flee(this); attack = new Attack(this); dead = new Dead(this); navAgent = GetComponentInParent <NavMeshAgent>(); tracker = GameObject.FindGameObjectWithTag("Tracker").GetComponent <Tracking>(); damageOutput = gameObject.GetComponentsInChildren <Damage>(); if (useAnimator == true) { anim = GetComponent <Animator>(); } if (dynamicWandering == false) { spawnpoint = transform.position; } } }
private void Awake() { myWander = this.GetComponentInChildren <Wander>(); myGetLaid = this.GetComponentInChildren <GetLaid>(); RandomiseStats(); }
void Awake() { rb2d = GetComponent<Rigidbody2D>(); enemyFireScript = GetComponent<BasicEnemyFire>(); wanderScript = GetComponent<Wander>(); colliderSize = GetComponent<BoxCollider2D>().size; }
public void WanderOn() { if (!behaviours.Contains(Wander.GetInstance())) { behaviours.Add(Wander.GetInstance()); } }
void Start() { wander = GetComponent <Wander>(); theAudio = FindObjectOfType <AudioManager>(); thePlayerStat = FindObjectOfType <Player_Stat>(); current_interMWT = inter_MoveWaitTime; }
public override void Enter() { ship.StartCoroutine(IUpdate()); patrolBehaviour = ship.boid.GetBehaviour <OffsetPursue> (); Pursue pursueBehaviour = ship.boid.GetBehaviour <Pursue> (); Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> (); if (wanderBehaviour != null) { wanderBehaviour.enabled = true; wanderBehaviour.weight = 0.25f; } if (patrolBehaviour != null) { patrolBehaviour.enabled = true; } if (pursueBehaviour != null) { pursueBehaviour.enabled = false; } }
public void Setup() { GameObject playerGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/Player")); Player = playerGameObject.GetComponent <player>(); GameObject enemyFGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/EnemyFollow")); enemyFollow = enemyFGameObject.GetComponent <Follow>(); GameObject enemyWEGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/EnemyExplode")); enemyWE = enemyWEGameObject.GetComponent <WanderExplode>(); GameObject enemyESGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/succ")); enemySucc = enemyESGameObject.GetComponent <EnemySuck>(); GameObject enemyEPGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/EnemyDropPuddle")); enemyPuddle = enemyEPGameObject.GetComponent <Wander>(); }
// Use this for initialization public void Starta(GameObject plane, GameObject swamps, float nodeSize) { fixedDeadCollider = false; poi = Vector3.zero; health = 100.0f; seesPlayer = false; seesDeadPeople = false; hearsSomething = false; disturbed = false; reachGoal = GetComponent <ReachGoal> (); wander = GetComponent <Wander> (); standstill = GetComponent <StandStill> (); patrol = GetComponent <Patrol> (); gc = player.GetComponent <GoalControl> (); reachGoal.plane = plane; reachGoal.swamps = swamps; reachGoal.nodeSize = nodeSize; reachGoal.goalPos = poi; reachGoal.Starta(); wander.Starta(); patrol.Starta(); standstill.Starta(); anim = GetComponent <Animation> (); anim.CrossFade(idle); walkingSpeed = 10.0f; gunShot = this.GetComponents <AudioSource> ()[0]; lr = this.GetComponentInParent <LineRenderer> (); seenTime = 0f; // Debug.Log (transform.name); }
private void Start() { wander = GetComponent <Wander>(); flee = GetComponent <Flee>(); zombieAnimator = GetComponent <Animator>(); zombieAnimator.GetBehaviours <ZombieState>().ToList().ForEach(zs => zs.zombie = this); }
void Awake() { wanderScript = GetComponent<Wander>(); fireScript = GetComponent<BasicEnemyFire>(); rb2d = GetComponent<Rigidbody2D>(); boxCollider2d = GetComponent<BoxCollider2D>(); }
void Update() { if (Input.GetMouseButtonDown(0)) { UnityEngine.EventSystems.PointerEventData eventData = new UnityEngine.EventSystems.PointerEventData(null); eventData.position = Input.mousePosition; List <UnityEngine.EventSystems.RaycastResult> results = new List <UnityEngine.EventSystems.RaycastResult>(); raycaster.Raycast(eventData, results); foreach (var result in results) { if (result.gameObject.layer == LayerMask.NameToLayer("Octo")) { Wander wander = result.gameObject.GetComponent <Wander>(); if (wander != null) { wander.OnPressed(Input.mousePosition); } else { CapturedOcto captured = result.gameObject.GetComponent <CapturedOcto>(); if (captured != null) { captured.OnPressed(); } } } else if (result.gameObject.layer == LayerMask.NameToLayer("CapturedOcto")) { CapturedOcto captured = result.gameObject.GetComponent <CapturedOcto>(); captured.OnPressed(); } } } }
public Steering GetSteering() { wanderOrientation += Random.Range(-1.0f, 1.0f) * wanderRate; wanderForce = Wander.GetSteering(npc, wanderForce, wanderCooldown, wanderRate, wanderOrientation, wanderCircleOffset, wanderCircleRadius, maxAccel, timeToTarget, visibleRays); return(GetSteering(npc, groupArea, decayCoefficient, maxAccel, visibleRays, timeToTarget, wanderCooldown, wanderRate, wanderOrientation, wanderCircleOffset, wanderCircleRadius, wanderForce, cohesionPriority, separationPriority, alignmentPriority, wanderPriority)); }
void OnTriggerEnter(Collider other) { //transform.localPosition = new Vector3 (transform.localPosition.x, transform.localPosition.y * -1f, 0f); Wander wander = transform.parent.GetComponent <Wander> (); wander.turn += 180f; }
void Awake() { steeringBehaviours = GetComponents <SteeringBehaviour>(); Wander wander = GetComponent <Wander>(); if (wander != null) { initialWanderWeight = wander.weight; } Flocking flocking = GetComponent <Flocking>(); if (flocking != null) { initialAlignmentWeight = flocking.alignmentWeight; initialCohesionWeight = flocking.cohesionWeight; initialSeperationWeight = flocking.seperationWeight; } // Get the physical collider (not the trigger) BoxCollider2D[] boxColliders = GetComponents <BoxCollider2D>(); foreach (BoxCollider2D bc in boxColliders) { if (!bc.isTrigger) { boxCollider = bc; break; } } }
// Use this for initialization protected override void Start() { anim = GetComponent <Animator>(); fov = GetComponent <FieldOfView>(); ankyFleeing = GetComponent <Flee>(); ankyWandering = GetComponent <Wander>(); // Assert default animation booleans and floats anim.SetBool("isIdle", true); anim.SetBool("isEating", false); anim.SetBool("isDrinking", false); anim.SetBool("isAlerted", false); anim.SetBool("isGrazing", false); anim.SetBool("isAttacking", false); anim.SetBool("isFleeing", false); anim.SetBool("isDead", false); anim.SetFloat("speedMod", 1.0f); // This with GetBool and GetFloat allows // you to see how to change the flag parameters in the animation controller stateMachine = new StateMachine <MyAnky>(this); stateMachine.ChangeState(StateBeginning.Instance); gameTimer = Time.time; Debug.Log("Started Anky!"); base.Start(); }
// Use this for initialization protected override void Start() { waterSource = GameObject.Find("Daylight Water"); thirst = 100; health = 100; energy = 100; currentState = ankyState.IDLE; ankyWander = GetComponent <Wander>(); ankyFlee = GetComponent <Flee>(); ankyView = GetComponent <FieldOfView>(); ankyFace = GetComponent <Face>(); ankyFaceEnemy = GetComponent <FaceEnemy>(); ankyPursue = GetComponent <Pursue>(); ankySeek = GetComponent <Seek>(); ankyAgent = GetComponent <Agent>(); anim = GetComponent <Animator>(); // Assert default animation booleans and floats anim.SetBool("isIdle", true); anim.SetBool("isEating", false); anim.SetBool("isDrinking", false); anim.SetBool("isAlerted", false); anim.SetBool("isGrazing", false); anim.SetBool("isAttacking", false); anim.SetBool("isFleeing", false); anim.SetBool("isDead", false); anim.SetFloat("speedMod", 1.0f); // This with GetBool and GetFloat allows // you to see how to change the flag parameters in the animation controller base.Start(); }
//Function to create leader ships void CreateLeaders(Vector3 newpos) { GameObject leader = GameObject.Instantiate <GameObject> (prefab); leader.transform.parent = this.transform; leader.transform.position = this.transform.TransformPoint(newpos); leader.transform.rotation = this.transform.rotation; //add steering behaviours Wander w = leader.AddComponent <Wander>(); Seek seek = leader.AddComponent <Seek> (); seek.enabled = !seek.enabled; //disable seek behaviour ObstacleAvoidance obavd = leader.AddComponent <ObstacleAvoidance> (); //Change speed of boid Boid b = leader.GetComponent <Boid> (); b.maxSpeed = 2; //Create followers of leader for (int i = 1; i <= followers; i++) { Vector3 offset = new Vector3(gap * i, 0, -gap * i); CreateFollower(offset, leader.GetComponent <Boid> ()); offset = new Vector3(-gap * i, 0, -gap * i); CreateFollower(offset, leader.GetComponent <Boid> ()); } }
// Use this for initialization protected override void Start() { Sight = GetComponent <FieldOfView>(); Search = GetComponent <AStarSearch>(); Path = GetComponent <ASPathFollower>(); Wander = GetComponent <Wander>(); Flee = GetComponent <Flee>(); Face = GetComponent <Face>(); Agent = GetComponent <Agent>(); Animator = GetComponent <Animator>(); Terrain = GameObject.Find("Terrain"); SearchAgent = GetComponent <ASAgent>(); herdCentre = GameObject.Find("HerdCentre").gameObject; Path.enabled = true; Path.path = new ASPath(); Path.enabled = false; State = new FiniteStateMachine <Ankylosaurus>(this); State.Change(Idle.Instance); collision_time = 0.0f; health_time = 0.0f; hunger_time = 0.0f; thirst_time = 0.0f; base.Start(); }
public FSMState curState; // current state // Use this for initialization void Awake() { wander = GetComponent <Wander>(); animator = GetComponent <Animator>(); currentChokingDuration = chokeDuration; curState = FSMState.Wander; }
// Use this for initialization void Start() { timer = transitionTime; agent = GetComponent <NavMeshAgent>(); wander = GetComponent <Wander>(); seek = GetComponent <SeekBehaviour>(); flee = GetComponent <RandFlee>(); }
private void Awake() { critter = GetComponent <Critter>(); wander = GetComponent <Wander>(); mtt = GetComponent <MoveToTarget>(); wander.speed = critter.speed; }
void Awake() { projectilePool = GameObject.Find("FireballPool").GetComponent<StackPool>(); animator = GetComponent<Animator>(); mainCam = GameObject.Find("Main Camera").GetComponent<Camera>(); wanderScript = GetComponent<Wander>(); rb2d = GetComponent<Rigidbody2D>(); }
// Use this for initialization void Start() { char_kinematic = GetComponent <Kinematic>(); seek = GetComponent <KinematicSeek>(); arrive = GetComponent <KinematicArrive>(); wander = GetComponent <Wander>(); }
public static Wander GetInstance() { if (instance == null) { instance = new Wander(); } return(instance); }
// Start is called before the first frame update void Start() { myMoveType = new Wander(); myMoveType.character = this; myRotateType = new LookWhereGoing(); myRotateType.character = this; }
public AIState(Agent _agent, Wander _wander, Flee _flee, Seek _seek, Face _face) { agent = _agent; wander = _wander; flee = _flee; seek = _seek; face = _face; }
private void Start() { animator = GetComponent <Animator>(); aiAgent = this.GetComponent <AIAgent>(); rb = GetComponent <Rigidbody>(); agent = this.GetComponent <NavMeshAgent>(); wanderScript = GetComponent <Wander>(); playerStats = GameObject.Find("Player").GetComponent <PlayerStats>(); target = GameObject.Find("Player").GetComponent <Transform>(); }
void SetupWanderScripts() { wanderScripts = new Wander[points.Length]; for (int i = 0; i < points.Length; i++) { Wander w = points[i].gameObject.AddComponent <Wander>(); w.Initialize(wanderSpeedRange, timeBetweenDirectionChangeRange); wanderScripts[i] = w; } }
// Start is called before the first frame update void Start() { myMoveType = new Wander(); myMoveType.character = this; myMoveType.target = myTarget; myRotateType = new Face(); myRotateType.character = this; myRotateType.target = myTarget; }
private void Awake() { _enemyConfig = GameSettings.Get.EnemyConfig; _stateMachine = new StateMachine(); _fieldOfView = Instantiate(_enemyConfig.FieldOfViewPrefab, Vector3.zero, Quaternion.identity) .GetComponent <FieldOfView>(); // Store component references. var navMeshAgent = GetComponent <NavMeshAgent>(); var character = GetComponent <ThirdPersonCharacter>(); var animator = GetComponent <Animator>(); var movementController = GetComponent <CustomMovementController>(); // Create wanted states. var staticState = new StaticState(); var wander = new Wander(this, movementController, navMeshAgent, animator); var chase = new Chase(this, movementController, navMeshAgent, animator); var attack = new Attack(this); var scouting = new Scouting(this, animator); // Assign state transitions void At(IState from, IState to, Func <bool> condition) => _stateMachine.AddTransition(from, to, condition); // TODO Move attack state to any state At(staticState, wander, NotStatic()); At(wander, attack, FoundPlayer()); At(wander, scouting, Scouting()); At(wander, chase, ChasingPlayer()); At(scouting, attack, FoundPlayer()); At(scouting, wander, ScoutingFinished()); At(scouting, chase, ChasingPlayer()); At(attack, chase, ChasingPlayer()); At(chase, attack, FoundPlayer()); At(chase, wander, NotChasingPlayer()); // Set start state. _stateMachine.SetState(staticState); // Transition logic between states. Func <bool> NotStatic() => () => !_isStatic; Func <bool> FoundPlayer() => () => Target != null; Func <bool> ChasingPlayer() => () => IsChasing; Func <bool> NotChasingPlayer() => () => !IsChasing; Func <bool> Scouting() => () => IsScouting; Func <bool> ScoutingFinished() => () => !IsScouting; }
// Use this for initialization public override void Start() { fleeScript = GetComponent<Flee>(); wanderScript = GetComponent<Wander> (); base.Start (); fleeDist = rayDist; interDist = 3.0f * rayDist; isReachingGoal = false; actualDist = Vector3.Distance (transform.position, goal.transform.position); setScripts (); }
void Awake() { squaredAttackDistance = attackDistance * attackDistance; rb2d = GetComponent<Rigidbody2D>(); boxCollider2d = GetComponent<BoxCollider2D>(); animator = GetComponent<Animator>(); wanderScript = GetComponent<Wander>(); fsm = new FiniteStateMachine<MeleeEnemyAI>(this, MeleeEnemyIdleState.Instance); meleeEnemies.Add(this); }
/// <summary> /// Creates a new instance /// </summary> public Behaviors() { Alignment = new Alignment(); Arrive = new Arrive(); Cohesion = new Cohesion(); Evade = new Evade(); Flee = new Flee(); Hide = new Hide(); Interpose = new Interpose(); ObstacleAvoidance = new ObstacleAvoidance(); OffsetPursuit = new OffsetPursuit(); PathFollowing = new PathFollowing(); Pursuit = new Pursuit(); Seek = new Seek(); Separation = new Separation(); WallAvoidance = new WallAvoidance(); Wander = new Wander(); }
protected void enemyStart(){ characterStart (); sphere.renderer.material.color = Color.red; grid = (Grid)GameObject.FindObjectOfType (typeof(Grid)); pathing = (PathFinding)GameObject.FindObjectOfType (typeof(PathFinding)); experienceBase = 25; xpGiven = false; lootGiven = false; lootFactory = GameObject.FindObjectOfType<LootFactory> (); // networking: makes sure each enemy is properly instantiated even on another game instance that didn't run the EnemyFactory code. target = (Fighter) GameObject.FindObjectOfType (typeof (Fighter)); // for the enemies perspective target is always fighter sorcerer = (Sorcerer)SorcererInstanceManager.getSorcerer (); // sorcerer = (Sorcerer) GameObject.FindObjectOfType (typeof (Sorcerer)); level = target.level; initializePrimaryStats(); initializeSecondaryStatsBase(); initializeSecondaryStats(); calculateSecondaryStats(); health = maxHealth; energy = maxEnergy; activeSkill1 = (BasicMelee)GetComponent<BasicMelee>(); this.transform.parent = GameObject.Find("Enemies").transform; // networking: enemyNetworkScript = (EnemyNetworkScript)GetComponent<EnemyNetworkScript> (); collider = GetComponent<CapsuleCollider>(); wanderScript = GetComponent<Wander> (); arriveScript = GetComponent<Arrive> (); }
// Use this for initialization void Start() { player = GameObject.Find("Player"); cc = GetComponent<CharacterController> (); wander = GetComponent<Wander> (); }
void Awake() { wanderController = GetComponent<Wander> (); rb = GetComponent<Rigidbody>(); navAgent = GetComponent<NavMeshAgent>(); }
// Use this for initialization public void Starta(GameObject plane, GameObject swamps, float nodeSize) { fixedDeadCollider = false; poi = Vector3.zero; health = 100.0f; seesPlayer = false; seesDeadPeople = false; hearsSomething = false; disturbed = false; reachGoal = GetComponent<ReachGoal> (); wander = GetComponent<Wander> (); standstill = GetComponent<StandStill> (); patrol = GetComponent<Patrol> (); gc = player.GetComponent<GoalControl> (); reachGoal.plane = plane; reachGoal.swamps = swamps; reachGoal.nodeSize = nodeSize; reachGoal.goalPos = poi; reachGoal.Starta (); wander.Starta (); patrol.Starta (); standstill.Starta (); anim = GetComponent<Animation> (); anim.CrossFade (idle); walkingSpeed = 10.0f; gunShot = this.GetComponents<AudioSource> ()[0]; lr = this.GetComponentInParent<LineRenderer> (); seenTime = 0f; // Debug.Log (transform.name); }
// float nextCue; // float cueStep = 2f; // Use this for initialization void Start () { airplane = GameObject.Find ("Airplane").GetComponent<Transform>(); //get leader leader = GameObject.FindGameObjectWithTag ("Leader").GetComponent<Wander>(); }
// Use this for initialization public void Starta(GameObject plane, float nodeSize, Vector3 sP) { fixedDeadCollider = false; poi = Vector3.zero; health = 100.0f; seesPlayer = false; lastSeen = Vector3.zero; lastSeenForward = Vector3.zero; seesDeadPeople = false; hearsSomething = false; disturbed = false; isDead = false; addToDeadSet = false; takingCover = false; coverSpot = Vector3.zero; reachedCover = false; sniperPosKnown = false; sniperPos = sP; isGoaling = false; isGoingToSeenPlayerPos = false; isGoingToCover = false; dirSearchCountDown = 0.0f; reachGoal = GetComponent<ReachGoal> (); wander = GetComponent<Wander> (); standstill = GetComponent<StandStill> (); patrol = GetComponent<Patrol> (); gc = player.GetComponent<GoalControl> (); reachGoal.plane = plane; reachGoal.nodeSize = nodeSize; reachGoal.goalPos = poi; reachGoal.sniperPos = sniperPos; reachGoal.Starta (); wander.Starta (); patrol.Starta (); standstill.Starta (); takeCover = new TakeCover (reachGoal.state.sGrid.hiddenSpaceCost, reachGoal.state.sGrid.grid, reachGoal.state.sGrid.spaceCostScalars); anim = GetComponent<Animation> (); anim.CrossFade (idle); walkingSpeed = 10.0f; gunShot = this.GetComponents<AudioSource> ()[0]; lr = this.GetComponentInParent<LineRenderer> (); seenTime = 0f; alertLevel = 0; maxAlertLevel = 3; needsToRaiseAlertLevel = false; isReloading = false; isShooting = false; ammoCount = 0; // Debug.Log (transform.name); }