//! ユニットを生成して返すだけ private Unit CreateUnit(string id, Vector2 spawnPos, Vector2 clickPos, UNITASIGN asign) { var setting = UnitSettingLoader.GetSetting(id); var unit = Instantiate(unitPrefab, asign == UNITASIGN.OWN ? unitParent : enemyParent, false); if (!setting.isTower) { var controller = Resources.Load <RuntimeAnimatorController> ("Animation/" + setting.appearanceId + "_anime"); unit.GetComponent <Animator> ().runtimeAnimatorController = controller; } else { var sprite = Resources.Load <Sprite> ("Textures/" + setting.appearanceId); unit.GetComponent <UnityEngine.UI.Image> ().sprite = sprite; } unit.GetComponent <RectTransform> ().anchoredPosition = spawnPos; unit.SetParameter(UnitSettingLoader.GetSetting(id), clickPos, GetNearEnemy, GetNearEnemyTower, Summon); unitTable [asign].Add(unit); if (asign == UNITASIGN.OPPONENT) { unit.GetComponent <UnityEngine.UI.Image> ().color = Color.black; } if (asign == UNITASIGN.OWN && unit.isTower) { var image = unit.transform.Find("Range").GetComponent <UnityEngine.UI.Image> (); image.rectTransform.sizeDelta = Vector2.one * unit.effectRange; image.color = new Color(1, 1, 1, 0.2f); } return(unit); }
float CheckPoint(UNITASIGN team) { var towers = unitTable [team].Where(x => x.isTower).ToList(); if (!towers.Any()) { return(0); } var effective = towers.Where(x => { return(towers.Any(y => { return x != y && x.effectRange + y.effectRange > Vector2.Distance(x.Rect.anchoredPosition, y.Rect.anchoredPosition); })); }).ToList(); float width = Screen.width; if (team == UNITASIGN.OWN) { return(effective.Sum(x => { if (x.Id == "small_tower") { return 3f * (x.Rect.anchoredPosition.x / width); } if (x.Id == "large_tower") { return 10f * (x.Rect.anchoredPosition.x / width); } return 0; })); } else { return(effective.Sum(x => { if (x.Id == "small_tower") { return 3f * (Mathf.Abs(width - x.Rect.anchoredPosition.x) / width); } if (x.Id == "large_tower") { return 10f * (Mathf.Abs(width - x.Rect.anchoredPosition.x) / width); } return 0; })); } }