コード例 #1
0
        public void CreateZombie(StgZombieBornDealer zombieDealer)
        {
            Transform trans = UnityEngine.Object.Instantiate(PrefabResources.Get("Zombie/" + zombieName));

            trans.position    = this.position + new Vector3(UnityEngine.Random.Range(-this.range, this.range), 0.3f, UnityEngine.Random.Range(-this.range, this.range));
            trans.eulerAngles = new Vector3(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
            ZombieAbs zombieAbs = trans.GetComponent <ZombieAbs>();

            zombieAbs.Agent.Warp(trans.position);
            zombieAbs.zombieDieDelegate = (Action <ZombieAbs>)Delegate.Combine(zombieAbs.zombieDieDelegate, new Action <ZombieAbs>(zombieDealer.HandleZombieDie));
            trans.gameObject.SetActive(true);
            StgZombieBornDealer.zombies.Add(zombieAbs);
        }
コード例 #2
0
 public void HandleZombieDie(ZombieAbs zombieController)
 {
     zombies.Remove(zombieController);
     this.nowCount--;
     this.deadCount++;
     lastDieTime = Time.realtimeSinceStartup;
     Debug.Log("僵尸死亡:" + deadCount + "/" + totalCount);
     // zombieDieAct暂时用不上
     if (this.deadCount >= this.totalCount)
     {
         // 所有僵尸死掉了再进行下一步
         if (this.stgEvent.isBlock)
         {
             Debug.Log("进行下一步:HeroController.INSTANCE.StartCurrentEvent();");
             HeroController.INSTANCE.StartCurrentEvent();
         }
         zombieDealers.Remove(this);
         Destroy(base.gameObject);
     }
 }
コード例 #3
0
        // 击中僵尸
        protected virtual void ProcessHitZombie()
        {
            string    str           = this.target.tag.ToLower();
            ZombieAbs zombieAbsComp = this.target.transform.root.GetComponent <ZombieAbs>();

            if (zombieAbsComp != null)
            {
                float num = Random.Range(0f, 1f);
                // 僵尸出血,需要位置点产生血
                BloodSequence.Show("Effect/Blood/BloodSplatEffect", this.targetPos);
                // 僵尸的血溅到屏幕上,需要距离判断是否会溅到
                float hitPointDist = Vector3.Distance(this.targetPos, GameCameraController.INSTANCE.MainCameraTrans.position);
                ZombieAttackedBlood.Show("Effect/ZombieAttacked", hitPointDist);
                Vector3 backward     = -zombieAbsComp.transform.forward;
                Vector2 vertBack     = new Vector2(backward.x, backward.y);
                Vector2 normVertBack = vertBack.normalized;
                Vector2 lhs          = new Vector2(-normVertBack.y, normVertBack.x);

                Vector3 targetDir     = this.targetPos - this.originalPos; // 从玩家指向集中目标
                Vector2 vertTargetDir = new Vector2(targetDir.x, targetDir.z);
                Vector2 rhs           = vertTargetDir.normalized;

                Vector2 attackedForce = new Vector2(Vector2.Dot(lhs, rhs), Vector2.Dot(normVertBack, rhs));
                Vector2 zero          = Vector2.zero;
                float   baseDmg       = this.baseDmg;

                if (str.EndsWith("head"))
                {
                    zero = new Vector2(0f, 1f);
                    //baseDmg *= 2f;
                    baseDmg = 100f;
                }
                else if (str.EndsWith("body"))
                {
                    zero             = new Vector2(0f, 0f);
                    attackedForce.y *= 0.7f;
                }
                else if (str.EndsWith("leftarm"))
                {
                    zero             = new Vector2(-1f, 1f);
                    attackedForce.x -= 0.15f;
                    attackedForce   /= 2f;
                }
                else if (str.EndsWith("rightarm"))
                {
                    zero             = new Vector2(1f, 1f);
                    attackedForce.x -= 0.15f;
                    attackedForce   /= 2f;
                }
                else if (str.EndsWith("leftleg"))
                {
                    zero           = new Vector2(-1f, -1f);
                    attackedForce /= 2f;
                }
                else if (str.EndsWith("rightleg"))
                {
                    zero           = new Vector2(1f, -1f);
                    attackedForce /= 2f;
                }
                else if (str.EndsWith("special"))
                {
                    zero           = new Vector2(2f, 0f);
                    attackedForce /= 2f;
                }
                if (((zombieAbsComp.hp <= baseDmg) && (zombieAbsComp.hp > 0f)) && (zombieAbsComp.dangerLevel < 0x3e8))
                {
                    // 计算各种统计信息
                    StgZombieBornDealer.normalKillCount++;
                    if (zero.x == 0 && zero.y == 1)
                    {
                        StgZombieBornDealer.normalHeadshotCount++;
                        AudioManager.INSTANCE.Play("Effect/headshot");
                    }
                }
                attackedForce.y *= this.basePower;
                // attackedForce.y的取值范围为(-∞, -0.3f] && [0.3f, ∞)
                if (attackedForce.y > -0.3f && attackedForce.y < 0.3f)
                {
                    attackedForce.y = (attackedForce.y >= 0f) ? 0.3f : -0.3f;
                }
                zombieAbsComp.Hit(baseDmg, zero, attackedForce, this.basePower);
            }
        }