Example #1
0
 public void Kill()
 {
     if (ms_DivebombLock == this)
     {
         ms_DivebombLock = null;
     }
 }
Example #2
0
        void AcquireOffset()
        {
            if (m_Divebombing && ms_DivebombLock == this)
            {
                ms_DivebombLock = null;
            }

            if (!m_Divebombing && !ms_DivebombLock && UnityEngine.Random.Range(0.0f, 1.0f) > 0.7f)
            {
                ms_DivebombLock = this;
                m_Divebombing   = true;
                m_Offset        = Vector3.zero;

                return;
            }
            m_Divebombing = false;

            var down    = RadialGravity.GetDirectionAtPoint(transform.position);
            var forward = Vector3.Cross(down, Vector3.forward);

            m_Offset = down * UnityEngine.Random.Range(-7.0f, -5.0f) + forward * UnityEngine.Random.Range(-8.0f, 8.0f);
            // temp easily see pos
            //transform.position = m_Aggro.transform.position + m_Offset;
        }
Example #3
0
        public void FixedUpdate()
        {
            float dt = Time.fixedDeltaTime;

            m_T += dt;

            if (m_Aggro != null)
            {
                m_StateT += dt;
                if (m_StateT > 3.0f)
                {
                    m_StateT = 0.0f;
                    AcquireOffset();
                }


                if (!IsTargetValid(m_Aggro))
                {
                    if (ms_DivebombLock == this)
                    {
                        ms_DivebombLock = null;
                    }
                    m_Aggro = null;
                    return;
                }
                var targetPos = m_Aggro.transform.position + m_Offset;
                var delta     = targetPos - transform.position;

                if (m_Divebombing && delta.magnitude < 3.0f)
                {
                    m_Character.Args.m_DoAttack = true;
                }

                var rb = GetComponent <Rigidbody>();

                if (m_Aggro)
                {
                    m_Character.Args.m_TargetPos = m_Aggro.transform.position + m_Offset;
                }
                else
                {
                    m_Character.Args.m_TargetPos = Vector3.zero;
                }

                /*
                 * var oldVel = rb.velocity;
                 * var oldSpeed = m_Speed;
                 * var newSpeed = oldSpeed + AllowedAccel(targetPos) * dt;
                 * newSpeed = Mathf.Clamp(newSpeed, 0.0f, AllowedSpeed(targetPos));
                 * float angPerSec = 90.0f;
                 * m_Ang = Mathf.MoveTowardsAngle(m_Ang, Mathf.Rad2Deg*Mathf.Atan2(delta.y, delta.x), angPerSec * dt);
                 * rb.velocity = TwoDee.Math3d.FromLengthAngleDegrees2D(newSpeed, m_Ang);
                 */

                // m_Speed = newSpeed;
            }
            else
            {
                m_Character.Args.m_TargetPos = m_HomeBase;
                foreach (var player in TwoDee.ComponentList.GetCopiedListOfType <TwoDee.ThirdPersonUserControl>())
                {
                    if (!IsTargetValid(player.gameObject))
                    {
                        continue;
                    }

                    var playerpos = player.gameObject.transform.position;

                    if ((playerpos - transform.position).magnitude < 5.0f)
                    {
                        m_Aggro       = player.gameObject;
                        m_Divebombing = false;
                        AcquireOffset();
                        return;
                    }
                }
            }

            m_Character.ControlUpdate();
        }