public void RobotControl(BattleHero hero) { if (hero.CurPlat == null) { return; } if (hero.CurPlat.Index == oldPlatIndex) { ++oldPlatTimes; } else { oldPlatIndex = hero.CurPlat.Index; oldPlatTimes = 0; } if (oldPlatTimes < Random.Range(5, 35)) { hero.Idle(); } else { BattlePlat nextPlat = BattleManager.GetInst().GetPlat(hero.PlayerId, hero.CurPlat.Index + 1); if (nextPlat != null) { if (nextPlat.Type == 5) { nextPlat = BattleManager.GetInst().GetPlat(hero.PlayerId, hero.CurPlat.Index + 2); } if (nextPlat.Y + BattleManager.GetInst().GetFieldPos(hero.PlayerId) < -4.5f) { hero.Idle(); } else { if (hero.m_Transform.localPosition.x > nextPlat.X + 1.1f) { hero.RunLeft(); } else if (hero.m_Transform.localPosition.x < nextPlat.X - 1.1f) { hero.RunRight(); } else { if (nextPlat.X > hero.CurPlat.X) { hero.RunRight(); } else { hero.RunLeft(); } } } } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Role")) { ResourceMgr.PushItem(this); BattleHero hero = collision.GetComponent <BattleHero>(); BattleManager.GetInst().EnqueueSkill(hero.PlayerId, Type); CommonCommand.ExecuteLongBattle(Client2ServerList.GetInst().C2S_BATTLE_GET_ITEM, new ArrayList() { (byte)Type }); } }
private void OnTriggerEnter2D(Collider2D collider) { if (collider.CompareTag("Role")) { if (BattleManager.GetInst().BattleType == 2) { BattleHero hero = collider.GetComponent <BattleHero>(); CommonCommand.ExecuteLongBattle(Client2ServerList.GetInst().C2S_BATTLE_HERO_FAILED, new ArrayList() { hero.PlayerId }); } } }
public void ChangePlatScale(int count, BattleHero hero) { float curHeroY = hero.m_Transform.localPosition.y; for (int i = _iCurMinIndex; i < count; ++i) { if (_dicPlat.ContainsKey(i)) { if (_dicPlat[i].Y < curHeroY) { _dicPlat[i].m_Transform.localScale = _vecScale; } } } }
//------ public void ChangePlatType(int count, int type, BattleHero hero) { float curHeroY = hero.m_Transform.localPosition.y; for (int i = _iCurMinIndex; i < count; ++i) { if (_dicPlat.ContainsKey(i)) { if (_dicPlat[i].Y < curHeroY) { RemovePlat(_dicPlat[i]); } } } }
public void LoadMy(Vector3 pos) { int playerId = PlayerData.PlayerId, index = 0; _dicPlayerIndex.Add(index, playerId); BattleField field = ResourceLoader.LoadAssetAndInstantiate("Prefab/BattleFiled", BattleRootTran, pos).GetComponent <BattleField>(); field.Load(playerId, PlayerData.CurHero, PlayerData.CurScene); _dicField.Add(playerId, field); BattleHero heroM = ResourceLoader.LoadAssetAndInstantiate("Prefab/BattleHero", _dicField[playerId].ForegroundTran).GetComponent <BattleHero>(); heroM.Init(playerId, false, PlayerData.CurHero); _dicHeros.Add(playerId, heroM); }
public void LoadOther(Vector3 pos, BattlePlayerData other, int index, float scale) { int playerId = other.PlayerId; _dicPlayerIndex.Add(index, playerId); BattleField field = ResourceLoader.LoadAssetAndInstantiate("Prefab/BattleFiled", BattleRootTran, pos).GetComponent <BattleField>(); field.SetScale(scale); field.Load(playerId, other.HeroId, other.SceneId); _dicField.Add(playerId, field); BattleHero heroE = ResourceLoader.LoadAssetAndInstantiate("Prefab/BattleHero", _dicField[playerId].ForegroundTran).GetComponent <BattleHero>(); heroE.Init(playerId, other.IsRobot, other.HeroId); _dicHeros.Add(playerId, heroE); }