/// <summary> /// 일선 모험가에게 레벨에 적합한 사냥터를 반환해주는 메서드 /// </summary> /// <param name="level">일선 모험가의 레벨</param> /// <returns></returns> public HuntingArea FindHuntingAreaSpAdv(int level) { HuntingArea searchResult = null; //Debug.Log("HA IDX : " + ConqueringHuntingAreaIndex); // LevelMax만 검사함. 사냥터에 진입 못할 모험가는 애초에 생성을 안하는 방향으로. for (int i = 0; i <= ConqueringHuntingAreaIndex; i++) { if (level <= huntingAreas[i].LevelMax) { if (searchResult == null) { searchResult = huntingAreas[i]; } else if (searchResult.LevelMax >= huntingAreas[i].LevelMax) { searchResult = huntingAreas[i]; } } } // 일선 모험가는 나가면 안되므로 가장 높은 곳으로 그냥 찍어줌. if (searchResult == null) { searchResult = huntingAreas[ConqueringHuntingAreaIndex]; } return(searchResult); }
protected void ResetCurHuntingArea() { if (curHuntingArea != null) { curHuntingArea.ExitAdventurer(this.gameObject); curHuntingArea = null; } }
private void Start() { huntingArea = GetComponentInParent <HuntingArea>(); //check public values if (moveSpeedMax * 10 > huntingArea.boundRadius) { Debug.Log("moveSpeedに対して領域が狭すぎるかもよ"); } }
protected void EnteringHuntingArea() { curHuntingArea = destinationPlace as HuntingArea; curHuntingArea.EnterAdventurer(this.gameObject); destinationPlace = null; // 사용 후에는 비워주기. destinationTileForMove = curHuntingArea.FindNearestBlank(curTileForMove); destinationTile = destinationTileForMove.GetParent(); curState = State.PathFinding; }
//public List<HuntingArea> GetHuntingAreas() //{ // return huntingAreas; //} //public List<BossArea> GetBossAreas() //{ // return bossAreas; //} /// <summary> /// 모험가에게 레벨에 적합한 사냥터를 반환해주는 메서드 /// </summary> /// <param name="level">모험가의 레벨</param> /// <returns></returns> public HuntingArea FindHuntingAreaAdv(int level) { HuntingArea searchResult = null; //Debug.Log("HA IDX : " + PublicHuntingAreaIndex); // LevelMax만 검사함. 사냥터에 진입 못할 모험가는 애초에 생성을 안하는 방향으로. for (int i = 0; i <= PublicHuntingAreaIndex; i++) { if (level <= huntingAreas[i].LevelMax) { if (searchResult == null) { searchResult = huntingAreas[i]; } else if (searchResult.LevelMax >= huntingAreas[i].LevelMax) { searchResult = huntingAreas[i]; } } } return(searchResult); }
public void Init() { Debug.Log("Start"); var parent = gameObject.transform.parent; Debug.Log(parent.name); huntingArea = parent.GetComponent <HuntingArea>(); foodHunterParams = parent.GetComponent <FoodHunterParams>(); MaxStep = foodHunterParams.maxStep; //set properties moveSpeedMax = foodHunterParams.moveSpeedMax; angleMax = foodHunterParams.angleMax; agentType = transform.CompareTag("food") ? AgentType.Food : AgentType.Hunter; //Get bady brother = GetBrother(); /* * //check public values * if(moveSpeedMax * 10 > huntingArea.boundRadius) * Debug.Log("moveSpeedに対して領域が狭すぎるかもよ"); */ }
// 사냥터 건설 public void ConstructHuntingArea(int areaNum, int areaIndex, GameObject pointTile) { #region InstantiateStructure() string stageNum = "stage" + SceneManager.GetActiveScene().name; int huntingAreaNum = areaNum; //Debug.Log("stageNum : " + stageNum + " areaNum : " + huntingAreaNum); //Debug.Log("디버그2: " + huntingAreaJson[stageNum][huntingAreaNum]["name"]); //Debug.Log("HuntingArea/HuntingAreaPrefabs/" + stageNum + "/" + huntingAreaNum); constructing = (GameObject)Instantiate(Resources.Load("CombatArea/HuntingAreaPrefabs/" + stageNum + "/" + huntingAreaNum.ToString())); constructing.transform.parent = rootCombatAreaObject.transform; //임시 HuntingArea huntingArea = constructing.GetComponent <HuntingArea>(); huntingArea.name = huntingAreaJson[stageNum][huntingAreaNum]["name"]; int conquerCondition = huntingAreaJson[stageNum][huntingAreaNum]["conquerCondition"].AsInt; bool isBossArea = huntingAreaJson[stageNum][huntingAreaNum]["isBossArea"].AsBool; //서로 알 필요 없지않나? //Debug.Log(huntingAreaJson[stageNum][huntingAreaNum]["isBossRoom"].AsBool); int levelMax = huntingAreaJson[stageNum][huntingAreaNum]["levelMax"].AsInt; int monsterMax = huntingAreaJson[stageNum][huntingAreaNum]["monsterMax"].AsInt; int monsterPerRegen = huntingAreaJson[stageNum][huntingAreaNum]["monsterPerRegen"].AsInt; float monsterRegenRate = huntingAreaJson[stageNum][huntingAreaNum]["monsterRegenRate"].AsFloat; float monsterRatio = huntingAreaJson[stageNum][huntingAreaNum]["monsterRatio"].AsFloat; // 몬스터 프로토타입 넣기. 우선 번호부터. string monsterSet = huntingAreaJson[stageNum][huntingAreaNum]["monsterSet"]; int monsterSample1Num = huntingAreaJson[stageNum][huntingAreaNum]["monsterSample1Num"].AsInt; int monsterSample2Num = huntingAreaJson[stageNum][huntingAreaNum]["monsterSample2Num"].AsInt; // 몬스터 샘플 instantiate //GameObject monsterSample1, monsterSample2; //LoadMonsterSamples(monsterSet, monsterSample1Num, monsterSample2Num, out monsterSample1, out monsterSample2); GameObject monsterSample1 = LoadMonsterFromJson(monsterSet, monsterSample1Num); GameObject monsterSample2 = LoadMonsterFromJson(monsterSet, monsterSample2Num); huntingArea.InitHuntingArea(conquerCondition, isBossArea, levelMax, monsterMax, monsterPerRegen, monsterRegenRate, monsterRatio, monsterSample1, monsterSample2); huntingArea.areaConquered += OnHuntingAreaConquered; // 저장용. huntingArea.stageNum = stageNum; huntingArea.huntingAreaNum = areaNum; huntingArea.index = areaIndex; //관광 수치 저장해야할 수도 있음. 수정요망. //건설공간 지정 int x = huntingAreaJson[stageNum][huntingAreaNum]["sitewidth"].AsInt; huntingArea.extentWidth = x; int y = huntingAreaJson[stageNum][huntingAreaNum]["siteheight"].AsInt; huntingArea.extentHeight = y; #if DEBUG_CREATE_HA Debug.Log("siteWidth = " + x + ", siteHeight = " + y + ", Extent[0][0] = " + huntingAreaJson[stageNum][huntingAreaNum]["site"][0]); #endif huntingArea.extent = new int[x, y]; for (int i = 0; i < x * y; i++) { huntingArea.extent[i % x, i / x] = huntingAreaJson[stageNum][huntingAreaNum]["site"][i].AsInt; } #endregion #region AllocateStructure() // 건설할 건물의 position 설정 constructing.transform.position = pointTile.transform.position; // 문제 생길지도 모름. 수정요망 TileLayer tileLayer = TileMapGenerator.Instance.tileMap_Object.transform.GetChild(0).GetComponent <TileLayer>(); SetHuntingAreaPoint(pointTile.GetComponent <Tile>()); #endregion #region ConstructStructure() Tile tile = huntingArea.point; int[,] extent = huntingArea.GetExtent(); constructing.tag = "CombatArea"; // 인덱스 값 넣어줌. huntingArea.index = huntingAreas.Count; // 리스트에 추가 huntingAreas.Add(huntingArea); for (int i = 0; i < huntingArea.extentHeight; i++) { for (int j = 0; j < huntingArea.extentWidth; j++) { Tile thatTile = tileLayer.GetTileAsComponent(tile.GetX() + j, tile.GetY() + i); if (extent[j, i] == 1) { thatTile.SetIsBuildingArea(false); thatTile.SetIsStructed(false); thatTile.SetIsHuntingArea(true); //디버깅용임시 thatTile.gameObject.GetComponent <SpriteRenderer>().color = new Color(0, 1.0f, 1.0f); // #if DEBUG_CREATE_HA Debug.Log(thatTile); #endif // 여기서 딕셔너리에 TileForMove 영역을 추가해주자. //foreach(TileForMove child in thatTile.childs) //{ // huntingArea.AddTerritory(child); //} // 디버깅용임시 // thatTile.SetPassable(true); for (int k = 0; k < 4; k++) { huntingArea.AddTerritory(thatTile.childs[k]); } //thatTile.SetStructure(structure); // 일단 쓰는 곳 없어서 안넣고 둠. } else if (extent[j, i] == 2) { //thatTile.SetIsStructed(true); thatTile.gameObject.GetComponent <SpriteRenderer>().color = new Color(1.0f, 1.0f, 0); //if (thatTile.GetBuildable()) //{ huntingArea.addEntrance(thatTile); //} } else if (extent[j, i] == 3) { thatTile.SetIsActive(false); thatTile.gameObject.GetComponent <SpriteRenderer>().color = new Color(0.0f, 0.0f, 0.0f); thatTile.SetIsWall(true); } } } constructing = null; #endregion }
public HuntingAreaData(HuntingArea input) : base(input) { huntingAreaNum = input.huntingAreaNum; index = input.index; killCount = input.GetKillCount(); }