public void Escape(BasicEnemy enemy) { BasicEntity entity = enemy.m_entity; VoxelBlocks map = GameObject.Find("Voxel Map").GetComponent <VoxelBlocks> (); List <BasicEntity> enemyList = entity.GetComponent <MonitorComponent> ().m_enemy; if (AiToInput.CallFriend(entity, enemyList)) { //呼叫成功 StateComponent state = entity.GetComponent <StateComponent> (); state.AnimationStart(); state.m_actionPoint -= 1; state.Invoke("AnimationEnd", 1); return; } Vector3 escapePos = FindPath.GetNearestFriend(entity.GetComponent <BlockInfoComponent> ().m_logicPosition); if (escapePos == Vector3.down) { //无路可走等死 return; } else { AiToInput.Move(entity, escapePos); } return; }
public void Survey(BasicEntity entity) { List <Vector3> voice = entity.GetComponent <MonitorComponent> ().m_voice; Vector3 mPos = entity.GetComponent <BlockInfoComponent> ().m_logicPosition; List <Vector3> newVoice = new List <Vector3> (); List <int> i = new List <int> (); for (int j = 0; j < voice.Count; j++) { Vector3 pos = voice [j]; if (mPos != pos && FindPath.GetPathByStep(mPos, pos, 100) != Vector3.down) { newVoice.Add(pos); } else { i.Add(j); } } for (int j = 0; j < i.Count; j++) { voice.Remove(voice [i [j]]); } if (newVoice.Count != 0) { AiToInput.Move(entity, newVoice [newVoice.Count - 1]); } }
public void Attack(BasicEntity entity) { VoxelBlocks map = GameObject.Find("Voxel Map").transform.GetComponent <VoxelBlocks> (); Vector3 ePos = entity.GetComponent <BlockInfoComponent> ().m_logicPosition; Vector3 tPos = target.GetComponent <BlockInfoComponent> ().m_logicPosition; if ((Mathf.Abs(ePos.x - tPos.x) <= 1.5f) && (Mathf.Abs(ePos.y - tPos.y) <= 1.5f)) { AiToInput.Attack(entity, tPos); } else { target.GetComponent <BlockInfoComponent> ().m_blockType = BlockType.None; List <Vector3> path = FindPath.GetPath(ePos, tPos); target.GetComponent <BlockInfoComponent> ().m_blockType = BlockType.Player; if (path != null) { path.Remove(tPos); tPos = path [path.Count - 1]; AiToInput.Move(entity, tPos); } else { Debug.Log("Fail to Attack"); } } }
public void Patrol(BasicEntity entity) { //寻找一个坐标进行来回移动 AIComponent ai = entity.GetComponent <AIComponent> (); StateComponent state = entity.GetComponent <StateComponent> (); List <Vector3> path = ai.m_patrolPoint; Vector3 entityPos = entity.GetComponent <BlockInfoComponent> ().m_logicPosition; if (path [0] == entityPos) { Vector3 t = path [0]; path.Remove(t); path.Add(t); } AiToInput.Move(entity, path [0]); }