public void ChangeCameraFocus() { bool meetPre = false; PlayerController firstLive = null; bool isMeetLive = false; foreach (PlayerController pl in PhotonManager.getInstance().playerList) { if (!pl.isDied && !isMeetLive) { isMeetLive = true; firstLive = pl; } if (pl.ID == player.targetFocus.ID) { meetPre = true; continue; } if (meetPre && !pl.isDied) { player.targetFocus = pl; Debug.Log("NextID = " + pl.ID); return; } } if (firstLive != null) { player.targetFocus = firstLive; } }
public void GameOver() { Debug.Log("GameOverrrrrrrrrrrr"); MainGameManager.getInstance().isGameOver = true; List <PlayerController> list = PhotonManager.getInstance().playerList; CoroutineUtility.GetInstance() .Do() .Wait(1.2f) .Then(() => MainGameManager.getInstance().gameOverUI.SetActive(true)) .Wait(3.5f) .Then(() => MainGameManager.getInstance().map.DisableBGM()) .Then(() => ScoreManager.getInstance().scoreObj.SetActive(true)) .Go(); foreach (PlayerController p in list) { if (!p.isDied) { MainGameManager.getInstance().changeCameraFocusPanel.SetActive(false); CoroutineUtility.GetInstance() .Do() .Wait(1.5f) .Then(() => p.canMove = false) .Go(); p.playerRig.velocity = Vector2.zero; ScoreManager.getInstance().SetRank(0, p); } } //MainGameManager.getInstance().GameOver(); }
public void SetAllPlayerCanMove(bool can) { foreach (PlayerController pl in PhotonManager.getInstance().playerList) { pl.canMove = can; } }
public void SetRank(int index, PlayerController player) { int playerCount = PhotonManager.getInstance().playerList.Count; int reward = MainGameManager.getInstance().rewardSugar[playerCount].num[index]; if (player.isOwner()) { EntireGameManager.getInstance().playerData.sugar += reward; EntireGameManager.getInstance().Save(); } Debug.Log("Rank = " + index); if (index <= 2) { SetWinnerImage(index, player.animal, player.cup, player.liquid); if (index == 1 && SceneManager.GetActiveScene().name == "MainGame") { } } if (index == 0) { Debug.Log("第一名"); } PlayerNameText[index].text = player.NickName; rewardText[index].text = reward.ToString(); }
public void CreateNewRoom() { Debug.Log(PhotonNetwork.connectionState); if (PhotonManager.getInstance().isInLobby()) { PhotonManager.getInstance().createRoom(); } }
public void ApplyMapBuff() { foreach (PlayerController pl in PhotonManager.getInstance().playerList) { pl.maxVelcocity += speedBuff; pl.maxMaxSpeed += speedBuff; } }
public void SetOwnerID(int id) { ownerID = id; if (GetComponent <Collider2D>() != null) { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), PhotonManager.getInstance().FindPlayerByID(ownerID).GetComponent <Collider2D>()); } }
public void joinThisRoom() { if (nowPlayers != maxPlayers) { PhotonManager.getInstance().joinRoom(roomID); } else { MainUIManager.CreateCheckBox(() => { }, "房間人數已滿"); } }
public void StartGame() { PhotonManager.getInstance().ConnectToServer(); if (EntireGameManager.getInstance().playerData.isNewPlayer) { StartCoroutine(EntireGameManager.LoadSceneWithLoadingScene("Tutorial")); } else { StartCoroutine(EntireGameManager.LoadSceneWithLoadingScene("RoomList")); } }
public void SetTransform(int playerID, Vector3 pos, Vector3 scale, float maxLiveTime) { SetOwnerID(playerID); if (GetComponent <CatBall>() != null) { GetComponent <CatBall>().StartCreate(playerID); } transform.SetParent(PhotonManager.getInstance().FindPlayerByID(playerID).playerSprite.transform); transform.localPosition = pos + new Vector3(0, 0, Random.Range(-0.1f, 0.1f)); transform.localScale = scale; this.maxLiveTime = maxLiveTime; }
public void ImReady() { MainGameManager.getInstance().PlayerLoadingFinishCount++; if (MainGameManager.getInstance().PlayerLoadingFinishCount >= PhotonManager.getInstance().playerList.Count) { CoroutineUtility.GetInstance() .Do() .Wait(1.5f) .Then(() => gameObject.GetPhotonView().RPC("StartGame", PhotonTargets.All)) .Go(); Debug.Log("EveryBodyFinishLoading"); } }
public void Initial(int index, int id, bool isAI, string nickName) { int wait = 1; if (SceneManager.GetActiveScene().name == "Tutorial") { wait = 0; } CoroutineUtility.GetInstance() .Do() .Wait(wait) .Then(() => SpawnAnimation.SetActive(true)) .Wait(0.3f) .Then(() => playerSprite.SetActive(true)) .Wait(1f) .Then(() => SpawnAnimation.SetActive(false)) .Go(); this.isAI = isAI; if (PhotonManager.getInstance().playerList == null) { PhotonManager.getInstance().playerList = new List <PlayerController>(); } PhotonManager.getInstance().playerList.Add(this); ID = id; this.index = index; this.NickName = nickName; PlayerNameText.text = nickName; if (isOwner()) { OnSceneLoaded(); MainGameManager.getInstance().player = this; if (SceneManager.GetActiveScene().name == "Tutorial") { TutorialManager.GetInstance().player = this; } //MainUIManager.instance.UpdateHealthBar(hp); SaveData playerData = EntireGameManager.getInstance().playerData; SetCharacterSprite(playerData.nowEquipment.animal, playerData.nowEquipment.cup, playerData.nowEquipment.liquid); gameObject.GetPhotonView().RPC("SetCharacterSprite", PhotonTargets.All, playerData.nowEquipment.animal, playerData.nowEquipment.cup, playerData.nowEquipment.liquid); GameObject inputer = PhotonNetwork.Instantiate("FakeInputer", Vector3.zero, Quaternion.identity, 0); fakeInputer = inputer.GetComponent <FakeInputer>(); fakeInputer.playerID = id; inputer.GetPhotonView().RPC("SetID", PhotonTargets.MasterClient, id); gameObject.GetPhotonView().RPC("SetSkill", PhotonTargets.All, playerData.nowEquipment.animal); } else if (isAI && PhotonNetwork.isMasterClient) { OnSceneLoaded(); } }
public void SetID(int id) { List <PlayerController> player = PhotonManager.getInstance().playerList; playerID = id; for (int i = 0; i < player.Count; i++) { if (player[i].ID == id) { attachPlayerController = player[i]; return; } } }
public void BackToRoomList() { if (SceneManager.GetActiveScene().name == "Tutorial") { if (EntireGameManager.getInstance().playerData.isNewPlayer) { EntireGameManager.getInstance().playerData.isNewPlayer = false; EntireGameManager.getInstance().Save(); EntireGameManager.nextScene = ""; SocialManager.UnlockAchievement(LiquidKnightResources.achievement); SocialManager.AddAchievementQueue("新手貓貓", 5); } } PhotonManager.getInstance().BackToRoomList(); //StartCoroutine(EntireGameManager.LoadSceneWithLoadingScene("RoomList")); }
public void UpdateRoomList() { while (roomItemList.Count > 0) { Destroy(roomItemList[0]); roomItemList.Remove(roomItemList[0]); } roomList = PhotonManager.getInstance().GetRoomList(); if (roomList.Length <= 0) { return; } int posY = 0; for (int i = 0; i < roomList.Length; i++) { if (roomList[i].Name != filter && filter != string.Empty) { continue; } if ((bool)roomList[i].CustomProperties.ContainsKey("isTutorial")) { continue; } if (!roomList[i].IsOpen) { continue; } string name = roomList[i].Name; string map = (string)roomList[i].CustomProperties["Map"]; int maxPlayers = roomList[i].MaxPlayers; //int nowPlayers = roomList[i].PlayerCount; int nowPlayers = 1; if (roomList[i].CustomProperties.ContainsKey("PlayerCount")) { nowPlayers = (int)roomList[i].CustomProperties["PlayerCount"]; } addRoomItemToList(name, map, maxPlayers, nowPlayers, posY); posY -= itemHeight; content.sizeDelta = new Vector2(content.sizeDelta.x, -posY); } }
public void CheckLivePlayerCount() { if (!PhotonNetwork.isMasterClient) { return; } int count = 0; foreach (PlayerController pl in PhotonManager.getInstance().playerList) { if (!pl.isDied) { count++; } } if (count <= 3) { ItemFactory.getInstance().frequency = 5; } }
public void SpawnTutorialAI() { Vector3 pos = new Vector3(0, 0, -1) - player.transform.position; Vector3 spawnPoint = player.transform.position + (pos.normalized * 6); spawnPoint.z = -1; Character ch; ch.animal = "dog"; ch.cup = "teacup"; ch.liquid = "wine"; ch.name = "阿福"; GameObject playerObj = PhotonNetwork.InstantiateSceneObject(PhotonManager.getInstance().playerObj.name, spawnPoint, PhotonManager.getInstance().playerObj.transform.rotation, 0, null); PlayerController playerController = playerObj.GetComponent <PlayerController>(); TutorialObject tutorialObj = playerObj.AddComponent <TutorialObject>(); tutorialObj.triggerType = TriggerType.OnCollisionEnter; if (tutorialObj.TriggerTurtorialEvent == null) { tutorialObj.TriggerTurtorialEvent = new UnityEvent(); } tutorialObj.TriggerTurtorialEvent.AddListener(MoveNext); tutorialObj.TriggerTurtorialEvent.AddListener(() => SetPlayerCanMove(false)); tutorialObj.TriggerTurtorialEvent.AddListener(() => player.Damaged(8)); tutorialObj.TriggerTurtorialEvent.AddListener(StopPlayer); tutorialObj.TriggerTurtorialEvent.AddListener(() => CoroutineUtility.GetInstance().Do().Wait(1f).Then(StopAI).Go()); tutorialObj.TriggerTurtorialEvent.AddListener(() => CoroutineUtility.GetInstance().Do().Wait(0.2f).Then(() => Destroy(tutorialObj)).Go()); //playerList.Add(playerController); PhotonManager.getInstance().playerList.Add(playerController); int id = -1; playerController.willDamaged = false; playerObj.GetPhotonView().RPC("Initial", PhotonTargets.AllBuffered, 2, id, true, ch.name); playerObj.GetPhotonView().RPC("SetCharacterSprite", PhotonTargets.AllBuffered, ch.animal, ch.cup, ch.liquid); playerObj.GetPhotonView().RPC("SetSkill", PhotonTargets.AllBuffered, ch.animal); playerController.canMove = false; tutorialAI = playerController; }
public void SpawnPlayer() { PhotonManager.getInstance().spawnPlayer(PhotonManager.getInstance().playerObj, PhotonManager.getInstance().map.spawnPoint); ScoreManager.getInstance().InitialCount(2); }
public void PlayerDied() { animalObj.gameObject.SetActive(false); cupObj.gameObject.SetActive(false); liquidObj.gameObject.SetActive(false); MinimapIconSprite.gameObject.SetActive(false); PlayerNameText.gameObject.SetActive(false); GetComponent <Collider2D>().enabled = false; canMove = false; hp = 0; isDied = true; canMove = false; DeadAnimation.SetActive(true); if (isOwner() || MainGameManager.getInstance().player.targetFocus.GetComponent <PlayerController>() == this) { CoroutineUtility.GetInstance() .Do() .Wait(1.5f) .Then(() => MainGameManager.getInstance().ChangeCameraFocus()) .Then(() => MainGameManager.getInstance().changeCameraFocusPanel.SetActive(true)) .Go(); } if (isOwner()) { MainGameManager.getInstance().canUseSkill = false; } if (PhotonNetwork.isMasterClient) { int rank = OnPlayerDied(); gameObject.GetPhotonView().RPC("SetPlayerRank", PhotonTargets.All, rank); if (rank == 1) { Debug.Log("GameOver"); gameObject.GetPhotonView().RPC("GameOver", PhotonTargets.All); } else if (rank == 3 || rank == 2) { PlayerController targetEnemy = null; PlayerController targetEnemy2 = null; int count = 0; foreach (PlayerController pl in PhotonManager.getInstance().playerList) { if (!pl.isDied) { count++; if (count <= 1) { targetEnemy = pl; } else { targetEnemy2 = pl; break; } } } foreach (PlayerController pl in PhotonManager.getInstance().playerList) { if (pl.isAI) { pl.isAIFocusEnemy = true; if (pl == targetEnemy) { pl.AIFocusEnemy = targetEnemy2; } else { pl.AIFocusEnemy = targetEnemy; } } } } } }
void Start() { PhotonManager.getInstance().ConnectToServer(); }
public void RandomJoin() { PhotonManager.getInstance().RandomJoinRoom(); }
public void LeaveRoom() { MainUIManager.CreateDialogBox(() => PhotonManager.getInstance().LeaveRoom(), "確定要離開房間嗎?"); }