Пример #1
0
    private GameObject CreateShipGroup(ClientShip targetShip, string targetShipResPath, float shipWrapRadius)
    {
        GameObject group = new GameObject();

        group.transform.SetParent(DeploySceneManager.Instance.PlayerGridDrawer.GridInstance.transform);

        //约定组名为目标舰船在数据索引值,记录之,方便传给战斗布阵单元的坐标
        group.name = PlayerSys.GetPlayerShipList().IndexOf(targetShip).ToString();
        // 初始化阵形
        BattleSys.SetFormation(true, targetShip);
        //成组上阵,组中舰船的数量
        int groupMemberCount = targetShip.Reference.stack ? targetShip.Reference.stack_num : 1;

        BoxCollider tempCollider = null;

        for (int i = 0; i < groupMemberCount; i++)
        {
            Vector3    pos    = targetShip.FormationList == null ? Vector3.zero : targetShip.FormationList[i];
            GameObject member = CreateShip(targetShipResPath, group.transform, GridDrawer.OffsetByWrapRadius(pos, shipWrapRadius));

            if (tempCollider == null)
            {
                tempCollider = member.GetComponent <BoxCollider>();
            }
            Destroy(member.GetComponent <BoxCollider>());
            DestoryTrailEffect(member);
        }

        //添加tag,用于点选式布阵的碰撞检测
        group.tag = "ShipModel";

        return(group);
    }