void Set_Nav(TrueGodGameObject subj, Vector3 pos) { if (subj.Get_OBJ() == null) { return; } UnityEngine.AI.NavMeshAgent nav = subj.Get_OBJ().GetComponent <UnityEngine.AI.NavMeshAgent>(); nav.stoppingDistance = 1f; nav.speed = subj.Get_SPD(); nav.SetDestination(pos); }
void Set_Nav(TrueGodGameObject subj, TrueGodGameObject obj) { if (subj.Get_OBJ() == null || obj.Get_OBJ() == null) { return; } UnityEngine.AI.NavMeshAgent nav = subj.Get_OBJ().GetComponent <UnityEngine.AI.NavMeshAgent>(); nav.stoppingDistance = 1f; nav.speed = subj.Get_SPD(); nav.SetDestination(obj.Get_OBJ().transform.position); }
void Fire(TrueGodGameObject attacker, TrueGodGameObject defender) { GameObject prf = Resources.Load("Prefabs/Bullet") as GameObject; GameObject new_bullet = Instantiate(prf) as GameObject; new_bullet.transform.position = attacker.Get_OBJ().transform.position; new_bullet.GetComponent <Bullet>().direction = defender.Get_OBJ().transform.position - attacker.Get_OBJ().transform.position; }
bool Attack(Vector3 atk_pos, TrueGodGameObject defender, float atk, float range) { if (!defender.Is_Dead()) { float distance = Vector3.Distance(atk_pos, defender.Get_OBJ().transform.position); if (distance <= range) { defender.Endure_Attack(atk); if (defender.Is_Dead()) { print(defender.Get_OBJ().name + " Destroyed!!!"); GameObject.Destroy(defender.Get_OBJ()); } return(true); } } return(false); }
bool Attack(TrueGodGameObject attacker, TrueGodGameObject defender) { if (Time.time - attacker.timer >= 1f / attacker.Get_FQC() && !attacker.Is_Dead() && !defender.Is_Dead()) { float distance = Vector3.Distance(attacker.Get_OBJ().transform.position, defender.Get_OBJ().transform.position); if (distance <= attacker.Get_RAG()) { attacker.Launch_Attack(defender); Fire(attacker, defender); attacker.timer = Time.time; if (defender.Is_Dead()) { print(defender.Get_OBJ().name + " Destroyed!!!"); GameObject.Destroy(defender.Get_OBJ()); if (defender.Is_Enemy()) { Add_Score(defender.Get_SCR()); } } return(true); } } return(false); }
int Get_Closest <T>(TrueGodGameObject subject, List <T> objects) where T : TrueGodGameObject { float closest = 1000000; int index = -1; for (int i = 0; i < objects.Count; i++) { if (objects [i].Is_Dead() || subject.Is_Dead()) { continue; } float distance = Vector3.Distance(subject.Get_OBJ().transform.position, objects[i].Get_OBJ().transform.position); if (distance < closest) { closest = distance; index = i; } } return(index); }