コード例 #1
0
    private void Start()
    {
        UserSceneDataBean userGroundData = GroundBuildHandler.Instance.currentGroundData;
        //显示友方区域
        List <GroundHexagons> listPlayerData = GroundBuildHandler.Instance.manager.GetInfluence(userGroundData.GetPlayerBelongId());

        for (int i = 0; i < listPlayerData.Count; i++)
        {
            GroundHexagons itemGroundHexagons = listPlayerData[i];

            if (itemGroundHexagons.groundHexagonsData.GetAreaType() == AreaTypeEnum.Base)
            {
                Vector3 basePosition = itemGroundHexagons.groundHexagonsData.coordinatesForWorld;
                CameraHandler.Instance.MoveCameraToPositionXZ(basePosition);
            }

            Action actionRolloverTerrainStart = () =>
            {
                itemGroundHexagons.areaType.ShowAreaType();
            };

            Action actionChangeDiscoveryComplete = () =>
            {
                itemGroundHexagons.areaTerrain.RolloverTerrain(actionRolloverTerrainStart, null);
            };

            itemGroundHexagons.ChangeDiscoveryStatus(AreaDiscoveryStatusEnum.Explore, actionChangeDiscoveryComplete);
        }

        UIHandler.Instance.manager.OpenUI(UIEnum.GameStart);
    }
コード例 #2
0
    /// <summary>
    /// 创建单个六角地形
    /// </summary>
    /// <param name="groundHexagonsData"></param>
    public void BuildItemGroundHexagons(GroundHexagonsBean groundHexagonsData)
    {
        //创建六角实例
        GameObject     objGroundHexagons  = Instantiate(gameObject, modelForGroundHexagons.gameObject, groundHexagonsData.coordinatesForWorld);
        GroundHexagons itemGroundHexagons = objGroundHexagons.GetComponent <GroundHexagons>();

        //设置数据
        itemGroundHexagons.SetGroundHexagonsData(groundHexagonsData);
        manager.AddGroundHexagons(itemGroundHexagons);
    }
コード例 #3
0
    /// <summary>
    /// 为地形设置区域类型
    /// </summary>
    /// <param name="groundHexagons"></param>
    protected void SetAreaTypeForGroundHexagons(AreaTypeEnum areaType, GroundHexagons groundHexagons)
    {
        groundHexagons.groundHexagonsData.SetAreaType(areaType);
        //随机设置模型名称
        AreaTypeInfoBean areaTypeInfo = manager.GetRandomAreaTypeInfo(groundHexagons.groundHexagonsData.GetAreaType());

        groundHexagons.groundHexagonsData.areaTypeModelName = areaTypeInfo.model_name;
        //获取区域类型模型
        GameObject objModelAreaType = manager.GetAreaTypeModel(groundHexagons.groundHexagonsData.GetAreaType(), groundHexagons.groundHexagonsData.areaTypeModelName);
        AreaType   areaTypeCpt      = BuildItemAreaType(groundHexagons.areaTerrain.gameObject, objModelAreaType);

        groundHexagons.SetAreaType(areaTypeCpt);
    }
コード例 #4
0
 /// <summary>
 /// 增加势力范围
 /// </summary>
 /// <param name="belongId"></param>
 /// <param name="groundHexagons"></param>
 public void AddInfluence(string belongId, GroundHexagons groundHexagons)
 {
     if (dicInfluence.TryGetValue(belongId, out List <GroundHexagons> listData))
     {
         listData.Add(groundHexagons);
     }
     else
     {
         dicInfluence.Add(belongId, new List <GroundHexagons>()
         {
             groundHexagons
         });
     }
 }
コード例 #5
0
    protected List <GroundHexagons> GetGroundHexagons(List <GroundHexagons> listData, Vector3 offsetPosition)
    {
        if (listData == null)
        {
            listData = new List <GroundHexagons>();
        }
        GroundHexagons groundHexagonsData = GetGroundHexagons(offsetPosition);

        if (groundHexagonsData != null)
        {
            listData.Add(groundHexagonsData);
        }
        return(listData);
    }
コード例 #6
0
    /// <summary>
    /// 初始化区域资源
    /// </summary>
    public void InitAreaTypeForRes()
    {
        List <GroundHexagons> listData = manager.GetListGroundHexagons();

        for (int i = 0; i < listData.Count; i++)
        {
            GroundHexagons groundHexagons = listData[i];
            if (groundHexagons.groundHexagonsData.GetAreaType() == AreaTypeEnum.Null)
            {
                //随机设置区域类型
                AreaTypeEnum areaType = (AreaTypeEnum)Random.Range(1, 4);
                SetAreaTypeForGroundHexagons(areaType, groundHexagons);
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// 初始化基地
    /// </summary>
    /// <param name="enemyIds"></param>
    public void InitAreaTypeForBase(List <string> enemyIds)
    {
        List <GroundHexagons> listData = manager.GetListGroundHexagons();
        //首先修建友方建筑
        GroundHexagons playerBase = RandomUtil.GetRandomDataByList(listData);

        List <GroundHexagons> aroundData = manager.GetGroundHexagonsForAround(playerBase);

        for (int i = 0; i < aroundData.Count; i++)
        {
            GroundHexagons itemGroundHexagons = aroundData[i];
            //基地初始化
            SetAreaTypeForGroundHexagons(AreaTypeEnum.BaseInit, itemGroundHexagons);
            manager.AddInfluence(currentGroundData.GetPlayerBelongId(), itemGroundHexagons);
        }
        //设置区域类型
        SetAreaTypeForGroundHexagons(AreaTypeEnum.Base, playerBase);
        manager.AddInfluence(currentGroundData.GetPlayerBelongId(), playerBase);
    }
コード例 #8
0
    /// <summary>
    /// 获取环绕四周的地形
    /// </summary>
    /// <param name="groundHexagons"></param>
    /// <returns></returns>
    public List <GroundHexagons> GetGroundHexagonsForAround(GroundHexagons groundHexagons)
    {
        List <GroundHexagons> listData = new List <GroundHexagons>();
        Vector3 offsetPosition         = groundHexagons.groundHexagonsData.coordinatesForOffset;

        listData = GetGroundHexagons(listData, offsetPosition + new Vector3(1, 0, 0));
        listData = GetGroundHexagons(listData, offsetPosition + new Vector3(-1, 0, 0));
        listData = GetGroundHexagons(listData, offsetPosition + new Vector3(0, 0, 1));
        listData = GetGroundHexagons(listData, offsetPosition + new Vector3(0, 0, -1));
        if (offsetPosition.x % 2 == 0)
        {
            listData = GetGroundHexagons(listData, offsetPosition + new Vector3(1, 0, 1));
            listData = GetGroundHexagons(listData, offsetPosition + new Vector3(-1, 0, 1));
        }
        else
        {
            listData = GetGroundHexagons(listData, offsetPosition + new Vector3(-1, 0, -1));
            listData = GetGroundHexagons(listData, offsetPosition + new Vector3(1, 0, -1));
        }

        return(listData);
    }
コード例 #9
0
 /// <summary>
 /// 增加地面数据
 /// </summary>
 /// <param name="data"></param>
 public void AddGroundHexagons(GroundHexagons data)
 {
     dicGroundHexagons.Add(data.groundHexagonsData.coordinatesForOffset, data);
 }