public override bool OnEnter() { CurrArgs.m_bValue2 = false; myTree = CurrCtrl.GetComponentInChildren <BehaviorTree>(); myAni = CurrCtrl.GetChild(0).GetComponent <Animator>(); skeletonAnimation = CurrCtrl.GetChild(0).GetComponent <SkeletonAnimation>(); agent = CurrCtrl.GetComponentInChildren <PolyNavAgent>(); m_BufferCrl = CurrCtrl.GetComponentInChildren <BufferController>(); actionCtl = CurrCtrl.GetComponent <MonsterActionCtl>(); //怪物停止移动 if (CurrArgs.m_bValue1) { UseUI(); CurrArgs.m_bValue2 = true; actionCtl.EnterFetter(); } else { if (!actionCtl.superArmor) { UseUI(); CurrArgs.m_bValue2 = true; actionCtl.EnterFetter(); } } return(true); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ap = animator.gameObject.GetComponent <AgentPatrol> (); agent = animator.gameObject.GetComponent <PolyNavAgent> (); shoot = animator.gameObject.GetComponent <RepeatShoot> (); oldMaxSpeed = agent.maxSpeed; oldStoppingDist = agent.stoppingDistance; oldSlowingDist = agent.slowingDistance; oldAccelRate = agent.accelerationRate; oldDecelRate = agent.decelerationRate; // SetNewAgent (); agent.SetDestination(ap.playerLastPos); if (shoot) { UpdateTargetPos(); shoot.StopShoot(); } shooting = false; // if(shoot){ // shoot.StartShoot (); // shooting = true; // } }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); collider = GetComponent <Collider2D>(); polyNavAgent = GetComponent <PolyNavAgent>(); StartCoroutine(SpawnRoutine()); }
/// <summary> /// Called to sacrifice Ally AI to heal player. /// </summary> public void AssimilateIntoPlayer() { #region Consts for readability const string _assimilatedAlly = "Assimilator"; #endregion Consts for readability #region Variable Instantiation _isAIActive = false; PolyNavAgent agent = gameObject.GetComponent <PolyNavAgent>(); #endregion Variable Instantiation agent.Stop(); gameObject.tag = _assimilatedAlly; gameObject.GetComponent <CircleCollider2D>().enabled = false; GameObject newLight = Instantiate(assimilationIndicator, transform); newLight.transform.localPosition = new Vector3(0, 0, -0.7f); // emit particles for a bit before dying; ParticleSystem regenSparkles = Instantiate(assimilationParticles, transform); regenSparkles.transform.localScale = new Vector3(0.02f, 0.06f, 0.06f); _myCombatController.Die(false, 2.5f); }
public override bool OnEnter() { CurrArgs.m_bValue1 = false; myTree = CurrCtrl.GetComponentInChildren <BehaviorTree> (); myAni = CurrCtrl.GetChild(0).GetComponent <Animator> (); skeletonAnimation = CurrCtrl.GetChild(0).GetComponent <SkeletonAnimation> (); agent = CurrCtrl.GetComponentInChildren <PolyNavAgent> (); m_BufferCrl = CurrCtrl.GetComponentInChildren <BufferController> (); actionCtl = CurrCtrl.GetComponent <MonsterActionCtl> (); //怪物停止移动 if (!actionCtl.superArmor) { if (CurrArgs.m_iBufferUI == 1) { dizznessBuff = Resources.Load("MonsterResources/MonsterBuffs/MonsterDizznessBuff") as GameObject; temp = GameObject.Instantiate(dizznessBuff, CurrCtrl.GetComponent <MonsterMessage> ().monsterHead.transform.position, Quaternion.identity) as GameObject; if (CurrCtrl.transform.rotation.y != 0f) { temp.transform.rotation = new Quaternion(0f, 180f, 0f, 0f); } temp.transform.SetParent(CurrCtrl.GetComponent <MonsterMessage> ().monsterHead.transform); temp.transform.localScale = new Vector3(m_BufferCrl.buffScale, m_BufferCrl.buffScale, m_BufferCrl.buffScale); temp.transform.position = new Vector3(temp.transform.position.x + m_BufferCrl.xDis, temp.transform.position.y + m_BufferCrl.yDis, temp.transform.position.z); } CurrArgs.m_bValue1 = true; actionCtl.EntryFetter(); } return(true); }
// Use this for initialization void Start() { _agent = GetComponent <PolyNavAgent>(); _agent.OnDestinationReached += onDestinationReached; getWaypoints(); _agent.SetDestination(_wpStack.Pop().position); }
IEnumerator DelayDamageTick(Collider2D[] colliders) { yield return(new WaitForSeconds(destructDelay)); foreach (Collider2D collider in colliders) { Debug.Log("In Foreach Loop"); if (collider.gameObject.CompareTag("Enemy")) { Debug.Log("thing"); HealthScript enemyHealth = collider.gameObject.GetComponent <HealthScript>(); PolyNavAgent agent = collider.gameObject.GetComponentInChildren <PolyNavAgent>(); Rigidbody2D rb = collider.gameObject.GetComponent <Rigidbody2D>(); if (enemyHealth) { enemyHealth.TakeDamage(damage); //Debug.Log("Enemy Taking Damage"); } if (agent) { agent.enabled = false; StartCoroutine(EnemyPathfindDelay(agent)); } if (rb) { Vector2 forceVector = (transform.position - collider.gameObject.transform.position).normalized; rb.AddForce(forceVector * force); } } } StartCoroutine(PlayerControlDelay()); }
static int set_OnDestinationReached(IntPtr L) { try { PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject(L, 1, typeof(PolyNavAgent)); EventObject arg0 = null; if (LuaDLL.lua_isuserdata(L, 2) != 0) { arg0 = (EventObject)ToLua.ToObject(L, 2); } else { return(LuaDLL.luaL_throw(L, "The event 'PolyNavAgent.OnDestinationReached' can only appear on the left hand side of += or -= when used outside of the type 'PolyNavAgent'")); } if (arg0.op == EventOp.Add) { System.Action ev = (System.Action)arg0.func; obj.OnDestinationReached += ev; } else if (arg0.op == EventOp.Sub) { System.Action ev = (System.Action)arg0.func; obj.OnDestinationReached -= ev; } return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
protected override void Awake() { base.Awake(); player = GameObject.FindGameObjectWithTag(Tags.PLAYER); agent = GetComponent <PolyNavAgent>(); setSpeed(); }
public ChaseState(PolyNavAgent navAgent, float terminalDistance) { stateID = FSMStateID.Chase; agent = navAgent; agroRange = terminalDistance; }
/// <param name="p_retreatEndDistance">Should always be less than agro range</param> public RetreatState(PolyNavAgent navAgent, float p_retreatEndDistance) { stateID = FSMStateID.Retreat; agent = navAgent; retreatEndDistance = p_retreatEndDistance; normalSlowingDistance = agent.slowingDistance; }
public override bool OnEnter() { CurrArgs.m_bValue1 = false; myTree = CurrCtrl.GetComponentInChildren <BehaviorTree> (); myAni = CurrCtrl.GetChild(0).GetComponent <Animator> (); skeletonAnimation = CurrCtrl.GetChild(0).GetComponent <SkeletonAnimation> (); agent = CurrCtrl.GetComponentInChildren <PolyNavAgent> (); m_BufferCrl = CurrCtrl.GetComponentInChildren <BufferController> (); actionCtl = CurrCtrl.GetComponent <MonsterActionCtl> (); //怪物停止移动 if (!actionCtl.superArmor) { CurrArgs.m_bValue1 = true; if (CurrArgs.m_iBufferUI == 1) { freeezBuff = Resources.Load("MonsterResources/MonsterBuffs/MonsterFreezeBuff") as GameObject; temp = GameObject.Instantiate(freeezBuff, new Vector3(-100, 100, 0) + new Vector3(0, 0, -0.01f), Quaternion.identity) as GameObject; temp.transform.localScale = new Vector3(m_BufferCrl.buffScale, m_BufferCrl.buffScale, m_BufferCrl.buffScale); temp.transform.position = CurrCtrl.GetComponent <MonsterMessage> ().monsterFoot.transform.position + new Vector3(0f, 0f, -0.01f); temp.transform.SetParent(CurrCtrl.GetComponent <MonsterMessage> ().monsterFoot.transform); } actionCtl.EnterFreeze(); } return(true); }
public void CancelReservation(PolyNavAgent agentToRemove) { if (reserveList.Contains(agentToRemove)) { reserveList.Remove(agentToRemove); } }
static int SetDestination(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject <PolyNavAgent>(L, 1); UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 2); bool o = obj.SetDestination(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 3) { PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject <PolyNavAgent>(L, 1); UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 2); System.Action <bool> arg1 = (System.Action <bool>)ToLua.CheckDelegate <System.Action <bool> >(L, 3); bool o = obj.SetDestination(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: PolyNavAgent.SetDestination")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Start is called before the first frame update void Start() { Active = true; playerTransform = GameObject.FindGameObjectWithTag("Player").transform; navAgent = gameObject.GetComponent <PolyNavAgent>(); Initalize(); currentState.OnStateEnter(playerTransform, gameObject); }
public static void drawPath(GameObject who) { PolyNavAgent agent = who.GetComponentInChildren <PolyNavAgent>(); List <Vector2> path = agent.activePath; Unit unit = who.GetComponentInChildren <Unit>(); //unit.lineList = path; //unit.movepathline.active = true; }
protected override void Initalize() { //currentHealth = initalHealth; BuildFSM(); agent = gameObject.GetComponent <PolyNavAgent>(); }
public int preState; //前一个state void Awake() { navAgent = this.GetComponent <PolyNavAgent>(); randomPatrol = this.GetComponent <PatrolRandomWaypoints>(); patrol = this.GetComponent <PatrolWaypoints>(); curTarget = GameObject.FindGameObjectWithTag("Player").transform; curState = 0; }
public virtual void Awake() { agent = GetComponent <PolyNavAgent>(); anim = GetComponentInChildren <Animator>(); sr = anim.GetComponent <SpriteRenderer>(); healthBar = GetComponentInChildren <HealthBar>(); unitState = UnitState.ROAMING; }
// Start is called before the first frame update void Start() { //Active = false; playerTransform = GameObject.FindGameObjectWithTag("Player").transform; navAgent = gameObject.GetComponent <PolyNavAgent>(); enemyAnim = gameObject.GetComponent <Animator>(); Initalize(); currentState.OnStateEnter(playerTransform, gameObject); }
private void Awake() { NavAgent = GetComponent <PolyNavAgent>(); Player = GameObject.FindGameObjectWithTag("Player"); Main_Camera = GameObject.FindGameObjectWithTag("MainCamera"); Anim = GetComponent <NormalEnemyAnim>(); playerLayer = LayerMask.NameToLayer("Player"); lightController = Main_Camera.GetComponent <FogOfWar>(); GetComponent <NormalEnemyAnim>().enabled = true; }
private void AddAndConfigurePolyNavAgent() { PolyNavAgent newPolyNavAgent = newEnemyObject.AddComponent <PolyNavAgent>(); newPolyNavAgent.mass = mass; newPolyNavAgent.maxSpeed = characterMoveSpeed; newPolyNavAgent.avoidRadius = avoidanceRadius; newPolyNavAgent.avoidanceConsiderStuckedTime = stuckTime; newPolyNavAgent.avoidanceConsiderReachedDistance = reachedTime; }
protected override void InitSkill() { m_polyNavAgent = GetComponent <PolyNavAgent>(); playerTransform = GameObject.FindWithTag("Player").GetComponent <Transform>(); nonEnemyLayerMask = ~LayerMask.GetMask("Enemy"); m_skillType = SkillType.lasting; m_skillState = SkillState.none; canBeInterrupt = true; }
void Start() { HP = MaxHp; agent = GetComponent <PolyNavAgent>(); if (WayPoints.Count == 0) { throw new NotImplementedException("Waypoints not set"); } StartCoroutine(TryPath()); }
public bool ReservePlace(PolyNavAgent agentToReserve) { if (reserveList.Count < capacity) { return(reserveList.Add(agentToReserve)); } else { return(false); } }
private void Awake() { bossSkill = GetComponent <BossSkill>(); NavAgent = GetComponent <PolyNavAgent>(); Player = GameObject.FindGameObjectWithTag("Player"); Anim = GetComponent <QueenAnim>(); Main_Camera = GameObject.FindGameObjectWithTag("MainCamera"); playerLayer = LayerMask.NameToLayer("Player"); lightController = Main_Camera.GetComponent <FogOfWar>(); StartCoroutine(NormalAttack()); StartCoroutine(UseSkill()); }
public PatrolState(List <GameObject> points, PolyNavAgent navAgent, float agroRange) { stateID = FSMStateID.Patrol; if (points.Count == 0) { Debug.LogError("No patrol points are listed. Add patrol points to this enemy in the inspector"); } PatrolPoints = points; agent = navAgent; DestPos = SelectPatrolPoint(); agroDistance = agroRange; }
void OnEnable() { if (WayPoints.Count == 0) { throw new NotImplementedException("Waypoints not set"); } if (agent == null) { agent = GetComponent <PolyNavAgent>(); } //agent.SetDestination(WayPoints[0].position); }
/// <summary> /// Prepare all variables and components /// </summary> public void PersonInitialize() { //Debug.Log("Initializing Person"); agent = GetComponent<PolyNavAgent>(); sr = GetComponent<SpriteRenderer>(); //if (CompareTag("Patient")) //{ // sr.color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f)); //} destinationName = ""; manager = Manager._manager; moving = false; }
static int Stop(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject <PolyNavAgent>(L, 1); obj.Stop(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetReachedCallback(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject <PolyNavAgent>(L, 1); System.Action <bool> arg0 = (System.Action <bool>)ToLua.CheckDelegate <System.Action <bool> >(L, 2); obj.SetReachedCallback(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Use this for initialization void Awake() { catTransform = GetComponent<Transform>(); anim = GetComponent<Animator>(); bigCollider = catTransform.FindChild("BigCollider").gameObject; smallCollider = catTransform.FindChild("SmallCollider").gameObject; polyNav = GetComponent<PolyNavAgent>(); polyNav.maxSpeed = catSpeed; changeColliders(anim.GetBool("Sleeping")); if (Application.loadedLevel == 2) { isLevel1 = true; } if (DEBUG) Debug.Log("Cat's current position is: " + catTransform.position.x + ", " + catTransform.position.y); }
void Start() { ball = GameObject.FindGameObjectWithTag("Ball"); agent = GetComponent<PolyNavAgent>(); }
public override void OnAwake() { polyNavAgent = gameObject.GetComponent<PolyNavAgent>(); }
/// <summary> /// Move to specified location. Called by Hotspot or Manager /// </summary> /// <param name="m">Location to move to</param> /// <param name="dName">Tag of destination</param> /// <param name="pObject">Is this a Patient Object?</param> /// <param name="officeobject">The class</param> public void PersonMove(Vector2 m, string dName, bool pObject = true, OfficeObject officeobject = null) { //if I am a nurse, set myself to busy if (gameObject.CompareTag("Nurse")) { (this as Nurse).IsBusy(-1); if (Vector2.Distance(m, transform.position) > Mathf.Abs(0.1f)) { (this as Nurse).NurseAnimation("Walk", true, false); } } else if (gameObject.CompareTag("Patient")) { //Debug.Log("Setting Patient Walking to True"); (this as Patient).PatientAnimation("Highlight", false, false); (this as Patient).PatientAnimation("Walking", false, true); } //make sure that I have a reference to my polynav agent. if (agent == null) { agent = GetComponent<PolyNavAgent>(); } destinationName = dName; //Debug.Log("OfficeObject = " + officeobject); if (officeobject) { patientObject = pObject; officeObject = officeobject; } //make sure that the agent is enabled, and then set the agent's destination. agent.enabled = true; moving = true; agent.SetDestination(m, PersonMovementStatus); }
void Start() { spriteRenderer = GetComponent<SpriteRenderer>(); collider = GetComponent<Collider2D>(); polyNavAgent = GetComponent<PolyNavAgent>(); StartCoroutine(SpawnRoutine()); }