Example #1
0
    public void UpdateDashState(State currState, float deltaTime)
    {
        m_CurrDashTime -= deltaTime;
        if (m_CurrDashTime <= 0.0f)
        {
            m_PlayerStateMachine.CanChangeState = true;
        }

        m_Animation.CrossFade("Run");

        if (Vector3.SqrMagnitude(m_LastDashDecalPointAdded - transform.position) >= (m_DecalPointAddDist * m_DecalPointAddDist))
        {
            RaycastHit rayHit;
            if (PhysicsUtils.RaycastToGround(transform.position, out rayHit))
            {
                m_LastDashDecalPointAdded = rayHit.point;
            }
            else
            {
                m_LastDashDecalPointAdded = transform.position;
            }

            m_CurrentDecal.AddPoint(m_LastDashDecalPointAdded + Vector3.up * m_DecalUpOffset);
        }
        m_CurrRunTime = m_RunTimeToDash;
    }
Example #2
0
    // End Walk, Run State
    // -----------------

    // -----------------
    // Start Dash State
    public void BeginDashState(State prvState, State newState)
    {
        //m_Animation.Play();
        //SetCharacterFlag(CharacterFlag.eCF_ResetMoveSpeedAfterUse);
        CurrentVelocity    = new Vector3(0.0f, m_OnGroundYVelocity, 0.0f);
        m_CurrentDashSpeed = m_DefaultMoveSpeed * m_DashSpeedMultiplier;// Can be current speed.
        CurrentMoveSpeed   = m_CurrentDashSpeed;
        m_PlayerStateMachine.CanChangeState = false;
        m_CurrRunTime = m_RunTimeToDash;

        m_CurrentDecal = m_DecalsManaer.CreateDecal(DecalsManager.DecalsType.DT_Tape);

        RaycastHit rayHit;

        if (PhysicsUtils.RaycastToGround(transform.position, out rayHit))
        {
            m_LastDashDecalPointAdded = rayHit.point;
        }
        else
        {
            m_LastDashDecalPointAdded = transform.position;
        }

        m_CurrentDecal.Thickness = m_DecalThickness;
        m_CurrentDecal.AddPoint(m_LastDashDecalPointAdded + Vector3.up * m_DecalUpOffset);
        m_CurrentDecal.UpVector = transform.up;

        m_CurrDashTime = m_MaxDashTime;
        m_Animation.CrossFade("Run");

        m_PlayerHUD.ShowMeter();
    }
Example #3
0
 // Called when any types weapon collides with this, returns true if it is successful attack
 // returns false if attack is blocked
 public override bool Attacked(Actor attacker, GameObject bodyPartGotHit, float damage)
 {
     if (attacker.GetType().IsSubclassOf(typeof(Projectile)))
     {
         Projectile proj = (Projectile)attacker;
         if (proj != null)
         {
             GameObject go = GameObject.Instantiate(m_ParticlePrefab);
             RaycastHit rayHit;
             if (PhysicsUtils.RaycastToGround(transform.position, out rayHit))
             {
                 go.transform.position = rayHit.point;
             }
             else
             {
                 go.transform.position = proj.transform.position;
             }
             proj.ShowGroundDecalAndDestroy();
         }
     }
     return(true);
 }
Example #4
0
    // Update is called once per frame
    protected override void Update()
    {
        if (m_Launch && !m_Launched)
        {
            m_Launched = true;
            Launch();
        }
        if (m_ToBeDestroyed)
        {
            m_ToBeDestroyed = false;
            Manager.DestroyProjectile(this);
        }
        if (!m_AddingDecals && m_ShowGroundDecalAndDestroy)
        {
            m_AddingDecals           = true;
            m_CurrentDecal           = m_DecalsManager.CreateDecal(DecalsManager.DecalsType.DT_Crack);
            m_CurrentDecal.Thickness = m_DecalWidth;


            RaycastHit rayHit;
            if (PhysicsUtils.RaycastToGround(transform.position, out rayHit))
            {
                m_LastDecalPos = rayHit.point;
            }
            else
            {
                m_LastDecalPos = transform.position;
            }

            m_CurrentDecal.AddPoint(m_LastDecalPos + Vector3.up * m_DecalUpOffset);

            Vector3 velocity = Velocity;
            velocity.y          = 0.0f;
            m_CurrDecalAddSpeed = velocity.magnitude;
            m_DecalAddDir       = velocity.normalized;
            m_CurrDecalAddDist  = 0.0f;

            m_MeshRenderer.enabled = false;

            //
            SetToDestroy();
            m_CurrentDecal.AddPoint(m_LastDecalPos + Vector3.up * m_DecalUpOffset + m_DecalAddDir * m_DecalWidth);
        }

        /*if (m_AddingDecals)
         * {
         *  m_CurrDecalAddSpeed -= m_DecalAddDeAcceleration * Time.deltaTime;
         *  m_CurrDecalAddDist += m_CurrDecalAddSpeed * Time.deltaTime;
         *
         *  if (m_CurrDecalAddDist >= m_DecalPointAddDist || m_CurrDecalAddSpeed <= 0.0f)
         *  {
         *      m_LastDecalPos += m_DecalAddDir * m_CurrDecalAddDist;
         *      m_CurrentDecal.AddPoint(m_LastDecalPos + Vector3.up * m_DecalUpOffset);
         *      m_CurrDecalAddDist = 0.0f;
         *  }
         *
         *  if (m_CurrDecalAddSpeed <= 0)
         *  {
         *      SetToDestroy();
         *      m_AddingDecals = false;
         *  }
         * }*/
    }