private bool CreateMobSpawners( Random rng, out String result) { bool success = true; result = SuccessMessages.GENERAL_SUCCESS; for (RoomIndexIterator iterator = new RoomIndexIterator(m_roomGrid); success && iterator.Valid; iterator.Next()) { RoomIndex roomIndex = iterator.Current; RoomLayout room = GetRoomByIndex(roomIndex); RoomTemplate roomTemplate = m_roomTemplateSet.GetTemplateByName(room.static_room_data.room_template_name); foreach (MobSpawnerTemplate mobSpawnerTemplate in roomTemplate.MobSpawnerTemplates) { MobSpawner spawner = MobSpawner.CreateMobSpawner( room.room_key, mobSpawnerTemplate, m_mobSpawnTableSet, rng); // Don't bother adding mob spawners that don't have any spawns left if (spawner.RemainingSpawnCount > 0) { room.mobSpawners.Add(spawner); } } } return(success); }
// Use this for initialization void Start() { level = 1; levelStart = false; paused = true; spawner = GameObject.FindGameObjectWithTag("MobSpawn").GetComponent <MobSpawner>(); mvmt = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement> (); tFire = GameObject.FindGameObjectWithTag("Bow").GetComponent <TurretFire> (); spawner.enabled = false; mvmt.enabled = false; tFire.enabled = false; spawnerObj = GameObject.FindGameObjectWithTag("MobSpawn"); tFireObj = GameObject.FindGameObjectWithTag("Bow"); play = gameObject.GetComponentInChildren <Text> (); //skelesMax = 2; playButton.onClick.AddListener(Play); }
public StartUp(IGameScene gameScene, IMouse mouse, ISound sound) { GameScene = gameScene; Mouse = mouse; var parameters = new Parameters(); Sound = new PixSound(new Sounds(sound)); Drawer = new Drawer(parameters, gameScene); var IdProcessor = new BlockIdProcessor(); var tileManager = new TileManager(Drawer, IdProcessor, parameters); engine = new Engine.Engine(tileManager, Drawer); var craftingSystem = new CraftingModule(Craftings.GetCraftings(), tileManager); var StatusWindow = new InventoryForm(craftingSystem, engine, mouse, Drawer, gameScene); var playerstatus = new PlayerStatus(StatusWindow, parameters); var blockConverter = new BlockConverter(Drawer, IdProcessor); var moveDefiner = new PlayerMoveDefiner(gameScene, mouse); SaveManager = new SaveManager(tileManager, playerstatus, blockConverter, engine.Center, engine); var pauseMenu = new PauseForm(engine, SaveManager, mouse, Drawer, gameScene); var oreTable = new OreTable(OreResource.InitOreTable()); pointerController = new PointerController(playerstatus, tileManager, moveDefiner, Drawer, Sound, parameters, engine, mouse); player = new Player(pauseMenu, tileManager, moveDefiner, playerstatus, Drawer, engine, Sound, parameters, gameScene, pointerController); MobSpawner = new MobSpawner(engine, tileManager, Drawer, Sound, player); Generator = new Generator(tileManager, oreTable, Drawer, parameters); }
public void SetOrb(Vector3 target, MobSpawner spawner, float spawnPoints) { this.target = target; moveDir = MyMath.GetDirectionRatio(target, this.transform.position); this.spawner = spawner; this.spawnPoints = spawnPoints; }
/// <summary> /// Generate a chunk /// </summary> /// <param name="CX">Chunk X</param> /// <param name="CZ">Chunk Z</param> /// <param name="b">Blocks</param> /// <param name="mh">Map handler</param> /// <param name="r">Random</param> /// <returns></returns> public static bool MakeDungeon(int CX, int CZ, ref byte[, ,] b, ref IMapHandler mh, Random r) { int CH = (int)mh.ChunkScale.X; int CV = (int)mh.ChunkScale.Y; int x = r.Next(0 + DungeonSizeX - 1, CH - DungeonSizeX + 1); int y = r.Next(0 + DungeonSizeY - 1, CV - DungeonSizeY + 1); int z = r.Next(0 + DungeonSizeZ - 1, CH - DungeonSizeZ + 1); Vector3i position = mh.Local2Global(CX, CZ, new Vector3i(x, y, z)); //Console.WriteLine("Creating dungeon in {0}...", position); if (!CheckForDungeonSpace(b, x, y, z)) { return(false); } Vector3i size = new Vector3i((DungeonSizeX * 2) + 1, (DungeonSizeY * 2) + 1, (DungeonSizeZ * 2) + 1); Vector3i sizeAir = new Vector3i(size.X - 1, size.Y - 1, size.Z - 1); FillRect(ref b, 48, position, size); // Do walls (RANDOMIZE) FillRect(ref b, 0, position, sizeAir); // Add air MobSpawner ms = new MobSpawner(); ms.Delay = 20; ms.EntityId = Entity.GetRandomMonsterID(r); ms.Pos = mh.Local2Global(CX, CZ, new Vector3i(x, y - DungeonSizeZ + 1, z)); ms.UUID = Guid.NewGuid(); mh.SetTileEntity(ms); b[x, y - DungeonSizeZ + 1, z] = 52; return(true); }
private MobSpawner <ZombieFactory> CreateMobSpawner(ILogger logger, UnityTimeProvider timeProvider, EntitiesSpawner entitiesSpawner, TypeTargetLocator tankMobTargetLocator, StateMachineFactory stateMachineFactory, DefaultRandom random) { var zombieFactories = new List <ZombieFactory>(); foreach (var zombiePrefab in Zombies) { var pool = new SimplePool <Zombie>(logger, 15, 10, p => { var zombie = Instantiate(zombiePrefab); return(zombie); }); var zombieFactory = new ZombieFactory(timeProvider, entitiesSpawner, tankMobTargetLocator, stateMachineFactory, _deps.Doors, pool); zombieFactories.Add(zombieFactory); } var zombieSpawnPoints = GetZombieSpawnPoints(_deps.ZombieSpawnPoints); var mobSpawner = new MobSpawner <ZombieFactory>(random, entitiesSpawner, new MobSpawnerSettings(AliveZombieCount, zombieSpawnPoints), zombieFactories); return(mobSpawner); }
private void Tile_Click(object sender, RoutedEventArgs e) { if (Window == null) { Window = new CommandsGeneratorTemplate(this); Window.win = (Application.Current.MainWindow as IMainWindowCommands).AddWindow(Icon, Window, "命令生成器", this); Window.win.WindowClosed += Win_WindowClosed; } object content = null; string title = (sender as Tile).Title; switch (title) { case "基础命令": content = new BasicCommands(Window); break; case "服务器命令": content = new ServerCommands(Window); break; case "实体命令": content = new EntityCommands(Window); break; case "玩家命令": content = new PlayerCommands(Window); break; case "Json书": content = new Book(Window); break; case "告示牌": content = new Sign(Window); break; case "消息文本": content = new Tellraw(Window); break; case "显示标题": content = new Title(Window); break; case "记分板目标": content = new ScoreboardObjective(Window); break; case "记分板玩家": content = new ScoreboardPlayers(Window); break; case "记分板队伍": content = new ScoreboardTeam(Window); break; case "物品NBT": content = new ItemNBT(Window); break; case "实体NBT": content = new EntityNBT(Window); break; case "物品与生成": content = new GetElement(); break; case "检测与执行": content = new ExecuteAndDetect(); break; case "方块NBT/放置填充方块": content = new SetBlocks(Window); break; case "村民交易": content = new VillagerTrade(Window); break; case "刷怪笼": content = new MobSpawner(Window); break; case "烟花": content = new Firework(Window); break; case "旗帜/盾牌": content = new Banners(Window); break; case "药水/药水箭": content = new Potion(Window); break; case "盔甲架": content = new ArmorStand(Window); break; } Window.AddPage(title, content); }
void Awake() { MobSpawnerInstance = this; // Init of the pooling lists for (int i = 0; i < mobPrefabArray.Length; i++) { _mobMasterPool.Add(new MobMasterPool()); } }
protected override void start() { base.start(); this.spawners = new List <MobSpawner>(); foreach (GameObject g in this.spawnerObjects) { MobSpawner ms = g.GetComponent <MobSpawner>(); this.spawners.Add(ms); } }
void Start() { isDead = false; hpBar = hpBarObj.GetComponent <Bar>(); hpBar.SetMax(maxHP); hp = maxHP; damaged = false; animator = GetComponent <Animator>(); spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <MobSpawner>(); enemyAudio = GetComponent <AudioSource>(); }
private void GameInit(float time, int mobCount, Vector2 levelSize) { _totalTime = time; Level.Build((int)levelSize.x, (int)levelSize.y); MobSpawner.SpawnMobs(mobCount); SpawnPlayer(1, Level.sizeY - 2); StartCoroutine(GameTimer()); }
public static MobBehaviour InstantiateMob(Vector3 position, MobBehaviour mob, MobSpawner spawn) { MobBehaviour newGm = GameObject.Instantiate <MobBehaviour>(mob); newGm.Init(new Vector3(position.x, position.y, 5), spawn); newGm.transform.SetParent(backGround.transform, true); BoxCollider2D box = newGm.gameObject.AddComponent <BoxCollider2D>(); box.isTrigger = true; return(newGm); }
private void CheckFire() { int x = Mathf.RoundToInt(_transform.position.x); int y = Mathf.RoundToInt(_transform.position.y); if (Level.map[x, y].typeId == 4) { Level.map[x, y].typeId = 0; MobSpawner.KillMob(_transform); } }
private IEnumerator GameTimer() { while (_totalTime > 0) { yield return(new WaitForSeconds(1f)); _totalTime--; } MobSpawner.SpawnBosses(); }
public override void LoadContent() { Texture2D playerSprite = game.Content.Load <Texture2D>("PlayerSpriteSheet"); background = game.Content.Load <Texture2D>("RightBG"); Controls controls = Game1.rightControls; Control = controls; BasicWeapon = new BasicWeapon(game.Content.Load <Texture2D>("Bullet"), game.Content.Load <SoundEffect>("GameSounds/playershoot")); player = new RightPlayer(playerSprite, controls); MobSpawner.LoadContent(game); }
public static void UpdateMobSpawner( AsyncRPGDataContext db_context, MobSpawner spawner) { var roomMobSpawnerQuery = from s in db_context.MobSpawners where s.MobSpawnerID == spawner.ID select s; foreach (MobSpawners dbMobSpawner in roomMobSpawnerQuery) { dbMobSpawner.RandomSeed = spawner.RandomSeed; dbMobSpawner.RemainingSpawnCount = spawner.RemainingSpawnCount; } db_context.SubmitChanges(); }
IEnumerator RespawnCoroutine(MobSpawner spawner) { var mob = spawner.Mob; var TimeToRespawn = spawner.TimeToRespawn; //TODO: Check min distance to Player var comp = mob.GetComponent <Mob>(); comp.Cost += comp.AdditionAfterDeath; yield return(new WaitForSeconds(TimeToRespawn)); mob.transform.position = MapController.Global.RandomPosition(); yield return(new WaitForEndOfFrame()); mob.SetActive(true); mob.GetComponent <BoxCollider2D>().enabled = true; }
public static MobSpawner GetSpawner(Vector2Int hex) { MobSpawner retSpawner = null; if (spawners != null) { foreach (MobSpawner spawner in spawners) { if (spawner.spawnHexes != null) { if (spawner.spawnHexes.Contains(hex)) { return(spawner); } } } } return(retSpawner); }
public static List <MobSpawner> GetMobSpawners( AsyncRPGDataContext context, MobSpawnTableSet mobSpawnTableSet, RoomKey roomKey) { List <MobSpawner> mobSpawners = new List <MobSpawner>(); var roomMobSpawnerQuery = from s in context.MobSpawners where s.GameID == roomKey.game_id && s.RoomX == roomKey.x && s.RoomY == roomKey.y && s.RoomZ == roomKey.z select s; foreach (MobSpawners dbMobSpawner in roomMobSpawnerQuery) { MobSpawner mobSpawner = MobSpawner.CreateMobSpawner(dbMobSpawner, mobSpawnTableSet); mobSpawners.Add(mobSpawner); } return(mobSpawners); }
public void Respawn(Mob mob) { MobSpawner spawner = null; foreach (var spawn in Spawners) { if (spawn.Mob == mob.gameObject) { spawner = spawn; break; } } if (spawner != null) { StartCoroutine(RespawnCoroutine(spawner)); } else { Debug.LogError("No such mob to respawn: " + mob.name); } }
/// <summary> /// Spawns the mobs on the MapServer, by reading the config for the current MapIndex /// </summary> private void InitSpawners(string mapsFolderPath) { //MobSpawner spawner = new MobSpawner(ModelType.MeleeNPC, new Vector3(1000, 0, 1000), 500f, 5000); //spawner.SpawnAll(this); try { Console.WriteLine("Reading spawner info..."); Console.WriteLine("Spawner info read."); if (mapsFolderPath.Length > 0) { mapsFolderPath += "/"; } string[] spawnerInfos = File.ReadAllLines(mapsFolderPath + "Map" + MapIndex + ".spawner"); byte mobType = byte.Parse(spawnerInfos[0]); Console.WriteLine("Creating spawners..."); for (int i = 1; i < spawnerInfos.Length; i++) { Console.WriteLine("Creating spawner..."); string[] spawnerInfo = spawnerInfos[i].Split(';'); float x = float.Parse(spawnerInfo[0]); float z = float.Parse(spawnerInfo[1]); float r = float.Parse(spawnerInfo[2]); int count = int.Parse(spawnerInfo[3]); MobSpawner spawner = new MobSpawner((ModelType)mobType, new Vector3(x, 0, z), r, (ushort)count); Console.WriteLine("Spawner created."); Console.WriteLine("Spawning mobs..."); spawner.SpawnAll(this); Console.WriteLine("Spawner mobs spawned."); } Console.WriteLine("Mobs spawned."); } catch (Exception e) { Console.WriteLine("\n" + e); } }
public void StartMe() { if (!inst) { inst = this; DontDestroyOnLoad(this.gameObject); } else if (inst) { if (inst != this) { Destroy(this.gameObject); } } if (MaxMobCount <= 0) { CanCreate = false; } else if (MaxMobCount > 0) { CanCreate = true; } active = true; }
private void Start() { if (SceneManager.GetActiveScene().buildIndex == 6) { PlayerPrefs.DeleteAll(); } UICanvasAnim = GameObject.Find("Canvas UI").GetComponent <Animator>(); mobSpawner = GameObject.Find("Mob Spawner").GetComponent <MobSpawner>(); if (PlayerPrefs.GetInt("SavedProgress") != 0) { unveilAnim = GameObject.Find("Curtain Unveal").GetComponent <Animator>(); unveilAnim.SetBool("Unveal", true); GameObject.Find("Player").transform.position = new Vector2(PlayerPrefs.GetFloat("SpawnX"), 0f); UICanvasAnim.SetBool("isEnabled", true); } if (hasAudio) { audioSource = GetComponent <AudioSource>(); } MessagePopCanvas = GameObject.Find("Message Pop Canvas"); }
public MobAIBehaviorState(MobSpawner spawner) { active_behavior_stack = ""; random_seed = (spawner != null) ? spawner.RandomSeed : 0; }
public void Init(Vector3 position, MobSpawner spawner) { transform.position = position; this.spawner = spawner; transform.GetComponent <SpriteRenderer>().sortingOrder = 2; }
public SpawnOrb(Vector3 target, MobSpawner spawner) { this.target = target; moveDir = MyMath.GetDirectionRatio(target, this.transform.position); this.spawner = spawner; }
// Update is called once per frame void FixedUpdate() { overButton = false; mousePos = GetMousePosition(); mousePos.z = -2; snapPos = mousePos; snapPos.z = 0; snapPos = MyMath.SnapToSub(subSnaps, snapPos); transform.position = mousePos; if (UIHits.Count > 0) { TriButton hitButton; ButtonClick clickButton; foreach (RaycastResult hit in UIHits) { if (hit.gameObject != null) { hitButton = hit.gameObject.GetComponent <TriButton>(); clickButton = hit.gameObject.GetComponent <ButtonClick>(); triMenu.ResetButtons(); if (hitButton != null) { overButton = true; hitButton.SetState(1); } if (clickButton != null) { overButton = true; } } } } UIHits = new List <RaycastResult>(); UIEvent = new PointerEventData(UIEventSystem); UIEvent.position = Input.mousePosition; UICaster.Raycast(UIEvent, UIHits); if (selectedBuilding == null && selectedSpawner == null && !keepDetails) { triMenu.DestroyDetails(); } if (UIHits.Count > 0) { //Debug.Log("UI hit"); TriButton hitButton; LinkToggle linkButton; foreach (RaycastResult hit in UIHits) { //Check For TriMenu hitButton = hit.gameObject.GetComponent <TriButton>(); if (hitButton != null) { // Load details for whichever button hit. Vector2 detailPos = GetScreenPosition(hexHook.transform.position); detailPos.x -= 120; string buttonVal = hitButton.getValue().ToLower(); switch (buttonVal) { case "build_speed_augment_button": case "build_range_augment_button": case "build_damage_augment_button": case "build_chain_augment_button": case "build_fork_augment_button": case "build_multi_augment_button": case "build_ethereal_augment_button": triMenu.DestroyDetails(); triMenu.CreateDetails(detailPos); triMenu.AddDetail(hitButton.getValue(), -1); triMenu.LoadDetails(Towers.instance.GetAugment(buttonVal.Replace("build_", "").Replace("_button", "").Replace("_augment", ""))); triMenu.RefreshDetails(); keepDetails = true; break; case "build_fire_tower_button": case "build_water_tower_button": case "build_earth_tower_button": case "build_air_tower_button": case "build_basic_tower_button": triMenu.DestroyDetails(); triMenu.CreateDetails(detailPos); triMenu.AddDetail(Translator.Get(buttonVal), -1); string tower = buttonVal.Replace("build_", "").Replace("_button", "").Replace("_tower", ""); triMenu.LoadDetails(Towers.instance.GetTower(tower)); triMenu.RefreshDetails(); keepDetails = true; break; default: break; } if (lastButtonHover != buttonVal && triMenu.CurrentMenu() == "towers_build") { PreviewTowerRange(buttonVal.Replace("build_", "").Replace("_button", "").Replace("_tower", "")); } lastButtonHover = buttonVal; } //Check For Link Toggle linkButton = hit.gameObject.GetComponent <LinkToggle>(); if (linkButton != null) { Vector2 detailPos = GetScreenPosition(hexHook.transform.position); detailPos.x -= 96; } } } if (Input.GetAxis("Jump") == 1) { if (currentCamera == CurrentCamera.main) { ChangeCamera(CurrentCamera.overhead); } } else { ChangeCamera(CurrentCamera.main); } if (mouseCheck[0] == 1) { if (UIHits.Count > 0) { MenuPositioner dragHandle; foreach (RaycastResult UIhit in UIHits) { dragHandle = UIhit.gameObject.GetComponent <MenuPositioner>(); if (dragHandle != null) { dragHandle.StartDrag(); dragging = true; } } } } //Check left mouse button up; if (mouseCheck[0] == -1) { dragging = false; Ray ray; if (currentCamera == CurrentCamera.main) { ray = gameCam.ScreenPointToRay(Input.mousePosition); } else { ray = overHeadCam.ScreenPointToRay(Input.mousePosition); } RaycastHit hit; if (UIHits.Count > 0) { TriButton hitButton; ButtonClick clickButton; foreach (RaycastResult UIhit in UIHits) { hitButton = UIhit.gameObject.GetComponent <TriButton>(); clickButton = UIhit.gameObject.GetComponent <ButtonClick>(); if (hitButton != null) { string buttonValue = hitButton.getValue().ToLower(); TowerTypes towerType = TowerTypes.none; AugmentTypes augmentType = AugmentTypes.none; BuildingType buildingType = BuildingType.none; buttonValue = buttonValue.Replace("_button", ""); if (buttonValue.Contains("build_")) { buttonValue = buttonValue.Replace("build_", ""); if (buttonValue.Contains("_tower")) { buttonValue = buttonValue.Replace("_tower", ""); towerType = TowerBase.GetTowerType(buttonValue); } else if (buttonValue.Contains("_augment")) { buttonValue = buttonValue.Replace("_augment", ""); augmentType = Towers.GetAugmentType(buttonValue); } } MobSpawner spawner; switch (buttonValue) { case "path": PathKeeper.indexes[PathType.normal]++; PathKeeper.pathKeeper.FindGoal(PathType.normal, TerrainGen.GetGridPosition2D(PathKeeper.goal), TerrainGen.GetGridPosition2D(hexHook.transform.position)); break; case "select": TerrainGen.mapGenState = MapGen.pathing; buildingType = BuildingType.Base; break; case "regen": TerrainGen.instance.KillTerrain(); TerrainGen.mapGenState = MapGen.terrain; break; case "towers": triMenu.DestroyMenu(); triMenu.CreateMenu("towers_build"); break; case "augments": triMenu.DestroyMenu(); triMenu.CreateMenu("augments"); break; case "buildings": triMenu.DestroyMenu(); triMenu.CreateMenu("buildings"); break; case "sell": if (selectedBuilding != null) { float value = selectedBuilding.Sell(); value *= 0.8f; player.GiveGold((int)value); TowerBase.UpdateTowerHexes(); triMenu.DestroyMenu(); hexHook.SetActive(false); HexHighlighter.ResetGrid(); } break; case "upgrade": if (selectedBuilding != null) { if (player.hasGold(100)) { player.TakeGold(100); selectedBuilding.AddValue(100); selectedBuilding.GetComponent <TowerBase>().LevelUp(); triMenu.CreateDetails(); triMenu.LoadDetails(selectedBuilding.GetComponent <TowerBase>().GetDetails()); triMenu.RefreshDetails(); } } break; case "points": spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (spawner != null) { spawner.wavePoints *= 1.1f; CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } break; case "more": spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (spawner != null) { spawner.spawnNumber += 1; CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } break; case "less": spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (spawner != null) { spawner.spawnNumber -= 1; if (spawner.spawnNumber < 0) { spawner.spawnNumber = 0; } CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } break; case "faster": spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (spawner != null) { spawner.coolDownTime -= 1; if (spawner.coolDownTime < 1) { spawner.coolDownTime = 1; } CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } break; case "slower": spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (spawner != null) { spawner.coolDownTime += 1; CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } break; case "wall": buildingType = BuildingType.Wall; break; default: break; } int cost = Towers.instance.GetCost(buttonValue.Replace("build_", "").Replace("_button", "")); if (towerType != TowerTypes.none) { if (player.hasGold(cost)) { TowerBase towerBase = Instantiate(towerFabBasic, hexHook.transform.position, new Quaternion(), towerParent.transform) .GetComponent <TowerBase>(); player.TakeGold(cost); towerBase.SetProjectileParent(projectileParent); string tower = buttonValue.Replace("build_", "").Replace("_button", ""); towerBase.SetTower(TowerBase.GetTowerType(tower)); towerBase.UpdateLinks(); UpdateGrid(); CloseMenu(); // // // } } if (augmentType != AugmentTypes.none) { if (player.hasGold(cost)) { AugmentBase augmentBase = Instantiate(augmentFabBasic, hexHook.transform.position, new Quaternion(), towerParent.transform) .GetComponent <AugmentBase>(); player.TakeGold(cost); augmentBase.SetAugmentType(buttonValue); augmentBase.AddValue(cost); UpdateGrid(); CloseMenu(); } } if (buildingType != BuildingType.none) { if (player.hasGold(cost)) { if (buttonValue == "select") { buttonValue = "base"; } BuildingBase buildingBase = Instantiate(buildingFabBasic, hexHook.transform.position, new Quaternion(), towerParent.transform) .GetComponent <BuildingBase>(); buildingBase.SetBuilding(buttonValue); player.TakeGold(cost); UpdateGrid(hexHook.transform.position); CloseMenu(); } } } if (clickButton != null) { switch (clickButton.buttonClick) { case "pathing": if (HexHighlighter.showingType != GridType.path) { PathKeeper.ShowOnGrid(PathType.normal); HexHighlighter.showingType = GridType.path; } else { HexHighlighter.ResetGrid(); HexHighlighter.showingType = GridType.grid; } break; case "height": if (HexHighlighter.showingType != GridType.height) { HexHighlighter.ShowHeightMap(); HexHighlighter.showingType = GridType.height; } else { HexHighlighter.ResetGrid(); HexHighlighter.showingType = GridType.grid; } break; case "towerrange": if (HexHighlighter.showingType != GridType.range) { HexHighlighter.ResetGrid(); HexHighlighter.ShowTowersRange(true); HexHighlighter.showingType = GridType.range; } else { HexHighlighter.ResetGrid(); HexHighlighter.showingType = GridType.grid; } break; case "undock_details": triMenu.DockDetails(); break; } } } } else if (Physics.Raycast(ray, out hit, 10, UIMask)) { Debug.Log("Other Ui hits>"); LinkToggle hitToggle; hitToggle = hit.transform.parent.GetComponent <LinkToggle>(); if (hitToggle != null) { hitToggle.Toggle(); UpdateLinks(); showingRange = true; } } else { triMenu.DestroyMenu(); //Ray ray = gameCam.ScreenPointToRay(Input.mousePosition); Debug.DrawRay(ray.origin, ray.direction, Color.blue, 1); if (Physics.Raycast(ray, out hit)) { hexHook.SetActive(true); if (hit.transform.position != Vector3.zero) { PlaceHexHook(hit.transform.position); } else { PlaceHexHook(hit.point); } } BuildingBase buildingBase = null; if (hit.collider != null) { buildingBase = hit.transform.parent.GetComponent <BuildingBase>(); if (buildingBase != null) { triMenu.DestroyMenu(); Vector2 detailPos = GetScreenPosition(hexHook.transform.position); detailPos.x -= 120; triMenu.CreateMenu("towerselect"); triMenu.CreateDetails(detailPos); triMenu.LoadDetails(buildingBase.GetDetails()); triMenu.AddDetail("Upgrade Cost:", 100); triMenu.RefreshDetails(); selectedBuilding = buildingBase; selectedBuilding.UpdateLinks(); UpdateLinks(); //triMenu.DestroyButtons(); if (!showingRange && buildingBase is TowerBase towerBase) { towerBase.ShowHexes(); } } } Vector2 menuPos = GetScreenPosition(hexHook.transform.position); menuPos.x += 60; triMenu.transform.position = menuPos; // if (buildingBase == null) { selectedBuilding = null; HexHighlighter.ResetGrid(); hexHook.GetComponentInChildren <MeshRenderer>(true).gameObject.SetActive(false); MobSpawner spawner = MobSpawner.GetSpawner(TerrainGen.GetGridPosition2D(hexHook.transform.position)); if (TerrainGen.mapGenState == MapGen.terrainCon) { triMenu.CreateMenu("startmenu"); } else if (spawner == null) { triMenu.CreateMenu("base"); } else { CloseMenu(); triMenu.gameObject.SetActive(true); selectedSpawner = spawner; triMenu.CreateMenu("spawner"); triMenu.CreateDetails(); triMenu.LoadDetails(spawner.GetDetails()); triMenu.RefreshDetails(); } } else { hexHook.GetComponentInChildren <MeshRenderer>(true).gameObject.SetActive(true); } } mouseCheck[0] = 0; } if (mouseCheck[1] == -1) { if (!overButton) { if (rightClickTime <= 0.33f) { triMenu.DestroyMenu(); selectedBuilding = null; selectedSpawner = null; hexHook.SetActive(false); mouseCheck[1] = 0; lastButtonHover = null; HexHighlighter.ResetGrid(); showingRange = false; } } else if (overButton && !didBack) { if (triMenu.CurrentMenu() != "startmenu") { didBack = true; triMenu.DestroyMenu(); triMenu.CreateMenu("base"); } } } bool inX = !dragging && !overButton && Input.mousePosition.x > 0 - overBorder && Input.mousePosition.x < Screen.width + overBorder; bool inside = inX && Input.mousePosition.y > 0 - overBorder && Input.mousePosition.y < Screen.height + overBorder; if (inside) { MoveCamera(); } if (mouseCheck[1] == 1) { RotateCamera(); } if (triMenu.HaveLinks()) { triMenu.ReDrawLinks(); } }
public void SetSpawner(MobSpawner newSpawner) { spawner = newSpawner; }
public MobAIBehaviorState(MobSpawner spawner) { active_behavior_stack = ""; random_seed = (spawner != null) ? spawner.RandomSeed : 0; }
void Start() { // 플레이어 관련 GameObject temp = GameObject.Find("Player"); PlayerScript = temp.GetComponent <Player>(); if (PlayerScript == null) { Debug.LogError("PlayerScript 못 찾음"); return; } GunScript = temp.transform.Find("Gun").GetComponent <Gun>(); if (GunScript == null) { Debug.LogError("GunScript 못 찾음"); return; } MousePointScript = GameObject.Find("MousePoint").GetComponent <MousePoint>(); if (MousePointScript == null) { Debug.LogError("MousePointScript 못 찾음"); return; } PlayerSprite = temp.transform.Find("Image").GetComponent <SpriteRenderer>(); if (PlayerSprite == null) { Debug.LogError("PlayerSprite 못 찾음"); return; } PlayerAnimator = temp.GetComponentInChildren <Animator>(); if (PlayerAnimator == null) { Debug.LogError("PlayerAnimator 못 찾음"); return; } Shadow = PlayerSprite.transform.GetChild(0); if (Shadow == null) { Debug.LogError("Shadow 못 찾음"); return; } HeartDestroyScript = temp.transform.Find("HitPoint").GetComponent <HeartDestroy>(); if (HeartDestroyScript == null) { Debug.LogError("HeartDestroyScript 못 찾음"); return; } // 스프라이트 Sprite[] tempSprite = Resources.LoadAll <Sprite>("Sprites/LinkImage"); LoseSprites = new Sprite[3]; VictorySprites = new Sprite[5]; int LoseCount = 0; int VictoryCount = 0; for (int i = 0; i < tempSprite.Length; i++) { // 패배 if (LoseCount < 3) { if (tempSprite[i].name.Contains("Lose")) { LoseSprites[LoseCount] = tempSprite[i]; LoseCount++; } } // 승리 if (VictoryCount < 5) { if (tempSprite[i].name.Contains("Victory")) { VictorySprites[VictoryCount] = tempSprite[i]; VictoryCount++; } } } if (LoseSprites[LoseSprites.Length - 1] == null) { Debug.LogError("LoseSprites 끝까지 못 찾음"); return; } if (VictorySprites[VictorySprites.Length - 1] == null) { Debug.LogError("VictorySprites 끝까지 못 찾음"); return; } // 패배 이미지 temp = GameObject.Find("Result"); LoseImage = temp.transform.Find("Lose").GetComponent <Image>(); if (LoseImage == null) { Debug.LogError("LoseImage 못 찾음"); return; } // 패배 텍스트 LoseText = temp.transform.Find("LoseText").GetComponent <Text>(); if (LoseText == null) { Debug.LogError("LoseText 못 찾음"); return; } // 승리 이미지 VictoryImage = temp.transform.Find("Victory").GetComponent <Image>(); if (VictoryImage == null) { Debug.LogError("VictoryImage 못 찾음"); return; } // 적 관련 EnemyScript = GameObject.Find("Enemy").GetComponent <Enemy>(); if (EnemyScript == null) { Debug.LogError("EnemyScript 못 찾음"); return; } BulletSpawnerScript = GameObject.Find("E_BulletSpawner").GetComponent <BulletSpawner>(); if (BulletSpawnerScript == null) { Debug.LogError("BulletSpawnerScript 못 찾음"); return; } GasterSpawnerScript = GameObject.Find("E_GasterSpawner").GetComponent <GasterSpawner>(); if (BulletSpawnerScript == null) { Debug.LogError("GasterSpawnerScript 못 찾음"); return; } LaserSpawnerScript = GameObject.Find("E_LaserSpawner").GetComponent <LaserSpawner>(); if (BulletSpawnerScript == null) { Debug.LogError("LaserSpawnerScript 못 찾음"); return; } MobSpawnerScript = GameObject.Find("E_MobSpawner").GetComponent <MobSpawner>(); if (MobSpawnerScript == null) { Debug.LogError("MobSpawnerScript 못 찾음"); return; } //패배스프라이트 deadSpirte = GameObject.Find("Enemy").GetComponentInChildren <SpriteRenderer>(); if (deadSpirte == null) { Debug.LogError("deadSpirte 못 찾음"); return; } else { //패배이미지 SetDeadSprite(); } }
public override void Update(GameTime gameTime) { startDelayTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (startDelayTimer < Game1.PLAY_START_DELAY) { player.Update(gameTime); foreach (Projectile p in projectiles) { p.Update(gameTime); } return; } MobSpawner.Update(gameTime); player.Update(gameTime); removeProjectiles = new List <Projectile>(); removeMobs = new List <Mob>(); foreach (Mob m in mobs) { m.Update(gameTime); if (player.Intersect(m.Rectangle) && !m.IsDead) { m.Hit(1000000); player.Hit(1); } if (m.IsDead) { removeMobs.Add(m); } } foreach (Projectile p in projectiles) { p.Update(gameTime); if (!p.MobShot) { foreach (Mob m in mobs) { if (m.Intersect(p.Rectangle)) { m.Hit(p.Damage); removeProjectiles.Add(p); } if (m.IsDead) { if (m.GetType() == typeof(Boss)) { game.Victory(m.Location); } } } } else { if (player.Intersect(p.Rectangle)) { player.Hit(p.Damage); removeProjectiles.Add(p); } } if (p.Y < -30 || p.Y > Game1.HEIGHT || p.X + p.Width < 0 || p.X > Game1.WIDTH / 2) { removeProjectiles.Add(p); } } foreach (Projectile p in removeProjectiles) { projectiles.Remove(p); } foreach (Mob m in removeMobs) { mobs.Remove(m); } }