Exemplo n.º 1
0
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // create the empty shell
        GameObject obj = MyCache.Spawn(wpn.mShell, wpn.ShellEjector.position, wpn.ShellEjector.rotation);

        obj.GetComponent <Rigidbody>().velocity = wpn.ShellEjector.TransformDirection(Vector3.left * 8.0f);

        obj.transform.Rotate(Random.Range(-wpn.Dispersion_Y * 55.0f, wpn.Dispersion_Y * 55.0f) * Time.deltaTime,
                             Random.Range(-wpn.Dispersion_X * 55.0f, wpn.Dispersion_X * 55.0f) * Time.deltaTime, 0.0f);

        wpn.OnImpact();
    }
Exemplo n.º 2
0
    /*
     *  private void ChangeDispersionSize()
     *  {
     *          DispersionTime += Time.deltaTime;
     *          if ( DispersionTime > 0.8f )
     *          {
     *                  DispersionSize -= DecDispersionSize;
     *
     *                  if ( DispersionSize < 0.12 )
     *                  {
     *                          DSDefault = true;
     *                          DispersionTime = 0f;
     *                  }
     *          }
     *  }
     */
    #endregion

    #region Messages
    public void OnImpact()
    {
        RaycastHit hit;
        var        ray = new Ray(transform.position, transform.forward);

        if (Physics.Raycast(ray, out hit, Range))
        {
            var effect = ImpactManager.Instance.GetImpactEffect(hit.transform.gameObject);
            if (effect == null)
            {
                return;
            }
            var effectIstance = MyCache.Spawn(effect, hit.point, new Quaternion()) as GameObject;
            effectIstance.transform.LookAt(hit.point + hit.normal);
            //  MyCache.Destroy(effectIstance, 4); // de-activate after 4 secs
        }
    }
Exemplo n.º 3
0
    // This will be called when the animator first transitions to this state.
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        wpn = animator.gameObject.GetComponent <Weapon>();

        GameObject go = MyCache.Spawn(wpn.mBullet, wpn.Muzzle.position, wpn.Muzzle.rotation) as GameObject;

        go.transform.position = wpn.Muzzle.position;
        go.transform.rotation = wpn.Muzzle.rotation;

        go.GetComponent <Rigidbody>().velocity = wpn.Muzzle.TransformDirection(Vector3.forward * wpn.BulletSpeed);
        //	go.transform.Rotate( Random.Range ( -Dispersion_Y * 55f, Dispersion_Y * 55f ) * Time.deltaTime,
        //											             Random.Range ( -Dispersion_X * 55f, Dispersion_X * 55f ) * Time.deltaTime, 0.0f );

        wpn.AudioSource.PlayOneShot(wpn.ShotSFX);
        wpn.MuzzleFlash.SetActive(true);
        wpn.transform.localPosition += wpn.Recoil;


        //   decal = MyCache.Spawn(wpn.Bullethole, wpn.Muzzle.position, wpn.Muzzle.rotation) as GameObject;
        //   MyImpactManager.Impact(wpn.Muzzle, wpn.BulletMass, wpn.BulletSpeed, decal);
    }