public void SetMode(bool isRanged) { if (isRanged) { GetComponent<Image>().sprite=rangedSprite; currentMode=AttackMode.Ranged; } else { GetComponent<Image>().sprite=meleeSprite; currentMode=AttackMode.Melee; } }
public void SetAnimFramekEvent(float time, AttackMode mode, int value) { if (_keyAttacks == null) { _keyAttacks = new List<AnimFramekEvent>(); } Attack atk = new Attack() { attackMode = mode, attackValue = value }; _keyAttacks.Add(new AnimFramekEvent() { keyFrame = time, attack = atk }); }
protected override void ReadPacket(BinaryReader reader) { Mode = (AttackMode)reader.ReadByte(); }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass) reader.ReadByte(); Gender = (MirGender) reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode) reader.ReadByte(); PMode = (PetMode) reader.ReadByte(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) Inventory[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader); if (SMain.Envir.BindItem(item) && i < Equipment.Length) Equipment[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) continue; Magics.Add(magic); } if (Envir.LoadVersion < 2) return; Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if (Envir.LoadVersion < 4) return; count = reader.ReadInt32(); for (int i = 0; i < count; i++) Pets.Add(new PetInfo(reader)); if (Envir.LoadVersion < 5) return; AllowGroup = reader.ReadBoolean(); }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); if (Envir.LoadVersion < 62) { Level = (ushort)reader.ReadByte(); } else { Level = reader.ReadUInt16(); } Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode)reader.ReadByte(); PMode = (PetMode)reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) { Inventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) { Equipment[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) { QuestInventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) { continue; } Magics.Add(magic); } //reset all magic cooldowns on char loading < stops ppl from having none working skills after a server crash for (int i = 0; i < Magics.Count; i++) { Magics[i].CastTime = 0; } if (Envir.LoadVersion < 2) { return; } Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if (Envir.LoadVersion > 46) { MentalState = reader.ReadByte(); } if (Envir.LoadVersion < 4) { return; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Pets.Add(new PetInfo(reader)); } if (Envir.LoadVersion < 5) { return; } AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) { return; } if (Envir.LoadVersion == 12) { count = reader.ReadInt32(); } for (int i = 0; i < Globals.FlagIndexCount; i++) { Flags[i] = reader.ReadBoolean(); } if (Envir.LoadVersion > 27) { GuildIndex = reader.ReadInt32(); } if (Envir.LoadVersion > 30) { AllowTrade = reader.ReadBoolean(); } if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { QuestProgressInfo quest = new QuestProgressInfo(reader); if (SMain.Envir.BindQuest(quest)) { CurrentQuests.Add(quest); } } } if (Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buff buff = new Buff(reader); if (Envir.LoadVersion == 51) { buff.Caster = SMain.Envir.GetObject(reader.ReadUInt32()); } Buffs.Add(buff); } } if (Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader, Envir.LoadVersion, Envir.LoadCustomVersion)); } } //IntelligentCreature if (Envir.LoadVersion > 44) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) { continue; } IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); } if (Envir.LoadVersion > 49) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CompletedQuests.Add(reader.ReadInt32()); } } if (Envir.LoadVersion > 50 && Envir.LoadVersion < 54) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Poison poison = new Poison(reader); if (Envir.LoadVersion == 51) { poison.Owner = SMain.Envir.GetObject(reader.ReadUInt32()); } Poisons.Add(poison); } } if (Envir.LoadVersion > 56) { if (reader.ReadBoolean()) { CurrentRefine = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); } if (CurrentRefine != null) { SMain.Envir.BindItem(CurrentRefine); } CollectTime = reader.ReadInt64(); CollectTime += SMain.Envir.Time; } if (Envir.LoadVersion > 58) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Friends.Add(new FriendInfo(reader)); } } if (Envir.LoadVersion > 75) { count = reader.ReadInt32(); for (var i = 0; i < count; i++) { RentedItems.Add(new ItemRentalInformation(reader)); } HasRentedItem = reader.ReadBoolean(); } if (Envir.LoadVersion > 59) { Married = reader.ReadInt32(); MarriedDate = DateTime.FromBinary(reader.ReadInt64()); Mentor = reader.ReadInt32(); MentorDate = DateTime.FromBinary(reader.ReadInt64()); isMentor = reader.ReadBoolean(); MentorExp = reader.ReadInt64(); } if (Envir.LoadVersion >= 63) { int logCount = reader.ReadInt32(); for (int i = 0; i < logCount; i++) { GSpurchases.Add(reader.ReadInt32(), reader.ReadInt32()); } } }
// void DrawAbilityIcons() { // Icons dimentsions //Rect diamondRect = new Rect(Screen.width * 0.75f, Screen.height * 0.7f, // Screen.width * 0.15f, Screen.width * 0.15f); Rect chargeFrameRect = new Rect(Screen.width * 0.92f, Screen.height * 0.7f, Screen.width * 0.05f, Screen.width * 0.15f); // Overheat float overHeat = robotControl.CurrentOverHeat; float maxOverheat = gameManager.playerAttributes.maxOverheat; float overheatRectHeight = overHeat * chargeFrameRect.height / maxOverheat; Rect overheatRect = new Rect(chargeFrameRect.x + (chargeFrameRect.width * 0.01f), chargeFrameRect.y + (overheatRectHeight * 0.01f) + chargeFrameRect.height - overheatRectHeight, chargeFrameRect.width * 0.98f, overheatRectHeight * 0.98f); Rect overheatCoordRect = new Rect(0, 0, 1, overHeat); // Charge float chargeRectHeight = robotControl.ChargedAmount * chargeFrameRect.height; Rect chargeRect = new Rect(chargeFrameRect.x + (chargeFrameRect.width * 0.01f), chargeFrameRect.y + (chargeRectHeight * 0.01f) + chargeFrameRect.height - chargeRectHeight, chargeFrameRect.width * 0.98f, chargeRectHeight * 0.98f); Rect chargeCoordRect = new Rect(0, 0, 1, robotControl.ChargedAmount); // Abilities diamond and icons GUI.DrawTexture(diamondRect, diamondsBackgroundTexture); GUI.DrawTextureWithTexCoords(overheatRect, overheatTexture, overheatCoordRect); GUI.DrawTextureWithTexCoords(chargeRect, chargeTexture, chargeCoordRect); GUI.DrawTexture(chargeFrameRect, chargeFrameTexture); // if (robotControl.CurrentActionCharging != ActionCharguing.None && !charguingAnimationPlaying) { AssignChargeDrawingPosition(); charguingAnimationPlaying = true; } // if (charguingAnimationPlaying) { ChargeDrawing(); } // //Texture iconToUse = null; // Jump ones if (gameManager.playerAttributes.unlockedJumpActions > 0) { GUI.DrawTexture(new Rect(diamondRect.x + (diamondRect.width / 4), diamondRect.y + (diamondRect.height / 2), diamondRect.width / 2, diamondRect.height / 2), jumpTexture); } //Sprint ones if (gameManager.playerAttributes.unlockedSprintActions > 0) { GUI.DrawTexture(new Rect(diamondRect.x, diamondRect.y + (diamondRect.height / 4), diamondRect.width / 2, diamondRect.height / 2), sprintTexture); } // Attack ones if (gameManager.playerAttributes.unlockedAttackActions > 0) { AttackMode attackMode = robotControl.ActiveAttackMode; Texture iconToUse = null; switch (attackMode) { case AttackMode.Pulse: iconToUse = pulseAttackIcon; break; case AttackMode.RapidFire: iconToUse = rapidFireIcon; break; case AttackMode.Canon: iconToUse = cannonIcon; break; case AttackMode.ParticleCascade: iconToUse = particleCascadeIcon; break; } GUI.DrawTexture(new Rect(diamondRect.x + (diamondRect.width / 2), diamondRect.y + (diamondRect.height / 4), diamondRect.width / 2, diamondRect.height / 2), iconToUse); } //Defense ones if (gameManager.playerAttributes.unlockedDefenseActions > 0) { GUI.DrawTexture(new Rect(diamondRect.x + (diamondRect.width / 4), diamondRect.y, diamondRect.width / 2, diamondRect.height / 2), sphereDefenseTexture); } }
public static EvaluateInfo Evaluate(PeEntity npc, Enemy enemy, ItemObject obj) { float RANGE_DATA = 5.0f; ItemProto.WeaponInfo weaponInfo = obj.protoData.weaponInfo; AttackMode mode = obj.protoData.weaponInfo.attackModes[0]; EvaluateInfo info = new EvaluateInfo(); //当前装备 if (npc.motionEquipment.PEHoldAbleEqObj == obj) { info.setEquipment(1.2f); } else { info.setEquipment(1.0f); } if (mode.type == AttackType.Ranged) { info.SetRangeFir(2.0f); } else { info.SetRangeFir(1.0f); } //bool npcFeetInwater = npc.biologyViewCmpt != null && npc.biologyViewCmpt.monoPhyCtrl != null ? npc.biologyViewCmpt.monoPhyCtrl.feetInWater : false; float hpNpc = npc.GetAttribute(AttribType.Hp); //float atkNpc = npc.GetAttribute(AttribType.Atk); float defNpc = npc.GetAttribute(AttribType.Def); float enemyAtk = enemy.entityTarget.GetAttribute(AttribType.Atk); bool rangeFrist = ((enemyAtk - defNpc > hpNpc * 0.1f) && mode.type == AttackType.Ranged) ? true : false; // && !enemy.IsInWater && !npcFeetInwater //飞行怪物或者boss 只能远程攻击 if (enemy.entityTarget.Field == MovementField.Sky || enemy.entityTarget.IsBoss || rangeFrist) { if (mode.type == AttackType.Ranged) { info.SetLongRange(2.0f); } else { info.SetLongRange(0); } } //}//水中 只能用近战 //else if(npcFeetInwater) //{ // if(mode.type == AttackType.Melee) // info.SetLongRange(2.0f); // else // info.SetLongRange(0); //} else { info.SetLongRange(1.0f); } // float distance = PETools.PEUtil.MagnitudeH(npc.position, enemy.position); if (mode.IsInRange(distance)) { info.SetRangeValue(2.0f); } else { if (distance < mode.minRange && distance + RANGE_DATA > mode.minRange) { info.SetRangeValue(1.0f + Mathf.Clamp01(distance / mode.minRange)); } else if (distance > mode.maxRange && mode.maxRange + RANGE_DATA > distance) { info.SetRangeValue(1.0f + Mathf.Clamp01(RANGE_DATA - (distance - mode.maxRange) / RANGE_DATA)); } else { if (mode.type == AttackType.Ranged) { info.SetRangeValue(1.8f); } else { info.SetRangeValue(1.0f); } } } // info.SetDPS(mode.damage / (mode.frequency < PETools.PEMath.Epsilon ? 1.0f : mode.frequency)); if (weaponInfo.useEnergry) { GunAmmo gunAmmo = obj.GetCmpt <GunAmmo>(); if (gunAmmo != null) { int shootCount = gunAmmo.count / Mathf.Max(weaponInfo.costPerShoot, 1); //float energy = npc.GetAttribute(AttribType.Energy); if (shootCount > 3) { info.SetSurplusCnt(1.0f); } else if (shootCount >= 1 || npc.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon) { info.SetSurplusCnt(0.5f); } else { info.SetSurplusCnt(0); } } else { info.SetSurplusCnt(0); } } else if (weaponInfo.costItem > 0) { GunAmmo gunAmmo = obj.GetCmpt <GunAmmo>(); if (gunAmmo == null) { if (npc.GetItemCount(weaponInfo.costItem) < 3) { info.SetSurplusCnt(0.5f); } else { info.SetSurplusCnt(1.0f); } } else { if (gunAmmo.count < 3) { if (npc.GetItemCount(weaponInfo.costItem) < 3) { info.SetSurplusCnt(0.5f); } else { info.SetSurplusCnt(1.0f); } } else { info.SetSurplusCnt(1.0f); } } } else { info.SetSurplusCnt(1.0f); } info.SetObj(obj); return(info); }
public void SetCurrentAttackModeLabel(AttackMode attackMode) { modeLbl.text = string.Format("Mode: {0}", attackMode.ToString()); }
public void SimulateBattle() { CreateEnemy(); AttackMode attackMode = new AttackMode(); DefenseMode defenseMode = new DefenseMode(); Random random = new Random(); bool enemyAttacking = false; bool wrongButton = false; bool triedDef = false; int userDamage = 0; bool userDefended = false; bool enemyDefended = false; while (player.IsAlive && enemy.IsAlive) { if (enemyAttacking) { Console.WriteLine("Apparently the enemy will attack... Try to defense it\n"); } ShowInfo(player.Name, player.CurrentHealth, player.Weapon, enemy.Name, enemy.CurrentHealth, enemy.Weapon); string[] menu = { "[1] Front Attack", "[2] Vertical Attack", "[3] Horizontal Attack", "[4] Defense Front", "[5] Defense Vertically", "[6] Defense Horizontally" }; cw.CWStringArray(menu); ConsoleKeyInfo selection = Console.ReadKey(); Console.Clear(); switch (selection.Key) { case ConsoleKey.D1: userDamage = (attackMode.GetData(AttackType.NormalAttack).DataItem as IAttack).Damage((int)player.Weapon.AttackRating); break; case ConsoleKey.D2: userDamage = (attackMode.GetData(AttackType.VerticalSlashAttack).DataItem as IAttack).Damage((int)player.Weapon.AttackRating); break; case ConsoleKey.D3: userDamage = (attackMode.GetData(AttackType.HorizontalSlashAttack).DataItem as IAttack).Damage((int)player.Weapon.AttackRating); break; case ConsoleKey.D4: userDefended = (defenseMode.GetData(DefenseType.NormalDefense).DataItem as IDefense). GetDefense((DefenseType)random.Next((int)Enum.GetValues(typeof(DefenseType)).Cast <DefenseType>().Max()) + 1); triedDef = true; break; case ConsoleKey.D5: userDefended = (defenseMode.GetData(DefenseType.VerticalDefense).DataItem as IDefense). GetDefense((DefenseType)random.Next((int)Enum.GetValues(typeof(DefenseType)).Cast <DefenseType>().Max()) + 1); triedDef = true; break; case ConsoleKey.D6: userDefended = (defenseMode.GetData(DefenseType.HorizontalDefense).DataItem as IDefense). GetDefense((DefenseType)random.Next((int)Enum.GetValues(typeof(DefenseType)).Cast <DefenseType>().Max()) + 1); triedDef = true; break; default: Console.WriteLine("You did nothing..."); wrongButton = true; break; } if (enemyAttacking) { if (!userDefended) { int enemyDamage = (attackMode.GetData((AttackType)random. Next((int)Enum.GetValues(typeof(AttackType)). Cast <AttackType>().Max()) + 1).DataItem as IAttack). Damage((int)enemy.Weapon.AttackRating); player.DamagePlayer(enemyDamage); if (triedDef) { Console.WriteLine($"You failed to block { enemy.Name }'s attack"); } Console.WriteLine($"{ enemy.Name } landed { enemyDamage } damage to you."); } else { Console.WriteLine($"You successfully defended { enemy.Name }'s attack"); } if (userDamage > 0) { enemy.DamageEnemy(userDamage); Console.WriteLine($"You landed { enemy.Name } to { userDamage } damage"); } } else { if (userDamage > 0) { // enemy tries to defense if (random.Next(100) < 25) { enemyDefended = (defenseMode.GetData((DefenseType)random. Next((int)Enum.GetValues(typeof(DefenseType)).Cast <DefenseType>().Max()) + 1). DataItem as IDefense). GetDefense((DefenseType)random. Next((int)Enum.GetValues(typeof(DefenseType)).Cast <DefenseType>().Max()) + 1); } if (!enemyDefended) { enemy.DamageEnemy(userDamage); Console.WriteLine($"You landed { enemy.Name } to { userDamage } damage"); } else { Console.WriteLine($"{ enemy.Name } managed to block your attack"); } } else { if (!wrongButton) { Console.WriteLine("You made an defense move but it was meaningless..."); } } } Console.WriteLine(); if (!player.IsAlive) { Console.Clear(); Console.WriteLine($"{ player.Name } Died"); Console.WriteLine("...GAME OVER..."); Console.ReadLine(); Console.Clear(); } if (!enemy.IsAlive) { Console.Clear(); Console.WriteLine($"{ player.Name } killed { enemy.Name }"); Console.WriteLine($"...CONGRUCULATIONS..."); Console.ReadLine(); Console.Clear(); } userDamage = 0; userDefended = false; triedDef = false; wrongButton = false; enemyAttacking = !enemyAttacking; } }
//发出攻击 public void Attack(AttackMode m, ITarget t, float attackValue) { m.AttackFly(target, attackValue); }
public AssignmentTroopObjectInitializer(ITroopObject existingTroopObject, TroopBattleGroup group, AttackMode mode, Formula formula) { this.existingTroopObject = existingTroopObject; this.group = group; this.mode = mode; this.formula = formula; }
private void ChangeAMode(S.ChangeAMode p) { AMode = p.Mode; switch (p.Mode) { case AttackMode.Peace: ChatDialog.ReceiveChat("[攻击模式: 和平]", ChatType.Hint); break; case AttackMode.Group: ChatDialog.ReceiveChat("[攻击模式: 组队]", ChatType.Hint); break; case AttackMode.Guild: ChatDialog.ReceiveChat("[攻击模式: 行会]", ChatType.Hint); break; case AttackMode.EnemyGuild: ChatDialog.ReceiveChat("[攻击模式: 敌对]", ChatType.Hint); break; case AttackMode.RedBrown: ChatDialog.ReceiveChat("[攻击模式: 善恶]", ChatType.Hint); break; case AttackMode.All: ChatDialog.ReceiveChat("[攻击模式: 全体]", ChatType.Hint); break; } }
public AttackStat(AttackMode mode, int value) { Mode = mode; Value = value; }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Player2 : MonoBehaviour { public string[] animType; Animator animator; public GameObject P1HP; public GameObject attackEffect; public GameObject getEffect; public bool pause = false; public float speed; public AttackMode currentAttackMode; int hp; /// <summary> /// 操作モード /// </summary> public enum ControlMode { Human, // 人間 AI // AI } public enum AttackMode { Attack, // 人間 Tornade,// AI Combo, Cutin } public ControlMode Mode = ControlMode.AI; /// <summary> /// 攻撃状態ならtrue /// </summary> public bool IsAttacking; /// <summary> /// ダメージ状態ならtrue /// </summary> public bool IsDamaged; /// <summary> /// 死んだらtrue /// </summary> public bool IsDead; /// <summary> /// 敵 /// </summary> [SerializeField] Player1 Enemy; //自分のHPバー public GameObject hpbar; // Use this for initialization void Start() { animator = GetComponent<Animator>(); } private void OnEnable() { if (Mode == ControlMode.AI){ StartCoroutine("Attack"); } } // Update is called once per frame void Update() { animator.SetBool("damage", IsDamaged); //ダメージを受けていたら何もしない if (IsDamaged) return; //死んでたら何もしない if (IsDead) return; if(pause){ return; } switch( Mode ) { case ControlMode.Human: var h = Input.GetAxis("Horizontal2"); var v = Input.GetAxis("Vertical2"); Vector2 direction = new Vector2(h, v).normalized; // 移動する向きとスピードを代入 GetComponent<Rigidbody2D>().velocity = direction * speed; if (Input.GetButtonDown("Attack2")) { Debug.Log("Attack2"); animator.SetTrigger("attack"); currentAttackMode = AttackMode.Attack; } if (Input.GetButtonDown("Tornade2")) { Debug.Log("Tornade2"); animator.SetTrigger("tornade"); currentAttackMode = AttackMode.Tornade; } if (Input.GetButtonDown("Combo2")) { Debug.Log("Combo2"); animator.SetTrigger("combo"); currentAttackMode = AttackMode.Combo; } if (Input.GetButtonDown("Cutin2")) { Debug.Log("Cutin2"); currentAttackMode = AttackMode.Cutin; } break; case ControlMode.AI: Vector3 diff = transform.position - Enemy.transform.position; if (diff.x > +1) transform.position += Vector3.left * 0.05f; else if (diff.x < -1) transform.position += Vector3.right * 0.05f; break; } } // コルーチン private IEnumerator Attack() { // コルーチンの処理 while (!IsDead) { float waitTime = Random.Range(1.0f, 2.0f); yield return new WaitForSeconds(waitTime); int animIndex = Random.Range(0, animType.Length); // Debug.Log(animType[animIndex]); animator.SetBool(animType[animIndex], true); } } //ダメージを受ける public void Damage() { // 既にダメージを受けていたら何もしない if (IsDamaged) return; //死んでたら何もしない if (IsDead) return; // Debug.Log("Player 2 Damaged!"); IsDamaged = true; Debug.Log("StartCoroutine damaged"); StartCoroutine(damaged()); P1HP.GetComponent<SetSpriteToHP>().addHP(); //コピーして表示 Instantiate(attackEffect, gameObject.transform.position, Quaternion.identity); } // ダメージを受けたフラグを管理するコルーチン private IEnumerator damaged() { Debug.Log("damaged started"); // n秒待機してから、ダメージ状態を解除する yield return new WaitForSeconds(1.0f); Debug.Log("damaged 1"); IsDamaged = false; Debug.Log("damaged 2"); } //ダメージを受けました void OnCollisionStay2D(Collision2D col) { if (col.gameObject != Enemy.gameObject) return; //ダメージ中は追加ダメージを受けない if (IsDamaged) return; //死んでいたらダメージはない if (IsDead) return; //敵が攻撃中ではないなら、ダメージにはならない if (!Enemy.IsAttacking) return; Player1.AttackMode enemyMode = Enemy.GetComponent<Player1>().currentAttackMode; switch ( enemyMode){ case Player1.AttackMode.Attack: switch( currentAttackMode){ case Player2.AttackMode.Attack: damaged(1); break; case Player2.AttackMode.Combo: damaged(8); break; case Player2.AttackMode.Tornade: damaged(3); break; case Player2.AttackMode.Cutin: break; default: break; } break; case Player1.AttackMode.Combo: switch (currentAttackMode) { case Player2.AttackMode.Attack: damaged(3); break; case Player2.AttackMode.Combo: damaged(1); break; case Player2.AttackMode.Tornade: damaged(8); break; case Player2.AttackMode.Cutin: break; default: break; } break; case Player1.AttackMode.Tornade: switch (currentAttackMode) { case Player2.AttackMode.Attack: damaged(8); break; case Player2.AttackMode.Combo: damaged(3); break; case Player2.AttackMode.Tornade: damaged(1); break; case Player2.AttackMode.Cutin: break; default: break; } break; case Player1.AttackMode.Cutin: switch (currentAttackMode) { case Player2.AttackMode.Attack: break; case Player2.AttackMode.Combo: break; case Player2.AttackMode.Tornade: break; case Player2.AttackMode.Cutin: break; default: break; } break; } // damaged(3); if (hp > 0) { Damage(); } else { //HPが0以下なので、「そこまで!」 GameManager.Instance.GameSet(1); animator.SetBool("die", true); } } public void damaged(int v) { var slider = hpbar.GetComponent<Slider>(); hp = (int)slider.value; hp -= v; slider.value = hp; } private void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Star") { Instantiate(getEffect, coll.gameObject.transform.position, Quaternion.identity); Destroy(coll.gameObject); } } } // http://developer.wonderpla.net/entry/blog/engineer/Unity_Co-routine/
private void ChangeAMode(S.ChangeAMode p) { AMode = p.Mode; switch (p.Mode) { case AttackMode.Peace: ChatDialog.ReceiveChat("[Attack Mode: Peaceful]", ChatType.Hint); break; case AttackMode.Group: ChatDialog.ReceiveChat("[Attack Mode: Group]", ChatType.Hint); break; case AttackMode.Guild: ChatDialog.ReceiveChat("[Attack Mode: Guild]", ChatType.Hint); break; case AttackMode.EnemyGuild: ChatDialog.ReceiveChat("[Attack Mode: Enemy Guild]", ChatType.Hint); break; case AttackMode.RedBrown: ChatDialog.ReceiveChat("[Attack Mode: Red+Brown]", ChatType.Hint); break; case AttackMode.All: ChatDialog.ReceiveChat("[Attack Mode: All]", ChatType.Hint); break; } }
public Assignment CreateAssignmentFromDb(int id, ITribe tribe, uint x, uint y, ILocation target, AttackMode mode, DateTime targetTime, uint dispatchCount, string description, bool isAttack) { return(new Assignment(id, tribe, x, y, target, mode, targetTime, dispatchCount, description, isAttack, kernel.Get <Formula>(), kernel.Get <IDbManager>(), kernel.Get <IGameObjectLocator>(), kernel.Get <IScheduler>(), kernel.Get <Procedure>(), kernel.Get <ITileLocator>(), kernel.Get <IActionFactory>(), kernel.Get <ILocker>(), kernel.Get <ITroopObjectInitializerFactory>())); }
public AttackResult Attack(Role target, AttackMode attackmode) { return AttackResult.Invalid; }
private string AssignmentCreate(Session session, string[] parms) { bool help = false; string cityName = string.Empty; uint x = 0; uint y = 0; TimeSpan time = TimeSpan.MinValue; AttackMode mode = AttackMode.Normal; bool? isAttack = null; try { var p = new OptionSet { { "?|help|h", v => help = true }, { "city=", v => cityName = v.TrimMatchingQuotes() }, { "x=", v => x = uint.Parse(v) }, { "y=", v => y = uint.Parse(v) }, { "timespan=", v => time = TimeSpan.Parse(v.TrimMatchingQuotes()) }, { "mode=", v => mode = (AttackMode)Enum.Parse(typeof(AttackMode), v, true) }, { "isattack=", v => isAttack = Boolean.Parse(v) } }; p.Parse(parms); } catch (Exception) { help = true; } if (help || string.IsNullOrEmpty(cityName) || x == 0 || y == 0 || time == TimeSpan.MinValue || !isAttack.HasValue) { return ("AssignmentCreate --city=city_name --x=x --y=y --timespan=00:00:00 --isattack=true/false [--mode=attack_mode]"); } uint cityId; if (!world.Cities.FindCityId(cityName, out cityId)) { return("City not found"); } ICity city; if (!world.TryGetObjects(cityId, out city)) { return("City not found!"); } if (city.Owner.Tribesman == null) { return("Not in tribe"); } ITribe tribe = city.Owner.Tribesman.Tribe; IStructure targetStructure = world.Regions.GetObjectsInTile(x, y).OfType <IStructure>().FirstOrDefault(); if (targetStructure == null) { return("Could not find a structure for the given coordinates"); } return(locker.Lock(city, tribe, targetStructure.City).Do(() => { if (city.DefaultTroop.Upkeep == 0) { return "No troops in the city!"; } targetStructure = world.Regions.GetObjectsInTile(x, y).OfType <IStructure>().First(); if (targetStructure == null) { return "Could not find a structure for the given coordinates"; } // TODO: Clean this up.. shouldnt really need to do this here var stub = city.CreateTroopStub(); FormationType formation = isAttack.GetValueOrDefault() ? FormationType.Attack : FormationType.Defense; stub.AddFormation(formation); foreach (var unit in city.DefaultTroop[FormationType.Normal]) { stub.AddUnit(formation, unit.Key, unit.Value); } int id; Error error = tribe.CreateAssignment(city, stub, x, y, targetStructure.City, DateTime.UtcNow.Add(time), mode, "", isAttack.GetValueOrDefault(), out id); if (error != Error.Ok) { city.Troops.Remove(stub.TroopId); return Enum.GetName(typeof(Error), error); } return string.Format("OK ID[{0}]", id); })); }
/// <summary> /// 简单实现接口 /// </summary> /// <param name="target"></param> /// <param name="attackmode"></param> /// <returns></returns> public AttackResult Attack(Role target, AttackMode attackmode) { int damage=0; if (target.Allow_Attack) { if (attackmode == AttackMode.Physics) { Random rd = new Random(0); int r=rd.Next(2); if (r == 1) { damage = m_PhysicsPower * 2 - target.PhysicsDEF; if (damage > 0) target.HP -= damage; return AttackResult.Crit; } damage = m_PhysicsPower - target.PhysicsDEF; if (damage > 0) target.HP -= damage; return AttackResult.Hit; } else { Random rd = new Random(0); int r = rd.Next(10); if (r == 1) { damage = m_MagicPower * 2 - target.MagicalDEF; if (damage > 0) target.HP -= damage; return AttackResult.Crit; } damage = m_MagicPower - target.MagicalDEF; if (damage > 0) { target.HP -= damage; return AttackResult.Hit; } else return AttackResult.Absorb; } } else return AttackResult.Invalid; }
//Handle movement depending on PatrolSate and AttackMode void MovementManager() { //If the AI sees or hears the target if (canHear || targetInSight) { if (targetInSight) { RotateTurret(); Fire(); } if (canHear) { RotateTurret(); } //Keep track of time gameTime = Time.time; //This will be the targets current position //for as long as the target is seen lastSeenLocation = target.position; //Get the current states before setting the new ones //and wait until the AI isn't searching in order to set it again //This is preventing the lastPatrolType and lastAttackMode //from being overwritten every frame if (searching == false && attackMode != AttackMode.Idle) { //Store the last states lastPatrolType = currentPatrolType; lastAttackMode = attackMode; //And make the AI stop looking for waypoints to move towards currentPatrolType = PatrolType.Idle; //Debug.Log("Hear"); //The AI is now set to search for the target if it loses track searching = true; } //If the AI's low on health and it's not currently in the flee state //set it to the flee State if (currentHealth <= healthToFlee && attackMode != AttackMode.Flee) { attackMode = AttackMode.Flee; } //If the AI is searching and it finds the target //Stop searching and put it in its lastAttackMode if (attackMode == AttackMode.Searching) { attackMode = lastAttackMode; } if (attackMode == AttackMode.Chase) { Chase(); } if (attackMode == AttackMode.Flee) { Flee(); } if (attackMode == AttackMode.Idle) { Patrol(); } } //If AI cant see or hear target else if (!canHear && !targetInSight) { //If it's time for the AI to search and it isnt trying to to run away if (searching == true && Time.time < gameTime + searchTime && attackMode != AttackMode.Flee && attackMode != AttackMode.Idle) { attackMode = AttackMode.Searching; } else if (searching == true && Time.time > gameTime + searchTime) { //Give the AI its previous settings searching = false; attackMode = lastAttackMode; currentPatrolType = lastPatrolType; //Debug.Log("lost track"); } if (attackMode == AttackMode.Searching) { Search(); } //Go back to patrolling Patrol(); } }
public Error CreateAssignment(ICity city, ISimpleStub simpleStub, uint x, uint y, ILocation target, DateTime time, AttackMode mode, string desc, bool isAttack, out int id) { id = 0; if (assignments.Count > 20) { return(Error.AssignmentTooManyInProgress); } // Create troop ITroopStub stub; if (!procedure.TroopStubCreate(out stub, city, simpleStub, isAttack ? TroopState.WaitingInOffensiveAssignment : TroopState.WaitingInDefensiveAssignment)) { return(Error.TroopChanged); } // Max of 48 hrs for planning assignments if (DateTime.UtcNow.AddDays(2) < time) { procedure.TroopStubDelete(city, stub); return(Error.AssignmentBadTime); } if (assignments.Count > 30) { procedure.TroopStubDelete(city, stub); return(Error.AssignmentTooManyInProgress); } if (stub.Upkeep < ASSIGNMENT_MIN_UPKEEP) { procedure.TroopStubDelete(city, stub); return(Error.AssignmentTooFewTroops); } if (stub.City.Owner.Tribesman == null) { procedure.TroopStubDelete(city, stub); return(Error.TribeNotFound); } if (target.LocationType == LocationType.City) { ICity targetCity; if (!cityManager.TryGetCity(target.LocationId, out targetCity)) { procedure.TroopStubDelete(city, stub); return(Error.CityNotFound); } // Cant attack other tribesman if (isAttack && targetCity.Owner.Tribesman != null && targetCity.Owner.Tribesman.Tribe == stub.City.Owner.Tribesman.Tribe) { procedure.TroopStubDelete(city, stub); return(Error.AssignmentCantAttackFriend); } // Cant defend the same city if (targetCity == stub.City) { procedure.TroopStubDelete(city, stub); return(Error.DefendSelf); } } else if (target.LocationType == LocationType.Stronghold) { IStronghold stronghold; if (!strongholdManager.TryGetStronghold(target.LocationId, out stronghold)) { procedure.TroopStubDelete(city, stub); return(Error.StrongholdNotFound); } // Cant attack your stronghold if (isAttack && stronghold.Tribe == stub.City.Owner.Tribesman.Tribe) { procedure.TroopStubDelete(city, stub); return(Error.AttackSelf); } // Cant defend other tribe's stronghold if (!isAttack && stronghold.Tribe != stub.City.Owner.Tribesman.Tribe) { procedure.TroopStubDelete(city, stub); return(Error.DefendSelf); } } else { procedure.TroopStubDelete(city, stub); return(Error.ObjectNotAttackable); } // Player creating the assignment cannot be late (Give a few minutes lead) int distance = tileLocator.TileDistance(stub.City.PrimaryPosition, 1, new Position(x, y), 1); DateTime reachTime = DateTime.UtcNow.AddSeconds(formula.MoveTimeTotal(stub, distance, true)); if (reachTime.Subtract(new TimeSpan(0, 1, 0)) > time) { procedure.TroopStubDelete(city, stub); return(Error.AssignmentUnitsTooSlow); } // Create assignment Assignment assignment = assignmentFactory.CreateAssignment(this, x, y, target, mode, time, desc, isAttack); id = assignment.Id; assignments.Add(assignment.Id, assignment); assignment.AssignmentComplete += RemoveAssignment; var result = assignment.Add(stub); if (result != Error.Ok) { procedure.TroopStubDelete(city, stub); } SendUpdate(); return(result); }
BehaveResult Tick(Tree sender) { if (Enemy.IsNullOrInvalid(selectattackEnemy) || !entity.target.ContainEnemy(selectattackEnemy)) { return(BehaveResult.Failure); } if (Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Failure); } entity.NpcCmpt.EqSelect.ClearSelect(); entity.NpcCmpt.EqSelect.ClearAtkSelects(); if (entity.NpcCmpt.EqSelect.SetSelectObjsAtk(entity, EeqSelect.combat)) { entity.NpcCmpt.EqSelect.GetBetterAtkObj(entity, selectattackEnemy); } if (entity.NpcCmpt.EqSelect.BetterAtkObj != null && Weapon != null && !Weapon.Equals(null) && entity.NpcCmpt.EqSelect.BetterAtkObj != Weapon.ItemObj) { return(BehaveResult.Failure); } if (!IsNpcBase && !SelectItem.MatchEnemyAttack(entity, selectattackEnemy.entityTarget)) //entity.HPPercent < 0.3f && m_Mode.type == AttackType.Melee) { return(BehaveResult.Failure); } ////是否被挡住 bool _IsInSpSence = (Pathea.PeGameMgr.IsAdventure && RandomDungenMgr.Instance != null && RandomDungenMgrData.dungeonBaseData != null) || (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsSingle && Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand) || (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsTutorial && Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand) || (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsMulti && PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId != (int)Pathea.SingleGameStory.StoryScene.MainLand); bool _isBlock = !_IsInSpSence && PEUtil.IsBlocked(entity, selectattackEnemy.entityTarget); if (_isBlock) { Vector3 movePos = GetMovePos(selectattackEnemy); Vector3 v3 = position + transform.forward; bool _IsUnderBlock = PEUtil.IsUnderBlock(entity); bool _IsForwardBlock = PEUtil.IsForwardBlock(entity, existent.forward, 2.0f); if (_IsUnderBlock) { if (_IsForwardBlock || _isBlock) { if (movePos.y >= v3.y) { v3.y = movePos.y; } SetPosition(v3); } else { MoveDirection(movePos - position, SpeedState.Run); } } else { if (Stucking()) { if (movePos.y >= v3.y) { v3.y = movePos.y; } SetPosition(v3); } MoveToPosition(movePos, SpeedState.Run); } return(BehaveResult.Running); } if (Weapon == null || Weapon.Equals(null)) { bool canSwitchWeapon = true; if (entity.motionMgr != null && entity.motionMgr.IsActionRunning(PEActionType.SwordAttack)) { canSwitchWeapon = false; } if (entity.motionMgr != null && entity.motionMgr.IsActionRunning(PEActionType.TwoHandSwordAttack)) { canSwitchWeapon = false; } if (entity.motionEquipment.IsSwitchWeapon()) { canSwitchWeapon = false; } if (entity.isRagdoll) { canSwitchWeapon = false; } if (entity.netCmpt != null && !entity.netCmpt.IsController) { canSwitchWeapon = false; } if (canSwitchWeapon) { IWeapon tempweapon = SwitchWeapon(selectattackEnemy); if (tempweapon != null && !tempweapon.Equals(null)) { if (entity.motionEquipment.Weapon == null || entity.motionEquipment.Weapon.Equals(null)) { //Vector3 forward = Vector3.ProjectOnPlane(entity.peTrans.trans.forward, Vector3.up); //Vector3 direction = Vector3.ProjectOnPlane(selectattackEnemy.Direction, Vector3.up); //float angle = Vector3.Angle(forward, direction); //bool canHold = (entity.Race != ERace.Puja && entity.Race != ERace.Paja) || angle < 45f; if (!tempweapon.HoldReady) { StopMove(); tempweapon.HoldWeapon(true); AimTarget(Weapon); return(BehaveResult.Running); } } else { if (!entity.motionEquipment.Weapon.Equals(tempweapon)) { StopMove(); entity.motionEquipment.SwitchHoldWeapon(entity.motionEquipment.Weapon, tempweapon); AimTarget(Weapon); return(BehaveResult.Running); } } } } return(BehaveResult.Running); } else { m_Index = SwitchAttackIndex(Weapon); if (m_Index < 0 || m_Index >= Weapon.GetAttackMode().Length) { return(BehaveResult.Failure); } m_Mode = Weapon.GetAttackMode()[m_Index]; if (Time.time - m_LastAttackTime <= m_Mode.frequency) { return(BehaveResult.Failure); } if (Weapon == null || Weapon.Equals(null) || m_Mode == null) { return(BehaveResult.Failure); } //只能使用拳套,则把装备栏里不能使用的装备收回去 if (Weapon is PEGloves && entity.motionEquipment.ActiveableEquipment != null) { SelectItem.TakeOffEquip(entity); } IAimWeapon aimWeapon = Weapon as IAimWeapon; if (aimWeapon != null) { if (m_Mode.type == AttackType.Ranged) { aimWeapon.SetAimState(true); aimWeapon.SetTarget(selectattackEnemy.CenterBone); } else { aimWeapon.SetAimState(false); aimWeapon.SetTarget(null); } } if (selectattackEnemy.entityTarget.target != null) { int n = selectattackEnemy.entityTarget.monsterProtoDb != null && selectattackEnemy.entityTarget.monsterProtoDb.AtkDb != null ? selectattackEnemy.entityTarget.monsterProtoDb.AtkDb.mNumber : 3; if (m_Mode.type == AttackType.Melee) { selectattackEnemy.entityTarget.target.AddMelee(entity, n); } else { selectattackEnemy.entityTarget.target.RemoveMelee(entity); } } if (selectattackEnemy.GroupAttack == EAttackGroup.Threat) { return(BehaveResult.Failure); } float minRange = m_Mode.minRange; float maxRange = m_Mode.maxRange; float sqrDistanceXZ = selectattackEnemy.SqrDistanceLogic; //PETools.PEUtil.Magnitude(position,selectattackEnemy.position); Vector3 direction = selectattackEnemy.Direction; //是否被挡住 bool isBlock = !m_Mode.ignoreTerrain && (PEUtil.IsBlocked(entity, selectattackEnemy.entityTarget) || PEUtil.IsNpcsuperposition(entity, selectattackEnemy)); //距离是否可以攻击 bool isRange = sqrDistanceXZ <= maxRange * maxRange && sqrDistanceXZ >= minRange * minRange; //角度是否可以攻击 bool isAngle = PEUtil.IsScopeAngle(direction, transform.forward, Vector3.up, m_Mode.minAngle, m_Mode.maxAngle); //是否可以攻击 bool isAttack = isRange && isAngle && !isBlock; //是否瞄准 bool isAimed = m_Mode.type == AttackType.Melee || aimWeapon == null || aimWeapon.Aimed; //是否需要调整站位 bool ischangeStand = !isBlock && m_Mode.type == AttackType.Ranged && entity.target.beSkillTarget; //寻找可攻击位置 m_Local = GetLocalPos(selectattackEnemy, m_Mode); m_Local = Vector3.ProjectOnPlane(m_Local, Vector3.up); //开始后退的距离 float retreatRange = minRange; if (m_Mode.type == AttackType.Ranged) { retreatRange += Mathf.Lerp(minRange, maxRange, 0.2f); } //目标发动技能攻击(移动) bool isSkillAttacking = entity.target.beSkillTarget; if (Time.time - m_LastRetreatTime > 3.0f) { m_RetreatLocal = Vector3.zero; m_LastRetreatTime = Time.time; m_ChangeLocal = Vector3.zero; m_LastChangeTime = Time.time; } //攻击移动 if (sqrDistanceXZ > maxRange * maxRange || isBlock) { Vector3 movePos = GetMovePos(selectattackEnemy); if (isBlock) { Vector3 v3 = position + transform.forward; if (Stucking()) { if (movePos.y >= v3.y) { v3.y = movePos.y; } SetPosition(v3); } MoveToPosition(movePos, SpeedState.Run); } else { Vector3 dir0 = movePos - position; Vector3 dir = isSkillAttacking ? Vector3.Lerp(Vector3.Cross(dir0, Vector3.up), dir0, Time.time) : dir0; SpeedState speed = CalculateChaseSpeed(); MoveDirection(dir, speed); } } else if (sqrDistanceXZ < retreatRange * retreatRange) { if (Time.time - m_LastRetreatTime < 2.0f) { if (m_RetreatLocal == Vector3.zero) { m_RetreatLocal = GetRetreatPos(selectattackEnemy.position, transform, minRange, maxRange); } FaceDirection(direction); MoveToPosition(m_RetreatLocal, SpeedState.Run); } else { StopMove(); } } else if (ischangeStand) { if (Time.time - m_LastChangeTime < 2.0f) { if (m_ChangeLocal == Vector3.zero) { m_ChangeLocal = GetRetreatPos(selectattackEnemy.position, transform, minRange, maxRange); } FaceDirection(direction); MoveToPosition(m_ChangeLocal, SpeedState.Run); } } else { StopMove(); } //攻击旋转 if (!isBlock) { if (!isAngle || !isAimed) { FaceDirection(direction); } else { FaceDirection(Vector3.zero); } } if (selectattackEnemy.entityTarget.target != null) { Enemy TargetEnemy = selectattackEnemy.entityTarget.target.GetAttackEnemy(); if (!Enemy.IsNullOrInvalid(TargetEnemy) && selectattackEnemy.entityTarget.IsAttacking && TargetEnemy.entityTarget == entity && IsInEnemyFoward(selectattackEnemy, entity) && Time.time - m_StartDefenceTime >= 3.0f) { m_StartDefenceTime = Time.time; bool canShield = CanDoAction(PEActionType.HoldShield); bool canStep = CanStep(); if (canShield && canStep) { if (Random.value > 0.5f) { DoStep(); } else { DoSheid(); } m_Attacked = false; m_StartAttackTime = Time.time; return(BehaveResult.Running); } else if (canShield) { DoSheid(); m_Attacked = false; m_StartAttackTime = Time.time; return(BehaveResult.Running); } else if (canStep) { DoStep(); m_Attacked = false; m_StartAttackTime = Time.time; return(BehaveResult.Running); } } } if (!m_Attacked) { //是否需要瞄准 if (isAttack && isAimed) { WeaponAttack(Weapon, selectattackEnemy, m_Index); //Weapon.Attack(m_Index); m_Attacked = true; } return(BehaveResult.Running); } else { //range need CD bool _IsCD = m_Mode != null && m_Mode.type == AttackType.Ranged ? Weapon.IsInCD() : false; //是否连击 if (isAttack && Weapon != null && !Weapon.Equals(null) && !_IsCD) { m_StartAttackTime = Time.time; //Weapon.Attack(m_Index); WeaponAttack(Weapon, selectattackEnemy, m_Index); } return(BehaveResult.Running); } } }
public X8Timer ShootTimer = new X8Timer(.5f); //this will time how longer the player faces the recticle void Start() { innerShield = gameObject.GetComponentInChildren <RaydraShield>(); //!search for the sheild in the children of the parent object _myCamera = this.GetComponentInChildren <Camera>(); //get the camera that is connected to this game object bool ScoreMode = false; //initally we are not in score mode //!the player info that unity will keep tract of p_fCameraAngleTheta = 43f; //!initialize the angle that player if facing p_fCameraAnglePhi = 45f; //!The camera is initially yyyyin this state p_fPlayerToFocusAngleTheta = 43f; //!initialize the angle that player if facing p_fPlayerToFocusAnglePhi = 45f; //!//!initialize the angle that player if facing in the upward direction p_fJumpVelocity = .40f; //!initialize the upward jump force ForceOfGravity = 1f / 60f; //!this will have a unit per second force of gravity, in the downward direction p_fOrientationAngle = 90f; //!Angle that the player is facing in degrees p_v3OrientationVect = new Vector3(0, 0, 1f); //!Direction player is facing represented as an angle p_v3PlayerToFocusVect = new Vector3(0, 0, 0); //!The vector the represents the direction the camera if facing p_v3PlayerToCameraVect = new Vector3(0, 0, 0); //!The Vector Data the represent the player to camera direction PlayerMovementState = MovingState.IsStandingStill; //!Intially the player is not moving PlayerJumpState = JumpingState.NotJumping; //!initlialize the the player is not jumping PlayerTackleHitState = TackeHitState.NoContact; //!Initial the tackle state of the player PlayerTackleState = TackleState.IsNotTackling; //!Initial the tackle state of the player PlayerAttackState = AttackMode.NotFiringAbility; //!Initial the shoot state of the player PlayerRaydraState = RaydraState.NotInRaydraMode; //!initailly the player is not in Raydra Mode PlayerCameraState = CameraPerspective.Normal; //!initially the camera to do nothing PlayerPhaseState = PhaseState.IsNotPhasing; PlayerBallThrowState = BallThrowingState.NotBeingThrown; //!Initial the vertical state of the player PlayerBallPossessionState = BallPossessionState.HasBall; //!Initial the Possession State of the player // PlayerMotionVector = new Vector3 (this.transform.position.x,.transform.position.y,playerData.transform.position.z); p_v3PlayerVectorDirection = Vector3.zero; //! This is direction that te player is headed as a vector _armWeapon = this.GetComponentInChildren <RaydraWeapon>(); //!reference to the arm weapon on the player which is null to begin with p_bFacePlayer = false; //! variable that determines weather or not to face the player, this variable determine weather or not this medthod is recursive p_fMass = 0f; //!initialize the mass of the player p_StateTime = 0f; // Time elasped in current state p_Collider = null; //initialize the first collider connect to this body pRidgidBody = null; Controls = GetComponent <RaydraControls>(); if (CameraFocusOverHead != null) { p_v3PlayerToCameraVect = CameraFocusOverHead.transform.position - _myCamera.transform.position; } p_fCameraAnglePhi = Vector3.Angle(new Vector3(0, 1, 0), p_v3PlayerToCameraVect); p_fCameraAngleTheta = Vector3.Angle(new Vector3(1, 0, 0), p_v3PlayerToCameraVect); p_fPlayerToFocusAnglePhi = Vector3.Angle(new Vector3(0, 1, 0), p_v3PlayerToFocusVect); p_fPlayerToFocusAngleTheta = Vector3.Angle(new Vector3(1, 0, 0), p_v3PlayerToFocusVect); X8Animator = GetComponent <Animator>(); isGrounded = false; if (p_v3PlayerToFocusVect.z < 0) { p_fPlayerToFocusAngleTheta = 360 - p_fPlayerToFocusAngleTheta; //make sure that the angle is at the correct corridinate } if (p_v3PlayerToCameraVect.z < 0) { p_fCameraAngleTheta = 360 - p_fCameraAngleTheta; //make sure that the angle is at the correct corridinate } TheBall = FindObjectOfType <RaydraCellz>(); X8Animator = GetComponent <Animator>(); //get the reference to the animator PlayerMovementState = MovingState.IsStandingStill; EnemyAI = GetComponent <Ai>(); //get the ai script attached to the player (if there is one) if (EnemyAI != null) { Debug.Log("enemy AI" + EnemyAI.ToString()); } }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode)reader.ReadByte(); PMode = (PetMode)reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) { Inventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) { Equipment[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, Envir.LoadVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) { QuestInventory[i] = item; } } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) { continue; } Magics.Add(magic); } if (Envir.LoadVersion < 2) { return; } Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if (Envir.LoadVersion > 46) { MentalState = reader.ReadByte(); } if (Envir.LoadVersion < 4) { return; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Pets.Add(new PetInfo(reader)); } if (Envir.LoadVersion < 5) { return; } AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) { return; } if (Envir.LoadVersion == 12) { count = reader.ReadInt32(); } for (int i = 0; i < Globals.FlagIndexCount; i++) { Flags[i] = reader.ReadBoolean(); } if (Envir.LoadVersion > 27) { GuildIndex = reader.ReadInt32(); } if (Envir.LoadVersion > 30) { AllowTrade = reader.ReadBoolean(); } if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { CurrentQuests.Add(new QuestProgressInfo(reader)); } } if (Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buffs.Add(new Buff(reader)); } } if (Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader)); } } //IntelligentCreature if (Envir.LoadVersion > 44) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) { continue; } IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); } }
public void SetAttackMode(AttackMode attackMode) { AttackMode = attackMode; }
public ITroopObjectInitializer CreateCityTroopObjectInitializer(uint cityId, ISimpleStub simpleStub, TroopBattleGroup @group, AttackMode mode) { return(new CityTroopObjectInitializer(cityId, simpleStub, @group, mode, kernel.Get <IGameObjectLocator>(), kernel.Get <Formula>(), kernel.Get <Procedure>(), kernel.Get <IWorld>())); }
public ITroopObjectInitializer CreateAssignmentTroopObjectInitializer(ITroopObject existingTroopObject, TroopBattleGroup @group, AttackMode mode) { return(new AssignmentTroopObjectInitializer(existingTroopObject, @group, mode, kernel.Get <Formula>())); }
void Update() { if(lock_move==false){ //movement if(Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift)){ walking = true; running = true; walkingtime = walkingtime + Time.deltaTime; soundManager.PlayAudioClip(soundManager.run,soundManager.Volum_run); maincamera.camera.fieldOfView = Mathf.Lerp(55f, 62f, walkingtime/3f); movespeed = 10f; transform.Translate(Vector3.forward * Time.deltaTime * movespeed); } else if(Input.GetKey(KeyCode.W)){ soundManager.PlayAudioClip(soundManager.walk,soundManager.Volum_walk); walking = true; movespeed = 5f; transform.Translate(Vector3.forward * Time.deltaTime * movespeed); } if(Input.GetKey(KeyCode.S)){ soundManager.PlayAudioClip(soundManager.walk,soundManager.Volum_walk); transform.Translate(Vector3.back * Time.deltaTime * movespeed); walking = true; } if(Input.GetKey(KeyCode.A)){ soundManager.PlayAudioClip(soundManager.walk,soundManager.Volum_walk); transform.Translate(Vector3.left * Time.deltaTime * movespeed/2); walking = true; } if(Input.GetKey(KeyCode.D)){ soundManager.PlayAudioClip(soundManager.walk,soundManager.Volum_walk); transform.Translate(Vector3.right * Time.deltaTime * movespeed/2); walking = true; } if(walking==true){ walking = false; } else if(walking==false){ soundManager.StopAudioClip(soundManager.walk); soundManager.StopAudioClip(soundManager.run); if(running==true){ StartCoroutine(LerpBack(walkingtime)); running = false; walkingtime = 0; } } } //mouse RotationX = Input.GetAxis("Mouse X") * mousesensitivity; RotationY = Input.GetAxis("Mouse Y") * mousesensitivity; //look left&right transform.Rotate(0.0f, RotationX, 0.0f); //look up&down (within -30~30 degree) viewangle = maincamera.transform.localEulerAngles.x + -RotationY; if(viewangle>300f) viewangle -= 360f; viewangle = Mathf.Clamp(viewangle,-30f,30f); maincamera.transform.localEulerAngles = new Vector3(viewangle,0f,0f); //Sword if(Input.GetKey(KeyCode.Mouse1) && attackmode == AttackMode.idle){ soundManager.PlayAudioClip(soundManager.punch,soundManager.Volum_punch); swordScript.swordON(); attackmode = AttackMode.Melee; } //Fireball if(Input.GetKeyUp(KeyCode.Mouse0)&& attackmode == AttackMode.Fireball){ GameObject.Find("FireballR").GetComponent<FireballScript>().DeactiveBall(); if(fire_ready==true){ soundManager.StopAudioClip(soundManager.firehold); soundManager.PlayAudioClip(soundManager.firefly,soundManager.Volum_firefly); fireball = Instantiate(GameObject.Find("Fireball")) as GameObject; fireball.name = "Fireball" + fireballID.ToString(); fireballID ++; fireball.transform.position = GameObject.Find("FireballR").transform.position; Vector3 initial_force = GameObject.Find("FirePosition").transform.position - GameObject.Find("r_middle01").transform.position; fireball.GetComponent<Rigidbody>().AddForce(initial_force*10f); Destroy(fireball,3f); } else{ soundManager.StopAudioClip(soundManager.firehold); } attackmode = AttackMode.idle; fire_chargetime = 0f; fire_ready = false; } else if(Input.GetKeyDown(KeyCode.Mouse0) && attackmode == AttackMode.idle){ GameObject.Find("FireballR").GetComponent<FireballScript>().ActiveBall(); attackmode = AttackMode.Fireball; fire_chargetime = 0f; } //Thunder if(Input.GetKeyUp(KeyCode.Space)&& attackmode == AttackMode.Thunder){ GameObject.Find("ElectricBallR").GetComponent<ElectricBallScript>().DeactiveBall(); if(thunder_ready==true){ //thunder effects soundManager.PlayAudioClipNew(soundManager.thunder3,soundManager.Volum_thunder3); Instantiate(Thunder,GameObject.Find("ThunderPosition").transform.position,GameObject.Find("ThunderPosition").transform.rotation); } else{ //nothing happend } attackmode = AttackMode.idle; thunder_chargetime = 0f; thunder_ready = false; } else if(Input.GetKeyDown(KeyCode.Space) && attackmode == AttackMode.idle){ GameObject.Find("ElectricBallR").GetComponent<ElectricBallScript>().ActiveBall(); attackmode = AttackMode.Thunder; thunder_chargetime = 0f; } //Shield if(Input.GetKeyDown(KeyCode.F)){ soundManager.PlayAudioClip(soundManager.shield,soundManager.Volum_shield); shieldScript.shieldON(); guiScript.shielded = true; } else if(Input.GetKeyUp(KeyCode.F)){ soundManager.StopAudioClip(soundManager.shield); soundManager.PlayAudioClip(soundManager.unshield,soundManager.Volum_unshield); shieldScript.shieldOFF(); guiScript.shielded = false; } //update check attack if(attackmode==AttackMode.Fireball){ if(fire_ready==false){ //keep recharging soundManager.PlayAudioClip(soundManager.firehold,soundManager.Volum_firehold); if(fire_chargetime < FIREBALL_CHARGETIME){ fire_chargetime += Time.deltaTime; } else{ GameObject.Find("FireballR").GetComponent<FireballScript>().ReadyBall(); fire_ready = true; } } else if(fire_ready==true){ //wait for release } } else if(attackmode==AttackMode.Melee){ if(swordScript.sword_on==false){ attackmode = AttackMode.idle; } } else if(attackmode==AttackMode.Thunder){ if(thunder_ready==false){ //keep recharging soundManager.PlayAudioClip(soundManager.thunder1,soundManager.Volum_thunder1); if(thunder_chargetime < THUNDER_CHARGETIME){ thunder_chargetime += Time.deltaTime; } else{ GameObject.Find("ElectricBallR").GetComponent<ElectricBallScript>().ReadyBall(); thunder_ready = true; } } else if(thunder_ready==true){ //wait for release soundManager.PlayAudioClip(soundManager.thunder2,soundManager.Volum_thunder2); } } //checkpoint if(Input.GetKeyDown(KeyCode.F1)){ transform.position = GameObject.Find("CheckPoint0").transform.position; transform.rotation = GameObject.Find("CheckPoint0").transform.rotation; } else if(Input.GetKeyDown(KeyCode.F2)){ transform.position = GameObject.Find("CheckPoint1").transform.position; transform.rotation = GameObject.Find("CheckPoint1").transform.rotation; } else if(Input.GetKeyDown(KeyCode.F3)){ transform.position = GameObject.Find("CheckPoint1.1").transform.position; transform.rotation = GameObject.Find("CheckPoint1.1").transform.rotation; } else if(Input.GetKeyDown(KeyCode.F4)){ transform.position = GameObject.Find("CheckPoint2").transform.position; transform.rotation = GameObject.Find("CheckPoint2").transform.rotation; } else if(Input.GetKeyDown(KeyCode.F5)){ transform.position = GameObject.Find("ElevatorPosition4").transform.position; transform.rotation = GameObject.Find("ElevatorPosition4").transform.rotation; } }
void ShowGetReady(AttackMode attackMode) { _buttonNamePanel.Hide(); _getReadyPanel.Show(attackMode); _theBigButton.Reset(); }
public CharacterInfo(BinaryReader reader) { Index = reader.ReadInt32(); Name = reader.ReadString(); Level = reader.ReadByte(); Class = (MirClass) reader.ReadByte(); Gender = (MirGender) reader.ReadByte(); Hair = reader.ReadByte(); CreationIP = reader.ReadString(); CreationDate = DateTime.FromBinary(reader.ReadInt64()); Banned = reader.ReadBoolean(); BanReason = reader.ReadString(); ExpiryDate = DateTime.FromBinary(reader.ReadInt64()); LastIP = reader.ReadString(); LastDate = DateTime.FromBinary(reader.ReadInt64()); Deleted = reader.ReadBoolean(); DeleteDate = DateTime.FromBinary(reader.ReadInt64()); CurrentMapIndex = reader.ReadInt32(); CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); Direction = (MirDirection)reader.ReadByte(); BindMapIndex = reader.ReadInt32(); BindLocation = new Point(reader.ReadInt32(), reader.ReadInt32()); HP = reader.ReadUInt16(); MP = reader.ReadUInt16(); Experience = reader.ReadInt64(); AMode = (AttackMode) reader.ReadByte(); PMode = (PetMode) reader.ReadByte(); if (Envir.LoadVersion > 34) { PKPoints = reader.ReadInt32(); } int count = reader.ReadInt32(); Array.Resize(ref Inventory, count); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Inventory.Length) Inventory[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < Equipment.Length) Equipment[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (!reader.ReadBoolean()) continue; UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (SMain.Envir.BindItem(item) && i < QuestInventory.Length) QuestInventory[i] = item; } count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserMagic magic = new UserMagic(reader); if (magic.Info == null) continue; Magics.Add(magic); } if (Envir.LoadVersion < 2) return; Thrusting = reader.ReadBoolean(); HalfMoon = reader.ReadBoolean(); CrossHalfMoon = reader.ReadBoolean(); DoubleSlash = reader.ReadBoolean(); if(Envir.LoadVersion > 46) { MentalState = reader.ReadByte(); } if (Envir.LoadVersion < 4) return; count = reader.ReadInt32(); for (int i = 0; i < count; i++) Pets.Add(new PetInfo(reader)); if (Envir.LoadVersion < 5) return; AllowGroup = reader.ReadBoolean(); if (Envir.LoadVersion < 12) return; if (Envir.LoadVersion == 12) count = reader.ReadInt32(); for (int i = 0; i < Globals.FlagIndexCount; i++) Flags[i] = reader.ReadBoolean(); if (Envir.LoadVersion > 27) GuildIndex = reader.ReadInt32(); if (Envir.LoadVersion > 30) AllowTrade = reader.ReadBoolean(); if (Envir.LoadVersion > 33) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { QuestProgressInfo quest = new QuestProgressInfo(reader); if (SMain.Envir.BindQuest(quest)) CurrentQuests.Add(quest); } } if(Envir.LoadVersion > 42) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Buff buff = new Buff(reader); if (Envir.LoadVersion == 51) { buff.Caster = SMain.Envir.GetObject(reader.ReadUInt32()); } Buffs.Add(buff); } } if(Envir.LoadVersion > 43) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) Mail.Add(new MailInfo(reader, Envir.LoadVersion, Envir.LoadCustomVersion)); } //IntelligentCreature if (Envir.LoadVersion > 44) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { UserIntelligentCreature creature = new UserIntelligentCreature(reader); if (creature.Info == null) continue; IntelligentCreatures.Add(creature); } if (Envir.LoadVersion == 45) { var old1 = (IntelligentCreatureType)reader.ReadByte(); var old2 = reader.ReadBoolean(); } PearlCount = reader.ReadInt32(); } if (Envir.LoadVersion > 49) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) CompletedQuests.Add(reader.ReadInt32()); } if (Envir.LoadVersion > 50 && Envir.LoadVersion < 54) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Poison poison = new Poison(reader); if (Envir.LoadVersion == 51) { poison.Owner = SMain.Envir.GetObject(reader.ReadUInt32()); } Poisons.Add(poison); } } if (Envir.LoadVersion > 56) { if (reader.ReadBoolean()) CurrentRefine = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion); if (CurrentRefine != null) SMain.Envir.BindItem(CurrentRefine); CollectTime = reader.ReadInt64(); CollectTime += SMain.Envir.Time; } if (Envir.LoadVersion > 58) { count = reader.ReadInt32(); for (int i = 0; i < count; i++) Friends.Add(new FriendInfo(reader)); } if (Envir.LoadVersion > 59) { Married = reader.ReadInt32(); MarriedDate = DateTime.FromBinary(reader.ReadInt64()); Mentor = reader.ReadInt32(); MentorDate = DateTime.FromBinary(reader.ReadInt64()); isMentor = reader.ReadBoolean(); MentorExp = reader.ReadInt64(); } }
public void SwitchAttackMode(AttackMode attackMode) { attackStrength = attackMode; }
protected override void Dispose(bool disposing) { if (disposing) { Scene = null; User = null; MoveTime = 0; AttackTime = 0; NextRunTime = 0; CanMove = false; CanRun = false; MapControl = null; MainDialog = null; ChatDialog = null; ChatControl = null; InventoryDialog = null; CharacterDialog = null; StorageDialog = null; BeltDialog = null; MiniMapDialog = null; InspectDialog = null; OptionDialog = null; MenuDialog = null; NPCDialog = null; QuestDetailDialog = null; QuestListDialog = null; QuestLogDialog = null; QuestTrackingDialog = null; GameShopDialog = null; MentorDialog = null; RelationshipDialog = null; CharacterDuraPanel = null; DuraStatusPanel = null; HoverItem = null; SelectedCell = null; PickedUpGold = false; UseItemTime = 0; PickUpTime = 0; InspectTime = 0; DisposeItemLabel(); AMode = 0; PMode = 0; Lights = 0; NPCTime = 0; NPCID = 0; DefaultNPCID = 0; for (int i = 0; i < OutputLines.Length; i++) if (OutputLines[i] != null && OutputLines[i].IsDisposed) OutputLines[i].Dispose(); OutputMessages.Clear(); OutputMessages = null; } base.Dispose(disposing); }
public void ForceAttack(Character target, float damagePercentage, DamageType type, AttackMode mode) { var posCharacters = target.GetType() == typeof(Hero) ? heroSlots : monsterSlots; var targets = new List <Character>(); var targetPos = target.position; var posVictims = new int[4] { targetPos - 3, targetPos - 1, targetPos + 1, targetPos + 3 }; switch (mode) { case AttackMode.AllClose: foreach (var posPosition in posVictims) { if (posPosition < 0 || posPosition > 8) { continue; } var id = posCharacters[posPosition].AppliedId; if (!controller.allCharacters.TryGetValue(id, out var victim)) { continue; } targets.Add(victim); } break; case AttackMode.Random: if (controller.positionedMonsters.Count <= 1) { break; } var pool = controller.positionedMonsters; pool.Remove(target.position); var randTarget = pool[UnityEngine.Random.Range(0, pool.Count)]; targets.Add(randTarget); break; case AttackMode.RandomClose: var randTargets = new List <Character>(); foreach (var posPosition in posVictims) { if (posPosition < 0 || posPosition > 8) { continue; } var id = posCharacters[posPosition].AppliedId; if (!controller.allCharacters.TryGetValue(id, out var victim)) { continue; } randTargets.Add(victim); } var randTarget1 = randTargets[UnityEngine.Random.Range(0, randTargets.Count)]; targets.Add(randTarget1); break; } foreach (var t in targets) { DealDamage(t); } void DealDamage(Character victim) { var amount = 0f; if (target.GetType() == typeof(Hero)) { var hero = target as Hero; amount = UnityEngine.Random.Range(hero.MinPhysicalDamage, hero.MaxPhysicalDamage + 1); } else { var monster = target as Monster; amount = UnityEngine.Random.Range(monster.minPhysicalDamage, monster.maxPhysicalDamage + 1); } amount = amount * damagePercentage; var appliedDamage = victim.ApplyDamage(target, type, amount, 0); } }