Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
1
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Hero : MonoBehaviour { [SerializeField] internal float exp; [SerializeField] internal int lvl = 1, str = 1, lov = 1, _int = 1; [SerializeField] internal string name; [SerializeField] internal GameObject _3dobj; [SerializeField] float hp; [SerializeField] float atak; [SerializeField] float radiusdliaAtk = 2.5f; [SerializeField] float radiusAtk = 2.5f; [SerializeField] bool isMassAtk; TextMesh textMesh; float time; [SerializeField] float bestDist = 0; [SerializeField] GameObject target; [SerializeField] List<GameObject> enems = new List<GameObject>(); float distation; private void Update() { if(target !=null) bestDist = Vector3.Distance(transform.position, target.transform.position); if (time > 0f) time -= Time.deltaTime; if (time <= 0) { GameObject[] Enemu = null; if (gameObject.tag == "Player") { Enemu = GameObject.FindGameObjectsWithTag("Enemy"); } else if (gameObject.tag == "Enemy") { Enemu = GameObject.FindGameObjectsWithTag("Player"); } if (target == null) foreach (GameObject enem in Enemu) { Vector3 newpos = enem.transform.position; distation = Vector3.Distance(transform.position, newpos); if (distation < bestDist || bestDist == 0) { target = enem; print(target); } } if (bestDist > radiusdliaAtk) { gameObject.GetComponent<Testmove>().enabled = true; gameObject.GetComponent<Testmove>().Move(target.transform.position); //gameObject.GetComponent<Testmove>().isMove = true; } else { gameObject.GetComponent<Testmove>().enabled = false; if (isMassAtk) foreach (GameObject enem in Enemu) { Vector3 newpos = enem.transform.position; float distation = Vector3.Distance(transform.position, newpos); if (distation <= radiusAtk) { Hero hero = enem.transform.GetComponent<Hero>(); hero.HP = Atak; if (hero.HP == 0) Destroy(target.gameObject); time += 1f; } } else { if (target != null) { Hero hero = target.transform.GetComponent<Hero>(); hero.HP = Atak; if (hero.HP == 0) Destroy(target.gameObject); time += 1f; } } } } } internal float HP { set { hp = hp > 0 ? hp - value : 0; if (hp <= 0) Destroy(gameObject); Textmesh_HP(); //print(gameObject.name + " получил урон " + value + "\nосталось хп " + hp); } get { return hp; } } public float Atak { get { return atak; } set { atak = (float)(str * 1.5 + lov / 2); } } private void Start() { textMesh = transform.Find("hp").GetComponent<TextMesh>(); atak = (float)(str * 1.5 + lov / 2); hp = (str * 10) + (lov * 7) + (_int * 3); HP = 0; name = gameObject.name; } public void Atk(Transform transform) { Hero enemu = transform.GetComponent<Hero>(); enemu.HP = Atak; if (gameObject.tag == "Player") print(enemu.HP + " / " + HP); if (enemu.HP == 0) Destroy(enemu.gameObject); } private void OnTriggerExit(Collider other) { enems.Remove(other.gameObject); } void Textmesh_HP() { } }
run
|
edit
|
history
|
help
0
Проверка на одинаковые цифры в пятизначном числе.
Order of Ops 5 (easier)
filter distinct items from the array without builtin function - Seeni
FileNameCharCheck
30272 Program Ex4 if
Demo
Class Objects
Access Modifiers
Intuit // C# // listing_4.7 (case // calculator)
Дамир