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(); } } } } } }
public void AddPlat() { if (++_iPlatIndex > BattleManager.GetInst().Stairs) { return; } BattleFieldData field = BattleManager.GetInst().GetFieldData(_iPlatIndex); BattlePlat plat = ResourceMgr.PopBox(SceneId, field.Type); plat.Index = _iPlatIndex; plat.X = field.X; plat.Y = field.Y; plat.m_Transform.SetParent(ForegroundTran); plat.m_Transform.localPosition = new Vector3(field.X, field.Y, 0f); plat.m_Transform.localScale = Vector3.one; if (field.Item > 0) { string itemId = ConfigData.GetValue("Scene_Common", SceneId.ToString(), string.Format("Item{0}", field.Item)); if (itemId != "-1") { int id = int.Parse(itemId); BattleItem item = ResourceMgr.PopItem(id); item.Type = id; item.m_Transform.SetParent(plat.m_Transform, false); } } _dicPlat.Add(_iPlatIndex, plat); }
public static void PushBox(int scene, int type, BattlePlat plat) { if (!_dicBoxes[scene][type].Contains(plat)) { plat.m_Transform.SetParent(BattleManager.GetInst().BattlePoorTran); plat.m_Transform.localPosition = PositionMgr.vecHidePos; _dicBoxes[scene][type].Push(plat); } }
private void CheckStay(Collider2D collider) { if (collider.tag == "Plat") { BattlePlat plat = collider.GetComponent <BattlePlat>(); switch (plat.Type) { case 1: MoveLeft(); break; case 2: MoveRight(); break; } } }
private void CheckEnter(Collider2D collider) { if (collider.tag == "Plat") { CurPlat = collider.GetComponent <BattlePlat>(); switch (CurPlat.Type) { case 3: RemovePlat(collider); break; case 4: _rigidbody.AddForce(Vector2.up * 200, ForceMode2D.Force); break; case 5: ReduceHp(1); break; } } }
public static BattlePlat PopBox(int scene, int type) { if (!_dicBoxes.ContainsKey(scene)) { _dicBoxes.Add(scene, new Dictionary <int, Stack <BattlePlat> >()); } if (!_dicBoxes[scene].ContainsKey(type)) { _dicBoxes[scene].Add(type, new Stack <BattlePlat>()); } if (_dicBoxes[scene][type].Count > 0) { return(_dicBoxes[scene][type].Pop()); } BattlePlat plat = (Object.Instantiate(_boxes[scene, type]) as GameObject).GetComponent <BattlePlat>(); plat.Type = type; return(plat); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Role")) { collision.GetComponent <BattleHero>().ReduceHp(1); } else { BattlePlat plat = collision.GetComponent <BattlePlat>(); if (plat != null) { TriggerCbFunc(plat); return; } BattleItem item = collision.GetComponent <BattleItem>(); if (item != null) { ResourceMgr.PushItem(item); return; } } }
public void PlatOutField(BattlePlat plat) { RemovePlat(plat); _iCurMinIndex = plat.Index + 1; }
public void RemovePlat(BattlePlat plat) { _dicPlat.Remove(plat.Index); ResourceMgr.PushBox(SceneId, plat.Type, plat); AddPlat(); }
public void RemovePlat(int playerId, BattlePlat plat) { _dicField[playerId].RemovePlat(plat); }