public static void FlinchMessage(Pokemon target, Move moveUsed) { string targetsName = string.IsNullOrEmpty(target.nickname) ? target.pokemonName : target.nickname; string msg = moveUsed.moveName + " caused " + targetsName + "(" + target.trainerName + ") to flinch!"; DarkRiftAPI.SendMessageToAll(TagIndex.Chat, TagIndex.ChatSubjects.BattleChat, msg); }
public void CheckWinLose(WinLoseDraw cond) { if (GameHasStarted) { Debug.Log("Changing win lose text"); switch (cond) { case WinLoseDraw.Draw: WinLose.text = "DRAW"; DarkRiftAPI.SendMessageToAll(NetworkingTags.Controller, NetworkingTags.ControllerSubjects.GameOver, ""); break; case WinLoseDraw.Win: WinLose.text = "YOU WIN"; DarkRiftAPI.SendMessageToAll(NetworkingTags.Controller, NetworkingTags.ControllerSubjects.GameOver, ""); break; case WinLoseDraw.Lose: //DarkRiftAPI.SendMessageToServer(NetworkingTags.Server, NetworkingTags.ServerSubjects.ILose, ""); WinLose.text = "YOU LOSE"; break; } WinLose.gameObject.SetActive(true); GameHasStarted = false; } }
public static void PartiallyTrappedMessage(Pokemon target, Move moveUsed) { string targetsName = string.IsNullOrEmpty(target.nickname) ? target.pokemonName : target.nickname; string msg = targetsName + "(" + target.trainerName + ") was trapped by " + moveUsed.moveName + "!"; DarkRiftAPI.SendMessageToAll(TagIndex.Chat, TagIndex.ChatSubjects.BattleChat, msg); }
void Start() { //Enable Background Running Application.runInBackground = true; //Enable custom log CustomLogger.LogIt("Start Logging"); //Application.dataPath Debug.Log(Application.dataPath); //Connect to the DarkRift Server using the Ip specified (will hang until connected or timeout) DarkRiftAPI.Connect(serverIP, serverPort); //Setup a receiver so we can create players when told to. DarkRiftAPI.onDataDetailed += ReceiveData; //Tell others that we've entered the game and to instantiate a player object for us. if (DarkRiftAPI.isConnected) { Debug.Log("Connected to the Server!"); //Get everyone else to tell us to spawn them a player (this doesn't need the data field so just put whatever) DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "hi"); //Then tell them to spawn us a player! (this time the data is the spawn position) DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, new Vector3(0f, 0f, 0f)); } else { Debug.LogError("Failed to connect to DarkRift Server!"); } }
void SendEventKeyboardDown(Direction theDir) { OnKeyboardButtonDown(theDir, client_id); if (DarkRiftAPI.isConnected) { DarkRiftAPI.SendMessageToAll(NetworkingTags.Events, NetworkingTags.EventSubjects.KeyboardEvent, theDir); } }
public void SendChatMessage() { if (!string.IsNullOrEmpty(chatInput.text.Trim())) { DarkRiftAPI.SendMessageToAll(TagIndex.Chat, TagIndex.ChatSubjects.MainChat, chatInput.text); chatInput.text = string.Empty; } }
public static void SerialisePokemonData(PokemonData data, string trainername, Vector3 position) { using (DarkRiftWriter writer = new DarkRiftWriter()) { writer.Write(new string[] { data.pokemonName, data.nickname, data.equippedItem, trainername }); writer.Write(new int[] { data.gender, data.nature, data.level, data.curMaxHP, data.curMaxPP, data.curMaxATK, data.curMaxDEF, data.curMaxSPATK, data.curMaxSPDEF, data.curMaxSPD, data.curHP, data.curPP, data.curATK, data.curDEF, data.curSPATK, data.curSPDEF, data.curSPD, data.hpEV, data.ppEV, data.atkEV, data.defEV, data.spatkEV, data.spdefEV, data.spdefEV, data.hpIV, data.ppIV, data.atkIV, data.defIV, data.spatkIV, data.spdefIV, data.spdIV, data.curEXP, data.id }); writer.Write(data.fromTrade); writer.Write(new double[] { position.x, position.y, position.z }); DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPokemon, writer); } }
public void TryToConnect() { if (DarkRiftAPI.isConnected) { return; } string sd = GameObject.Find("InputField").GetComponentsInChildren <Text>()[1].text; if (sd == "") { sd = serverIP; } if (!DarkRiftAPI.Connect(sd, 4296)) { return; } GameObject go = GameObject.Find("Name1"); //go.GetComponent<UnityEngine.UI.InputField>().text = "chiucken"; Application.runInBackground = true; DarkRiftAPI.onDataDetailed += ReceiveData; DontDestroyOnLoad(transform.gameObject); if (DarkRiftAPI.isConnected) { DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "hi"); DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, new Vector3(0.0f, 0.0f, 0.0f)); int index = DarkRiftAPI.id - 1; GameObject.Find("Canvas").GetComponentsInChildren <Image>()[index].color = Color.white; if (DarkRift.DarkRiftAPI.id != 1) { GameObject.Find("Button").GetComponentsInChildren <Button>()[index].interactable = false; } } else { Debug.Log("Failed to connect to DarkRift Server!"); } int id = playerNumber = DarkRiftAPI.id; if (id > playerCount) { playerCount = id; } SendData(TagIndex.Controller, TagIndex.PlayerUpdate, factions[DarkRiftAPI.id - 1]); }
private void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) { hud.loadingPanel.SetActive(false); if (DarkRiftAPI.isConnected) { DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "hi"); DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, trainerData.lastPosition); } else { Debug.LogWarning("There is no connection to the server right now."); } SceneManager.sceneLoaded -= OnLevelFinishedLoading; }
void Start() { if (!DarkRiftAPI.isConnected) { CustomNetworkManager.Instance.Connect("127.0.0.1"); } DarkRiftAPI.onDataDetailed += ReceiveData; currentPlayerCount = 0; thePlayerBoxes = new GameObject[thePlayerBoxesParent.childCount]; for (int i = 0; i < thePlayerBoxesParent.childCount; i++) { thePlayerBoxes[i] = thePlayerBoxesParent.GetChild(i).gameObject; thePlayerBoxes[i].SetActive(false); } DarkRiftAPI.SendMessageToAll(NetworkingTags.Room, NetworkingTags.RoomSubjects.JoinRoom, ""); DarkRiftAPI.SendMessageToServer(NetworkingTags.Server, NetworkingTags.ServerSubjects.ChangeStateToRoom, ""); }
void OnTriggerEnter2D(Collider2D collider) { if (collider.CompareTag(Explosion)) { Explosion theEx = collider.GetComponentInParent <Explosion>(); this.MinusHealthPoints((int)theEx.damage, (ushort)theEx.ID); } else if (collider.CompareTag(Gold)) { CurrentPlayer.Instance.Money += collider.GetComponent <Gold>().MoneyGiven; DarkRiftAPI.SendMessageToAll(NetworkingTags.Misc, NetworkingTags.MiscSubjects.GoldPickedUp, collider.transform.position); } else if (collider.CompareTag(EndExplosion)) { this.MinusHealthPoints(999, 999); } }
void Start() { //Connect to the DarkRift Server using the Ip specified (will hang until connected or timeout) DarkRiftAPI.Connect(serverIP); //Setup a reciever so we can create players when told to. DarkRiftAPI.onDataDetailed += RecieveData; //Tell others that we've entered the game and to instantiate a player object for us. if (DarkRiftAPI.isConnected) { //Get everyone else to tell us to spawn them a player (this doesnt need the data field so just put whatever) DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "hi"); //Then tell them to spawn us a player! (this time the data is the spawn position) DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, new Vector3(0f, 0f, 0f)); } }
void Start() { if (DarkRiftAPI.isConnected) { //Recieve Data DarkRiftAPI.onDataDetailed += ReceiveData; //Get everyone else to tell us to spawn them a player DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "New Player Joined"); //Spawn the player DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, Vars.lobby); //Instantiate(playerObject, Vars.lobby, Quaternion.identity); } else { Debug.LogWarning("Failed to connect to DarkRift Server!"); SceneManager.LoadScene(0); } }
public static void DamageMessage(Pokemon attacker, Pokemon target, Move moveUsed, int damage, bool critical) { string attackersName = string.IsNullOrEmpty(attacker.nickname) ? attacker.pokemonName : attacker.nickname; string targetsName = string.IsNullOrEmpty(target.nickname) ? target.pokemonName : target.nickname; string msg; if (critical) { msg = attackersName + "(" + attacker.trainerName + ") dealt " + damage + " damage to " + targetsName + "(" + target.trainerName + ") using " + moveUsed.moveName + "!!!"; } else { msg = attackersName + "(" + attacker.trainerName + ") dealt " + damage + " damage to " + targetsName + "(" + target.trainerName + ") using " + moveUsed.moveName + "."; } DarkRiftAPI.SendMessageToAll(TagIndex.Chat, TagIndex.ChatSubjects.BattleChat, msg); }
public static void StatModMessage(Pokemon target, Move moveUsed, StatType stat, bool trueForUp) { string targetsName = string.IsNullOrEmpty(target.nickname) ? target.pokemonName : target.nickname; string statString = string.Empty; if (stat == StatType.ATTACK) { statString = "attack"; } else if (stat == StatType.DEFENSE) { statString = "defense"; } else if (stat == StatType.SPECIALATTACK) { statString = "special attack"; } else if (stat == StatType.SPECIALDEFENSE) { statString = "special defense"; } else if (stat == StatType.SPEED) { statString = "speed"; } string msg; if (trueForUp) { msg = targetsName + "(" + target.trainerName + ") raised its " + statString + " using " + moveUsed.moveName + "!"; } else { msg = targetsName + "(" + target.trainerName + ") had its " + statString + " lowered by " + moveUsed.moveName + "!"; } DarkRiftAPI.SendMessageToAll(TagIndex.Chat, TagIndex.ChatSubjects.BattleChat, msg); }
void Start() { Map.Offset += 2.0f; waitForTimer = new WaitForSeconds(1); PlayerReady = 0; theTileMap = TileMapInterfacer.Instance.TileMap; if (Sandbox == true) { theObj.transform.position = theTileMap.ConvertTileToWorld(new Vector2(1, 1)); } else if (!Sandbox) { if (!DarkRiftAPI.isConnected) { string IPAddress = "127.0.0.1"; CustomNetworkManager.Instance.Connect(IPAddress); } DarkRiftAPI.SendMessageToAll(NetworkingTags.Controller, NetworkingTags.ControllerSubjects.JoinMessage, "hi"); //DarkRiftAPI.SendMessageToServer(NetworkingTags.Server, NetworkingTags.ServerSubjects.ChangeStateToGame, ""); } DarkRiftAPI.onDataDetailed += ReceiveData; DarkRiftAPI.onPlayerDisconnected += OnPlayerDisconnect; EventManager.OnDisplayKD += DisplayKD; string showBomb = System.IO.File.ReadAllText("showBomb.txt"); if (showBomb == "True" || showBomb == "true") { RevealFogExplosion.Trigger = true; } else { RevealFogExplosion.Trigger = false; } CurrentPlayer.Instance.Start(); }
private IEnumerator PokemonReturn() { if (localPlayer) { GetStatsBack(); } returnBall.audioS.Play(); yield return(new WaitForSeconds(1.0f)); returnBall.target = pokemon.gameObject; returnBall.lineRenderer.enabled = true; // if(localPlayer) // pokemon.RpcBeingCaptured(); yield return(new WaitForSeconds(1.0f)); // Vector3 scale = Vector3.zero; // // while(Vector3.Distance(trainer.activePokemon.gameObject.transform.localScale, scale) > 0.1f) // { // trainer.activePokemon.gameObject.transform.localScale = Vector3.Lerp(trainer.activePokemon.gameObject.transform.localScale, scale, Time.deltaTime * 5.0f); // yield return null; // } DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.DestroyPokemon, "Hi"); returnBall.target = null; yield return(new WaitForSeconds(1.5f)); returnBall.lineRenderer.enabled = false; if (localPlayer) { RemovePokemon(); } components.input.FinishedReturning(); //if(isServer && inBattle && opponent) //{ // bool allDead = true; // for(int i = 0; i < PokemonRoster.Count; i++) // { // if(PokemonRoster[i].curHP > 0) // allDead = false; // } // if(allDead) // { // canBattle = false; // RpcEndTrainerBattle(false); // opponent.RpcEndTrainerBattle(true); // } //} yield return(null); }
public void NetworkStartGame() { DarkRiftAPI.SendMessageToAll(Roland.NetworkingTags.Server, Roland.NetworkingTags.ServerSubjects.StartGameFromHost, ""); }