public void InitCharacters(Dictionary <int, bool> characterIds, Model.Master.MBattlefield battlefieldMaster) { int index = 0; List <MCharacter> characters = Global.charactersManager.mCharacters; characters.Clear(); System.Array.ForEach(Global.SUser.self.characters, (model) => { if (characterIds.ContainsKey(model.characterId)) { Model.Master.MBattleOwn own = battlefieldMaster.owns[index++]; model.belong = Belong.self; model.coordinate.x = own.x; model.coordinate.y = own.y; CharacterInit(model); characters.Add(model); } }); foreach (Model.Master.MBattleNpc battleNpc in battlefieldMaster.enemys) { MCharacter mCharacter = NpcCacher.Instance.GetFromBattleNpc(battleNpc); mCharacter.belong = Belong.enemy; CharacterInit(mCharacter); characters.Add(mCharacter); } foreach (App.Model.Master.MBattleNpc battleNpc in battlefieldMaster.friends) { MCharacter mCharacter = NpcCacher.Instance.GetFromBattleNpc(battleNpc); mCharacter.belong = Belong.friend; CharacterInit(mCharacter); characters.Add(mCharacter); } this.dispatcher.Set("characters", characters); }
/// <summary> /// 动作结束后处理 /// </summary> public IEnumerator ActionOverNext() { if (battleMode == BattleMode.moving) { currentVCharacter.action = ActionType.idle; } yield return(AppManager.CurrentScene.StartCoroutine(ActionEndSkillsRun())); currentVCharacter.actionOver = true; currentMCharacter.roadLength = 0; tilesManager.ClearCurrentTiles(); Global.battleEvent.DispatchEventCharacterPreview(null); battleMode = BattleMode.none; Belong belong = currentMCharacter.belong; this.currentMCharacter = null; this.currentVCharacter = null; if (!Global.charactersManager.mCharacters.Exists(c => c.hp > 0 && !c.isHide && c.belong == belong && !c.actionOver)) { ChangeBelong(belong); } else { Global.battleEvent.DispatchEventOperatingMenu(false); } }
public void ClickNoneNode(Vector2Int coordinate) { MCharacter mCharacter = Global.charactersManager.GetCharacter(coordinate); if (mCharacter != null) { currentVCharacter = Global.charactersManager.GetVCharacter(mCharacter); this.currentMCharacter = mCharacter; this.currentMCharacter.roadLength = 0; tilesManager.ShowCharacterMovingArea(mCharacter); tilesManager.ShowCharacterSkillArea(mCharacter); Global.battleEvent.DispatchEventCharacterPreview(mCharacter); _oldCoordinate.x = mCharacter.coordinate.x; _oldCoordinate.y = mCharacter.coordinate.y; ActionType action = currentVCharacter.action; float x = currentVCharacter.X; Direction direction = currentVCharacter.direction; if (mCharacter.belong == Belong.self) { Global.battleEvent.DispatchEventOperatingMenu(true); } returnAction = () => { this.currentMCharacter.coordinate.y = _oldCoordinate.y; this.currentMCharacter.coordinate.x = _oldCoordinate.x; currentVCharacter.X = x; currentVCharacter.direction = direction; currentVCharacter.action = action; }; } }
public MCharacter GetFromBattleNpc(App.Model.Master.MBattleNpc mBattleNpc) { Model.Master.MNpc npc = Get(mBattleNpc.npcId); MCharacter mCharacter = GetFromNpc(npc); if (mBattleNpc.horse > 0) { mCharacter.horse = mBattleNpc.horse; } if (mBattleNpc.weapon > 0) { mCharacter.weapon = mBattleNpc.weapon; } if (mBattleNpc.clothes > 0) { mCharacter.clothes = mBattleNpc.clothes; } if (mBattleNpc.star > 0) { mCharacter.star = mBattleNpc.star; } mCharacter.skills = Service.HttpClient.Deserialize <App.Model.Character.MSkill[]>(mBattleNpc.skills); mCharacter.coordinate.x = mBattleNpc.x; mCharacter.coordinate.y = mBattleNpc.y; return(mCharacter); }
public void ClickMovingNode(Vector2Int coordinate) { if (this.currentMCharacter.belong != currentBelong || this.currentMCharacter.actionOver) { CharacterReturnNone(); return; } MCharacter mCharacter = Global.charactersManager.GetCharacter(coordinate); if (mCharacter != null) { bool sameBelong = Global.charactersManager.IsSameBelong(mCharacter.belong, this.currentMCharacter.belong); bool useToEnemy = this.currentMCharacter.currentSkill.useToEnemy; if (useToEnemy ^ sameBelong) { ClickSkillNode(coordinate); } return; } if (this.tilesManager.IsInMovingCurrentTiles(coordinate)) { MoveStart(coordinate); } else if (battleMode != Model.BattleMode.move_after_attack) { CharacterReturnNone(); } }
private async void button2_Click(object sender, EventArgs e) { try { Regex rx = new Regex(@"(http|https)://\S+\.mp4"); var match = rx.Match(videoUrlTextBox.Text); if (match.Success) { request.VideoUrl = videoUrlTextBox.Text; } request.Title = textBox1.Text; request.Summary = textBox2.Text; request.AirDate = dateTimePicker1.Value; var selectedCharacters = this.listView2.SelectedItems; foreach (ListViewItem item in selectedCharacters) { int id = Int32.Parse(item.Text); var character = new MCharacter { Id = id }; request.MainCharacters.Add(character); } await _episodeService.Update <MEpisode>(_eId, request); await RefreshEpisodeList(); MessageBox.Show("Updated"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IEnumerator OnBoutStart() { while (true) { MCharacter mCharacter = System.Array.Find(mBaseMap.Characters, c => c.Belong == this.currentBelong && c.Hp > 0 && !c.IsHide && !c.boutEventComplete); if (mCharacter == null) { break; } App.Model.Master.MSkill skill = mCharacter.BoutFixedDamageSkill; if (skill != null) { List <VCharacter> characters = vBaseMap.Characters.FindAll(c => c.ViewModel.Hp.Value > 0 && !c.ViewModel.IsHide.Value && !this.charactersManager.IsSameBelong(c.ViewModel.Belong.Value, currentBelong)); yield return(OnBoutFixedDamage(mCharacter, skill, characters)); } mCharacter.boutEventComplete = true; } if (currentBelong != Belong.self) { ai.Execute(currentBelong); } else { CloseOperatingMenu(); if (scriptWaitPaths != null) { WaitScript(scriptWaitPaths); } } }
public void DispatchEventCharacterPreview(MCharacter mCharacter) { if (CharacterPreviewHandler != null) { CharacterPreviewHandler(mCharacter); } }
private void SearchInit(MCharacter mCharacter, bool obstacleEnable = false) { foreach (VTile tile in vBaseMap.tileUnits) { tile.SearchInit(); } if (cBattlefield == null || !obstacleEnable) { return; } foreach (MCharacter character in mBaseMap.Characters) { if (character.Hp == 0 || character.IsHide || cBattlefield.charactersManager.IsSameCharacter(mCharacter, character)) { continue; } VTile tile = cBattlefield.mapSearch.GetTile(character.CoordinateX, character.CoordinateY); if (cBattlefield.charactersManager.IsSameBelong(mCharacter.Belong, character.Belong)) { continue; } tile.IsRoad = false; List <Vector2> coordinates = cBattlefield.mapSearch.GetNeighboringCoordinates(baseMapMaster.GetCoordinateFromIndex(tile.Index)); foreach (Vector2 vec in coordinates) { VTile childTile = vBaseMap.tileUnits[(int)vec.y * vBaseMap.mapWidth + (int)vec.x]; if (childTile.CoordinateX == mCharacter.CoordinateX && childTile.CoordinateY == mCharacter.CoordinateY) { continue; } childTile.IsAllCost = true; } } }
/*public void MovePlayer(int x, int y){ * MCharacter mCharacter = System.Array.Find(mBaseMap.Characters, c=>c.CharacterId >= App.Util.Global.Constant.user_characters[0] && c.CharacterId <= App.Util.Global.Constant.user_characters[1]); * MoveCharacter(mCharacter, x, y); * }*/ public void MoveSelf(int index, int x, int y) { int characterId = (this as App.Controller.Battle.CBattlefield).characterIds[index]; MCharacter mCharacter = System.Array.Find(mBaseMap.Characters, c => c.CharacterId == characterId && c.Belong == Belong.self); MoveCharacter(mCharacter, x, y); }
public MCharacter GetCharacter(int index, MCharacter[] characters = null) { Vector2 coordinate = baseMapMaster.GetCoordinateFromIndex(index); MCharacter mCharacter = System.Array.Find(characters == null ? mBaseMap.Characters : characters, c => c.Hp > 0 && !c.IsHide && c.CoordinateX == coordinate.x && c.CoordinateY == coordinate.y); return(mCharacter); }
public override IEnumerator OnLoad(Request request) { MCharacter mCharacter = request.Get <MCharacter>("character"); VMInit(mCharacter); yield return(StartCoroutine(base.OnLoad(request))); }
public void SetSelfAction(int index, ActionType action) { int characterId = (this as App.Controller.Battle.CBattlefield).characterIds[index]; MCharacter mCharacter = System.Array.Find(mBaseMap.Characters, c => c.CharacterId == characterId && c.Belong == Belong.self); this.StartCoroutine(SetAction(mCharacter, action)); }
public void SetSelfDirection(int index, Direction direction) { int characterId = (this as App.Controller.Battle.CBattlefield).characterIds[index]; MCharacter mCharacter = System.Array.Find(mBaseMap.Characters, c => c.CharacterId == characterId && c.Belong == Belong.self); mCharacter.Direction = direction; }
public System.Collections.IEnumerator OnBoutFixedDamage(MCharacter mCharacter, Model.Master.MSkill skill, List <VCharacterBase> characters) { TileMap mapSearch = Global.mapSearch; Manager.BattleCharactersManager charactersManager = Global.charactersManager; VTile targetTile = mapSearch.GetTile(mCharacter.coordinate); foreach (VCharacter child in characters) { VTile tile = mapSearch.GetTile(child.mCharacter.coordinate); if (mapSearch.GetDistance(targetTile, tile) <= skill.radius) { int hert = skill.strength; if (child.hp - hert <= 0) { hert = child.hp - 1; } Model.Battle.MDamageParam arg = new Model.Battle.MDamageParam(-hert); child.SendMessage(CharacterEvent.OnDamage.ToString(), arg); } } while (charactersManager.HasDynamicCharacter()) { yield return(new UnityEngine.WaitForEndOfFrame()); } }
public void ShowCharacterSkillArea(MCharacter mCharacter) { //技能攻击扩展范围 List <int[]> distances = mCharacter.skillDistances; distances.Add(mCharacter.currentSkill == null ? new int[] { 0, 0 } : mCharacter.currentSkill.master.distance); int maxDistance = 0; foreach (int[] distance in distances) { if (distance[1] > maxDistance) { maxDistance = distance[1]; } } currentAttackTiles = Global.battleManager.breadthFirst.Search(mCharacter, maxDistance); //VTile characterTile = currentAttackTiles.Find(v => v.coordinate.Equals(mCharacter.coordinate)); //Debug.LogError("currentAttackTiles " + currentAttackTiles.Count); currentAttackTiles = currentAttackTiles.FindAll((tile) => { int length = Global.mapSearch.GetDistance(tile.coordinate, mCharacter.coordinate); return(distances.Exists(d => length >= d[0] && length <= d[1])); }); if (mCharacter.currentSkill == null) { return; } Global.battleEvent.DispatchEventAttackTiles(currentAttackTiles, mCharacter.belong); if (mCharacter.belong == Belong.self && !mCharacter.actionOver) { ShowCharacterSkillTween(mCharacter, currentAttackTiles); } }
MCharacter() { if (m_Instance == null) { m_Instance = this; } }
private void VMInit(MCharacter mCharacter) { icon.BindingContext = mCharacter.ViewModel; icon.UpdateView(); vBattleCharacterPreview.BindingContext = mCharacter.ViewModel; vBattleCharacterPreview.UpdateView(); }
public void CharacterSelectComplete() { MCharacter character = characters[index]; Request req = Request.Create("characterId", character.CharacterId); this.StartCoroutine(Global.SceneManager.ShowDialog(SceneManager.Prefabs.RegisterConfirmDialog, req)); }
/// <summary> /// 武将状态显示 /// </summary> /// <param name="mCharacter">M character.</param> public void OpenBattleCharacterPreviewDialog(MCharacter mCharacter) { battleCharacterPreview.gameObject.SetActive(true); Request req = Request.Create("character", mCharacter); this.StartCoroutine(battleCharacterPreview.OnLoad(req)); }
public void ShowCharacterSkillTween(MCharacter mCharacter, List <VTile> tiles) { foreach (VTile tile in tiles) { if (tile.IsAttackTween) { continue; } MCharacter character = cBattlefield.charactersManager.GetCharacter(tile.Index); if (character == null || character.Hp == 0 || character.IsHide) { continue; } bool sameBelong = cBattlefield.charactersManager.IsSameBelong(character.Belong, mCharacter.Belong); bool useToEnemy = mCharacter.CurrentSkill.UseToEnemy; if (useToEnemy ^ sameBelong) { GameObject attackTween = cBattlefield.CreateAttackTween(); tile.SetAttackTween(attackTween); attackIcons.Add(attackTween); } /* * if (character == null || cBattlefield.charactersManager.IsSameBelong(character.Belong, mCharacter.Belong)) * { * continue; * }*/ } }
/// <summary> /// 恢复量= /// </summary> /// <param name="attackCharacter">Attack character.</param> /// <param name="targetCharacter">Target character.</param> public int Heal(MCharacter attackCharacter, MCharacter targetCharacter, VTile tile = null, VTile targetTile = null) { MSkill skill = attackCharacter.CurrentSkill; App.Model.Master.MSkill skillMaster = skill.Master; return(1 + attackCharacter.Level + attackCharacter.Ability.MagicAttack * skillMaster.strength); }
public void ClickMovingNode(int index) { if (this.mCharacter.Belong != cBattlefield.currentBelong || this.mCharacter.ActionOver) { CharacterReturnNone(); return; } MCharacter mCharacter = cBattlefield.charactersManager.GetCharacter(index); if (mCharacter != null) { bool sameBelong = cBattlefield.charactersManager.IsSameBelong(mCharacter.Belong, this.mCharacter.Belong); bool useToEnemy = this.mCharacter.CurrentSkill.UseToEnemy; if (useToEnemy ^ sameBelong) { ClickSkillNode(index); } return; } if (cBattlefield.tilesManager.IsInMovingCurrentTiles(index)) { MoveStart(index); } else if (cBattlefield.battleMode != CBattlefield.BattleMode.move_after_attack) { CharacterReturnNone(); } }
public void ShowCharacterSkillArea(MCharacter mCharacter) { //技能攻击扩展范围 List <int[]> distances = mCharacter.SkillDistances; distances.Add(mCharacter.CurrentSkill == null ? new int[] { 0, 0 } : mCharacter.CurrentSkill.Master.distance); //int[] distance = mCharacter.CurrentSkill == null ? new int[]{0,0} : mCharacter.CurrentSkill.Master.distance; int maxDistance = 0; foreach (int[] distance in distances) { if (distance[1] > maxDistance) { maxDistance = distance[1]; } } currentAttackTiles = cBattlefield.breadthFirst.Search(mCharacter, maxDistance); VTile characterTile = currentAttackTiles.Find(v => v.CoordinateX == mCharacter.CoordinateX && v.CoordinateY == mCharacter.CoordinateY); currentAttackTiles = currentAttackTiles.FindAll((tile) => { int length = cBattlefield.mapSearch.GetDistance(tile, characterTile); return(distances.Exists(d => length >= d[0] && length <= d[1])); }); if (mCharacter.CurrentSkill == null) { return; } vBaseMap.ShowAttackTiles(currentAttackTiles); if (mCharacter.Belong == Belong.self && !mCharacter.ActionOver) { ShowCharacterSkillTween(mCharacter, currentAttackTiles); } }
/// <summary> /// 动作结束后处理 /// </summary> public IEnumerator ActionOverNext() { if (cBattlefield.battleMode == CBattlefield.BattleMode.moving) { this.mCharacter.Action = ActionType.idle; } yield return(cBattlefield.StartCoroutine(ActionEndSkillsRun())); this.mCharacter.ActionOver = true; this.mCharacter.roadLength = 0; cBattlefield.tilesManager.ClearCurrentTiles(); cBattlefield.HideBattleCharacterPreviewDialog(); cBattlefield.battleMode = CBattlefield.BattleMode.none; Belong belong = this.mCharacter.Belong; this.mCharacter = null; if (!System.Array.Exists(mBaseMap.Characters, c => c.Hp > 0 && !c.IsHide && c.Belong == belong && !c.ActionOver)) { ChangeBelong(belong); } else { cBattlefield.CloseOperatingMenu(); } }
public void ClickNoneNode(int index) { MCharacter mCharacter = cBattlefield.charactersManager.GetCharacter(index); if (mCharacter != null) { this.mCharacter = mCharacter; this.mCharacter.roadLength = 0; cBattlefield.tilesManager.ShowCharacterMovingArea(mCharacter); cBattlefield.tilesManager.ShowCharacterSkillArea(mCharacter); cBattlefield.OpenBattleCharacterPreviewDialog(mCharacter); oldCoordinate[0] = mCharacter.CoordinateX; oldCoordinate[1] = mCharacter.CoordinateY; ActionType action = mCharacter.Action; float x = mCharacter.X; Direction direction = mCharacter.Direction; if (mCharacter.Belong == Belong.self) { cBattlefield.OpenOperatingMenu(); } returnAction = () => { this.mCharacter.CoordinateY = oldCoordinate[1]; this.mCharacter.CoordinateX = oldCoordinate[0]; this.mCharacter.X = x; this.mCharacter.Direction = direction; this.mCharacter.Action = action; }; } //Debug.LogError("this.mCharacter = " + this.mCharacter + ", mCharacter = " + mCharacter); }
private void SetActionCharacterList(MCharacter actionCharacter, MCharacter targetCharacter, bool canCounter) { int count = cBattlefield.calculateManager.SkillCount(actionCharacter, targetCharacter); int countBack = count; while (count-- > 0) { actionCharacterList.Add(actionCharacter); } if (!canCounter || !cBattlefield.calculateManager.CanCounterAttack(actionCharacter, targetCharacter, actionCharacter.CoordinateX, actionCharacter.CoordinateY, targetCharacter.CoordinateX, targetCharacter.CoordinateY)) { return; } count = cBattlefield.calculateManager.CounterAttackCount(actionCharacter, targetCharacter); while (count-- > 0) { actionCharacterList.Add(targetCharacter); } //反击后反击 if (actionCharacter.CurrentSkill.Master.effect.special == App.Model.Master.SkillEffectSpecial.attack_back_attack) { while (countBack-- > 0) { actionCharacterList.Add(actionCharacter); } } }
private VTile GetNearestNode(MCharacter target, List <VTile> tiles) { if (mCharacter.Mission == Mission.defensive) { return(tiles.Find(t => t.CoordinateX == mCharacter.CoordinateX && t.CoordinateY == mCharacter.CoordinateY)); } if (cBattlefield.tilesManager.CurrentMovingTiles.Count == 1) { return(cBattlefield.tilesManager.CurrentMovingTiles[0]); } tiles.Sort((a, b) => { bool aNotRoad = System.Array.Exists(mBaseMap.Characters, c => c.Hp > 0 && !c.IsHide && c.CoordinateX == a.CoordinateX && c.CoordinateY == a.CoordinateY); if (aNotRoad) { return(1); } bool aCanAttack = cBattlefield.charactersManager.IsInSkillDistance(target.CoordinateX, target.CoordinateY, a.CoordinateX, a.CoordinateY, mCharacter); bool bCanAttack = cBattlefield.charactersManager.IsInSkillDistance(target.CoordinateX, target.CoordinateY, b.CoordinateX, b.CoordinateY, mCharacter); if (aCanAttack && !bCanAttack) { return(-1); } else if (!aCanAttack && bCanAttack) { return(1); } else if (aCanAttack && bCanAttack) { bool aCanCounter = cBattlefield.calculateManager.CanCounterAttack(mCharacter, target, a.CoordinateX, a.CoordinateY, target.CoordinateX, target.CoordinateY); bool bCanCounter = cBattlefield.calculateManager.CanCounterAttack(mCharacter, target, b.CoordinateX, b.CoordinateY, target.CoordinateX, target.CoordinateY); if (aCanCounter && !bCanCounter) { return(1); } else if (!aCanCounter && bCanCounter) { return(-1); } else if (aCanCounter && bCanCounter) { //地形优势 float aTileAid = mCharacter.TileAid(a); float bTileAid = mCharacter.TileAid(b); if (aTileAid < bTileAid) { return(-1); } else if (aTileAid > bTileAid) { return(1); } } } int aDistance = cBattlefield.mapSearch.GetDistance(mCharacter.CoordinateX, mCharacter.CoordinateY, a.CoordinateX, a.CoordinateY); int bDistance = cBattlefield.mapSearch.GetDistance(mCharacter.CoordinateX, mCharacter.CoordinateY, b.CoordinateX, b.CoordinateY); return(aDistance - bDistance); }); return(cBattlefield.tilesManager.CurrentMovingTiles[0]); }
public CharacterDetailPage(MCharacter character) { InitializeComponent(); BindingContext = CharacterDetailsVM = new CharacterDetailsViewModel { Character = character }; CharacterDetailsVM.CheckRelation(); }
public override IEnumerator OnLoad(Request request) { MCharacter mCharacter = Global.SUser.self.characters[0]; this.dispatcher.Set("currentCharacter", mCharacter); this.dispatcher.Set("characters", Global.SUser.self.characters); this.dispatcher.Notify(); yield return(StartCoroutine(base.OnLoad(request))); }