private void Awake() { if (level == -1) { //random stage stage = DataUtils.getRandomStage(world, GameControl.control.getWorldLevel(world)); } else { stage = Instantiate(Resources.Load <StageAsset>("LevelAssets/" + world.ToString() + "/" + world.ToString() + level)); if (wonLastLevel()) { stage = DataUtils.WonLastLvlStage(stage, world, level); } } GameControl.control.GetComponent <Canvas>().enabled = false; GameControl.control.GetComponent <GraphicRaycaster>().enabled = true; setBackground(); PlayerData enemyPlayerData = getEnemyData(); userPlayer = gameObject.AddComponent <ExplorePlayer>(); enemyPlayer = gameObject.AddComponent <ExplorePlayer>(); float CatScale = GameControl.control.playerData.team.Count > enemyPlayerData.team.Count ? getCatScale(GameControl.control.playerData.team.Count) : getCatScale(enemyPlayerData.team.Count); userPlayer.init(GameControl.control.playerData, enemyPlayer, catGameObjectPrefab, CatScale, userPos, Vector3.zero, checkGameOver); enemyPlayer.setAsEnemy(userPlayer); enemyPlayer.init(enemyPlayerData, userPlayer, catGameObjectPrefab, CatScale, enemyPos, new Vector3(0, 180, 0), checkGameOver); setUpStart(); MapManager.StageTransition(1, 0, world, () => { if (level == -1) { string[] randomEncounters = new string[] { enemyPlayerData.team[0].Name + " is happy to see you!", enemyPlayerData.team[0].Name + " is excited to see you!", enemyPlayerData.team[0].Name + " stops you to say hi!", enemyPlayerData.team[0].Name + " wants to play with you!", enemyPlayerData.team[0].Name + " interrupts your journey!", enemyPlayerData.team[0].Name + " confronts you!", "You've been stopped by " + enemyPlayerData.team[0].Name + "!", enemyPlayerData.team[0].Name + " saw you and wants to play!", }; Notify(new string[] { randomEncounters[UnityEngine.Random.Range(0, randomEncounters.Length)] }, Init); return; } Init(); }); }
//always used for game over, unless game finished via a CatAction public void checkGameOver(ExplorePlayer p) { if (p.aliveCats.Count == 0) { Debug.Log("set active false"); exploreChoice.gameObject.SetActive(false); exploreChoice.selector.gameObject.SetActive(false); GameOver(p.enemy); // return false; } else if (exploreChoice != null && !exploreChoice.gameObject.activeSelf) { exploreChoice.gameObject.SetActive(true); } }
public void init(PlayerData ownerPlayerData, ExplorePlayer enemyPlayer, GameObject catGameObjectPrefab, float CatScale, Vector2 pos, Vector3 rot, Action <ExplorePlayer> GameOver) { this.GameOver = GameOver; this.enemyPlayer = enemyPlayer; aliveCats = new List <ExploreCat>(); allCats = new ExploreCat[ownerPlayerData.team.Count]; HealthBar hBar = enemy ? transform.Find("enemy").GetComponent <HealthBar>() : transform.Find("player").GetComponent <HealthBar>(); Vector2[] offsets = DataUtils.getOffsets(ownerPlayerData.team.Count); for (int i = 0; i < ownerPlayerData.team.Count; i++) { aliveCats.Add(addCat(ownerPlayerData.team[i], i, catGameObjectPrefab, enemy ? new Vector2(-offsets[i].x, offsets[i].y) : offsets[i], pos, rot, CatScale, giveHealthBar(hBar, i, ownerPlayerData.team.Count))); allCats[i] = aliveCats[i]; } }
//check if any cat has advantage in the field due to their faction; if so, notify and add public void InitPlayerAdvantage(int i, ExplorePlayer player, Action onComplete) { for (; i < player.aliveCats.Count; i++) { if (DataUtils.isFactionCompatible(player.aliveCats[i].cat.getCatAsset().faction, world)) { player.aliveCats[i].factionAdvantage(); Notify(getAdvantageString(player.aliveCats[i].cat.Name, world.ToString()), () => InitPlayerAdvantage(i + 1, player, onComplete)); return; } } if (onComplete != null) { onComplete(); } }
public void init(Cat cat, ExplorePlayer owner, int i, HealthBar hb) { this.cat = cat; this.owner = owner; this.healthBar = hb; healthBar.initHealthBar(this); setStats(); cat.SetCat(transform.GetChild(0)); gameObject.name = cat.Name; Debug.Log("FIGHTER " + cat.Name + " at Lv." + cat.catLvl.level); //wait for user input to enable increment = i + (!owner.enemy ? 5 : 0); setPositionZ(transform.position); enabled = false; }
public void setAsEnemy(ExplorePlayer userPlayer) { enemy = true; noMagic = userPlayer.aliveCats.Any(x => x.cat.catType == CatType.doot); }