/// <summary> /// 生成矩形攻击范围 /// </summary> /// <param name="parentTrans">船体</param> /// <param name="radiateLen">长度</param> /// <param name="radiateWid">宽度</param> /// <param name="color">颜色</param> /// <returns></returns> public static AttackRangeDisplay InitRectangleAttackRange(Transform parentTrans, float radiateLen, float radiateWid, Color color) { GameObject go = new GameObject("RectangleAttackRange"); go.transform.parent = parentTrans; go.transform.localPosition = Vector3.zero; go.transform.localEulerAngles = Vector3.zero; go.transform.localScale = Vector3.one; AttackRangeDisplay display = go.AddComponent <AttackRangeDisplay>(); display.InitRectangleAttackRange(radiateLen, radiateWid, color); return(display); }
public void Init(ClientShip clientShip, Ship ship, List <GameObject> shipList, bool bPlayer) { IsDead = false; RootGo_ = new GameObject("Root_" + (bPlayer ? "Player" : "Enemy") + "_"); //+ clientShip.Reference.name ); RootGo_.transform.position = clientShip.Position; ClientShip_ = clientShip; //Ship_ = ship; Vector3[] tempFormationList = clientShip.FormationList; for (int i = 0; i < shipList.Count; i++) { ShipDisplay display = shipList[i].AddComponent <ShipDisplay>(); display.Init(this, ship, clientShip.Position, tempFormationList == null ? Vector3.zero : tempFormationList[i], bPlayer); ShipList_.Add(display); } bool isAdvancedShip = (clientShip.Reference.id == 40000 || clientShip.Reference.id == 60000);//暂时这样写,到时候根据tag来 BattleShipInfo_ = BattleShipInfo.Create(RootGo_.transform, this, clientShip.Name, ship.shieldRadius, bPlayer, isAdvancedShip); foreach (var iter in clientShip.PartsList) { float atkRangeMin = iter.Reference.atk_range_min; float atkRangeMax = iter.Reference.atk_range_max; float atkMoveRange = iter.Reference.attack_move_range; float angle = iter.Reference.atk_angle; // 最近和最远的攻击范围 AttackRangeDisplayList_.Add(AttackRangeDisplay.InitSectorAttackRange(bPlayer, RootGo_.transform, atkRangeMin, atkRangeMax, angle, Color.red)); // 移动攻击范围 AttackRangeDisplayList_.Add(AttackRangeDisplay.InitSectorAttackRange(bPlayer, RootGo_.transform, 0, atkMoveRange, angle, Color.gray)); } // 是玩家并且是旗舰,生成技能范围 if (bPlayer && clientShip.IsCommanderShip()) { for (int i = 0; i < 3; i++) { ClientSkill skill = clientShip.GetSkillByIndex(i); AttackRangeDisplay display = null; if (skill != null) { proto.SkillReference reference = skill.Prop; // 扇形 if (reference.skill_select_type == Def.SkillSelectType.CastScope) { display = AttackRangeDisplay.InitSectorAttackRange(true, RootGo_.transform, 0, reference.cast_range, reference.cast_angle, Color.blue); } //else if( reference.skill_select_type == Def.SkillSelectType.PlayerSelect ) { // 圆形 //if( reference.shape_type == Def.ShapeType.Circle ) { // display = AttackRangeDisplay.InitCircleAttackRange( RootGo_.transform, reference.aoe_range, Color.blue ); //} //} else if (reference.skill_select_type == Def.SkillSelectType.NoSelection) { // 矩形或圆形 if (reference.shape_type == Def.ShapeType.Rectangle) { display = AttackRangeDisplay.InitRectangleAttackRange(RootGo_.transform, reference.radiate_len, reference.radiate_wid * 2, Color.blue); } else if (reference.shape_type == Def.ShapeType.Circle) { display = AttackRangeDisplay.InitCircleAttackRange(RootGo_.transform, reference.aoe_range, Color.blue); } } if (display != null) { display.gameObject.name += "_skill"; } } SkillAttackRangeDisplayList.Add(display); } } if (HaloTemplate_ == null) { HaloTemplate_ = Resources.Load("Effect/Halo"); } HaloGo_ = GameObject.Instantiate(HaloTemplate_) as GameObject; HaloGo_.transform.GetChild(0).localPosition = Vector3.zero; HaloGo_.transform.parent = RootGo_.transform; HaloGo_.transform.localEulerAngles = Vector3.zero; HaloGo_.transform.localPosition = Vector3.zero + new Vector3(0, -1, 0); HaloGo_.transform.localScale = Vector3.one * clientShip.Reference.vol; }