public void ReAutoTarget() { // 타겟을 재 탐색합니다. mMonsterCount -= 1; TargetMonster = null; if(mMonsterCount == 0) { // 몬스터를 모두 클리어 하였습니다. Debug.Log ("Clear"); mLoopCount -= 1; // 모든 공격과 스텝을 중지시킵니다. StopCoroutine("ArcherAttack"); StopCoroutine("MonsterAttack"); StopCoroutine("AutoStep"); if(mLoopCount == 0) { // 모든 스테이지가 클리어 되었습니다. Debug.Log("Stage All Clear"); GameOver(); return; } // 던전 스텝을 초기화 시키고 다시 순환 시킵니다. mStatus = Status.Idle; StartCoroutine("AutoStep"); return; } // 타겟 재 탐색 GetAutoTarget(); }
public void ReAutoTarget() { //타깃을 재탐색합니다. mMonsterCount -= 1; TargetMonster = null; if (mMonsterCount == 0) { //몬스터를 모두 클리어했습니다. Debug.Log("Clear"); if (mStatus == Status.GameOver) { return; } //모든 공격과 스텝을 중지시킵니다. StopCoroutine("ArcherAttack"); StopCoroutine("MonsterAttack"); StopCoroutine("AutoStep"); //던전 스텝을 초기화시키고 다시 순환시킵니다. mStatus = Status.Idle; StartCoroutine("AutoStep"); return; } //타깃 재탐색 GetAutoTarget(); }
/// <summary> /// 造成伤害 /// </summary> /// <param name="attackHurtStruct"></param> public override CalculateHurt.Result GiveAttackHurtStruct(AttackHurtStruct attackHurtStruct) { MonsterControl monsterControl = GetComponent <MonsterControl>(); if (monsterControl != null && monsterControl.monsterDataInfo != null && monsterControl.monsterDataInfo.MonsterBaseAttribute != null) { PhysicDefenseFactor physicDefenseFactor = monsterControl.monsterDataInfo.PhysicDefenseFactor; //物理防御系数 MagicDefenseFactor magicDefenseFactor = monsterControl.monsterDataInfo.MagicDefenseFactor; //魔法防御系数 CalculateHurt.Result result = CalculateHurt.Calculate(attackHurtStruct, monsterControl.thisAttribute, physicDefenseFactor, magicDefenseFactor); monsterControl.GiveHit(); //显示伤害 base.ShowHurt(result, gameObject); //显示怪物的血条 iGameState.ShowMonsterHP = new MonsterHPUIStruct() { monsterName = monsterControl.monsterDataInfo.monsterPrefabName, maxHP = monsterControl.thisAttribute.MaxHP, nowHP = monsterControl.thisAttribute.HP, monsterObj = gameObject }; return(result); } return(default(CalculateHurt.Result)); }
private IEnumerator routine; //コルーチン // Use this for initialization void Start() { routine = Appearance(); monsterControl = GameObject.Find("GameRoot").GetComponent <MonsterControl>(); //配列の確保 existEnemys = new GameObject[createMonsters]; }
public void Shoot(MonsterControl monster) { mMonster = monster; Vector2 randomPos = Random.insideUnitCircle * 0.2f; iTween.MoveTo(gameObject, iTween.Hash("position", monster.transform.position + new Vector3(randomPos.x, randomPos.y, 0), "easetype", iTween.EaseType.easeOutCubic, "time", 0.3f)); }
public void ReAutoTarget() { mMonsterCount -= 1; Debug.Log ("몬스터 카운트= "+mMonsterCount); TargetMonster = null; if (mMonsterCount == 0) { //한 스테이지 클리어 mLoopCount -= 1; StopCoroutine ("HeroAutoAttack"); StopCoroutine ("HeroSkillAttack"); //mIngTextMassage.text = "모든 적을 격파"; if (mLoopCount == 0) { //모든 스테이지 클리어. -> 승리 결과창. mIngTextMassage.text = "스테이지 클리어!"; //Invoke ("GameOver", 2); GameOver(); return; } mStageStatus = StageStatus.Idle; StartCoroutine ("AutoStep"); return; } //타겟 재 탐색. GetSingleAutoTarget(); }
public void ReAutoTarget() { mMonsterCount -= 1; Debug.Log("몬스터 카운트= " + mMonsterCount); TargetMonster = null; if (mMonsterCount == 0) { //한 스테이지 클리어 mLoopCount -= 1; StopCoroutine("HeroAutoAttack"); StopCoroutine("HeroSkillAttack"); //mIngTextMassage.text = "모든 적을 격파"; if (mLoopCount == 0) { //모든 스테이지 클리어. -> 승리 결과창. mIngTextMassage.text = "스테이지 클리어!"; //Invoke ("GameOver", 2); GameOver(); return; } mStageStatus = StageStatus.Idle; StartCoroutine("AutoStep"); return; } //타겟 재 탐색. GetSingleAutoTarget(); }
private void GetSingleAutoTarget() { //1. HP로 소팅할 경우 이거 참조.. //TargetMonster = mMonster01.Where(m=>m.mHP > 0).OrderBy(m=>m.mHP).First(); //2. 타겟 넘버를 지정 맨 앞에 를 타겟으로 잡는다. TargetMonster = mMonster01.Where(m => m.TargetNumber > 0).OrderBy(m => m.TargetNumber).First(); TargetMonster.SetSingleTarget(); }
private void GetAutoTarget() { //Hp가 가장 낮은 몬스터를 타깃팅합니다. TargetMonster = mMonster.Where(m => m.mHp > 0).OrderBy(m => m.mHp).First(); //타깃은 충돌체가 준비됩니다. TargetMonster.SetTarget(); }
private void Awake() { aiPathStatus = gameObject.GetComponent <Pathfinding.AIPath>(); positionConstraint = gameObject.GetComponent <PositionConstraint>(); rigidbody = gameObject.GetComponent <Rigidbody>(); monsterControl = GameObject.Find("GameManager").GetComponent <MonsterControl>(); HookObj = GameObject.Find("Hook").gameObject; }
public void AddMonster(MonsterControl monster, float hurt) { if (!monsterAttackDict.ContainsKey(monster)) { monsterAttackDict.Add(monster, new List<float>()); } monsterAttackDict[monster].Add(hurt); }
void Start() { ob = PlayManager.Instance.GetTheObject(); pl = PlayManager.Instance.GetData(); parentMonster = GetComponentInParent <Monster>(); control = parentMonster.GetComponent <MonsterControl>(); moveToOb = new MonsterMoveAI(MoveToObject); moveToPl = new MonsterMoveAI(MoveToPlayer); control.monsterMoveAI += moveToOb; }
public void Shoot(MonsterControl monster) { mMonster = monster; //계층 뷰(Hierachy View)에서 Archer 게임오브젝트 Find mArcher = GameObject.Find("Archer").gameObject; Vector2 randomPos = Random.insideUnitCircle * 0.3f; iTween.MoveTo(gameObject, iTween.Hash("Position", mArcher.transform.position + new Vector3(randomPos.x, 1.5f + randomPos.y, 0), "easetype", iTween.EaseType.easeOutCubic, "time", 0.5f)); }
public void MonsterDie(MonsterControl monster, bool alive = false) { if (!alive) { CoinChange(100); } sceneMonsterList.Remove(monster); if (sceneMonsterList.Count <= 0) { //下一波 if (monsterSpawnIndex < _levelData.monsterIdList.Count) { CoinChange(300); if (monsterSpawnIndex == _levelData.monsterIdList.Count - 1) { if (spawnState) { return; } spawnState = true; WindowMgr.instance.ShowWindow <DialogWindow>() .Init(5, 7, () => { StartCoroutine(YanShi(5)); }); } else { if (spawnState) { return; } spawnState = true; StartCoroutine(YanShi(5)); } } else { //打完了 if (monsterSpawnIndex >= _levelData.monsterIdList.Count) { if (!gameEnd) { WindowMgr.instance.ShowWindow <GameEndWindow>().Init(true); } } } } }
private void GetSingleAutoTarget() { //1. HP로 소팅할 경우 이거 참조.. //TargetMonster = mMonster01.Where(m=>m.mHP > 0).OrderBy(m=>m.mHP).First(); //2. 타겟 넘버를 지정 맨 앞에 를 타겟으로 잡는다. if (mStageStatus == StageStatus.Battle) { TargetMonster = mMonster01.Where(m => m.TargetNumber > 0).OrderBy(m => m.TargetNumber).First(); TargetMonster.SetSingleTarget(); } else { //Debug.Log ("not in battle"); } }
void Update() { if(_target == null) { bool isTarget = false; // Find Monster foreach(var m in _monsterGenerator.MonsterControls) { if (m.Targeting == null) { isTarget = true; _target = m; m.Targeting = this; break; } } if(!isTarget) { // 가장 가까운 타겟으로 설정. foreach (var m in _monsterGenerator.MonsterControls) { _target = m; break; } } _animator.SetBool("Attack", false); } else { //Debug.Log("_taget != null"); if(Vector2.Distance(transform.position, _target.transform.position) < 0.8f) { _animator.SetBool("Attack", true); } else { // move transform.position = Vector2.MoveTowards(transform.position, _target.transform.position, _speed * Time.deltaTime); _animator.SetBool("Attack", false); } } }
void Update() { if (_target == null) { bool isTarget = false; // Find Monster foreach (var m in _monsterGenerator.MonsterControls) { if (m.Targeting == null) { isTarget = true; _target = m; m.Targeting = this; break; } } if (!isTarget) { // 가장 가까운 타겟으로 설정. foreach (var m in _monsterGenerator.MonsterControls) { _target = m; break; } } _animator.SetBool("Attack", false); } else { //Debug.Log("_taget != null"); if (Vector2.Distance(transform.position, _target.transform.position) < 0.8f) { _animator.SetBool("Attack", true); } else { // move transform.position = Vector2.MoveTowards(transform.position, _target.transform.position, _speed * Time.deltaTime); _animator.SetBool("Attack", false); } } }
/// <summary> /// 检测到攻击触发到对象(注意通过该函数实现的都是物理攻击,魔法攻击请在各自的子类中独立实现) /// </summary> /// <param name="iOjbInteractive"></param> protected virtual void CheckTargetResult(IObjInteractive iOjbInteractive) { if (NowCheckFrame == null) { return; } if (attackAnimationTime > NowCheckFrame.endTime || attackAnimationTime < NowCheckFrame.startTime) { return; } if (tempCheckedTargetList.Contains(iOjbInteractive)) { return; } tempCheckedTargetList.Add(iOjbInteractive); //计算伤害 MonsterControl monsterControl = GetComponent <MonsterControl>(); if (monsterControl == null) { return; } IAttributeState iAttributeState = monsterControl.GetMonsterAttributeState(); if (iAttributeState == null) { return; } iAttributeState.PhysicsAttacking *= NowCheckFrame.magnification; AttackHurtStruct attackHurtStruct = new AttackHurtStruct() { attributeState = iAttributeState, hurtFromObj = gameObject, hurtType = EnumHurtType.NormalAction, //怪物的伤害都依照普通攻击来计算(普通攻击和技能的区别暂时不知道) statusLevelDataInfos = new StatusDataInfo.StatusLevelDataInfo[0], //暂时没有附加状态 hurtTransferNum = 0, thisUsedMana = 0 //物理技能没有耗魔 }; iOjbInteractive.GiveAttackHurtStruct(attackHurtStruct); }
IEnumerator SpawnMonster() { Game.instance.DisplayNum(monsterSpawnIndex + 1, _levelData.monsterIdList.Count); List <LevelMonsterData> levelMonsterData = _levelData.monsterIdList[monsterSpawnIndex]; for (int i = 0; i < levelMonsterData.Count; i++) { GameObject monster = Instantiate(monsterList[levelMonsterData[i].monsterId], monsterContent); MonsterControl monsterControl = monster.GetComponent <MonsterControl>(); monsterControl.InitPath(monsterPathList[levelMonsterData[i].pathId].pathList); monster.SetActive(true); sceneMonsterList.Add(monsterControl); if (i == levelMonsterData.Count - 1) { spawnState = false; } yield return(waitForSeconds); } monsterSpawnIndex++; }
private void ResetMonsterStates(MonsterControl ec, SingleActionRecord monsterRecord) { ec.SetCdLabel(monsterRecord.getIntProp(BattleRecordConstants.BATTLE_MONSTER_SKILL_ROUND)); }
public virtual void Start() { monsterControl = GetComponent <MonsterControl>(); }
private void GetSingleAutoTarget() { //1. HP로 소팅할 경우 이거 참조.. //TargetMonster = mMonster01.Where(m=>m.mHP > 0).OrderBy(m=>m.mHP).First(); //2. 타겟 넘버를 지정 맨 앞에 를 타겟으로 잡는다. TargetMonster = mMonster01.Where (m => m.TargetNumber > 0).OrderBy (m => m.TargetNumber).First (); TargetMonster.SetSingleTarget (); }
/// <summary> /// 检测怪物数据的状态 /// 和玩家位置进行对比,用于创建移动或设置怪物AI /// </summary> private void CheckMonsterDataInfoState() { if (monsterDataInfos == null || thisSceneCanCheckMonsterObjDic == null || allMonsterObjDic == null || thisSceneCanCheckMonsterObjList == null) { return; } IPlayerState iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); if (iPlayerState.PlayerObj == null) { return; } //判断大区域 bool objListChanged = false;//对象集合是否发生了变化 //检测触发区域是否会发生变化 foreach (MonsterDataInfo monsterDataInfo in monsterDataInfos) { float distance = Vector2.Distance( new Vector2(monsterDataInfo.Center.x, monsterDataInfo.Center.z) , new Vector2(iPlayerState.PlayerObj.transform.position.x, iPlayerState.PlayerObj.transform.position.z)); if (distance > monsterDataInfo.Range + MaxRangeLeaveDistance) { if (thisSceneCanCheckMonsterObjDic.ContainsKey(monsterDataInfo)) { thisSceneCanCheckMonsterObjDic.Remove(monsterDataInfo); objListChanged = true; } } else if (distance <= monsterDataInfo.Range) { //获取当前任务状态是否可以显示 bool taskPass = monsterDataInfo.CanShowThis(temp => { TaskMap.RunTimeTaskInfo tempTaskInfoStruct = runtimeTaskData.GetTasksWithID(temp, false); if (tempTaskInfoStruct == null) { return(TaskMap.Enums.EnumTaskProgress.NoTake); } return(tempTaskInfoStruct.TaskProgress); }); if (taskPass)//可以显示 { if (!thisSceneCanCheckMonsterObjDic.ContainsKey(monsterDataInfo)) { if (!allMonsterObjDic.ContainsKey(monsterDataInfo)) { allMonsterObjDic.Add(monsterDataInfo, new List <GameObject>()); } thisSceneCanCheckMonsterObjDic.Add(monsterDataInfo, allMonsterObjDic[monsterDataInfo]); objListChanged = true; } } else//不可以显示 { if (thisSceneCanCheckMonsterObjDic.ContainsKey(monsterDataInfo)) { thisSceneCanCheckMonsterObjDic.Remove(monsterDataInfo); objListChanged = true; } } } } //移除所有对象字典空元素 foreach (KeyValuePair <MonsterDataInfo, List <GameObject> > tempData in allMonsterObjDic) { tempData.Value.RemoveAll(temp => temp == null); } //检测触发区域内的对象生成情况 foreach (KeyValuePair <MonsterDataInfo, List <GameObject> > tempData in thisSceneCanCheckMonsterObjDic) { MonsterDataInfo monsterDataInfo = tempData.Key; switch (monsterDataInfo.AIType) { case EnumMonsterAIType.Trigger: //触发型(更新时间到了并且在触发区域被且没有任何怪物时生成) MonsterAIData_Trigger monsterAIData_Trigger = monsterDataInfo.AIData as MonsterAIData_Trigger; if (monsterAIData_Trigger != null && tempData.Value.Count == 0 && monsterAIData_Trigger.NowUpdateTime <= 0) { float distance = Vector2.Distance( new Vector2(monsterDataInfo.Center.x, monsterDataInfo.Center.z) , new Vector2(iPlayerState.PlayerObj.transform.position.x, iPlayerState.PlayerObj.transform.position.z)); if (distance < monsterAIData_Trigger.TriggerRange && monsterDataInfo.MonsterPrefab != null) { monsterAIData_Trigger.NowUpdateTime = monsterAIData_Trigger.UpdateTime; //生成怪物 for (int i = 0; i < monsterAIData_Trigger.Count; i++) { Vector3 createPos = new Vector3( UnityEngine.Random.Range(monsterDataInfo.Center.x - monsterAIData_Trigger.CreateRange, monsterDataInfo.Center.x + monsterAIData_Trigger.CreateRange), monsterDataInfo.Center.y, UnityEngine.Random.Range(monsterDataInfo.Center.z - monsterAIData_Trigger.CreateRange, monsterDataInfo.Center.z + monsterAIData_Trigger.CreateRange)); GameObject createObj = GameObject.Instantiate <GameObject>(monsterDataInfo.MonsterPrefab, createPos, Quaternion.identity); MonsterControl monsterControl = createObj.AddComponent <MonsterControl>(); monsterControl.SameGroupObjList = tempData.Value; monsterControl.monsterDataInfo = tempData.Key; tempData.Value.Add(createObj); //设置位置(MonsterControl内部会进行y轴的设置) //createObj.transform.position = new Vector3( // UnityEngine.Random.Range(monsterDataInfo.Center.x - monsterAIData_Trigger.TriggerRange, monsterDataInfo.Center.x + monsterAIData_Trigger.TriggerRange), // monsterDataInfo.Center.y, // UnityEngine.Random.Range(monsterDataInfo.Center.z - monsterAIData_Trigger.TriggerRange, monsterDataInfo.Center.z + monsterAIData_Trigger.TriggerRange)); } objListChanged = true; } } break; case EnumMonsterAIType.GoOnPatrol: //巡逻型(更新时间到了并且怪物集合数量少与最大数量时生成) MonsterAIData_GoOnPatrol monsterAIData_GoOnPatrol = monsterDataInfo.AIData as MonsterAIData_GoOnPatrol; if (monsterAIData_GoOnPatrol != null && tempData.Value.Count < monsterAIData_GoOnPatrol.Count && monsterAIData_GoOnPatrol.NowUpdateTime <= 0) { monsterAIData_GoOnPatrol.NowUpdateTime = monsterAIData_GoOnPatrol.UpdateTime; //生成怪物 int createCount = monsterAIData_GoOnPatrol.Count - tempData.Value.Count; for (int i = 0; i < createCount; i++) { Vector3 createPos = new Vector3( UnityEngine.Random.Range(monsterDataInfo.Center.x - monsterAIData_GoOnPatrol.CreateRange, monsterDataInfo.Center.x + monsterAIData_GoOnPatrol.CreateRange), monsterDataInfo.Center.y, UnityEngine.Random.Range(monsterDataInfo.Center.z - monsterAIData_GoOnPatrol.CreateRange, monsterDataInfo.Center.z + monsterAIData_GoOnPatrol.CreateRange)); GameObject createObj = GameObject.Instantiate <GameObject>(monsterDataInfo.MonsterPrefab, createPos, Quaternion.identity); MonsterControl monsterControl = createObj.AddComponent <MonsterControl>(); monsterControl.SameGroupObjList = tempData.Value; monsterControl.monsterDataInfo = tempData.Key; tempData.Value.Add(createObj); //设置位置(MonsterControl内部会进行y轴的设置) //createObj.transform.position = new Vector3( // UnityEngine.Random.Range(monsterDataInfo.Center.x - monsterAIData_GoOnPatrol.CreateRange, monsterDataInfo.Center.x + monsterAIData_GoOnPatrol.CreateRange), // monsterDataInfo.Center.y, // UnityEngine.Random.Range(monsterDataInfo.Center.z - monsterAIData_GoOnPatrol.CreateRange, monsterDataInfo.Center.z + monsterAIData_GoOnPatrol.CreateRange)); } objListChanged = true; } break; case EnumMonsterAIType.Boss: //boss型(更新时间到了并且怪物没有生成是生成) MonsterAIData_Boss monsterAIData_Boss = monsterDataInfo.AIData as MonsterAIData_Boss; if (monsterAIData_Boss != null && tempData.Value.Count == 0 && monsterAIData_Boss.NowUpdateTime <= 0) { monsterAIData_Boss.NowUpdateTime = monsterAIData_Boss.UpdateTime; //生成怪物 GameObject createObj = GameObject.Instantiate <GameObject>(monsterDataInfo.MonsterPrefab); MonsterControl monsterControl = createObj.AddComponent <MonsterControl>(); monsterControl.SameGroupObjList = tempData.Value; monsterControl.monsterDataInfo = tempData.Key; tempData.Value.Add(createObj); //设置位置(MonsterControl内部会进行y轴的设置) createObj.transform.position = new Vector3( monsterDataInfo.Center.x, monsterDataInfo.Center.y, monsterDataInfo.Center.z); objListChanged = true; } break; } } //刷新时间 foreach (KeyValuePair <MonsterDataInfo, List <GameObject> > tempData in allMonsterObjDic) { switch (tempData.Key.AIType) { case EnumMonsterAIType.Trigger: if (tempData.Value.Count == 0 && tempData.Key.AIData != null) { tempData.Key.AIData.NowUpdateTime -= UpdateTime; } break; case EnumMonsterAIType.GoOnPatrol: MonsterAIData_GoOnPatrol monsterAIData_GoOnPatrol = tempData.Key.AIData as MonsterAIData_GoOnPatrol; if (monsterAIData_GoOnPatrol != null && tempData.Value.Count < monsterAIData_GoOnPatrol.Count) { monsterAIData_GoOnPatrol.NowUpdateTime -= UpdateTime; } break; case EnumMonsterAIType.Boss: if (tempData.Value.Count == 0 && tempData.Key.AIData != null) { tempData.Key.AIData.NowUpdateTime -= UpdateTime; } break; } } //重新构建检测集合 if (objListChanged) { thisSceneCanCheckMonsterObjList.Clear(); foreach (KeyValuePair <MonsterDataInfo, List <GameObject> > tempData in thisSceneCanCheckMonsterObjDic) { thisSceneCanCheckMonsterObjList.AddRange(tempData.Value); } } //移除检测集合的空元素 thisSceneCanCheckMonsterObjList.RemoveAll(temp => temp == null); }
// Start is called before the first frame update void Start() { cov = FindObjectOfType <MonsterControl>(); rb.GetComponent <Rigidbody2D>(); citizen = FindObjectOfType <GameManagerScript>(); }
// Use this for initialization void Start() { monsterControl = GameObject.Find("GameRoot").GetComponent <MonsterControl>(); }
protected virtual void Start() { MonsterControl monsterControl = GetComponent <MonsterControl>(); monsterControl.dizzyRate = dizzyRate; }
private void GetSingleAutoTarget() { //1. HP로 소팅할 경우 이거 참조.. //TargetMonster = mMonster01.Where(m=>m.mHP > 0).OrderBy(m=>m.mHP).First(); //2. 타겟 넘버를 지정 맨 앞에 를 타겟으로 잡는다. if (mStageStatus == StageStatus.Battle) { TargetMonster = mMonster01.Where (m => m.TargetNumber > 0).OrderBy (m => m.TargetNumber).First (); TargetMonster.SetSingleTarget (); } else{ //Debug.Log ("not in battle"); } }
private void GetAutoTarget() { // Hp가 가장 낮은 몬스터를 타겟팅 합니다. TargetMonster = mMonster.Where(m=>m.mHp > 0).OrderBy(m=>m.mHp).First(); // 타겟은 충돌체가 준비됩니다. TargetMonster.SetTarget(); }
public int GetHitCounter(MonsterControl monster) { return monsterAttackDict[monster].Count; }
void Start() { monsterHp = this.GetComponentInChildren <MonsterHP>(); monster = this.GetComponent <MonsterControl>(); hpCanvas = this.GetComponentInChildren <CanvasGroup>(); }
public float GetTotalHurt(MonsterControl monster) { var result = 0f; monsterAttackDict[monster].ForEach(value => result += value); return result; }
public void ReAutoTarget() { //타깃을 재탐색합니다. mMonsterCount -= 1; TargetMonster = null; if(mMonsterCount == 0) { //몬스터를 모두 클리어했습니다. Debug.Log("Clear"); if (mStatus == Status.GameOver) return; //모든 공격과 스텝을 중지시킵니다. StopCoroutine("ArcherAttack"); StopCoroutine("MonsterAttack"); StopCoroutine("AutoStep"); //던전 스텝을 초기화시키고 다시 순환시킵니다. mStatus = Status.Idle; StartCoroutine("AutoStep"); return; } //타깃 재탐색 GetAutoTarget(); }