public void MonsterAttackListTest() { // Setup a dummy monster with known moves Monster monster = new Monster(); List <MonsterAction> actList = new List <MonsterAction>(); for (int i = 0; i < 8; i++) { MonsterAction mAct = new MonsterAction(); mAct.Name = "Attack"; mAct.Level = i; mAct.Accuracy = i; mAct.MPCost = i; mAct.Target = "SingleEnemy"; actList.Add(mAct); } monster.ActionList = actList; // Expected odds per slot are roughly 20%, 20%, 20%, 10%, 10%, 10%, 5%, 5% // Using accuracy, build a found moves array and populate it based on GetAction int[] expectedOdds = { 20000, 20000, 20000, 10000, 10000, 10000, 5000, 5000 }; int[] foundOdds = new int[8]; for (int j = 0; j < 100000; j++) { foundOdds[monster.GetAction().Accuracy]++; } // Check that rolled odds are within a threshold of expected odds int threshold = 500; // 0.5% variance for (int ii = 0; ii < 8; ii++) { Assert.IsTrue(Math.Abs(expectedOdds[ii] - foundOdds[ii]) < threshold); } }
public void Ready_BossAttack(GameObject Monster_Group) { Monsters.Clear(); Monster_Group.GetComponent <BoxCollider>().enabled = false; //Monster_Group의 자식 == 출연할 몬스터 for (int i = 0; i < Monster_Group.transform.childCount; i++) { GameObject Monster = Monster_Group.transform.GetChild(i).gameObject; // 만약 자식오브젝트가 Monster가 아니라면 continue한다. if (Monster.CompareTag("Monster") == false) { continue; } MonsterAction monster_action = Monster.GetComponent <MonsterAction>(); PlayerManager.Get_Inctance().Set_ReTarget(monster_action); Monster.SetActive(true); Monsters.Add(Monster); } GameStateManager.Get_Inctance().Set_Boss(); StartCoroutine(Check_PlayerWin()); }
public void SetNextMove(MonsterAction action) { bool isAttack = action.isAttack, isStatus = action.isStatus, isHeal = action.isHeal; currentAction = action; MoveHeart.SetActive(false); MoveClaw.SetActive(false); MoveStatus.SetActive(false); MoveHeal.SetActive(false); if (isAttack || isHeal || isStatus) { MoveHeart.SetActive(true); } if (isAttack) { MoveClaw.SetActive(true); } if (isStatus) { MoveStatus.SetActive(true); } if (isHeal) { MoveHeal.SetActive(true); } if (isAttack) { moveNumber.text = action.GetNumberAttack(); } else { moveNumber.text = ""; } }
// Monster의 Target이 null이거나 active가 false면 PlayerManager에서 ReTarget함수를 실행시킨다. public void Check_Target() { for (int i = 0; i < Monsters.Count; i++) { if (Monsters[i] == null) { continue; } MonsterAction Monster = Monsters[i].GetComponent <MonsterAction>(); if (Monster.Check_StateProvocation()) { PlayerManager.Get_Inctance().Set_ReTarget(Monster); Monster.StartSet_Attack(); return; } else { if (Monster.Target == null || Monster.Target.gameObject.activeSelf == false) { PlayerManager.Get_Inctance().Set_ReTarget(Monster); return; } } } }
public SingleAction(MonsterAction actionType, float execTime, SpeedState speed, Vector3 dirtion) { ActionType = actionType; ExecTime = execTime; Speed = speed; Dirtion = dirtion; }
private void attackToolStripMenuItem_Click(object sender, EventArgs e) { MonsterAction ma = new MonsterAction(); list.Add(new MonsterActionForm(ma).edit(HistoryManager)); fill(); }
protected override Vector3 GenNextOffset(MonsterAction monster, bool init) { Vector3 targetPos = target.transform.position; targetPos.x = Mathf.Min(Mathf.Max(targetPos.x, leftBottomBound.x), rightTopBound.x); targetPos.z = Mathf.Min(Mathf.Max(targetPos.z, leftBottomBound.y), rightTopBound.y); return new Vector3(targetPos.x - monster.transform.position.x, 0f, targetPos.z - monster.transform.position.z); }
public override void Enter(MonsterAction monster) { base.Enter(monster); if (monster.GetComponent<MeshRenderer>() != null) { _oldColor = monster.GetComponent<MeshRenderer>().material.color; monster.GetComponent<MeshRenderer>().material.color = Color.yellow; } }
private void Awake() { // 플레이어 정보 가져오기 _player = GameObject.FindWithTag("Player").transform; //몬스터 스텟 정보 가져오기 _stat = GetComponent <MonsterStat>(); // 애니메이션 정보 가져오기 _ani = GetComponentInChildren <Animator>(); _aniParamID = Animator.StringToHash("CurrentState"); _aniManager = GetComponentInChildren <MonsterAniManager>(); //몬스터 상태, 행동들의 정보 가져오기 MonsterStates[] statesValues = (MonsterStates[])System.Enum.GetValues(typeof(MonsterStates)); MonsterActions[] actionValues = (MonsterActions[])System.Enum.GetValues(typeof(MonsterActions)); //몬스터 상태 스크립트 foreach (MonsterStates s in statesValues) { System.Type StateType = System.Type.GetType("Monster" + s.ToString("G") + "State"); MonsterState state = (MonsterState)GetComponentInChildren(StateType); if (state == null) { state = (MonsterState)transform.Find("StateScript").gameObject.AddComponent(StateType); } state.enabled = false; _states.Add(s, state); } //몬스터 행동 스크립트 foreach (MonsterActions a in actionValues) { System.Type ActionType = System.Type.GetType("Monster" + a.ToString("G")); MonsterAction action = (MonsterAction)GetComponent(ActionType); if (action == null) { action = (MonsterAction)transform.Find("ActionScript").gameObject.AddComponent(ActionType); } action.enabled = false; _actions.Add(a, action); } //행동 바꾸는 코루틴 _actionChangeCoroutine = this.ChangeState(); //몬스터 이동 코루틴 _moveCoroutine = this.monsterMove(); /* 네브메쉬 셋팅 */ _Agent = GetComponent <NavMeshAgent>(); }
public bool Check_MonsterState(GameObject Monster, string State) { MonsterAction monster = Monster.GetComponent <MonsterAction>(); if (monster.state.ToString().Equals(State)) { return(true); } return(false); }
public override void Enter(MonsterAction monster) { base.Enter(monster); _redirectTimer = 0f; _redirectInterval = Random.Range(minRedirectInterval, maxRedirectInterval); if (monster.GetComponent<MeshRenderer>() != null) { _oldColor = monster.GetComponent<MeshRenderer>().material.color; monster.GetComponent<MeshRenderer>().material.color = Color.magenta; } }
// 매개변수 Monster의 Target에 살아있는 Character를 찾아 할당해주는 함수. public void Set_ReTarget(MonsterAction Monster) { for (int i = 0; i < Characters.Length; i++) { if (Characters[i] == null || Characters[i].GetComponent <PlayerAction>().Check_Dead()) { continue; } Monster.Target = Characters[i].GetComponent <PlayerAction>(); } }
private void MoveMonsters() { Dictionary <Vector2Int, NetworkMonster> monsters = Map.I.Monsters; Dictionary <Vector2Int, NetworkMonster> newMonsterPositions = new Dictionary <Vector2Int, NetworkMonster>(monsters); List <NetworkPlayer> players = m_networkManager.ClientPlayers.Values.ToList(); foreach (KeyValuePair <Vector2Int, NetworkMonster> entry in monsters) { Vector2Int currentPosition = entry.Key; NetworkMonster monster = entry.Value; List <Vector2Int> targetTiles = new List <Vector2Int>(); MonsterAction action = MonsterAction.Wait; for (int i = 0; i < m_directions.Length; ++i) { Vector2Int targetTile = currentPosition + m_directions[i]; MonsterAction tempAction = GetMonsterAction(targetTile, newMonsterPositions, players); if (tempAction == MonsterAction.Move) { action = tempAction; targetTiles.Add(targetTile); } else if (tempAction == MonsterAction.Attack) { action = tempAction; targetTiles.Clear(); targetTiles.Add(targetTile); break; } } if (action == MonsterAction.Wait) { continue; } if (action == MonsterAction.Attack) { PerformMonsterAttack(monster, targetTiles[0], players); } else { Vector2Int targetTile = targetTiles[Random.Range(0, targetTiles.Count)]; newMonsterPositions.Add(targetTile, monster); monster.RpcMove(targetTile); newMonsterPositions.Remove(currentPosition); } } Map.I.Monsters = newMonsterPositions; }
public void PlayerTurnAttack(int monsterNum) { targetMonsterIndex = monsterNum; currentTurn = CURRENT_TURN.PLAYER; playerAttackCount += 1; MonsterAction monsterAction = monsters[targetMonsterIndex].GetComponent <MonsterAction>(); string playerName = playerAction.CharacterName(); string monsterName = monsterAction.CharacterName(); battleMsseage = string.Format("{0}の{1}への攻撃", playerName, monsterName); attacker = playerAction; defender = monsterAction; battleProcess = BATTLE_PROCESS.ATTACKING_MESSAGE; }
public void MonsterTurnAttack() { currentTurn = CURRENT_TURN.MONSTER; battleMenu.ControllBasicCommandButtons(false); int monsterIndex = Random.Range(0, monsters.Count); MonsterAction monsterAction = monsters[monsterIndex].GetComponent <MonsterAction>(); string monsterName = monsterAction.CharacterName(); battleMsseage = string.Format("{0}の攻撃", monsterName); attacker = monsterAction; defender = playerAction; battleProcess = BATTLE_PROCESS.ATTACKING_MESSAGE; }
protected override Vector3 GenNextOffset(MonsterAction monster, bool init) { Vector3 currPos = monster.transform.position; //absolutely need some improvement... Vector2 offset; Vector2 target; do { float dist = Random.Range(minDistEachMove, maxDistEachMove); float angle = Random.Range(0, Mathf.PI * 2f); offset = (new Vector2(Mathf.Cos(angle), Mathf.Sin(angle))) * dist; target = new Vector2(currPos.x, currPos.z) + offset; } while (target.x < leftBottomBound.x || target.x > rightTopBound.x || target.y < leftBottomBound.y || target.y > rightTopBound.y); return new Vector3(offset.x, 0f, offset.y); }
//function for creating actions panel private Panel buildMonsterActions() { Panel monsterActionsPanel = new Panel(); monsterActionsPanel.Height = 312; monsterActionsPanel.Width = 975; monsterActionsPanel.Location = new Point((int)((double)currentSelected.Width * 0.3384615384615385), (int)((double)currentSelected.Height * 0.5444325481798715)); monsterActionsPanel.BorderStyle = BorderStyle.FixedSingle; List <MonsterAction> actionList = toFight.getActions(); List <Button> actionButtons = new List <Button>(); for (int i = 0; i < actionList.Count; i++) { //define current Action MonsterAction currAction = actionList[i]; Button actionSelect = new Button(); actionSelect.Width = monsterActionsPanel.Width / actionList.Count; actionSelect.Height = 30; actionSelect.Text = currAction.getActionName(); actionSelect.Location = new Point(i * (monsterActionsPanel.Width / actionList.Count), 0); //if number of uses is limited, include in name if (currAction.getNumberUses() != 0) { actionSelect.Text += "[" + currAction.getNumberUses() + "]"; } //if action is legendary, cover in gold if (currAction.getIsLegendary()) { actionSelect.BackColor = Color.Gold; } //add actionButton to list actionButtons.Add(actionSelect); monsterActionsPanel.Controls.Add(actionSelect); } return(monsterActionsPanel); }
IEnumerator C_Update() { while (true) { // Hpbar의 대상이 죽거나 모종의 이유로 active가 false가 됬을경우 Hpbar의 active를 false한다. if (Target.GetComponent <MonsterAction>().Check_Dead()) { gameObject.SetActive(false); yield break; } float value = 0f; MonsterAction data = Target.GetComponent <MonsterAction>(); value = data.Get_HP() / data.InitHP; Gauge.value = value; yield return(null); } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { try { if (Clipboard.ContainsText()) { HistoryManager?.MakeHistory(null); using (StringReader sr = new StringReader(Clipboard.GetText())) { MonsterAction ma = (MonsterAction)ActionSerializer.Deserialize(sr); if (TraitOnly) { list.Add(new MonsterTrait(ma.Name, ma.Text)); } else { list.Add(ma); } fill(); } } } catch (Exception) { try { if (Clipboard.ContainsText()) { HistoryManager?.MakeHistory(null); using (StringReader sr = new StringReader(Clipboard.GetText())) { list.Add((MonsterTrait)TraitSerializer.Deserialize(sr)); fill(); } } } catch (Exception) { } } }
protected override Vector3 GenNextOffset(MonsterAction monster, bool init) { if (Vector2.Distance(new Vector2(monster.transform.position.x, monster.transform.position.z), new Vector2(predator.transform.position.x, predator.transform.position.z)) > safeRange) return Vector3.zero; else { Vector3 dir = monster.transform.position - predator.transform.position; dir.y = 0f; dir = dir.normalized; Vector3 target = monster.transform.position + dir * safeRange; float[] outOfBoundt = new float[4] { 1f, 1f, 1f, 1f }; if(target.x < leftBottomBound.x) outOfBoundt[0] = Mathf.InverseLerp(monster.transform.position.x, target.x, leftBottomBound.x); if (target.x > rightTopBound.x) outOfBoundt[1] = Mathf.InverseLerp(monster.transform.position.x, target.x, rightTopBound.x); if (target.z < leftBottomBound.y) outOfBoundt[2] = Mathf.InverseLerp(monster.transform.position.z, target.z, leftBottomBound.y); if (target.z > rightTopBound.y) outOfBoundt[3] = Mathf.InverseLerp(monster.transform.position.z, target.z, rightTopBound.y); float mint = 1f; foreach (float t in outOfBoundt) { if (t < mint) mint = t; } target = Vector3.Lerp(monster.transform.position, target, mint); return target - monster.transform.position; } }
public override void Exit(MonsterAction monster) { base.Exit(monster); if (monster.GetComponent<MeshRenderer>() != null) monster.GetComponent<MeshRenderer>().material.color = _oldColor; }
private void populateMonsterInfo() { string monsterQuery = "SELECT * from Monster WHERE Name = '" + this.Name + "'"; using (SqlConnection con = new SqlConnection(connectionString)) { using (SqlDataAdapter adaptor = new SqlDataAdapter(monsterQuery, con)) { DataTable monsterInfo = new DataTable(); adaptor.Fill(monsterInfo); DataTableReader infoReader = monsterInfo.CreateDataReader(); DataRow testRow = monsterInfo.Rows[0]; //fill basic monster info int monsterID = (int)monsterInfo.Rows[0]["MonsterID"]; type = (string)monsterInfo.Rows[0]["Type"]; size = (string)monsterInfo.Rows[0]["Size"]; alignment = (string)monsterInfo.Rows[0]["Alignment"]; maxHP = (int)monsterInfo.Rows[0]["MaxHitPoints"]; currHP = maxHP; ArmorClass = (int)monsterInfo.Rows[0]["AC"]; //fill speeds; walkspeed = (int?)monsterInfo.Rows[0]["LandSpeed"]; //flyspeed try { flyingspeed = int.Parse(monsterInfo.Rows[0]["FlySpeed"].ToString()); } catch (Exception e) { flyingspeed = null; } try { swimspeed = int.Parse(monsterInfo.Rows[0]["SwimSpeed"].ToString()); } catch (Exception e) { swimspeed = null; } try { burrowspeed = int.Parse(monsterInfo.Rows[0]["BurrowSpeed"].ToString()); }catch (Exception e) { burrowspeed = null; } //fill senses/skills senses = monsterInfo.Rows[0]["Senses"].ToString(); skills = monsterInfo.Rows[0]["Skills"].ToString(); //fill saving throws savingThrows = monsterInfo.Rows[0]["SavingThrows"].ToString(); //fill Languages string langaugeQuery = "SELECT Name From Languages as c LEFT JOIN Languages_xref as a ON((C.LanguageID = a.LanguageID)) WHERE a.MonsterID = '" + monsterID + "'"; using (SqlConnection languageConnection = new SqlConnection(connectionString)) { using (SqlDataAdapter languageAdaptor = new SqlDataAdapter(langaugeQuery, languageConnection)) { DataTable languageTable = new DataTable(); languageAdaptor.Fill(languageTable); foreach (DataRow languageRow in languageTable.Rows) { Languages.Add(((string)languageRow["Name"])); } } } //fill immunities immunities = new List <string>(); string ImminutiesQuery = "SELECT Name From DamageTypes as c LEFT JOIN DamageTypes_xref as a ON((C.DamageTypeID = a.DamageTypeID) AND a.ResistanceIndicator = '1') WHERE a.MonsterID = '" + monsterID + "'"; using (SqlConnection ImmunitiesConnection = new SqlConnection(connectionString)) { using (SqlDataAdapter languageAdaptor = new SqlDataAdapter(ImminutiesQuery, ImmunitiesConnection)) { DataTable immunitiesTable = new DataTable(); languageAdaptor.Fill(immunitiesTable); foreach (DataRow languageRow in immunitiesTable.Rows) { immunities.Add((((string)languageRow["Name"]))); } } } //fill actions string actionQuery = "Select * From MonsterActions Where MonsterID = '" + monsterID + "'"; actionList = new List <MonsterAction>(); using (SqlConnection ActionsConnection = new SqlConnection(connectionString)) { using (SqlDataAdapter actionsAdaptor = new SqlDataAdapter(actionQuery, ActionsConnection)) { DataTable actionsTable = new DataTable(); actionsAdaptor.Fill(actionsTable); foreach (DataRow actionRow in actionsTable.Rows) { string actionName = actionRow["Name"].ToString(); string actionDescription = actionRow["Description"].ToString(); bool isLegendary = (bool)actionRow["LegendaryIndicator"]; int numberUses; try { numberUses = (int)actionRow["Uses"]; }catch (Exception e) { numberUses = 0; } MonsterAction toAdd = new MonsterAction(actionName, isLegendary, actionDescription, numberUses); actionList.Add(toAdd); } } } //fill resistances //fill baseStats strength = (int)monsterInfo.Rows[0]["Strength"]; intelligence = (int)monsterInfo.Rows[0]["Intelligence"]; dexterity = (int)monsterInfo.Rows[0]["Dexterity"]; wisdom = (int)monsterInfo.Rows[0]["Wisdom"]; constitution = (int)monsterInfo.Rows[0]["Constitution"]; charisma = (int)monsterInfo.Rows[0]["Charisma"]; con.Close(); } } }
IEnumerator C_Update() { while (true) { // 만약 Hpbar의 대상이 없으면 Hpbar의 Active를 false한다. if (Target == null) { gameObject.SetActive(false); yield break; } // Hpbar의 대상이 죽거나 모종의 이유로 active가 false가 됬을경우 Hpbar의 active를 false한다. if (Target.activeSelf == false) { gameObject.SetActive(false); yield break; } // Hp / Hp초기값을 담을 변수 float value = 0f; //Target에 해당하는 스크립트를 가져와 value값을 준다. //만약 Target이 잘못된경우 Log를 찍고 코루틴을 종료한다. if (Target.CompareTag("Monster")) { MonsterAction data = Target.GetComponent <MonsterAction>(); value = data.Get_HP() / data.InitHP; } else if (Target.CompareTag("Player")) { PlayerAction data = Target.GetComponent <PlayerAction>(); value = data.Get_HP() / data.Init_Infomation.Hp; } else { Debug.Log("잘못된 Target입니다!"); yield break; } //Gauge의 길이를 value에 맞게 설정한다. Gauge.fillAmount = value; //만약 Gauge가 0이하일경우 0으로 고정한다. if (Gauge.fillAmount <= 0) { Gauge.fillAmount = 0; } //Target의 월드상위치를 Camera의 뷰위치로 변환한다. if (Camera.main == null) { yield return(new WaitForSeconds(1.0f)); } Vector3 p = Camera.main.WorldToViewportPoint(Target.transform.position); //Taget의 뷰위치를 UICamera의 뷰위치로 변환후 Hpbar의 위치로 할당한다. this.transform.position = UICamera.mainCamera.ViewportToWorldPoint(p); p = this.transform.localPosition; // RoundToInt(value) == value값과 가까운 정수를 반환한다. p.x = Mathf.RoundToInt(p.x); //실제 오브젝트보다 Hpbar가 위에 있어야하기때문에 y값을 추가한다. p.y = Mathf.RoundToInt(p.y) + 200f; p.z = 0f; this.transform.localPosition = p; yield return(null); } }
protected void SetMonsterAction(MonsterAction monsterAction) { mMonsterAction = monsterAction; //Debug.LogFormat("SetMonsterAction:{0}", mMonsterAction); }
public void GetMonsterByNameTest() { // Test invalid inputs Assert.ThrowsException <ArgumentException>(() => MonsterManager.GetMonsterByName(null)); Assert.ThrowsException <ArgumentException>(() => MonsterManager.GetMonsterByName("")); Assert.ThrowsException <Exception>(() => MonsterManager.GetMonsterByName("INVALIDNAMEDONTNAMEAMONTSERTHIS")); // Test that monsters properly load with known stats from data Monster monster = MonsterManager.GetMonsterByName("LegEater"); Assert.AreEqual(6, monster.HP); Assert.AreEqual(6, monster.HPMax); Assert.AreEqual(0, monster.MP); Assert.AreEqual(0, monster.MPMax); Assert.AreEqual(4, monster.Strength); Assert.AreEqual(0, monster.Defense); Assert.AreEqual(180, monster.Fear); Assert.AreEqual(1, monster.Hits); Assert.AreEqual(0, monster.Blocks); Assert.AreEqual(1, monster.MagicBlocks); Assert.AreEqual(60, monster.Accuracy); Assert.AreEqual(0, monster.Evasion); Assert.AreEqual(50, monster.MagicEvasion); HashSet <MonsterFamily> familySet = new HashSet <MonsterFamily>() { MonsterFamily.Earth }; Assert.IsTrue(monster.Families.SetEquals(familySet)); HashSet <Element> resistSet = new HashSet <Element>() { Element.Mind, Element.Body }; Assert.IsTrue(monster.Resistances.SetEquals(resistSet)); HashSet <Element> weakSet = new HashSet <Element>() { }; Assert.IsTrue(monster.Weaknesses.SetEquals(weakSet)); HashSet <Element> absorbSet = new HashSet <Element>() { }; Assert.IsTrue(monster.Absorbs.SetEquals(absorbSet)); HashSet <string> atkEffectList = new HashSet <string>() { }; Assert.IsTrue(monster.AttackEffects.SetEquals(atkEffectList)); // Create an all-attack actionList to compare against MonsterAction attack = new MonsterAction("Attack", 0, 0, 0, "SingleTarget"); List <MonsterAction> actionList = new List <MonsterAction>(); for (int i = 0; i < 8; i++) { actionList.Add(attack); } Assert.IsTrue(monster.ActionList.SequenceEqual(actionList)); // gildrops // itemdrops }
public void SetNextMove() { nextMonsterAction = enemy.GetMove(enemyHealthAndStatus.currentHealth / enemyHealthAndStatus.maximumHealth); NextMoveDisplay.instance.SetNextMove(nextMonsterAction); }