public RPGCharacter RemoveCharacterFromID(int id) { RPGCharacter rm = null; foreach (var v in players.Players) { if (v.Logic.GetID() == id) { rm = v; } } if (rm != null) { RemoveCharacter(rm); } foreach (var v in enemies.Enemies) { if (v.Logic.GetID() == id) { rm = v; } } if (rm != null) { RemoveCharacter(rm); } return(null); }
public void Possess(RPGCharacter _character) { UnPossess(); this.character = _character; this.character.SetController(this); this.camera.SetCharacter(_character.transform); }
public void AddEnemyToBattle(RPGCharacter ch) { UnityEngine.Assertions.Assert.AreEqual(ch.GetCamp(), EnumCharacterCamp.Enemy); RPGEnemy player = ch as RPGEnemy; enemies.Enemies.Add(player); }
/// <summary> /// 用于敌方行动回合移动到指定位置并攻击 /// </summary> public void MoveThenAttack(RPGCharacter Gamechar, int x, int y, UnityAction callStart = null, UnityAction callEnd = null) //直接移动到指定的地点,用于自动攻击的单位 { //Gamechar.SetTileCoord(x, y, false); Vector2Int point = new Vector2Int(x, y); if (_FootData.ContainsKey(point)) { buildMoveRoutine(x, y); } if (_MoveRoute != null) { if (_MoveRoute.Count > 1)//如果在原地则不移动,否则进行移动 { Vector3[] paths = new Vector3[_MoveRoute.Count]; int c = 0; for (int i = 0; i < _MoveRoute.Count; i++)//将动画数组复制到空间坐标 { //paths[c] = Vector2Int.Vector2IntToVector3(_MoveRoute[i].x, _MoveRoute[i].y, true); c++; } iTweenGameCharMove(Gamechar, paths, callStart, callEnd); } else { OnMoveEnd(Gamechar); } } }
public void KillUnitAt(Vector2Int tilePos, float v, UnityAction onComplete, bool triggerDeadEvent = false) { RPGCharacter ch = chapterManager.GetCharacterFromCoord(tilePos); KillUnit(ch, v, onComplete, triggerDeadEvent); PositionMath.ResetTileOccupyStatus(tilePos); }
void OnMoveStart(RPGCharacter Gamechar) { if (FuncMoveStart != null && FuncMoveStart.GetPersistentEventCount() > 0) { FuncMoveStart.Invoke(); } }
private void iTweenGameCharMove(RPGCharacter Gamechar, Vector3[] paths, UnityAction callStart, UnityAction callEnd) { //FuncMoveStart.RemoveAllListeners(); //FuncMoveEnd.RemoveAllListeners(); //FuncMoveStart.AddListener(callStart); //FuncMoveEnd.AddListener(callEnd); //Hashtable args = new Hashtable(); ////设置路径的点 //args.Add("path", paths); ////设置类型为线性,线性效果会好一些。 //args.Add("easeType", iTween.EaseType.linear); ////设置寻路的速度 //args.Add("speed", 15f); ////是否先从原始位置走到路径中第一个点的位置 //args.Add("movetopath", true); ////是否让模型始终面朝当面目标的方向,拐弯的地方会自动旋转模型 ////如果你发现你的模型在寻路的时候始终都是一个方向那么一定要打开这个 //args.Add("orienttopath", true); //args.Add("onstart", "OnMoveStart"); //args.Add("onstartparams", Gamechar); //args.Add("onstarttarget", gameObject); ////设置接受方法的对象,默认是自身接受,这里也可以改成别的对象接受, ////那么就得在接收对象的脚本中实现AnimationStart方法。 //args.Add("oncomplete", "OnMoveEnd"); //args.Add("oncompleteparams", Gamechar); //args.Add("oncompletetarget", gameObject); //iTween.MoveTo(Gamechar.GetGameObject(), args); }
private void InitUseProps(RPGCharacter Character) { for (int i = 0; i < Character.Logic.Info.Items.Props.Count; i++) { PropsItem item = Character.Logic.Info.Items.Props[i]; } }
public void exchangeItem(int char_Index0, int item_Index0, int char_Index1, int item_Index1) { RPGCharacter ch0 = _gameCharList[char_Index0]; RPGCharacter ch1 = _gameCharList[char_Index1]; WeaponItem item0 = ch0.Logic.Info.Items.GetWeaponByIndex(item_Index0); WeaponItem item1 = ch1.Logic.Info.Items.GetWeaponByIndex(item_Index1); if (item0 == null) { return; } if (item1 == null) { ch0.Logic.Info.Items.RemoveWeaponByIndex(item_Index0); ch1.Logic.Info.Items.AddWeapon(item0, null); } else { ch0.Logic.Info.Items.RemoveWeaponByIndex(item_Index0); ch1.Logic.Info.Items.RemoveWeaponByIndex(item_Index1); ch0.Logic.Info.Items.AddWeapon(item1, item_Index0); ch1.Logic.Info.Items.AddWeapon(item0, item_Index1); } ipBottom.Init(_gameCharList[selectedCharIndex].Logic); ipTop.Init(_gameCharList[exchangeCharIndex].Logic); }
public override bool OnStopExecuting() { Vector2Int startPos = Routine.First(); Vector2Int endPos = Routine.Last(); Assert.IsFalse(startPos == endPos, "移动点和终结点相同"); RPGCharacter ch = null; if (CharacterID >= 0) { ch = gameMode.ChapterManager.GetCharacterFromID(CharacterID); Assert.IsNotNull(ch, startPos + "处不存在角色"); var chPos = ch.GetTileCoord(); Assert.IsTrue(startPos == chPos, "移动起始点" + startPos + "与角色所在位置" + chPos + "不相符"); } else { ch = gameMode.ChapterManager.GetCharacterFromCoord(startPos); Assert.IsNotNull(ch, startPos + "处不存在角色"); } ch.Logic.SetTileCoord(endPos); gameMode.BattlePlayer.MoveUnitByRoutine(Routine, 0, null); return(true); }
public void Show(RPGCharacter ch) { if (ch != null) { var logic = ch.Logic; charIcon.sprite = logic.GetPortrait(); charName.text = logic.GetName(); hp.text = logic.GetCurrentHP() + "/" + ch.Logic.GetMaxHP(); lv.text = ch.Logic.GetLevel().ToString(); WeaponItem item = ch.Logic.Info.Items.GetEquipWeapon(); if (item != null) { weaponIcon.gameObject.SetActive(true); weaponName.text = item.GetDefinition().CommonProperty.Name; weaponIcon.sprite = item.GetDefinition().Icon; } else { weaponIcon.gameObject.SetActive(false); weaponName.text = null; weaponIcon.sprite = null; } gameObject.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z); gameObject.SetActive(true); } else { gameObject.SetActive(false); } }
public void init(int index, RPGCharacter ch) { CharIndex = index; gameChar = ch; textName.text = ch.Logic.GetName(); imageIcon.sprite = ch.Logic.GetPortrait(); }
public override void Action() { base.Action(); RPGCharacter target = Target(); if (target == null) { return; } EquipWeapon(target.Logic); var side = PositionMath.GetSidewayTilePos(target.GetTileCoord()); var avSidePos = PositionMath.MoveableAreaPoints.Intersect(side).ToList(); if (avSidePos.Count == 0) { return; } Vector2Int bestPos = PositionMath.GetBestTilePos(avSidePos); List <Vector2Int> routines = PositionMath.GetMoveRoutine(bestPos); var move = AddSequenceEvent <MoveCharacter>(); move.CameraFollow = true; move.Routine = routines; move.CharacterID = -1; move.WaitUntilFinished = true; move.Speed = EModeSpeed.Normal; BattlePlayer.AssembleAttackSequenceEvent(AddSequenceEvent <AttackAnimation>, logic, target.Logic); }
/// <summary> /// 添加到战场 /// </summary> public void AddPlayerToBattle(RPGCharacter ch) { UnityEngine.Assertions.Assert.AreEqual(ch.GetCamp(), EnumCharacterCamp.Player); RPGPlayer player = ch as RPGPlayer; players.Players.Add(player); players.PlayersLogic.Add(player.Logic); }
public Inventory(RPGCharacter _owner, ItemSlotBehaviour[] behaviours = null, ItemCondition[] conditions = null) { owner = _owner; Behaviours = behaviours; Conditions = conditions; Items = new List <ItemSlot> (); }
void OnMoveEnd(RPGCharacter Gamechar) //移动结束后 { if (FuncMoveEnd != null) { FuncMoveEnd.Invoke(); } Clear(); }
private void Check() { if (!enabled) { return; } RPGCharacter[] characters = RPGCharacter.All.ToArray(); Vector3 position = transform.position; for (int i = characters.Length - 1; i >= 0; i--) { RPGCharacter character = characters[i]; if (character.gameObject.activeInHierarchy && Distance > Vector3.Distance(character.transform.position, position)) { if (!InProximity.Contains(character)) { if (Conditions != null) { bool result = true; foreach (Func <RPGCharacter, bool> condition in Conditions.GetInvocationList()) { if (!condition(character)) { result = false; break; } } if (!result) { continue; } } InProximity.Add(character); if (OnEnter != null) { OnEnter(character); } } } else { if (InProximity.Contains(character)) { InProximity.Remove(character); if (OnExit != null) { OnExit(character); } } } } }
public void Show(RPGCharacter ch) { /*List<int> keyList = ch.SkillGroup.getAllActionSkill();//获取任务所有主动技能 * for (int i = 0; i < keyList.Count; i++) * { * AddButton(keyList[i]);//添加按钮 * } * this.gameObject.SetActive(true);*/ }
public void UnPossess() { if (this.character) { this.character.SetController(null); } this.character = null; this.camera.SetCharacter(null); }
public string GetHit(RPGCharacter ch, RPGCharacter enemy) { int hit = ch.Logic.GetHit() - enemy.Logic.GetAvoid(); if (hit < 0) { hit = 0; } return(hit.ToString()); }
/// <summary> /// 如果是显示使用道具传入true,装备武器传入false /// </summary> /// <param name="Props"></param> public void Show(RPGCharacter Character, bool UseProps) { base.Show(); if (UseProps) { } else { } }
public ItemSlot (RPGCharacter _owner, ItemSlotBehaviour[] behaviours = null, ItemCondition[] conditions = null) { owner = _owner; Behaviours = behaviours; Conditions = conditions; foreach (ItemSlotBehaviour behaviour in Behaviours) { behaviour.Setup (this); } }
public void Change(RPGCharacter ch, int ChangedHP, float delayTime = 0.0f) { if (ch.GetCamp() == EnumCharacterCamp.Player) { Player.Change(ChangedHP, delayTime); } else { Enemy.Change(ChangedHP, delayTime); } }
private void OnTriggerEnter(Collider other) { RPGCharacter character = other.GetComponent <RPGCharacter> (); AddResult result = character.inventory.Add(item); if (result == AddResult.Complete) { Destroy(gameObject); } }
public void GrantRewards(RPGCharacter character) { foreach (ItemGenerator generator in Rewards) { if (generator == null || generator.RewardTemplate == null) { continue; } character.inventory.Add(generator.Generate()); } }
public override void OnEnter() { int id = ID; if (ID < 0) { id = gameMode.BattleManager.CurrentCharacterLogic.GetID();; } RPGCharacter ch = gameMode.ChapterManager.GetCharacterFromID(id); gameMode.unitShower.Shake(ch.GetSpriteRender(), direction, duration, intensity, () => DelayContinue(delayContinue)); }
public string GetCritical(RPGCharacter ch, RPGCharacter enemy) { int cri = ch.Logic.GetCritical(); int criavoid = enemy.Logic.GetCriticalAvoid(); int critical = cri - criavoid; if (critical < 0) { critical = 0; } return(critical.ToString()); }
public void InitActionScope(RPGCharacter Gamechar, int Movement, bool Show = true) { HideAllRange(); bPlayer = (Gamechar.GetCamp() == EnumCharacterCamp.Player);//0,2为我方的单位 _Mov = Movement; /* if (Gamechar.SkillGroup.isHaveStaticSkill(18))//探险家,无视地形,将其职业设为天马 * _Job = 15;//medifyneed * if (Gamechar.SkillGroup.isHaveStaticSkill(19)) * _Mov += 2;*/ _Career = Gamechar.Logic.GetCareer(); CharacterCenter = new Vector2Int(Gamechar.GetTileCoord().x, Gamechar.GetTileCoord().x); ResetMoveAcessList(); bMoveAcessList[CharacterCenter.x, CharacterCenter.y] = true; bMoveAcessListExcluded[CharacterCenter.x, CharacterCenter.y] = true; _FootData.Add(CharacterCenter, new Vector2Int(-1, -1)); _TempFootData.Add(CharacterCenter, _Mov); int countPoint = 0; while (countPoint < _Mov) { _FindDistance(Gamechar.Logic.GetCareer(), _Mov);//递归查询距离 _FindDistance(Table._JobTable.getBranch(gamechar.attribute.Job), _Mov, 0, 0); countPoint++; } WeaponItem item = Gamechar.Logic.Info.Items.GetEquipWeapon(); item = new WeaponItem(1); if (item != null)//装备武器不为空 { _AttackRangeData.Clear(); _ItemRangeMin = item.GetDefinition().RangeType.SelectRange.x; _ItemRangeMax = item.GetDefinition().RangeType.SelectRange.y; _WeaponRangeType = item.GetDefinition().RangeType.SelectType; if (_ItemRangeMax != 0 && _ItemRangeMax - _ItemRangeMin > -1) //武器有距离 { for (int i = 0; i < PList.Count; i++) //遍历可移动的区域 { AttackScan(PList[i]); //递归查询距离 _FindDistance(Table._JobTable.getBranch(gamechar.attribute.Job), _Mov, 0, 0); } } } if (Show) { ShowMoveableRange(); ShowAttackableRange(); } }
public override void Action() { base.Action(); RPGCharacter target = Target(); if (target == null) { Debug.Log("攻击范围内没有找到目标"); return; } EquipWeapon(target.Logic); BattlePlayer.AssembleAttackSequenceEvent(AddSequenceEvent <AttackAnimation>, logic, target.Logic); }
public void Init() { Initialized = true; Character = new RPGCharacter(player); Inventory = new InventoryHandler(this); if (!Main.dedServ && player.IsLocalPlayer()) { _guiHandler = new GUIHandler(); } }