Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (GlobalCS.gameOver)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            ShootSound.Play();

            Ray        ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width * 0.5f, Screen.height * 0.5f));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 100, 1 << 9 | 1 << 10))         //100m 范围内:第九、第十层
            //Debug.Log ("####  hit name  ####" + hit.transform.name);

            //墙
            {
                if (hit.transform.gameObject.layer == 10)
                {
                    //clone Henji
                    GameObject henJi = (GameObject)Instantiate(bulletHenJi);
                    henJi.transform.position = hit.point;
                    henJi.transform.LookAt(hit.point + hit.normal);
                }

                //敌人
                if (hit.transform.gameObject.layer == 9)
                {
                    enemy = hit.transform.GetComponent <EnemyAnimCtrl> ();
                    enemy.healthCtrl();
                }
            }
        }
    }
 private void DeleteModel()
 {
     //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
     if (model != null)
     {
         if (playerLoader != null)
         {
             playerLoader.DeleteLoadedObjects();
             Object.Destroy(playerLoader);
             playerLoader = null;
         }
         if (enemyLoader != null)
         {
             enemyLoader.DeleteLoadedObjects();
             Object.Destroy(enemyLoader);
             enemyLoader   = null;
             enemyAnimCtrl = null;
         }
         if (itemLoader != null)
         {
             itemLoader.Clear();
             Object.Destroy(itemLoader);
             itemLoader = null;
         }
         Object.Destroy(model.get_gameObject());
         model = null;
         if (uiRenderTexture != null && uiRenderTexture.postEffectFilter != null)
         {
             uiRenderTexture.postEffectFilter = null;
         }
     }
     if (coroutine != null)
     {
         this.StopCoroutine(coroutine);
         coroutine = null;
     }
 }
 private IEnumerator DoViewing()
 {
     if (!(model == null))
     {
         model.set_localEulerAngles(Vector3.get_zero());
         uiRenderTexture.enableTexture = true;
         float rot_wait = 1f;
         if (playerLoader != null)
         {
             model.set_localPosition(modelPos);
             model.set_localEulerAngles(modelRot);
         }
         else if (npcLoader != null)
         {
             model.set_localPosition(modelPos);
             model.set_localEulerAngles(modelRot);
         }
         else if (enemyLoader != null)
         {
             if (enemyDispplayInfo == null)
             {
                 Bounds bounds = default(Bounds);
                 int    j      = 0;
                 for (int i = enemyLoader.renderersBody.Length; j < i; j++)
                 {
                     bounds.Encapsulate(enemyLoader.renderersBody[j].get_bounds());
                 }
                 Vector3   extents  = bounds.get_extents();
                 float     z        = extents.x * 0.5f / Mathf.Tan(0.3926991f) + 1f;
                 Transform obj      = model;
                 Vector3   extents2 = bounds.get_extents();
                 obj.set_localPosition(new Vector3(0f, extents2.y * -0.5f, z));
                 model.set_localEulerAngles(new Vector3(0f, 180f, 0f));
             }
             else
             {
                 model.set_localPosition(new Vector3(0f, -0.8f, 5f));
                 if (enemyDispplayInfo.seIdhowl > 0 && isEnemyHowl)
                 {
                     audioObject = SoundManager.PlayUISE(enemyDispplayInfo.seIdhowl);
                 }
                 enemyLoader.body.set_localPosition(enemyDispplayInfo.pos);
                 enemyLoader.body.set_localEulerAngles(new Vector3(0f, enemyDispplayInfo.angleY, 0f));
                 enemyAnimCtrl = model.get_gameObject().AddComponent <EnemyAnimCtrl>();
                 enemyAnimCtrl.Init(enemyLoader, uiRenderTexture.renderCamera, false);
                 Animator animator = enemyLoader.GetAnimator();
                 if (animator != null)
                 {
                     int stateHash = Animator.StringToHash("Base Layer.GACHA_HOWL");
                     if (animator.HasState(0, stateHash))
                     {
                         animator.Play(stateHash, 0, 0f);
                         animator.Update(0f);
                     }
                 }
             }
         }
         Vector3      lightDir = new Vector3(1.19f, -1.59f, -1f);
         Quaternion   rotation = Quaternion.AngleAxis(1f, new Vector3(-0.07124705f, 0f, -0.9974587f));
         MeshRenderer renderer = null;
         if (lightRotation)
         {
             renderer = model.GetComponentInChildren <MeshRenderer>();
         }
         while (true)
         {
             if (itemLoader != null)
             {
                 model.set_localPosition(new Vector3(0f, 0f, itemLoader.displayInfo.zFromCamera));
                 itemLoader.ApplyDisplayInfo();
                 if (rot_wait <= 0f)
                 {
                     model.Rotate(new Vector3(0f, rotateSpeed, 0f) * Time.get_deltaTime());
                 }
                 else
                 {
                     rot_wait -= Time.get_deltaTime();
                 }
                 if (lightRotation)
                 {
                     lightDir = rotation * lightDir;
                     renderer.get_material().SetVector("_LightDir", Vector4.op_Implicit(lightDir));
                 }
             }
             yield return((object)null);
         }
     }
     Log.Error("model is null!!");
 }