示例#1
0
 private IEnumerator Attack()
 {
     while (true)
     {
         anim.SetBool("Walking", false);
         agent.Stop();
         anim.SetTrigger("Attack");
         yield return(new WaitForSeconds(4f));
     }
 }
示例#2
0
 public override void Reason(Transform player, GameObject self)
 {
     if (selfHealthScript.currentHealth <= 0)
     {
         agent.Stop();
         parentFSM.SetTransition(FSMTransitions.OutOfHealth);
     }
     else if (Vector2.Distance(self.transform.position, player.position) > agroRange)
     {
         agent.Stop();
         parentFSM.SetTransition(FSMTransitions.PlayerOutOfRange);
     }
 }
示例#3
0
 public override void Reason(Transform player, GameObject self)
 {
     if (curHealthScript.currentHealth <= 0)
     {
         agent.Stop();
         parentFSM.SetTransition(FSMTransitions.OutOfHealth);
     }
     else if (Vector2.Distance(self.transform.position, player.position) >= retreatEndDistance)
     {
         agent.slowingDistance = normalSlowingDistance;
         agent.Stop();
         parentFSM.SetTransition(FSMTransitions.CloserDistanceReached);
     }
 }
    /// <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);
    }
示例#5
0
 public void Work(float worktime, System.Action finish_cb)
 {
     if (is_working_)
     {
         return;
     }
     agent_.Stop();
     is_working_     = true;
     rest_worktime   = worktime;
     work_finish_cb_ = finish_cb;
 }
示例#6
0
 public void StopMove()
 {
     if (moveCoroutine != null)
     {
         StopCoroutine(moveCoroutine);
         moveCoroutine = null;
         _PlayerState  = PlayerState.Idle;
         if (navAgent != null)
         {
             navAgent.Stop();
         }
     }
 }
示例#7
0
 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));
     }
 }
示例#8
0
    void ExitState()
    {
        if (onExitState != null)
        {
            onExitState();
        }

        ResetControllerVeriables();
        StopAllCoroutines();
        if (agent != null)
        {
            agent.Stop();
        }
    }
示例#9
0
        /// Update is called once per frame
        void Update()
        {
            // Remove all player control when we're in dialogue
            if (FindObjectOfType <DialogueRunner>().IsDialogueRunning == true)
            {
                agent.Stop();
                return;
            }

            if (Input.GetMouseButtonDown(1))
            {
                destination = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                agent.SetDestination(destination);
            }

            // Detect if we want to start a conversation
            if (Input.GetMouseButtonDown(0) && eventPanel.activeInHierarchy == false)
            {
                CheckForNearbyNPC();
            }
        }
示例#10
0
    protected void Follow(PolyNavAgent agent, float distanceFollow, bool front)
    {
        if (followCrono < 2f)
        {
            agent.Stop();
            anim.SetBool("Walking", false);
            followCrono += Time.deltaTime;
        }
        else
        {
            followCrono = 2f;
            anim.SetBool("Walking", true);

            if (front)
            {
                if (player.GetComponent <Character_Behaviour>().isLookLeft)
                {
                    agent.SetDestination(new Vector2(player.transform.position.x - (distanceFollow * 0.8f), player.transform.position.y));
                }
                else
                {
                    agent.SetDestination(new Vector2(player.transform.position.x + (distanceFollow * 0.8f), player.transform.position.y));
                }
            }
            else
            {
                if (player.GetComponent <Character_Behaviour>().isLookLeft)
                {
                    agent.SetDestination(new Vector2(player.transform.position.x + (distanceFollow * 0.8f), player.transform.position.y));
                }
                else
                {
                    agent.SetDestination(new Vector2(player.transform.position.x - (distanceFollow * 0.8f), player.transform.position.y));
                }
            }
        }
    }
示例#11
0
 protected override void EndSkill()
 {
     m_polyNavAgent.Stop();
     isOrigMoveDisabled = false;
     SetSkillState(SkillState.none);
 }
示例#12
0
        protected void doLogic()
        {
            if (!isPointsCollected)
            {
                BuildPatrolPoints();
            }
            AssessTarget();
            if (Target != null)
            {
                if (!Target.activeInHierarchy)
                {
                    State = PrimaryEnums.AiState.Wander;
                }
                if (Vector2.Distance(transform.position, Target.transform.position) <= minAttackDistance)
                {
                    State = PrimaryEnums.AiState.Attack;
                }
                else if (State == PrimaryEnums.AiState.Attack && Vector2.Distance(transform.position, Target.transform.position) >= maxAttackDistance)
                {
                    State = PrimaryEnums.AiState.Follow;
                }
                else if (State != PrimaryEnums.AiState.Attack && Vector2.Distance(transform.position, Target.transform.position) > minAttackDistance)
                {
                    State = PrimaryEnums.AiState.Follow;
                }
            }
            else
            {
                State = PrimaryEnums.AiState.Wander;
            }

            switch (State)
            {
            case PrimaryEnums.AiState.Wander:
                Speed          = (int)(MaxSpeed * 0.5f);
                agent.maxSpeed = Speed;
                TargetPos      = PatrolPoints[currentPatrolPoint].position;
                CheckPath(TargetPos);
                break;

            case PrimaryEnums.AiState.Follow:
                Speed          = (int)MaxSpeed;
                agent.maxSpeed = Speed;
                TargetPos      = Target.transform.TransformPoint(TargetTrackingOffset);
                CheckPath(TargetPos);
                break;

            case PrimaryEnums.AiState.Attack:

                if (!isStationaryAttacker)
                {
                    Speed          = (int)MaxSpeed;
                    agent.maxSpeed = Speed;
                    if (Target == null)
                    {
                        return;
                    }
                    TargetPos = Target.transform.TransformPoint(TargetTrackingOffset);
                    CheckPath(TargetPos);
                }
                else
                {
                    agent.Stop();
                }
                if (!isAttacking)
                {
                    Attack();
                    isAttacking = true;
                }
                break;

            default:
                break;
            }
        }
示例#13
0
 protected override void Stop()
 {
     polyNavAgent.Stop();
 }
 /// <summary>
 /// nulls out an objects current nav path.
 /// </summary>
 public void StopNavigation()
 {
     _myNavAgent.Stop();
 }