void DuOver() { _DuShanghai = 0; _DuShanghaiTimes = 0; _DuJishi = 0; IsDu = false; _CMaxDuChixuShijian = 0; if (_DUTXObj) { _DUTXObj.GetComponent <ParticleSystem>().Stop(); ObjectPools.GetInstance().DestoryObject2(_DUTXObj.gameObject); } //print(" 持续 毒伤害 结束 !!!! "+ ChixuDuodianTXList.Count); if (ChixuDuodianTXList.Count != 0) { for (int i = ChixuDuodianTXList.Count - 1; i >= 0; i--) { if (ChixuDuodianTXList[i].name == DuTXName) { IshasNameTX = true; ChixuDuodianTXList[i].GetComponent <ParticleSystem>().Stop(); ObjectPools.GetInstance().DestoryObject2(ChixuDuodianTXList[i].gameObject); //ChixuDuodianTXList.Remove(ChixuDuodianTXList[i]); } } if (IshasNameTX) { return; } } }
public IEnumerator IEDieDestory(float time) { yield return(new WaitForSeconds(time)); ObjectPools.GetInstance().DestoryObject2(this.gameObject); //this.gameObject.SetActive(false); }
/// <summary> /// 初始化助手 /// </summary> public void OnInitialization() { _module = Module as EntityManager; _entityRoot = _module.transform.Find("EntityRoot"); List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type => { return(type.IsSubclassOf(typeof(EntityLogicBase)) && !type.IsAbstract); }); for (int i = 0; i < types.Count; i++) { EntityResourceAttribute attribute = types[i].GetCustomAttribute <EntityResourceAttribute>(); if (attribute != null) { Entities.Add(types[i], new List <EntityLogicBase>()); GameObject group = new GameObject(types[i].Name + "[Group]"); group.transform.SetParent(_entityRoot); group.transform.localPosition = Vector3.zero; group.transform.localRotation = Quaternion.identity; group.transform.localScale = Vector3.one; group.SetActive(true); _entitiesGroup.Add(types[i], group); ObjectPools.Add(types[i], new Queue <GameObject>()); } else { throw new HTFrameworkException(HTFrameworkModule.Entity, "创建实体逻辑对象失败:实体逻辑类 " + types[i].Name + " 丢失 EntityResourceAttribute 标记!"); } } }
public static void CreateExplosionEntity(Vector3 position, string explosionKey, AllegianceInfo allegianceInfo, int layer, LayerMask damagableLayers, WeaponType weaponType) { GameObject explosion = ObjectPools.GetPooledObject(explosionKey); explosion.transform.position = position; explosion.GetComponent <Explosion>().DetonateWithWeaponType(weaponType, layer, damagableLayers, allegianceInfo); }
protected virtual void ShowACTX(string type, EventObject eventObject) { //print(type+" ??????? "+ eventObject.name); if (type == EventObject.FRAME_EVENT) { //print("子弹事件 "+ eventObject.name); if (eventObject.name == "zd" || eventObject.name == "zd2") { //闪一下点特效 GameObject shanGuang = ObjectPools.GetInstance().SwpanObject2(Resources.Load("TX_zidan1shan") as GameObject); //GlobalTools.GetGameObjectByName("TX_zidan1shan"); print(shanGuang + " ------ ?? " + zidanDian); shanGuang.transform.position = zidanDian.position; //判断子弹类型 和 动作类型 //zidan_1 zidan_2 //zidan_1_1 第三个1 是动作 atk_zd_+ '1' 如果没有就是 1 //1.普通子弹 2.高速子弹 3.跟踪子弹 4.3连弹 5.直线弹 GameObject zidan = ObjectPools.GetInstance().SwpanObject2(Resources.Load(ZDName) as GameObject); zidan.transform.position = zidanDian.position; zidan.transform.localScale = this.transform.localScale; //*************这里如果不加 如果有个 3散弹 的 对象池 就会 无法射击出去 注意************ zidan.GetComponent <TX_zidan>().IsAtkAuto = true; //放出子弹 子弹方向 点位置 - 目标位置+ -Y //print("发射子弹!!!!!!!!!!!!!!!!!!"); } } }
void ToziDan() { if (TX_ZidanFS) { TX_ZidanFS.Play(); } if (Audio_ZDFS) { Audio_ZDFS.Play(); } int zidanNums = 2 + GlobalTools.GetRandomNum(MoveZidanNums); for (int i = 0; i < zidanNums; i++) { float __x = 1 + GlobalTools.GetRandomDistanceNums(3); __x = this.transform.localScale.x > 0?-__x: __x; float __y = GlobalTools.GetRandomDistanceNums(-3) + GlobalTools.GetRandomDistanceNums(3); Vector2 v2 = new Vector2(__x, __y); GameObject zidan = ObjectPools.GetInstance().SwpanObject2(Resources.Load(ZidanName) as GameObject); zidan.GetComponent <TX_zidan>().CloseAutoFire(); zidan.GetComponent <Rigidbody2D>().velocity = Vector2.zero; zidan.transform.localScale = this.transform.localScale; zidan.transform.position = ZidanFasheiPos.position; zidan.GetComponent <Rigidbody2D>().velocity = v2; } }
protected virtual void Boom() { string bzName = "TX_HuoyanBaozha_2"; GameObject baozha = ObjectPools.GetInstance().SwpanObject2(Resources.Load(bzName) as GameObject); baozha.transform.position = this.transform.position; baozha.name = bzName; if (baozha.GetComponent <JN_Date>()) { baozha.GetComponent <JN_Date>().team = this.GetComponent <JN_Date>().team; } baozha.GetComponent <ParticleSystem>().Play(); if (GetComponent <Rigidbody2D>()) { GetComponent <Rigidbody2D>().velocity = Vector2.zero; } string BZSanpianName = "TX_Sanpians_1"; int nums = 10 + GlobalTools.GetRandomNum(14); for (int i = 0; i < nums; i++) { GameObject baozhaSanpian = GlobalTools.GetGameObjectInObjPoolByName(BZSanpianName); baozhaSanpian.name = BZSanpianName; Vector2 speed = new Vector2(300 - GlobalTools.GetRandomDistanceNums(600), 1000 - GlobalTools.GetRandomDistanceNums(2000)); speed = new Vector2(speed.x + 200 + GlobalTools.GetRandomDistanceNums(400), speed.y); if (GlobalTools.GetRandomNum() > 70) { speed = new Vector2(-200 - GlobalTools.GetRandomDistanceNums(400), speed.y); } baozhaSanpian.transform.position = this.transform.position; baozhaSanpian.GetComponent <Rigidbody2D>().AddForce(speed); } }
void ShowDiandings() { Remove4Dianding(); for (int i = 0; i < 4; i++) { GameObject dianding = ObjectPools.GetInstance().SwpanObject2(Resources.Load(DiandingName) as GameObject); dianding.transform.position = new Vector2(DianPos[i].position.x, DianPos[i].position.y + GlobalTools.GetRandomDistanceNums(2));// DianPos[i].position; dianding.GetComponent <JN_base>().atkObj = this.gameObject; dianding.GetComponent <JN_Date>().team = this.GetComponent <JN_Date>().team; dianding.GetComponent <RoleDate>().Live = dianding.GetComponent <RoleDate>().maxLive; dianding.GetComponent <TX_Dianding>().GetStart(); DiandingList.Add(dianding); //判断 该位置 是否 已经存在 电钉了 //if (!IsHasDiandingInPos(i)) //{ // GameObject dianding = ObjectPools.GetInstance().SwpanObject2(Resources.Load(DiandingName) as GameObject); // dianding.transform.position = DianPos[i].position; // dianding.GetComponent<JN_base>().atkObj = this.gameObject; // dianding.GetComponent<JN_Date>().team = this.GetComponent<JN_Date>().team; // dianding.GetComponent<RoleDate>().Live = dianding.GetComponent<RoleDate>().maxLive; // dianding.GetComponent<TX_Dianding>().GetStart(); // DiandingList.Add(dianding); //} } }
private void die() { foreach (DeathCallback callback in this.OnDeathCallbacks) callback(this); if (this.GibsPoolKey != null && this.GibsPoolKey != "") { GameObject gibs = ObjectPools.GetPooledObject(this.GibsPoolKey); gibs.transform.position = this.transform.position; gibs.transform.rotation = this.transform.rotation; GibsBehavior gibsBehavior = gibs.GetComponent<GibsBehavior>(); gibsBehavior.Knockback = _deathKnockback; gibsBehavior.ImpactVector = _deathImpactVector; AllegianceColorizer colorizer = this.GetComponent<AllegianceColorizer>(); if (colorizer != null) { gibsBehavior.AllegianceInfo = colorizer.AllegianceInfo; } } if (this.ShakeMagnitudeOnDeath > 0.0f) Camera.main.GetComponent<ShakeHandler>().ApplyImpact(this.ShakeMagnitudeOnDeath); Destroy(this.gameObject); }
public void Act(BaseAction action) { for (int i = 0; i < m_actionQueue.Count; ++i) { BaseAction c = m_actionQueue[i]; if (c.Connect(action)) { ObjectPools.CheckIn(action); return; } else if (c.CanReplace(action)) { ObjectPools.CheckIn(c); action.Prepare(); m_actionQueue[i] = action; return; } } m_actionQueue.Add(action); if (m_actionQueue.Count == 1) { action.Prepare(); } }
void Start() { _preloaded = this.SubBosses.Count / 3; ObjectPools.Preload(this.GibsPreloadKey, _preloaded); _preloadTimer = this.TimeBetweenPreloads; this.AttackTargets = PlayerTargetController.Targets; int hp = 1; foreach (GameObject subBoss in this.SubBosses) { subBoss.GetComponent <BossWeakSubBehavior>().OnAttackFinished = subBossAttackFinished; Damagable damagable = subBoss.GetComponent <Damagable>(); damagable.DirectSetHealth(hp); damagable.OnDeathCallbacks.Add(this.SubBossKilled); hp = hp >= 4 ? 1 : hp + 1; } for (int i = 0; i < this.EnemySpawners.Length; ++i) { this.EnemySpawners[i].SpawnCallback = enemySpawned; this.EnemySpawners[i].Targets = this.AttackTargets; } this.GetComponent <BossHealth>().DeathCallbacks.Add(onDeath); _stateMachine.AddState(ROTATION_STATE, updateRotation, enterRotation, exitRotation); _stateMachine.AddState(ATTACKING_STATE, updateAttacking, enterAttacking, exitAttacking); GlobalEvents.Notifier.Listen(BeginGameplayEvent.NAME, this, gameplayBegin); }
//间隔 先后 下砸 void JianGeXianhouXiaza() { for (int i = 0; i < intArr.Count; i++) { GameObject skillObj = Resources.Load(TXName) as GameObject; GameObject skill = ObjectPools.GetInstance().SwpanObject2(skillObj); skill.GetComponent <JN_base>().atkObj = this.gameObject; //出现位置 float __x = TLPos.position.x + 1.5f * intArr[i]; float __y = TLPos.position.y; if (i % 2 == 1) { __y += 1; skill.GetComponent <TX_XiazaiZidan>().SetZidanXiazaTime(1); } else { skill.GetComponent <TX_XiazaiZidan>().SetZidanXiazaTime(1.5f); } skill.transform.position = new Vector2(__x, __y); skill.transform.parent = this.gameObject.transform.parent; } }
public virtual void Init() { Debug.Log("Calling Start function"); op = ObjectPools.SharedInstance; player = GameObject.FindWithTag("Player"); health = MAX_HEALTH; isDead = false; state = State.ISALIVE; swordCollider = player.transform.GetChild(4).GetComponent <Collider2D>(); //target = player; isFacingLeft = false; detectionRange = 3.5f; jumpTimer = 0.5f; jumpForce = new Vector2(0.0f, 250.0f); spawnTimer = 0.5f; rigidBody2D = GetComponent <Rigidbody2D>(); canDestroy = false; destructionTime = 5.0f; searchTimer = 1.0f; //Direction for raycast leftVector = new Vector2(-1.0f, -1.0f); rightVector = directionVector = new Vector2(1.0f, -1.0f); pc = PlayerController.pc; }
protected override void ACSkillShowOut() { print(" dongzuo name shijian **********************ac " + TXName + " 重锤 "); //GetComponent<ShowOutSkill>().ShowOutSkillByName(TXName, true); Luoshi(); //if (!DachuiZhengdi1.activeSelf) DachuiZhengdi1.SetActive(true); //if (!DachuiZhengdi2.activeSelf) DachuiZhengdi2.SetActive(true); GameObject skillObj = Resources.Load(TX_Zhongchui1Name) as GameObject; GameObject skill = ObjectPools.GetInstance().SwpanObject2(skillObj); skill.GetComponent <JN_base>().atkObj = this.gameObject; skill.transform.position = Zhongchui1_pos.position; skill.transform.parent = this.gameObject.transform.parent; //skill.transform.position = Zhongchui1_pos.position; GameObject skillObj2 = Resources.Load(TX_Zhongchui2Name) as GameObject; GameObject skill2 = ObjectPools.GetInstance().SwpanObject2(skillObj2); skill2.GetComponent <JN_base>().atkObj = this.gameObject; skill2.transform.position = Zhongchui2_pos.position; skill2.transform.parent = this.gameObject.transform.parent; ObjectEventDispatcher.dispatcher.dispatchEvent(new UEvent(EventTypeName.CAMERA_SHOCK, "z2-0.6"), this); //return; //GameObject skillObj = Resources.Load(TXName) as GameObject; //if (skillObj == null) //{ // print(" skillObj = null "); // //Time.timeScale = 0; // return; //} ////GameObject skill = ObjectPools.GetInstance().SwpanObject2(skillObj); //if (skill.GetComponent<LiziJNControl>()) //{ // skill.GetComponent<LiziJNControl>().GetLiziObj().GetComponent<JN_base>().atkObj = this.gameObject; //} //if (FasheiPointNum == 1) //{ // skill.transform.position = zidanDian1.position; //} //else if (FasheiPointNum == 2) //{ // skill.transform.position = zidanDian2.position; //} //if (IsNeedSetScaleX) //{ // skill.transform.localScale = this.gameObject.transform.localScale; //} //skill.transform.parent = this.gameObject.transform.parent; //_gameBody.GetDB().animation.lastAnimationState.timeScale = 0.1f; //这里要实现 JNDate 赋值 }
public bool ApplyTool(string toolName, int x, int y) { if (GameState.Mode != GameMode.Playing) { return(false); } if (toolName == GameState.EDITOR_DELETE) { if (GameState.Devices[y, x] != null && GameState.Devices[y, x].CanDelete) { GameState.Parts[GameState.Devices[y, x].PartName]++; ObjectPools.Despawn(GameState.Devices[y, x]); GameState.Devices[y, x] = null; ToolPanel.Current.Refresh(); SoundBoard.Play(SOUND_DELETE); return(true); } } else if (toolName != null) { if (GameState.Devices[y, x] == null && GameState.Parts.ContainsKey(toolName) && GameState.Parts[toolName] > 0) { CreateDevice(toolName, x, y); GameState.Devices[y, x].PartName = toolName; GameState.Parts[toolName]--; ToolPanel.Current.Refresh(); SoundBoard.Play(SOUND_ADD); return(true); } } return(false); }
private void reset() { if (_collider != null) { _collider.RemoveFromCollisionPool(); } if (_allegianceInfo.Allegiance == Allegiance.Player) { _damager.RemoveAttackLandedCallback(landedAttack); } _trueRadius = 0.0f; IntegerCircleCollider circleCollider = this.integerCollider as IntegerCircleCollider; if (circleCollider != null) { circleCollider.Radius = Mathf.RoundToInt(_trueRadius); } if (_circleRenderer != null) { _circleRenderer.Radius = _trueRadius; } _destructionScheduled = false; _collisions.Clear(); ObjectPools.ReturnPooledObject(this.ObjectPoolKey, this.gameObject); }
protected virtual void ShowACTX(string type, EventObject eventObject) { //print(type+" ??????? "+ eventObject.name); if (type == EventObject.FRAME_EVENT) { if (eventObject.name == "ac") { print("GetZSName> " + GetZSName + " ZSName " + ZSName); if (GetZSName == ZSName) { ACSkillShowOut(); } } if (eventObject.name == "zd" || eventObject.name == "zd2") { //闪一下点特效 GameObject shanGuang = ObjectPools.GetInstance().SwpanObject2(Resources.Load("TX_zidan1shan") as GameObject); //GlobalTools.GetGameObjectByName("TX_zidan1shan"); shanGuang.transform.position = zidanDian1.position; //判断子弹类型 和 动作类型 //zidan_1 zidan_2 //zidan_1_1 第三个1 是动作 atk_zd_+ '1' 如果没有就是 1 //1.普通子弹 2.高速子弹 3.跟踪子弹 4.3连弹 5.直线弹 //GameObject zidan = ObjectPools.GetInstance().SwpanObject2(Resources.Load(ZDName) as GameObject); //zidan.transform.position = zidanDian.position; //zidan.transform.localScale = this.transform.localScale; //放出子弹 子弹方向 点位置 - 目标位置+ -Y //print("发射子弹!!!!!!!!!!!!!!!!!!"); } } }
void Awake() { if (CurrentObjectPool == null) { CurrentObjectPool = this; } }
bool CalculateHasTypeEquivalence() { if (BaseType?.HasTypeEquivalence == true) { return(true); } if (TIAHelper.IsTypeDefEquivalent(this)) { return(true); } var hash = GetAllInterfaces(this); foreach (var ifaceType in hash) { if (ifaceType.HasTypeEquivalence) { ObjectPools.Free(ref hash); return(true); } } ObjectPools.Free(ref hash); return(false); }
void UpdateBeam(int index) { if (beamsOn[index]) { if (beams[index] == null) { beams[index] = ObjectPools.Spawn <BeamDevice>(BEAM_POOL, BeamAttach.position, BeamAttach); beams[index].SetTile(TileX, TileY); beams[index].SetDirectionAndLayer( (index == 0) ? 1 : ((index == 1) ? -1 : 0), (index == 2) ? -1 : ((index == 3) ? 1 : 0), beamLayerOffsets[index] ); } else { beams[index].Tick(); } } else if (beams[index] != null) { ObjectPools.Despawn(beams[index]); beams[index] = null; } }
protected virtual IObjectPool <WorkerThread> NewObjectPool() { IBuilder <WorkerThread> builder = ObjectPools.NewObjectPoolConfigBuilder <WorkerThread>(); SetObjectPoolConfigBuilder <IBuilder <WorkerThread> >(builder); return(ObjectPools.NewObjectPool(builder.Build())); }
void HandleEndGame() { foreach (GameObject tie in GameObject.FindGameObjectsWithTag("tie")) { ObjectPools.ReturnTieToThePool(tie); } foreach (GameObject laser in GameObject.FindGameObjectsWithTag("laser")) { ObjectPools.ReturnLaserToThePool(laser); } ; Destroy(GameObject.FindGameObjectWithTag("hud")); foreach (GameObject laser in ObjectPools.laserPool) { Destroy(laser); } foreach (GameObject tieFighter in ObjectPools.tiePool) { Destroy(tieFighter); } ObjectPools.laserPool.Clear(); ObjectPools.tiePool.Clear(); Time.timeScale = 0; GameObject restartMenu = (GameObject)Instantiate(Resources.Load("prefabs/Restart")); GameObject.FindGameObjectWithTag("score").GetComponent <Text> ().text = "score = " + HUD.score.ToString(); }
public void Clear() { foreach (KeyValuePair <int, BaseBomb> bomb in m_dicBombs) { ObjectPools.CheckIn(bomb.Value); } m_dicBombs.Clear(); }
void Start() { _timedCallbacks = this.GetComponent <TimedCallbacks>(); _lerpMovement = this.GetComponent <LerpMovement>(); _lerpMovement.AddCallback(movementComplete); this.Damagable.OnDeathCallbacks.Add(onDeath); ObjectPools.Preload(this.BossGibsPoolKey, this.Subs.Length); }
/** * If we've been added as a child to another object that is now being released, separate from that object and release ourselves as well. */ void OnReturnToPool() { if (this.transform.parent != null) { this.transform.SetParent(null); ObjectPools.Release(this); } }
public void CheckIn(CharacterLogic pCharacter) { if (OnCharacterDelete != null) { OnCharacterDelete(pCharacter); } ObjectPools.CheckIn(pCharacter); }
/// <summary> /// 获取对象,单例 /// </summary> /// <returns></returns> public static ObjectPools GetInstance() { if (instance == null) { instance = new ObjectPools(); } return(instance); }
//击中特效 void HitTX(float psScaleX, string txName) { GameObject hitTx = Resources.Load(txName) as GameObject; hitTx = ObjectPools.GetInstance().SwpanObject2(hitTx); hitTx.transform.position = gameBody.transform.position; hitTx.transform.localScale = new Vector3(1, 1, psScaleX); }
/// <summary> /// 获取对象,单例 /// </summary> /// <returns></returns> public static ObjectPools GetInstance() { if (singleton == null) { singleton = new ObjectPools(); } return singleton; }
//将 徽章UI存入对象池 public void RemoveAllSkillHZUI() { foreach (GameObject o in HZList) { ObjectPools.GetInstance().DestoryObject2(o); } HZList.Clear(); }
void HitTX2(string txName) { GameObject hitTx = Resources.Load(txName) as GameObject; hitTx = ObjectPools.GetInstance().SwpanObject2(hitTx); hitTx.transform.position = _gameBody.transform.position; hitTx.transform.parent = _gameBody.transform; }