private void OnTriggerEnter2D(Collider2D collision) { BaseHP baseHP = FindObjectOfType <BaseHP>(); Attacker attacker = collision.gameObject.GetComponent <Attacker>(); if (attacker) { BaseDamager dmg = attacker.GetComponent <BaseDamager>(); baseHP.ReduceHP(dmg.getBaseDamage()); Destroy(collision.gameObject); } }
public override string ToString() { String Moves = ""; String Levels = ""; for (int i = 0; i < MoveLevels.Length; i++) { Moves = Moves + MoveList[i].ToString() + "¶"; Levels = Levels + MoveLevels[i].ToString() + "¶"; } Moves = Moves + "65535"; Levels = Levels + "65535" + "¶"; return(ID + "¶" + Name + "¶" + BaseHP.ToString() + "¶" + BaseAttack.ToString() + "¶" + BaseDefense.ToString() + "¶" + BaseSpecialAttack.ToString() + "¶" + BaseSpecialDefense.ToString() + "¶" + BaseSpeed.ToString() + "¶" + ((int)LevelingType).ToString() + "¶" + FormID.ToString() + "¶" + GenderValue.ToString() + "¶" + ((int)Type1).ToString() + "¶" + ((int)Type2).ToString() + "¶" + CatchRate.ToString() + "¶" + ExpYield.ToString() + "¶" + EffortYield.ToString() + "¶" + Item1.ToString() + "¶" + Item2.ToString() + "¶" + Ability1.ToString() + "¶" + Ability2.ToString() + "¶" + Ability3.ToString() + "¶" + DexEntry + "¶" + Levels + Moves); }
public override string ToString() { return($"new PokemonData({PokedexID}, \"{Name}\", PokemonData.Type.{Type1.ToUpper()}, PokemonData.Type.{Type2.ToUpper()}, \"{AbilityCheck(Ability1)}\", {AbilityCheck(Ability2)}, \"{AbilityCheck(HiddenAbility)}\",\n" + $"{MaleRatio}f, {CatchRate}, PokemonData.EggGroup.{EggGroup1.ToUpper()}, PokemonData.EggGroup.{EggGroup2.ToUpper()}, {HatchTime}, {Height}f, {Weight}f,\n" + $"{EvExp.ToString()}, PokemonData.LevelingRate.{ToUpperRemoveSpace(LevelingRate)}, {EvHP.ToString()}, {EvAttack.ToString()}, {EvDefense.ToString()}, {EvSpecialAttack.ToString()}, {EvSpecialDefense.ToString()}, {EvSpeed.ToString()}, PokemonData.PokedexColor.{ToUpperRemoveSpace(PokedexColor)}, {BaseFriendship.ToString()},\n" + $"\"{Species}\", \"{PokedexEntry}\",\n" + $"{BaseHP.ToString()}, {BaseAttack.ToString()}, {BaseDefense.ToString()}, {BaseSpecialAttack.ToString()}, {BaseSpecialDefense.ToString()}, {BaseSpeed.ToString()}, {Luminance.ToString()}f, Color.{LightColor.ToLower()}," + "new int[] {" + $"{MoveLevels(LevelMoves)}" + "},\n" + "new string[]\n" + "{\n" + $"{MoveNames(LevelMoves)}\n" + "},\n" + "new string[] { " + HMandTM(hmAndTM) + " },\n" + "new int[] {" + EvolutionID + "}, new string[] {" + $"\"Level,{EvolutionLevel}\"" + "}),\n"); }
private void Update() { if (Target != null) //если у нас есть цель { mob.rotation = Quaternion.Lerp(mob.rotation, Quaternion.LookRotation(new Vector3(Target.transform.position.x, 0.0f, Target.transform.position.z) - new Vector3(mob.position.x, 0.0f, mob.position.z)), mobRotationSpeed); //избушка-избушка, повернись к пушке передом! mob.position += mob.forward * MobCurrentSpeed * Time.deltaTime; //двигаем в сторону, куда смотрит моб float squaredDistance = (Target.transform.position - mob.position).sqrMagnitude; //меряем дистанцию до цели Vector3 structDirection = (Target.transform.position - mob.position).normalized; //получаем вектор направления float attackDirection = Vector3.Dot(structDirection, mob.forward); //получаем вектор атаки if (squaredDistance < attackDistance * attackDistance && attackDirection > 0) //если мы на дистанции атаки и цель перед нами { if (attackTimer > 0) { attackTimer -= Time.deltaTime; //если таймер атаки больше 0 - отнимаем его } if (attackTimer <= 0) //если же он стал меньше нуля или равен ему { BaseHP bhp = Target.GetComponent <BaseHP>(); //подключаемся к компоненту ХП цели if (bhp != null) { bhp.ChangeHP(-damage); //если цель ещё живая, наносим урон (мы можем не одни бить по цели, потому проверка необходима) } attackTimer = coolDown; //возвращаем таймер в исходное положение MobHP mhp = GetComponent <MobHP>(); mhp.curHP = 0; } } } else { GameObject baza = GameObject.FindGameObjectWithTag("Base"); //находим наш объект с базой, он всего один if (baza != null) { Target = baza; } } }
public void Save(int ID) { using (XmlWriter writer = XmlWriter.Create(Paths.DataPath + "Dex\\" + ID.ToString() + "-" + FormIndex + ".xml", Logger.XmlWriterSettings)) { writer.WriteStartDocument(); writer.WriteStartElement("FormEntry"); #region Basic data writer.WriteStartElement("General"); writer.WriteElementString("FormName", FormName); writer.WriteElementString("Height", Height.ToString()); writer.WriteElementString("Weight", Weight.ToString()); writer.WriteElementString("Male", MaleRatio.ToString()); writer.WriteElementString("Female", FemaleRatio.ToString()); writer.WriteElementString("RecruitRate", RecruitRate.ToString()); writer.WriteElementString("BodyStyle", BodyStyle.ToString()); writer.WriteEndElement(); #endregion #region Stats writer.WriteStartElement("BaseStats"); writer.WriteElementString("HP", BaseHP.ToString()); writer.WriteElementString("Atk", BaseAtk.ToString()); writer.WriteElementString("Def", BaseDef.ToString()); writer.WriteElementString("SpAtk", BaseSpAtk.ToString()); writer.WriteElementString("SpDef", BaseSpDef.ToString()); writer.WriteElementString("Speed", BaseSpeed.ToString()); writer.WriteEndElement(); #endregion #region Pokemon Info writer.WriteStartElement("FormInfo"); writer.WriteElementString("Type1", Type1.ToString()); writer.WriteElementString("Type2", Type2.ToString()); writer.WriteElementString("Ability1", Ability1); writer.WriteElementString("Ability2", Ability2); writer.WriteElementString("Ability3", Ability3); writer.WriteElementString("Exp", ExpYield.ToString()); writer.WriteEndElement(); #endregion #region Moves writer.WriteStartElement("Moves"); #region Level Up Moves writer.WriteStartElement("LevelUpMoves"); for (int i = 0; i < LevelUpMoves.Count; i++) { writer.WriteStartElement("LevelUpMove"); writer.WriteElementString("Level", LevelUpMoves[i].Level.ToString()); writer.WriteElementString("Name", GameData.MoveDex[LevelUpMoves[i].Move].Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region TM Moves writer.WriteStartElement("TMMoves"); for (int i = 0; i < TMMoves.Count; i++) { writer.WriteStartElement("TMMove"); writer.WriteElementString("Name", GameData.MoveDex[TMMoves[i]].Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region Egg Moves writer.WriteStartElement("EggMoves"); for (int i = 0; i < EggMoves.Count; i++) { writer.WriteStartElement("EggMove"); writer.WriteElementString("Name", GameData.MoveDex[EggMoves[i]].Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region DW Moves writer.WriteStartElement("DWMoves"); for (int i = 0; i < DWMoves.Count; i++) { writer.WriteStartElement("DWMove"); writer.WriteElementString("Name", GameData.MoveDex[DWMoves[i]].Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion #region Event Moves writer.WriteStartElement("EventMoves"); for (int i = 0; i < EventMoves.Count; i++) { writer.WriteStartElement("EventMove"); writer.WriteElementString("Name", GameData.MoveDex[EventMoves[i]].Name); writer.WriteEndElement(); } writer.WriteEndElement(); #endregion writer.WriteEndElement(); #endregion writer.WriteEndElement(); writer.WriteEndDocument(); } }