private RadarTypeInfo GetIconInfo(RadarTargetType type) { for (int i = 0; i < RadarTypeInfo.Length; i++) { if (RadarTypeInfo[i].Type == type) { return(RadarTypeInfo[i]); } } return(RadarTypeInfo[0]); }
private void AddTarget(GameObject enemy, RadarTargetType type) { if (enemy == null) { return; } if (EnemyList.ContainsKey(enemy)) { return; } var enemyInfo = CreateEnemyInfo(type); EnemyList.Add(enemy, enemyInfo); enemy.GetComponent <AdventureBehaviour>().OnDestroyAction += OnEnemyDestroy; }
private EnemyMap CreateEnemyInfo(RadarTargetType type) { var enemyInfo = new EnemyMap { EnemyArrow = (RectTransform)Instantiate(EnemyTarget, new Vector3(0, 0, 0), Quaternion.identity), EnemyPoint = (RectTransform)Instantiate(EnemyPoint, new Vector3(0, 0, 0), Quaternion.identity) }; var radarTypeInfo = GetIconInfo(type); enemyInfo.EnemyArrow.transform.parent = Root; enemyInfo.EnemyArrow.localPosition = new Vector3(0, 0, 0); enemyInfo.EnemyArrow.GetComponent <Image>().sprite = radarTypeInfo.ArrowIcon; enemyInfo.EnemyPoint.transform.parent = Root; enemyInfo.EnemyPoint.localPosition = new Vector3(0, 0, 0); enemyInfo.EnemyPoint.GetComponent <Image>().sprite = radarTypeInfo.Icon; return(enemyInfo); }