示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        UnitList   = StageCtl.UnitList[0];
        cpuTileMap = new cpuMapTile[StageCtl.TileLenX, StageCtl.TileLenY];
        map        = GameObject.Find("Grid").GetComponent <MapCtl>();

        //新しいユニットが生成されたかチェック
        foreach (var units in StageCtl.UnitList[0])
        {
            if (cpuUnitList.Any(u => u.tgtUnit == units) == false)
            {
                cpuUnit newUnit = new cpuUnit();
                newUnit.tgtUnit = units;
                cpuUnitList.Add(newUnit);
            }
        }

        //油田リスト
        visOilList.AddRange(map.tileList.Where(t => t.getType() == TileType.OilField).Select(t => new visOil(new Vector2Int(t.getPosX(), t.getPosY()))));
        Debug.Log("[visOilList=" + visOilList.Count() + "]" + visOilList[0].pos);

        foreach (var units in cpuUnitList)
        {
            switch (units.tgtUnit.units)
            {
            case Unit.Capital:                                  /* 首都 */
                var landList = map.landArea(units.tgtUnit.pos); /* 陸地をチェック */
                if (landList?.Count > 0)
                {
                    //Debug.Log("[landList="+ landList.Count +"]");
                    foreach (var land in landList)
                    {
                        //Debug.Log("[land="+ land +"]");
                        cpuTileMap[land.x, land.y].domain += 10;
                    }
                }
                break;
            }
        }
    }