public void RemoveBattleObject(BattleObject _bobj) { if (_bobj.Team == TeamType.Ally) { Ally_LiveData.LiveBattleObjects.Remove(_bobj); if (Ally_LiveData.IsAllEliminate) { StartCoroutine(FinishBattle(TeamType.Enemy)); } } else { Enemy_LiveData.LiveBattleObjects.Remove(_bobj); if (Enemy_LiveData.IsAllEliminate) { //다음 웨이브가 있다면 스폰! 없다면 승리! if (waveDatas.Exists(r => r.CrowdIndex == CurrentCrowdIndex + 1)) { CurrentCrowdIndex++; StartCoroutine(SpawnEnemys()); } else { StartCoroutine(FinishBattle(TeamType.Ally)); } } } }
public void ApplyModifier(BattleObject target) { if (effectType == ChipEffectTypes.damage) { target.health -= modifier; } }
public void RangeBulletEliminate(Vector3 centerPos, float range, bool getPoint) { float rangeSq = range * range; List <BattleObject> bulletList = GetObjectList(BattleObjectType.EnemyBullet); if (bulletList == null) { return; } for (int i = bulletList.Count - 1; i >= 0; --i) { BattleObject bulletObj = bulletList[i]; Vector3 disVec = bulletObj.transform.position - centerPos; if (disVec.sqrMagnitude < rangeSq) { EnemyBullet bullet = bulletObj as EnemyBullet; if (bullet != null) { bullet.Eliminate(); if (getPoint) { GameObject pointItem = BattleStageManager.Instance.SpawnObject("Item/PointItem"); pointItem.transform.position = bullet.transform.position; } } } } }
public BattleObject target; //伤害对象 #endregion Fields #region Constructors public Damage(BattleObject source, BattleObject target, int skillID, bool isWeaponDamage) { this.source = source; this.target = target; this.skillID = skillID; this.isWeaponDamage = isWeaponDamage; }
public IActionResult StartBattle(int id, int monster_id) { var character = _context.Characters.Include(c => c.CharacterState).FirstOrDefault(c => c.CharacterId == id); var monster = _context.ExistingMonsters.Include(m => m.Monster).FirstOrDefault(m => m.ExistingMonsterId == monster_id); BattleObject battleObject = new BattleObject(character, monster); return View("Battle", battleObject); }
public BattleObject LoadFighter(int player_num) { GameObject obj = new GameObject(); BattleObject battleObj = obj.AddComponent <BattleObject>(); if (abstract_fighter_info != null) { AbstractFighter fighter = obj.AddComponent <AbstractFighter>(); } if (sprite_handler_info != null) { SpriteHandler sprite = obj.AddComponent <SpriteHandler>(); //sprite.orientation = sprite_handler_info.orientation; } if (action_handler_info != null) { ActionHandler actions = obj.AddComponent <ActionHandler>(); //actions.action_json = action_handler_info.action_json; //actions.starting_action = action_handler_info.starting_action; } if (motion_handler_info != null) { MotionHandler mot = obj.AddComponent <MotionHandler>(); } if (ecb_info != null) { //EnvironmentCollider ecb = obj.AddComponent<EnvironmentCollider>(); } foreach (VarData vardata in variables) { battleObj.SetVar(vardata.name, vardata.value); } battleObj.LoadComponents(); return(battleObj); }
public override void OnCollisionWith(BattleObject other) { if (!Complete && other is Player player) { Complete = true; if (AltarSettings.Item == "Staff") { player.GearState--; player.DamageBonus += 5; } if (AltarSettings.Item == "Lungs") { player.MovementSpeedBonus += 3; } if (AltarSettings.Item == "Liver") { player.DamageBonus += 3; } if (AltarSettings.Item == "Eyes") { player.GearState--; player.HasEyes = true; } if (AltarSettings.DialogToTell.Length > 0) { player.DialogToTell = AltarSettings.DialogToTell; } } }
public BattleObject GetARandomEnemy(BattleObject bo) { if (bo.isEnemy) return players[UnityEngine.Random.Range (0, players.Count)]; else return enemys[UnityEngine.Random.Range (0, enemys.Count)]; }
public override void Execute(BattleObject actor, GameAction action) { base.Execute(actor, action); string name = (string)GetArgument("name", actor, action); actor.GetAbstractFighter().PlaySound(name); }
public List<BattleObject> GetAllEnemies(BattleObject bo) { if (bo.isEnemy) return new List<BattleObject>(players.ToArray()); else return new List<BattleObject>(enemys.ToArray()); }
public override void Execute(BattleObject actor, GameAction action) { base.Execute(actor, action); float degrees = (float)GetArgument("degrees", actor, action); actor.SendMessage("RotateSprite", degrees); }
public static void CheckBuff(BuffTrigger trigger, BattleObject source) { for(int i = 0; i < source.buffList.Count; i++) { source.buffList[i].Check(trigger); } }
public override void OnCollisionWith(BattleObject other) { if (!IsOpened && other is Player player && player.Room.CanProgressToNextRoom()) { IsOpened = true; if (ChestSettings.PossibleDrops.Count == 1) { SpawnDrops(ChestSettings.PossibleDrops[0].ItemPool, player); } else if (ChestSettings.PossibleDrops.Count > 1) { var bag = new List <DropTable>(); foreach (var drop in ChestSettings.PossibleDrops) { for (int i = 0; i < drop.Weight; i++) { bag.Add(drop); } } var randomlySelected = UnityEngine.Random.Range(0, bag.Count); SpawnDrops(bag[randomlySelected].ItemPool, player); } } }
public override void DealDamage(float damage, BattleObject source) { if (PropSettings.IsVulnerable) { Health -= damage; } }
public bool CheckCollision(BattleObject target) { CollisionType targetType = target.collisionType; switch (collisionType) { case CollisionType.Circle: if (targetType == CollisionType.Circle) { return(CircleCheck(target)); } else if (targetType == CollisionType.Box) { return(CircleBoxCheck(this, target)); } break; case CollisionType.Box: if (targetType == CollisionType.Circle) { return(CircleBoxCheck(target, this)); } else if (targetType == CollisionType.Box) { return(BoxCheck(target)); } break; } return(false); }
/// <summary> /// Create a new 3D representation of the 3D object. /// </summary> public static BattleObject3D CreateNewVisual(BattleObject data, BattleViewController viewController) { var prefab = data.Settings.LoadVisuals(); if (prefab == null) { Debug.LogWarning($"Failed to find prefab for {data.Settings}", data.Settings); return(null); } var newObject = BattleObject3D.Instantiate <BattleObject3D>(prefab); newObject.Data = data; newObject.Animator = newObject.gameObject.GetComponentInChildren <Animator>(); newObject.ViewController = viewController; newObject.Init(data); newObject.Sync(0); if (newObject.Animator) { newObject.Animator.logWarnings = false; } return(newObject); }
void CreateOrbs() { Sprite[] sprites = Resources.LoadAll <Sprite>("Sprites/actors"); BattleObject obj = new BattleObject(GameData.CurrentBattle.PlayerA); obj.Properties["isOrb"] = "true"; GameObject gObj = new GameObject("Orb_" + obj.Owner); SpriteRenderer r = gObj.AddComponent <SpriteRenderer>(); r.sprite = sprites[2]; obj.GameObject = gObj; obj.SetDescription(obj.Owner.Name + "'s Orb"); gObj.SetActive(true); obj.SetPosition(new Vector2(0, GameData.CurrentBattle.Board.Height / 2)); obj = new BattleObject(GameData.CurrentBattle.PlayerB); obj.Properties["isOrb"] = "true"; gObj = new GameObject("Orb_" + obj.Owner); r = gObj.AddComponent <SpriteRenderer>(); r.sprite = sprites[2]; obj.GameObject = gObj; obj.SetDescription(obj.Owner.Name + "'s Orb"); gObj.SetActive(true); obj.SetPosition(new Vector2(GameData.CurrentBattle.Board.Width - 1, GameData.CurrentBattle.Board.Height / 2)); }
/* * 技能相关静态方法 * */ public static void CheckSkillEffect(EffectTrigger trigger, BattleObject source) { int skillID = source.damage.skillID; bool isWeaponDamage = source.damage.isWeaponDamage; SkillData skillData = DataManager.Instance.GetSkillDataSet().GetSkillData(skillID); for(int i = 0; i < skillData.effectID.Count; i++) { if(skillData.effectID[i] == 0)continue; int random = UnityEngine.Random.Range(0, 101); if(random <= skillData.effectPercent[i]) { SkillEffectData effectData = DataManager.Instance.GetSkillDataSet().GetEffectData(skillData.effectID[i]); if(effectData.trigger == trigger) { SkillEffect.ExecuteSkillEffect(source, effectData.effectString); } } } if(isWeaponDamage) { CheckWeaponEffect(trigger, source); } }
void CreatePlayers() { List <Planet> planetsInSystem = new List <Planet>(); int idCounter = 0; //Create player and subscribe for events Planet planet = AssetsLibrary.Library_Prefabs.CreatePlanetPrefab(); planet.OnCreateProjectile += CreateProjectile; m_OnPauseStateChanged += planet.PauseUpdate; m_OnGameFinished += planet.PauseUpdate; m_InputManager.OnPlayerShoot += planet.Shoot; m_Player = planet; planet.Init(GetPlayerRandomHP(), AssetsLibrary.Library_Sprites.GetRandomPlayerSprite(), GetRandomOrbitPeriod(), AssetsLibrary.Library_Colors.PlayerHightlightColor, GameSettings.ProjectileStats[Random.Range(0, GameSettings.ProjectileStats.Length)], GameSettings.PlanetScaleToWeightMltp, true, idCounter++); //Add planet to list of planets for further orbit processing planetsInSystem.Add(planet); //Create enemies m_TotalEnemies = Random.Range(GameSettings.MinEnemiesAmount, GameSettings.MaxEnemiesAmount + 1); m_CurrentEnemies = m_TotalEnemies; for (int i = 0; i < m_TotalEnemies; i++) { planet = AssetsLibrary.Library_Prefabs.CreatePlanetPrefab(); planet.OnCreateProjectile += CreateProjectile; //Subscribe for pause event m_OnPauseStateChanged += planet.PauseUpdate; m_OnGameFinished += planet.PauseUpdate; planet.Init(GetEnemyRandomHP(), AssetsLibrary.Library_Sprites.GetRandomEnemySprite(), GetRandomOrbitPeriod(), AssetsLibrary.Library_Colors.EnemyHightlightColor, GameSettings.ProjectileStats[Random.Range(0, GameSettings.ProjectileStats.Length)], GameSettings.PlanetScaleToWeightMltp, false, idCounter++, GetRandomScale()); //Add planet to list of planets for further orbit processing planetsInSystem.Add(planet); //Add planet to physics processing PhysicsController.AddAttractor(planet); //Add planet to AI processing m_AIManager.AddObjectToProcessing(planet); } ApplyOrbits(planetsInSystem); }
public BattleObjectMenuView(Game game, BattleObject activeBattleObject, MenuItemSelectListener selectListener) { _activeBattleObject = activeBattleObject; _menuItemView = new BattleMenuItemView(game, selectListener) { Root = true, Selected = true }; LoadTreeFromBattleObject(game, _activeBattleObject); }
public override void Execute(BattleObject actor, GameAction action) { int frameNumber = (int)GetArgument("frameNumber", actor, action, 1); bool relative = (bool)GetArgument("relative", actor, action, false); action.ChangeFrame(frameNumber, relative); }
public override void Execute(BattleObject actor, GameAction action) { string name = ""; Dictionary <string, string> hbox_dict = new Dictionary <string, string>(); foreach (SubactionVarData data in arg_dict.Values) { if (data.name == "hitboxName") { name = (string)data.GetData(actor, action); } else { hbox_dict.Add(data.name, data.GetData(actor, action).ToString()); } } if (action.hitboxes.ContainsKey(name)) { Debug.LogWarning(string.Format("Creating a hitbox named {0} while one already exists. This hitbox will be overwritten with the new data.", name)); } Hitbox hbox = HitboxLoader.CreateHitbox(actor.gameObject, hbox_dict); //Hitbox hbox = HitboxLoader.loader.LoadHitbox(actor.GetAbstractFighter(), action, hbox_dict); action.hitboxes.Add(name, hbox); }
IEnumerator StartFight() { var dt = Data[Random.Range(0, Data.Length)]; var spirit = Spirit.GenerateSpirit(dt.SpiritType, dt.Level); var y = ScriptableObject.CreateInstance <SpiritTeam>(); y.Spirits = new List <Spirit>() { spirit }; var x = ScriptableObject.CreateInstance <SpiritTeam>(); x.Spirits = Player.Instance.team; var bo = new BattleObject(y, x); yield return(StartCoroutine(LoadBattle(bo))); if (bo.winner == 1) { StartCoroutine(Player.Instance.DefeatedInFight()); } }
void Next() { bool adding = false; while (addWarriors_index + 1 < GameData.CurrentBattle.CurrentPlayer.AvailableActors.Count) { addWarriors_index++; adding = true; BattleObject obj = GameData.CurrentBattle.CurrentPlayer.AvailableActors[addWarriors_index]; if (!(obj is BattleActor)) { continue; } BattleActor actor = obj as BattleActor; BattleSceneController.Main.HeadsupText.text = "Place " + GameData.CurrentBattle.CurrentPlayer.Name + "'s " + actor.Type.Name; break; } if (!adding && addWarriors_index + 1 >= GameData.CurrentBattle.CurrentPlayer.AvailableActors.Count) { addedPlayers++; if (addedPlayers == 2) { BattleSceneController.Main.SwitchFlow(FlowState.ChooseActorToPerform); } else { GameData.CurrentBattle.CurrentPlayer = GameData.CurrentBattle.CurrentPlayer.GetEnemy(); BattleSceneController.Main.SwitchFlow(FlowState.AddingWarriors); } } }
// 通知実行 public void NotifyDamegedObj(BattleObject Attacker, BattleObject Diffender, int BulletAtk, Buff_HPSP buff1, Buff_Others buff2) { if (_OnDamegedObj != null) { _OnDamegedObj(Attacker, Diffender, BulletAtk, buff1, buff2); } }
public static bool CanMoveAndAttack(BattleActor actor, BattleObject target, out Vector2 movePattern, out Vector2 attackPattern) { List <Vector2> moveLocations = actor.Type.Pattern.GetLocationsForFlags(PatternFlags.Movement); moveLocations.Add(Vector2.zero); List <Vector2> attackLocations = actor.Type.Pattern.GetLocationsForFlags(PatternFlags.Attack); Vector2 actorPos = actor.Position; Vector2 targetPos = target.Position; foreach (Vector2 movePos in moveLocations) { foreach (Vector2 attackPos in attackLocations) { if (movePos + attackPos + actorPos == targetPos && actor.CanMoveTo(actor.Position + movePos)) { movePattern = movePos; attackPattern = attackPos; return(true); } } } movePattern = Vector2.zero; attackPattern = Vector2.zero; return(false); }
public float GetDistance(BattleObject obj1, BattleObject obj2) { Vector3 attackerPos = new Vector3(obj1.transform.position.x, 0f, obj1.transform.position.z); Vector3 targetPos = new Vector3(obj2.transform.position.x, 0f, obj2.transform.position.z); return(Vector3.Distance(attackerPos, targetPos)); }
public ColliderProperties(BattleObject obj) { TriggerOnly = obj is Projectile; Shape = obj.Settings.ColliderType; Mass = obj.Settings.Mass; IsStatic = obj.Settings.IsStatic; Size = obj.Size; }
public BattleTrayCharacterView(Game game, BattleObject player) { _game = game; _battleObject = player; LoadTextures(); LoadDisplayBars(); }
public BattleObject getBattleObject() { if (battleObject == null) { battleObject = GetComponent <BattleObject>(); } return(battleObject); }
public override void OnCollisionWith(BattleObject obj) { base.OnCollisionWith(obj); if (obj is Mob || obj is Prop) { PatrolTarget = obj.Position + normalize(Position - obj.Position) * 2; } }
public override void Execute(BattleObject obj, GameAction action) { action.cond_depth--; if (action.cond_depth < 0) { action.cond_depth = 0; } }
public void OnObjectLeft(BattleObject battleObject) { AllObjects.Remove(battleObject); if (battleObject is Unit unit) { AllUnits.Remove(unit); } }
public override void Init(BattleObject data) { var player = (Player)Data; Animator.SetInteger("GearState", player.GearState); Light2D.transform.localScale = player.HasEyes ? Vector3.one : NoEyesLightScale * Vector3.one; Light2D.intensity = player.HasEyes ? 1 : NoEyesLightIntensity; }
public override void Execute(BattleObject actor, GameAction action) { base.Execute(actor, action); int frame = (int)GetArgument("frame", actor, action, 1); bool relative = (bool)GetArgument("relative", actor, action, true); action.ChangeFrame(frame, relative); }
public override void Init(bool hasTimer, BattleObject host, AttackObject atk) { base.Init(hasTimer, host, atk); float totalDrain = (atk.P_attackValue - (host.P_totalDefense)) * atk.P_statusMultiplier; if (atk.P_statusTimer < Utils.eps){ H_owner.Heal (totalDrain); } }
public override void OnCollisionWith(BattleObject other) { if (other is Player player) { player.DealDamage(Marus.MobSettings.AttackDamage, Marus); player.PushFrom(Position, Marus.MobSettings.AttackPush); } }
public void SizeToOwner(BattleObject obj) { float scale = obj.GetFloatVar(TussleConstants.SpriteVariableNames.PIXELS_PER_UNIT); //float scale = 50; Vector3 positionFromCenter = new Vector3(hitboxRect.center.x / scale, hitboxRect.center.y / scale, -0.1f); transform.localPosition = positionFromCenter; transform.localScale = new Vector3(hitboxRect.width / scale, hitboxRect.height / scale, 1.0f); }
public override void Init(bool hasTimer, BattleObject host, AttackObject atk) { base.Init(hasTimer, host, atk); float totalDamage = (atk.P_attackValue - (host.P_totalDefense)) * host.P_poisonResistance * atk.P_statusMultiplier; if (atk.P_statusTimer < Utils.eps){ H_host.LoseHP(totalDamage); }else { _damageRate = totalDamage / atk.P_statusTimer; } }
public virtual void Init(bool hasTimer, BattleObject host, AttackObject atk) { DontDestroyOnLoad(transform.gameObject); H_hasTimer = hasTimer; H_host = host; H_parentAttackValue = atk.P_attackValue; H_multiplier = atk.P_statusMultiplier; H_timer = atk.P_statusTimer; H_owner = atk.transform.parent.GetComponent<BattleObject>(); H_isInit = true; }
public static Buff CreateBuff(BattleObject bo, BuffData data, int effectTurns) { Buff buff = (Buff)Assembly.GetExecutingAssembly().CreateInstance("Buff" + data.buffEffect, true); buff.source = bo; buff.data = data; buff.effectTurns = effectTurns; buff.Init(); buff.AddBuffIcon(); return buff; }
public void Init(float damageDealt, BattleObject parent, bool healing) { _parent = parent; _currentText = GetComponent<GUIText>(); _isInit = true; _timer = 1.0F; _currentText.text = ((int)damageDealt).ToString(); _currentText.transform.position = _parent.transform.position; if (healing){ _currentText.color = new Color(0F,1F,0F,1F); } else { _currentText.color = new Color(0.6F, 0F, 0F, 1F); } }
public static void CheckBuffAdd(BattleObject source) { int skillID = source.damage.skillID; bool isWeaponDamage = source.damage.isWeaponDamage; SkillData skillData = DataManager.Instance.GetSkillDataSet().GetSkillData(skillID); for(int i = 0; i < skillData.buffID.Count; i++) { if(skillData.buffID[i] == 0)continue; int random = UnityEngine.Random.Range(0, 101); if(random <= skillData.buffPercent[i]) { if(skillData.buffAddTriggers[i] == (int)BuffAddTrigger.SelfAfterDamage) { source.AddBuff(skillData.buffID[i], skillData.buffTurns[i]); } else if(skillData.buffAddTriggers[i] == (int)BuffAddTrigger.TargetAfterDamage) { source.damage.target.AddBuff(skillData.buffID[i], skillData.buffTurns[i]); } } } if(isWeaponDamage) { WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon()); for(int i = 0; i < weaponData.buffID.Count; i++) { if(weaponData.buffID[i] == 0)continue; int random = UnityEngine.Random.Range(0, 101); if(random <= weaponData.buffPercent[i]) { if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.SelfAfterDamage) { source.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]); } else if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.TargetAfterDamage) { source.damage.target.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]); } } } } }
private void LoadTreeFromBattleObject(Game game, BattleObject activeBattleObject) { Tree<string> optionTree = new Tree<string>("root"); optionTree.AddChild("Attack"); foreach(var attack in activeBattleObject.AttackList) { optionTree.GetFirstChild("Attack").AddChild(attack); } optionTree.AddChild("Magic"); foreach(var magic in activeBattleObject.MagicList) { optionTree.GetFirstChild("Magic").AddChild(magic); } optionTree.AddChild("Item"); foreach(var item in activeBattleObject.ItemList) { optionTree.GetFirstChild("Item").AddChild(item); } _menuItemView.SetTree(optionTree); _menuItemView.SetFirstSelected(); }
public static void ExecuteSkillEffect(BattleObject bo,string effectName) { SkillEffect effect = (SkillEffect)Assembly.GetExecutingAssembly().CreateInstance("SkillEffect" + effectName, true); effect.source = bo; effect.Execute(); }
private void Attack(BattleObject from, BattleObject to, string actionText) { // find the action from the list loaded in var actions = _game.Content.Load<Actions>(@"BattleXML/Actions"); if(actions.ActionList.Any(x => x.Name == actionText)) { var action = actions.ActionList.First(x => x.Name == actionText); // determine the damage var damage = action.Damage * from.Str; to.HP -= damage; // start damage display (text of numbers popping up) InteractableBattleObjectView toBattleView = null; if(to.Enemy) { toBattleView = _battleView.EnemyPartyView.First(x => x.Name == to.Name); } else { toBattleView = _battleView.PlayerPartyView.First(x => x.Name == to.Name); } toBattleView.StartDamageText(damage); // start damage animation if(_activeBattleObjectsToProcess.Count == 0) { _battleState = BattleState.ActiveTime; } _activeBattleObject = null; _battleMenuView = null; } }
protected void OnReady() { timelinePosition = GlobalDataStructure.BATTLE_TIMELINE_READY; isBlocking = false; isEvading = false; battleStatus = BattleStatus.Ready; if(guardedTarget != null) { guardedTarget.guardTarget = null; guardedTarget = null; } if(data.battleType == BattleType.Physical) {//自愈机制 if(currentHP >= maxHP * GlobalDataStructure.HP_RECOVER_THRESHOLD && currentHP < maxHP) { int recoverAmount = currentHP; currentHP += (int) (maxHP * GlobalDataStructure.HP_RECOVER_AMOUNT); recoverAmount = currentHP - recoverAmount; MessageEventArgs args = new MessageEventArgs(); args.AddMessage("Name", GetName()); args.AddMessage("Amount", recoverAmount); EventManager.Instance.PostEvent (BattleEvent.OnHPAutoRecover, args); } } else if(data.battleType == BattleType.Magical) {//回复机制 if( currentHP < maxHP) { int recoverAmount = currentHP; currentHP += (int) (maxHP * GlobalDataStructure.MP_RECOVER_AMOUNT); recoverAmount = currentHP - recoverAmount; MessageEventArgs args = new MessageEventArgs(); args.AddMessage("Name", GetName()); args.AddMessage("Amount", recoverAmount); EventManager.Instance.PostEvent (BattleEvent.OnMPAutoRecover, args); } } List<Buff> toRemoveList = new List<Buff>(); foreach(Buff buff in buffList) { buff.Tick(); if(buff.effectTurns == 0) { toRemoveList.Add(buff); } } foreach(Buff buff in toRemoveList) { buffList.Remove(buff); } availableCommands = Command.GetAvailableCommands(this); }
//攻击倍率 public static float AttackMulti(BattleObject bo) { return 1 + bo.power / 100f + bo.attackMulti; }
private void StartActionFor(BattleObject battleObject) { _battleState = BattleState.StoppedTime; _activeBattleObjectsToProcess.Enqueue(battleObject); }
private void UpdateStopped(GameTime gameTime) { // figure out if there is an object ready if(_activeBattleObject == null && _activeBattleObjectsToProcess.Count > 0) { _activeBattleObject = _activeBattleObjectsToProcess.Dequeue(); if(_activeBattleObject.Enemy) { Attack(_activeBattleObject, _playerParty[0], _activeBattleObject.AttackList[0]); } else { _battleMenuView = new BattleObjectMenuView(_game, _activeBattleObject, this); } } }
//防御倍率 public static float DefenceMulti(BattleObject bo) { return Mathf.Min(bo.toughness / (100f + bo.toughness) + bo.defenceMulti, 1); }
public static bool FillCommandTarget(BattleObject source) { switch(source.commandToExecute.targetType) { case TargetType.SingleEnemy: case TargetType.SingleAlly: case TargetType.OtherAlly: return false; case TargetType.Self: source.commandToExecute.targetList.Add(source); break; case TargetType.AllEnemies: source.commandToExecute.targetList = BattleManager.Instance.GetAllEnemies(source); break; case TargetType.AllAllies: source.commandToExecute.targetList = BattleManager.Instance.GetAllAllies(source); break; case TargetType.EveryoneElse: source.commandToExecute.targetList = BattleManager.Instance.GetEveryoneElse(source); break; case TargetType.Everyone: source.commandToExecute.targetList = BattleManager.Instance.GetEveryone(); break; case TargetType.Random: source.commandToExecute.targetList.Add(BattleManager.Instance.GetARandomEnemy(source)); break; } return true; }
//命中率 public static float ExtraAccuracy(BattleObject bo) { return bo.skill + bo.luck / 9f + bo.accuracyMulti; }
//抗暴击率 public static float ExtraCritResist(BattleObject bo) { return bo.skill / 4.5f + bo.luck / 4.5f + bo.critMulti; }
public static void CheckWeaponEffect(EffectTrigger trigger, BattleObject source) { WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon()); for(int i = 0; i < weaponData.effectID.Count; i++) { if(weaponData.effectID[i] == 0)continue; int random = UnityEngine.Random.Range(0, 101); if(random <= weaponData.effectPercent[i]) { SkillEffectData effectData = DataManager.Instance.GetSkillDataSet().GetEffectData(weaponData.effectID[i]); if(effectData.trigger == trigger) { SkillEffect.ExecuteSkillEffect(source, effectData.effectString); } } } }
public TargetType targetType; //目标类型 #endregion Fields #region Methods public static List<Command> GetAvailableCommands(BattleObject bo) { List<Command> availableCommands = new List<Command>(); //检查攻击类技能 if(!bo.disableAttackCommand) { if(bo.GetBattleType() != BattleType.Magical && bo.GetWeapon() > 1000) { WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(bo.GetWeapon()); if(weaponData.skill1ID > 0) availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill1ID)); if(weaponData.skill2ID > 0) availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill2ID)); if(weaponData.skill3ID > 0) availableCommands.Add(new CommandUseWeaponSkill(weaponData, weaponData.skill3ID)); } if(bo.GetBattleType() != BattleType.Physical) { foreach(int magicID in bo.GetMagicList()) { MagicData magicData = DataManager.Instance.GetItemDataSet().GetMagicData(magicID); availableCommands.Add(new CommandUseMagicSkill(magicData, magicData.skillID)); } } } //检查防御技能 if(!bo.disableDefenceCommand) { availableCommands.Add(new CommandBlock()); availableCommands.Add(new CommandEvade()); availableCommands.Add(new CommandGuard()); } //检查物品 if(!bo.disableItemCommand) { if(bo.GetBattleType() != BattleType.Magical) { foreach(int weaponID in bo.GetWeaponList()) { if(weaponID != bo.GetWeapon()) availableCommands.Add(new CommandSwitchWeapon(weaponID)); } } foreach(var item in bo.GetItemList()) { availableCommands.Add(new CommandUseItem(item.Key, item.Value)); } } //检查策略 if(!bo.disableStrategyCommand) { availableCommands.Add(new CommandNone()); availableCommands.Add(new CommandEscape()); } foreach(Command command in availableCommands) { command.source = bo; } return availableCommands; }
/* * 高阶数值相关 * */ //最大生命值 public static int MaxHP(BattleObject bo) { int maxHP = Mathf.RoundToInt(Mathf.Pow(bo.stamina, 1.4f) * 4); return Mathf.RoundToInt(maxHP * (1 + bo.maxHPMulti)); }
//时间轴速度 public static int Speed(BattleObject bo) { int speed = Mathf.RoundToInt(Mathf.Log10(bo.agility) * 20); return Mathf.RoundToInt(speed * (1 + bo.speedMulti)); }
public static void CheckWeaponBuff(BattleObject source, int offID = 0) { if(offID > 0) { WeaponData oldWeaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(offID); for(int i = 0; i < oldWeaponData.buffID.Count; i++) { if(oldWeaponData.buffID[i] == 0)continue; if(oldWeaponData.buffAddTriggers[i] == (int)BuffAddTrigger.Self) { source.RemoveBuff(oldWeaponData.buffID[i]); } } } WeaponData weaponData = DataManager.Instance.GetItemDataSet().GetWeaponData(source.GetWeapon()); for(int i = 0; i < weaponData.buffID.Count; i++) { if(weaponData.buffID[i] == 0)continue; int random = UnityEngine.Random.Range(0, 101); if(random <= weaponData.buffPercent[i]) { if(weaponData.buffAddTriggers[i] == (int)BuffAddTrigger.Self) { source.AddBuff(weaponData.buffID[i], weaponData.buffTurns[i]); } } } }
//回避率 public static float ExtraEvasion(BattleObject bo) { return bo.skill * 0.9f + bo.luck / 4.5f + bo.evasionMulti; }