Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private void FixedUpdate()
        {
            if (m_navAgent.velocity.sqrMagnitude > float.Epsilon && m_state == MobState.Idle)
            {
                m_state = MobState.Walk;
            }

            if (this.IsServer)
            {
                switch (m_state)
                {
                case MobState.Idle:
                {
                    if (UnityEngine.Random.Range(0, 100) == 0)
                    {
                        m_state = MobState.Walk;
                        var target = GetRandomPointInSpawnArea();
                        m_navAgent.SetDestination(target);

                        var mobMovePacket = new Realms.Server.Packet.MobMovePacket(this.ID, target);
                        m_server.QueuePacketAll(mobMovePacket);
                    }
                }
                break;

                case MobState.Walk:
                {
                    if (m_navAgent.velocity.sqrMagnitude <= float.Epsilon)
                    {
                        m_state = MobState.Idle;
                    }
                }
                break;

                case MobState.Attack:
                {
                    if (Time.time - m_lastAttackTime >= 10.0f)
                    {
                        m_state = MobState.Idle;
                    }
                }
                break;
                }
            }
            else
            {
                if (m_state == MobState.Attack)
                {
                    // Do Attack animation
                }
                else if (m_navAgent.velocity.sqrMagnitude > float.Epsilon)
                {
                    m_animator.SetBool("IsWalking", true);
                }
                else
                {
                    m_animator.SetBool("IsWalking", false);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        private void FixedUpdate()
        {
            if (m_navAgent.velocity.sqrMagnitude > float.Epsilon && m_state == MobState.Idle)
            {
                m_state = MobState.Walk;
            }

            if (this.IsServer)
            {
                switch (m_state)
                {
                    case MobState.Idle:
                        {
                            if (UnityEngine.Random.Range(0, 100) == 0)
                            {
                                m_state = MobState.Walk;
                                var target = GetRandomPointInSpawnArea();
                                m_navAgent.SetDestination(target);

                                var mobMovePacket = new Realms.Server.Packet.MobMovePacket(this.ID, target);
                                m_server.QueuePacketAll(mobMovePacket);
                            }
                        }
                        break;

                    case MobState.Walk:
                        {
                            if (m_navAgent.velocity.sqrMagnitude <= float.Epsilon)
                            {
                                m_state = MobState.Idle;
                            }
                        }
                        break;
                    case MobState.Attack:
                        {
                            if (Time.time - m_lastAttackTime >= 10.0f)
                            {
                                m_state = MobState.Idle;
                            }
                        }
                        break;
                }
            }
            else
            {
                if (m_state == MobState.Attack)
                {
                    // Do Attack animation
                }
                else if (m_navAgent.velocity.sqrMagnitude > float.Epsilon)
                {
                    m_animator.SetBool("IsWalking", true);
                }
                else
                {
                    m_animator.SetBool("IsWalking", false);
                }
            }
        }