void InitZone() { Log.Sys("InitZone Properties "); allWaves.Clear(); var ze = Zones [currentZone].GetComponent <ZoneEntityManager>(); var prop = ze.properties.transform; var ex = Util.FindChildRecursive(Zones [currentZone].transform, "exitZone"); if (ex != null) { exitZone = ex.gameObject; } waveNum = 0; MaxWave = 0; foreach (Transform t in prop) { var spawn = t.gameObject.GetComponent <SpawnTrigger>(); if (spawn != null) { allWaves.Add(spawn); if (spawn.waveNum >= MaxWave) { MaxWave = spawn.waveNum + 1; } } } //prop.gameObject.SetActive(true); var world = WorldManager.worldManager.GetActive(); if (world.IsNet) { //StartCoroutine(CheckNetSpawn()); } else { ze.EnableProperties(); } }
void Awake() { //var bx = Util.FindChildRecursive(transform, "boxColldier"); //var bx1 = Util.FindChildRecursive(transform, "boxColldier2"); //Physics.IgnoreCollision(bx.collider, bx1.collider); var tower = Util.FindChildRecursive(transform, "tower"); tower.gameObject.AddComponent <TowerAutoCheck>(); attribute = GetComponent <NpcAttribute>(); ai = new TankCharacter(); ai.attribute = attribute; ai.AddState(new TankIdle()); ai.AddState(new TankMoveAndShoot()); ai.AddState(new TankDead()); ai.AddState(new TankKnockBack()); ai.AddState(new HumanStunned()); ai.AddState(new TankStop()); }
private IEnumerator CountDown() { while (WorldManager.worldManager.station != WorldManager.WorldStation.Enter) { yield return(null); } var uiRoot = WindowMng.windowMng.GetMainUI(); while (uiRoot == null) { uiRoot = WindowMng.windowMng.GetMainUI(); yield return(null); } var lt = WindowMng.windowMng.AddChild(uiRoot, Resources.Load <GameObject>("UI/LeftTimeUI")); ltui = lt.GetComponent <LeftTimeUI>(); var sui = WindowMng.windowMng.AddChild(uiRoot, Resources.Load <GameObject>("UI/ScoreUI")); scoreUI = sui.GetComponent <ScoreUI>(); var rtp = Util.FindChildRecursive(uiRoot.transform, "RightTop"); rtp.gameObject.SetActive(false); Color32 white = new Color32(255, 255, 255, 255); Color32 red = new Color32(255, 0, 0, 255); while (leftTime > 0) { var color = white; if (leftTime <= 60 & leftTime % 2 == 0) { color = red; } ltui.SetLabel("" + Util.ConvertTime(leftTime), color); leftTime--; yield return(new WaitForSeconds(1)); } }
public void StartCutScene() { var cinema = Util.FindChildRecursive(uiRoot.transform, "cinematicmenu"); otherDialog = Util.FindChildRecursive(cinema, "OtherDialog").GetComponent <UILabel>(); myDialog = Util.FindChildRecursive(cinema, "MyDialog").GetComponent <UILabel>(); otherDialog.text = ""; myDialog.text = ""; var ani = DialogCutScene.GetComponent <DialogCutScene> ().track; //gameObject.AddComponent<Animation> (); GetComponent <Animation>().AddClip(ani, "master"); GetComponent <Animation>().Play("master"); /* * Stop Player Control Move */ player.GetComponent <PlayerAIController> ().enabled = false; player.GetComponent <Animation>().CrossFade("idle"); }
private void Awake() { var tower = Util.FindChildRecursive(transform, "tower"); tower.gameObject.AddComponent <TowerAutoCheck>(); attribute = GetComponent <NpcAttribute>(); ai = new TankCharacter(); ai.attribute = attribute; ai.AddState(new TankIdle()); ai.AddState(new TankMoveAndShoot()); ai.AddState(new TankDead()); ai.AddState(new TankKnockBack()); ai.AddState(new HumanStunned()); ai.AddState(new TankStop()); run = BackgroundSound.Instance.PlayEffectLoop("run", 0.1f); run.Play(); StartCoroutine(CheckSpeed()); StartCoroutine(CheckHP()); }
public static void SetText(GameObject g, string name, string text) { var lab = Util.FindChildRecursive(g.transform, name); lab.GetComponent <UILabel> ().text = text; }
/// <summary> ///显示粒子效果的时候出现在特定位置 /// </summary> /// <returns>The particle.</returns> IEnumerator ShowParticle() { var skillConfig = Event.layout.GetComponent <SkillLayoutConfig>(); var particle = Event.layout.GetComponent <SkillLayoutConfig>().particle; //NGUITools.AddMissingComponent<RemoveSelf> (particle); Log.Sys("Init Particle for skill Layout " + particle + " " + skillConfig + " bone name " + skillConfig.boneName); if (particle != null) { if (skillConfig.delayTime > 0) { yield return(new WaitForSeconds(skillConfig.delayTime)); } //var g = GameObject.Instantiate(particle) as GameObject; var g = ParticlePool.Instance.GetGameObject(particle, ParticlePool.InitParticle); /* * var xft = g.GetComponent<XffectComponent>(); * if (xft != null) * { * xft.enabled = false; * } */ var dm = NGUITools.AddMissingComponent <DumpMono>(g); dm.StartCoroutine(ParticlePool.CollectParticle(g, 2)); if (skillConfig.boneName != "") { Log.Sys("add particle to bone " + skillConfig.boneName); //g.transform.parent = transform; var par = Util.FindChildRecursive(stateMachine.attacker.transform, skillConfig.boneName); if (par == null) { par = stateMachine.attacker.transform; } //g.transform.parent = g.transform.localPosition = skillConfig.Position + par.transform.position; g.transform.localRotation = Quaternion.identity; g.transform.localScale = Vector3.one; } else { Log.Ani("Particle TargetPos " + Event.TargetPos); if (Event.TargetPos) { if (stateMachine.target != null) { stateMachine.MarkPos = stateMachine.target.transform.position; g.transform.position = stateMachine.target.transform.position + skillConfig.Position; g.transform.localRotation = Quaternion.identity; g.transform.localScale = Vector3.one; } } else if (Event.AttachToTarget) { if (stateMachine.target != null) { g.transform.parent = stateMachine.target.transform; g.transform.localPosition = skillConfig.Position; g.transform.localRotation = Quaternion.identity; g.transform.localScale = Vector3.one; } } else if (Event.UseMarkPos) { g.transform.position = stateMachine.MarkPos + skillConfig.Position; g.transform.localRotation = Quaternion.identity; g.transform.localScale = Vector3.one; } else { g.transform.parent = transform; g.transform.localPosition = skillConfig.Position; g.transform.localRotation = Quaternion.identity; g.transform.localScale = Vector3.one; } } //火焰哨兵的激光直接给目标造成伤害 if (Event.SetBeamTarget) { Log.AI("SetBeamTarget is " + stateMachine.target.transform.position); var bt = Util.FindChildrecursive <BeamTarget>(g.transform); if (bt != null) { bt.transform.position = stateMachine.target.transform.position + Event.BeamOffset; } BeamTargetPos = stateMachine.target.transform.position + Event.BeamOffset; } /* * if (xft != null) * { * StartCoroutine(EnableXft(xft)); * } */ } }
void Awake() { col = Util.FindChildRecursive(transform, "collision").GetComponent <Collider> (); }
public override IEnumerator RunLogic() { activeSkill = GetAttr().GetComponent <SkillInfoComponent>().GetActiveSkill(); tower = Util.FindChildRecursive(GetAttr().transform, "tower").transform; yield return(GetAttr().StartCoroutine(Shoot())); }
public static IEnumerator SetBurn(GameObject go) { var mesh = Util.FindChildRecursive(go.transform, "obj"); /* * var mr = go.GetComponentInChildren<SkinnedMeshRenderer>(); * if(mr != null) { * mesh = mr.transform; * }else { * var m = go.GetComponentInChildren<MeshRenderer>(); * if(m != null) { * mesh = m.transform; * } * } */ if (mesh == null) { foreach (Transform t in go.transform) { if (t.GetComponent <SkinnedMeshRenderer>() != null) { mesh = t; break; } if (t.GetComponent <MeshRenderer>() != null) { mesh = t; break; } } if (mesh == null) { Debug.Log("Util::SetBurn Not Find Obj or Skinned Mesh"); } } Material[] mat = mesh.GetComponent <Renderer>().materials; var shaderRes = Resources.Load <ShaderResource>("levelPublic/ShaderResource"); for (int i = 0; i < mesh.GetComponent <Renderer>().materials.Length; i++) { mat [i].shader = Shader.Find("Custom/newBurnShader"); mat [i].SetTexture("_cloud", shaderRes.cloudImg); mat [i].SetFloat("_timeLerp", 0); } //Material mat = mesh.renderer.material; //mat.SetFloat("_timeLerp", 0); float passTime = 0; while (passTime < 1) { for (int i = 0; i < mat.Length; i++) { mat [i].SetFloat("_timeLerp", passTime); passTime += Time.deltaTime; } yield return(null); } }
/* *客户端表现粒子和服务器计算伤害的数值分离开来 */ private void HitSomething(Collider other) { Log.AI("Bullet collider enemy " + other.name + " " + other.tag); var otherAttr = NetworkUtil.GetAttr(other.gameObject); if (otherAttr != null && otherAttr.gameObject == attacker) { return; } if (SkillLogic.IsEnemyForBullet(attacker, other.gameObject)) { var oattr = NetworkUtil.GetAttr(other.gameObject); if (oattr != null) { var buff = oattr.GetComponent <BuffComponent>(); var fanTan = buff.CheckHasSuchBuff(Affix.EffectType.FanTanBullet); Log.Sys("CheckHasSuchBuff: " + fanTan); if (fanTan && fanTanNum == 0) { fanTanNum++; var dirY = transform.localRotation.eulerAngles.y; transform.localRotation = Quaternion.Euler(new Vector3(0, dirY + 180, 0)); this.runner.stateMachine.attacker = oattr.gameObject; var l2 = Util.FindChildRecursive(this.transform, "blue"); if (l2 != null) { l2.gameObject.SetActive(false); var l3 = Util.FindChildRecursive(this.transform, "red"); l3.gameObject.SetActive(true); } return; } } //攻击多个目标只释放一次 DieParticle CreateHitParticle(); //计算随机的弹射 反射方向 if (LeftRicochets > 0) { Log.AI("Generate new bullet " + LeftRicochets); LeftRicochets--; initPos = transform.position; //子弹应该冲入怪物群中 transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0)); } else { //地震是穿透的因此只会等待粒子自然死亡 //非穿透性子弹 if (!missileData.piercing) { GameObject.Destroy(gameObject); } } //伤害多个目标 if (missileData.IsAOE) { AOEDamage(); } else { DoDamage(other); } //非穿透性子弹 if (!missileData.piercing) { var evt = new MyEvent(MyEvent.EventType.EventMissileDie); evt.missile = transform; MyEventSystem.myEventSystem.PushLocalEvent( attacker.GetComponent <KBEngine.KBNetworkView>().GetLocalId(), evt); } //TODO::撞击其它玩家如何处理 } else { //装到墙体 或者建筑物 等对象身上 则 反射 Not used Log.AI("Bullet colldier with Wall " + other.name); CreateHitParticle(); if (LeftRicochets > 0) { Log.AI("Generate new bullet " + LeftRicochets); LeftRicochets--; initPos = transform.position; transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + 180 + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0)); //sleepTime = IgnoreTime; } else { if (!missileData.piercing) { GameObject.Destroy(gameObject); } } if (!missileData.piercing) { var evt = new MyEvent(MyEvent.EventType.EventMissileDie); evt.missile = transform; if (attacker != null) { MyEventSystem.myEventSystem.PushLocalEvent( attacker.GetComponent <KBEngine.KBNetworkView>().GetLocalId(), evt); } } } }
//角色装备变更 同时修正FakeObject的装备,FakeObject是背包UI界面上3d模型 void WieldEquip(EquipData ed) { if (ed == null || ed.itemData == null) { return; } Log.Sys("Wield Equip is " + ed.itemData.ItemName); if (!IsFakeObject) { FakeWieldEquip(ed); } var defeq = attribute.ObjUnitData.GetDefaultWardrobe(); if (string.IsNullOrEmpty(defeq)) { return; } partToData [ed.itemData.equipPosition] = ed; switch (ed.itemData.equipPosition) { case ItemData.EquipPosition.WEAPON: if (Weapon != null) { UnwieldEquip(ItemData.EquipPosition.WEAPON); } WeaponData = ed; //是否有刀鞘 if (WeaponData.itemData.HasScabbard) { var fullWeapon = Resources.Load <GameObject>(WeaponData.itemData.ModelName); Log.Sys("NpcEquipment::WieldEquip " + fullWeapon); Weapon = Instantiate(Util.FindChildRecursive(fullWeapon.transform, "weapon1").gameObject) as GameObject; Scabbard = Instantiate(Util.FindChildRecursive(fullWeapon.transform, "weapon2").gameObject) as GameObject; var Point3 = Util.FindChildRecursive(fullWeapon.transform, "Point3"); if (back != null) { Scabbard.transform.parent = back; Scabbard.transform.localPosition = Vector3.zero; Scabbard.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0)); foreach (Transform c in Scabbard.transform) { if (c.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(c.gameObject); } } } //PeaceMode Level if (WorldManager.worldManager.IsPeaceLevel()) { Weapon.transform.parent = back; var mat = Matrix4x4.TRS(Point3.localPosition, Point3.localRotation, Point3.localScale); var inv = mat.inverse; Weapon.transform.localPosition = inv.GetColumn(3); Weapon.transform.localRotation = Quaternion.LookRotation(inv.GetColumn(2), inv.GetColumn(1)); Weapon.transform.localScale = Vector3.one; foreach (Transform c in Weapon.transform) { if (c.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(c.gameObject); } } } else { //UI上对象 武器在手中 if (rightHand != null) { Weapon.transform.parent = rightHand; Weapon.transform.localPosition = Vector3.zero; Weapon.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0)); foreach (Transform c in Weapon.transform) { if (c.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(c.gameObject); } } } } } else { Weapon = Instantiate(Resources.Load <GameObject>(WeaponData.itemData.ModelName)) as GameObject; Log.Sys("NpcEquipment::WieldEquip No Scab " + Weapon); if (WorldManager.worldManager.IsPeaceLevel()) { if (back != null) { var Point3 = Util.FindChildRecursive(Weapon.transform, "Point3"); Log.Sys("Wield Weapon in Back " + Point3); var mat = Matrix4x4.TRS(Point3.localPosition, Point3.localRotation, Point3.localScale); var inv = mat.inverse; Weapon.transform.parent = back; Weapon.transform.localPosition = inv.GetColumn(3); Weapon.transform.localRotation = Quaternion.LookRotation(inv.GetColumn(2), inv.GetColumn(1)); Weapon.transform.localScale = Vector3.one; Log.Sys("Set Weapon Transform " + inv.GetColumn(3)); if (Weapon.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(Weapon); } foreach (Transform c in Weapon.transform) { if (c.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(c.gameObject); } } } else { Debug.Log("NpcEquipment:: Not Find Back For equip "); } } else { Log.Sys("Wield Weapon On RightHand"); if (rightHand != null) { Weapon.transform.parent = rightHand; Weapon.transform.localPosition = Vector3.zero; Weapon.transform.localRotation = Quaternion.identity; Weapon.transform.localScale = Vector3.one; //3dsmax if (Weapon.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(Weapon); } foreach (Transform c in Weapon.transform) { if (c.GetComponent <Renderer>() != null) { GetComponent <ShadowComponent>().SetShadowPlane(c.gameObject); } } } else { Debug.LogError("NpcEquipment:: Not Found RightHand"); } } } break; case ItemData.EquipPosition.BODY: SetArmor(ed, out Chest); ChestData = ed; defaultChest.SetActive(false); break; case ItemData.EquipPosition.GLOVES: SetArmor(ed, out Gloves); GlovesData = ed; defaultGloves.SetActive(false); break; case ItemData.EquipPosition.SHOES: SetArmor(ed, out Shoes); ShoesData = ed; defaultBoots.SetActive(false); break; case ItemData.EquipPosition.HEAD: Log.Trivial(Log.Category.System, "Wear Head"); SetArmor(ed, out Head); headData = ed; defaultHead.SetActive(false); break; case ItemData.EquipPosition.TROUSERS: SetArmor(ed, out Trousers); TrousersData = ed; defaultTrousers.SetActive(false); break; default: Debug.LogError("WieldEquip Not Exists " + ed.itemData.equipPosition); break; } SetFakeObjLayer(); }