public void Add(string name, BloodSequence bloodSeq) { if (!this.listDict.ContainsKey(name)) { this.listDict.Add(name, new BloodSequenceList()); } this.listDict[name].Add(bloodSeq); }
public bool isAvailable; // 是否为可用对象 public static void Show(string prefabName, Vector3 position) { BloodSequence bloodSeq = bloodLibrary.Get(prefabName); // 如果为空,就新实例化一个 if (bloodSeq == null) { Transform trans = Instantiate(PrefabResources.Get(prefabName)) as Transform; bloodSeq = trans.GetComponent <BloodSequence>(); bloodLibrary.Add(prefabName, bloodSeq); } bloodSeq.timer = 0f; // 设置 bloodSeq.isAvailable = false; bloodSeq.transform.position = position; bloodSeq.gameObject.SetActive(true); }
// 击中僵尸 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); } }
public void Add(BloodSequence bloodSeq) { this.count++; this.bloodList.Add(bloodSeq); }