// Start is called before the first frame update void Start() { playStatus = PlayerStatus.Instance; AudioManager2D.Instance.AudioBgm.clip = battleBgm; AudioManager2D.Instance.AudioBgm.Play(); battleTurn = BattleMode.Player; }
public void OnAgentBattle(int identity, byte playerPosition, BattleMode battleMode) { if (this.OnStartAgentBattle != null) { this.OnStartAgentBattle(identity, playerPosition, battleMode); } }
public void ShowTitle(ScreenNode screen, ResultsNode results, int userDMPlace) { BattleResultForClient resultForClient = results.battleResults.ResultForClient; BattleMode battleMode = resultForClient.BattleMode; screen.battleResultsAwardsScreen.SetupHeader(battleMode, resultForClient.MatchMakingModeType, resultForClient.PersonalResult.TeamBattleResult, Flow.Current.EntityRegistry.GetEntity(resultForClient.MapId).GetComponent <DescriptionItemComponent>().Name, userDMPlace); }
public void ReadFromByteArray(ByteArray byteArray) { this.Terrain = BattleTerrainHelper.ReadFromByteArray(byteArray); this.Mode = BattleModeHelper.ReadFromByteArray(byteArray); this.Caption = byteArray.ReadUTF(); this.CustomDataHash = byteArray.ReadUTF(); }
private void HandleBuildBattleServerEvent(BattleMode mode, BattleRuleSequence rules) { if (this.OnBuildBattleServer != null) { this.OnBuildBattleServer(mode, rules); } }
public void SetupHeader(BattleMode battleMode, BattleType matchMakingModeType, TeamBattleResult resultType, string mapName, int selfUserPlace) { this.title.color = this.titleColors[(int)resultType]; if (battleMode == BattleMode.DM) { this.title.text = string.Format((string)this.placeLocalizedField, selfUserPlace); } else if (resultType == TeamBattleResult.WIN) { this.title.text = this.winLocalizedField.Value; } else if (resultType == TeamBattleResult.DEFEAT) { this.title.text = this.defeatLocalizedField.Value; } else if (resultType == TeamBattleResult.DRAW) { this.title.text = this.drawLocalizedField.Value; } string str = string.Empty; if (matchMakingModeType == BattleType.ARCADE) { str = this.arcadeLocalizedField.Value; } else if (matchMakingModeType == BattleType.ENERGY) { str = this.energyLocalizedField.Value; } else if (matchMakingModeType == BattleType.RATING) { str = this.ratingLocalizedField.Value; } this.subTitle.text = $"{str}({battleMode}), {mapName}"; }
public void OnLogon(int sessionID, string identity, BattleMode modeInfo, string versionInfo) { int num; BattleAgent agent = null; if (int.TryParse(identity, out num)) { agent = this.GetAgent(num); } if (agent != null) { if (!agent.BattleEnd) { (base.GetClient(sessionID) as BattleAgentSession).AgentID = num; agent.UserLogon(sessionID, identity); base.Send(sessionID, PokemonBattleServerHelper.LogonSuccess()); } else { base.Send(sessionID, PokemonBattleServerHelper.LogonFail("对手已退出")); base.Disconnect(sessionID); } } else { base.Send(sessionID, PokemonBattleServerHelper.LogonFail("无法找到对应的对战代理")); base.Disconnect(sessionID); } }
public override void AfterInvoke(InvocationInfo info, ref object returnValue) { if (info.targetMethod.Equals("Update")) { if (_battleMode == null) { _battleMode = (BattleMode)info.target; } FieldInfo _turnInfo = typeof(BattleMode).GetField("currentTurn", BindingFlags.NonPublic | BindingFlags.Instance); var turn = (int)_turnInfo.GetValue(_battleMode); if (turn < 1) { _done = false; return; } _showStatsInfo = typeof(BattleMode).GetField("showUnitStats", BindingFlags.NonPublic | BindingFlags.Instance); if (_showStatsInfo != null && !(bool)_showStatsInfo.GetValue(_battleMode) && !_done) { typeof(BattleMode).GetMethod("toggleUnitStats", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(_battleMode, null); } _done = true; } }
private void BuildBattleServerForm(BattleMode battleMode, BattleRuleSequence rules) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildBattleServerFormEvent(this._myInfo.Name, battleMode, rules.Elements); if (form != null) { this.SetUserState(UserState.Battling); form.FormClosed += new FormClosedEventHandler(this.BattleFormClosed); form.Show(); } else { MessageBox.Show("please build battle server form"); this.SetUserState(UserState.Free); } } else { if (method == null) { method = delegate { this.BuildBattleServerForm(battleMode, rules); }; } base.Invoke(method); } }
private void BuildBattleClientForm(string serverAddress, BattleMode battleMode) { VoidFunctionDelegate method = null; if (!base.InvokeRequired) { Form form = this.HandleBuildBattleClientFormEvent(serverAddress, 2, this._myInfo.Name, battleMode); if (form != null) { this.SetUserState(UserState.Battling); form.FormClosed += new FormClosedEventHandler(this.BattleFormClosed); form.Show(); } else { MessageBox.Show("please build battle client form"); this.SetUserState(UserState.Free); } } else { if (method == null) { method = delegate { this.BuildBattleClientForm(serverAddress, battleMode); }; } base.Invoke(method); } }
// Constructs default ability data for each ability named in BattleMode. // Used only in case of read error. void SetAbilityDataDefaultValues() { abilityStatData.Clear(); foreach (BattleMode name in BattleMode.GetValues(typeof(BattleMode))) { abilityStatData.Add(name, new BattleAbility(name)); } }
private static bool OnDirectBattle(ByteArray byteArray, IRoomClientService clientService) { int server = byteArray.ReadInt(); BattleMode battleMode = BattleModeHelper.ReadFromByteArray(byteArray); clientService.OnDirectBattle(server, battleMode); return(true); }
private static string GetPath(BattleMode battleMode) { if (battleMode != BattleMode.PvP) { return("BattleActionProperties"); } return("BattleActionPropertiesPvP"); }
private Form HandleBuildBattleServerFormEvent(string userName, BattleMode mode, List <BattleRule> rules) { if (this.OnBuildBattleServerForm != null) { return(this.OnBuildBattleServerForm(userName, mode, rules)); } return(null); }
private static bool OnAgentBattle(ByteArray byteArray, IRoomClientService clientService) { int identity = byteArray.ReadInt(); byte playerPosition = byteArray.ReadByte(); BattleMode battleMode = BattleModeHelper.ReadFromByteArray(byteArray); clientService.OnAgentBattle(identity, playerPosition, battleMode); return(true); }
private static bool OnLogon(int sessionID, ByteArray byteArray, IPokemonBattleServerService serverService) { string identity = byteArray.ReadUTF(); BattleMode modeInfo = BattleModeHelper.ReadFromByteArray(byteArray); string versionInfo = byteArray.ReadUTF(); serverService.OnLogon(sessionID, identity, modeInfo, versionInfo); return(true); }
public void OnDirectBattle(int server, BattleMode battleMode) { User user = this.GetUser(server); if ((user != null) && (this.OnStartDirectBattle != null)) { this.OnStartDirectBattle(user.Address, battleMode); } }
private bool VerifyClient(string identity, BattleMode modeInfo, string versionInfo, out string message) { if (this.OnBattleClientConnected != null) { return(this.OnBattleClientConnected(identity, modeInfo, versionInfo, out message)); } message = ""; return(true); }
public int AddBattle(BattleMode mode, BattleRuleSequence rules) { this._battleIdentityBase++; BattleAgent agent = new BattleAgent(mode, rules.Elements, this); this._agents[this._battleIdentityBase] = agent; Logger.LogInfo("Add battle agent, ID : {0}", new object[] { this._battleIdentityBase }); return(this._battleIdentityBase); }
// Invokes the PropelHitTarget event, and begins return trip. // Objects that do not return are destroyed in an override of this method protected virtual void HitTarget() { rb2d.velocity = Vector2.zero; targetLastPosition = new Bounds(startPosition, new Vector2(BoundsMargin, BoundsMargin)); isReturning = true; battle_PropelHitTarget.Invoke(BattleID, targetBattleID, mode); propelSpeedModifier = 1f; mode = BattleMode.none; }
private void Awake() { Instance = this; LoadIcon(); Caster = new SkillCaster(); //角色拥有的测试技能 TotalSkills = GetTestSkills(); }
public static ByteArray Logon(string identity, BattleMode modeInfo, string versionInfo) { ByteArray byteArray = new ByteArray(); byteArray.WriteInt(0x5bbe67ef); byteArray.WriteUTF(identity); BattleModeHelper.WriteToByteArray(byteArray, modeInfo); byteArray.WriteUTF(versionInfo); return(byteArray); }
private bool UpdateBattleInfo() { if (!this.battle.HasComponent <EnergyBattleComponent>() && (!this.battle.HasComponent <ArcadeBattleComponent>() && !this.battle.HasComponent <RatingBattleComponent>())) { return(false); } BattleMode battleMode = this.battle.GetComponent <BattleModeComponent>().BattleMode; object[] objArray1 = new object[] { this.GetTypeText(), " (", battleMode, ")" }; this.battleInfo.text = string.Concat(objArray1); return(true); }
private void Start() { battle = BattleMode.Instance; battle.OnBattleStartEvent += () => { battle.OnChangeDiceEvent += SetDicesTransform; battle.OnChangeDiceEvent += SetSkillReference; //先生成一波参考技能 battle.Caster.RefreshReference(); battle.OnChangeDiceEvent.Invoke(); }; }
// Called just before being set active. Called by BattleManager.Click_Magic() // Used once in whole, but subsequently only sets HeroType. // Requires a HeroType to know what spells to set. public void Initialize(HeroType type) { // Set type before setting active. this.type = type; // The rest is only performed once. if (!initialized) { initialized = true; // Collect height from template float height = spellText.rectTransform.rect.height * spellText.rectTransform.localScale.y; // define 6 positions based on height and onset, for later use positions[0] = spellText.transform.localPosition; positions[1] = new Vector2(positions[0].x, positions[0].y - height); positions[2] = new Vector2(positions[0].x, positions[0].y - (2 * height)); positions[3] = new Vector2(positions[0].x + SecondColumnXOffset, positions[0].y); positions[4] = new Vector2(positions[0].x + SecondColumnXOffset, positions[0].y - height); positions[5] = new Vector2(positions[0].x + SecondColumnXOffset, positions[0].y - (2 * height)); // Store reference to parentTransform Transform parentTransform = spellText.transform.parent.transform; // Create a text object for each spell in the BattleMode enum, using spellText as template foreach (BattleMode mode in BattleMode.GetValues(typeof(BattleMode))) { if (mode.ToString().StartsWith("Magic_")) { string name = mode.ToString().Substring(6); GameObject newText = GameObject.Instantiate(spellText.gameObject); newText.transform.SetParent(parentTransform); newText.transform.localScale = spellText.transform.localScale; newText.GetComponent <Text>().text = name; newText.GetComponent <SpellClick>().SetMode(mode, this); spellTexts.Add(newText.GetComponent <Text>()); } } // Destroy template Destroy(spellText.gameObject); // Place ALL spellTexts using 6 positions for (int i = 0; i < spellTexts.Count; i++) { spellText.transform.localPosition = positions[i]; } } }
} // bypasses crit chance #endregion #region Constructor /// <summary> /// Constructor for BattleAbility /// </summary> /// <param name="name">Ability name as a BattleMode</param> /// <param name="isPhysical">Default true</param> /// <param name="mp">Default null</param> /// <param name="noReduction">Default false (ability can be reduced)</param> /// <param name="modifier">Damage multiplier (default 1.0)</param> /// <param name="noMiss">Default false (ability can be missed)</param> /// <param name="hitNumOverride">Default null (no num hits specified)</param> /// <param name="noCrit">Default false (ability can crit)</param> public BattleAbility(BattleMode name = BattleMode.none, bool isPhysical = true, int?mp = null, bool noReduction = false, float modifier = 1, bool noMiss = false, int?hitNumOverride = null, bool noCrit = false) { Name = name; IsPhysical = isPhysical; MP = mp; NoReduction = noReduction; Modifier = modifier; NoMiss = noMiss; HitNumOverride = hitNumOverride; NoCrit = noCrit; }
// Called whenever the subMenu becomes active. Enables and sorts spells for display public void SetSpells(HeroType type) { // Set the HeroType Initialize(type); // Form a list of available spells based on HeroType List <BattleMode> enableModes = new List <BattleMode>(); switch (type) { case HeroType.Celes: enableModes.Add(BattleMode.Magic_Cure); enableModes.Add(BattleMode.Magic_Heal); enableModes.Add(BattleMode.Magic_Fireball); enableModes.Add(BattleMode.Magic_Poison); break; case HeroType.Locke: enableModes.Add(BattleMode.Magic_Cure); enableModes.Add(BattleMode.Magic_Poison); break; default: // The Magic subMenu is disabled except for the above, so there // should never be a default case. enableModes.Add(BattleMode.Magic_Cure); break; } // Organize and enable spellTexts into position slots int i = 0; foreach (Text spellText in spellTexts) { // collect mode of this spellText BattleMode mode = spellText.gameObject.GetComponent <SpellClick>().Mode; // Compare to list of enabled spells. // If there's a match, enable and position, otherwise disable. if (enableModes.Contains(mode)) { spellText.gameObject.SetActive(true); spellText.gameObject.transform.localPosition = positions[i]; i++; } else { spellText.gameObject.SetActive(false); } } }
private bool ConnectTCPServer(BattleMode battleMode) { Screen.sleepTimeout = -1; Singleton <TCPUtil> .Instance.MakeTCPClient(); Singleton <TCPUtil> .Instance.battleMode = battleMode; Singleton <TCPUtil> .Instance.SetTCPCallBackMethod(new Action <Dictionary <string, object> >(this.TCPCallbackMethod)); Singleton <TCPUtil> .Instance.SetOnExitCallBackMethod(new Action(this.TCPDisconnectedCallbackMethod)); Singleton <TCPUtil> .Instance.SetExceptionMethod(new Action <short, string>(this.ExceptionCallbackMethod)); return(Singleton <TCPUtil> .Instance.ConnectTCPServer(ClassSingleton <MultiBattleData> .Instance.MyPlayerUserId)); }
public static string GetSpawnPointId(int enemiesNumber, BattleMode battleMode, int cameraType) { if (battleMode == BattleMode.PvP) { if (enemiesNumber == 1) { return("0001_enemiesOne_small"); } if (enemiesNumber == 2) { return("0002_enemiesTwo_small"); } if (enemiesNumber == 3) { return("0003_enemiesThree_small_pvp"); } } else if (cameraType == 1) { if (enemiesNumber == 1) { return("0001_enemiesOne_small_bigboss"); } if (enemiesNumber == 2) { return("0002_enemiesTwo_small"); } if (enemiesNumber == 3) { return("0003_enemiesThree_small"); } } else { if (enemiesNumber == 1) { return("0001_enemiesOne_small"); } if (enemiesNumber == 2) { return("0002_enemiesTwo_small"); } if (enemiesNumber == 3) { return("0003_enemiesThree_small"); } } global::Debug.LogError("値が不正です. (" + enemiesNumber + ")"); return(string.Empty); }
public BattleAgent(BattleMode mode, List <BattleRule> rules, BattleAgentServer server) { this._server = server; this._battleMode = mode; this._rules = rules; this._randomSeed = new Random().Next(); if (mode == BattleMode.Double_4P) { this._waitUserCount = 4; } else { this._waitUserCount = 2; } }
public override bool BeforeInvoke(InvocationInfo info, out object returnValue) { // we can obtain the BattleMode instance from this call if (info.targetMethod.Equals("handleMessage")) { if (bm == null) { bm = (BattleMode)info.target; } Message m = (Message)info.arguments[0]; if (m is GameInfoMessage) { GameInfoMessage gm = (GameInfoMessage)m; if (new GameType(gm.gameType).isMultiplayer()) // just multiplayer matches { try { String opponentName = getOpponentName(gm); // now use the api to get the player's data WebClientTimeOut wc = new WebClientTimeOut(); wc.TimeOut = 3000; wc.DownloadStringCompleted += (sender, e) => { parseJSONResult(e.Result, opponentName); }; wc.DownloadStringAsync(new Uri("http://a.scrollsguide.com/player?fields=all&name=" + opponentName)); } catch // could not get information { } } } } returnValue = null; return false; }
private void Initialize(BattleMode battleMode) { this.battleMode = battleMode; this.handManager = GetHandManager (); cardClickedMethodInfo = ReflectionsManager.GetMethod (battleMode, "cardClicked"); toggleUnitStatsMethodInfo = ReflectionsManager.GetMethod (battleMode, "toggleUnitStats"); deselectAllTilesMethodInfo = ReflectionsManager.GetMethod (battleMode, "deselectAllTiles"); gameMenu = (GUIBattleModeMenu)ReflectionsManager.GetValue (battleMode, "menu"); controlBoard = false; tileRow = 2; tileColumn = 1; }
//{"whiteGameState":{"playerName":"Eva","board":{"color":"white","tiles":[{"card":{"id":4269572,"typeId":153,"tradable":true,"isToken":false,"level":2},"ap":0,"ac":4,"hp":5,"position":"4,0"},{"card":{"id":18154143,"typeId":207,"tradable":true,"isToken":false,"level":0},"ap":0,"ac":2,"hp":5,"position":"0,2"},{"card":{"id":18628883,"typeId":204,"tradable":true,"isToken":false,"level":0},"ap":8,"ac":6,"hp":4,"position":"4,2"}],"idols":[10,10,4,7,7]},"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":0,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":3,"ENERGY":7,"GROWTH":0},"handSize":3,"librarySize":11,"graveyardSize":33}},"blackGameState":{"playerName":"iScrE4m","board":{"color":"black","tiles":[{"card":{"id":13865404,"typeId":205,"tradable":true,"isToken":false,"level":2},"ap":1,"ac":1,"hp":2,"position":"1,0"},{"card":{"id":-1,"typeId":96,"tradable":true,"isToken":true,"level":0},"ap":2,"ac":2,"hp":3,"position":"3,0"},{"card":{"id":21239788,"typeId":256,"tradable":true,"isToken":false,"level":0},"ap":2,"ac":6,"hp":3,"position":"1,2"},{"card":{"id":23944590,"typeId":281,"tradable":true,"isToken":false,"level":0},"ap":2,"ac":2,"hp":2,"position":"3,2"}],"idols":[10,10,10,10,10]},"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":2,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":0,"ENERGY":7,"GROWTH":0},"handSize":1,"librarySize":21,"graveyardSize":25}},"activeColor":"black","phase":"PreMain","turn":26,"hasSacrificed":false,"secondsLeft":90,"msg":"GameState"} private string getTiles(BattleMode bm, bool iswhite) { TileColor tc = TileColor.black; if (iswhite) tc = TileColor.white; List<Unit> units = bm.getUnitsFor(tc);//(List<Unit>)unitsMethod.Invoke(bm, new object[] { tc }); string retval = ""; //{"card":{"id":7837,"typeId":127,"tradable":true,"isToken":false,"level":0},"ap":4,"ac":2,"hp":3,"position":"1,0","buffs":[{"name":"Crown of Strength","description":"Enchanted unit gains +1 Attack and +2 Health.","type":"ENCHANTMENT"}]} foreach (Unit u in units) { Card c = u.getCard(); if (retval != "") retval = retval + ","; //{"card":{"id":7837,"typeId":127,"tradable":true,"isToken":false,"level":0}, retval = retval + "{\"card\":{\"id\":"+ c.getId()+ ",\"typeId\":"+ c.getType() + ",\"tradable\":"+c.tradable.ToString().ToLower()+",\"isToken\":"+c.isToken.ToString().ToLower()+",\"level\":"+c.level+"},"; //"ap":4,"ac":2,"hp":3,"position":"1,0" retval = retval + "\"ap\":" + u.getAttackPower() + ",\"ac\":" + u.getAttackInterval() + ",\"hp\":" + u.getHitPoints() + ",\"position\":\"" + u.getTilePosition().row + "," + u.getTilePosition().column + "\""; //,"buffs":[{"name":"Crown of Strength","description":"Enchanted unit gains +1 Attack and +2 Health.","type":"ENCHANTMENT"}] List<EnchantmentInfo> b = u.getBuffs(); if (b.Count >= 1) { retval = retval + ",\"buffs\":["; string buffes=""; foreach (EnchantmentInfo e in b) { if (buffes != "") buffes = buffes + ","; buffes = buffes + "{\"name\":\"" + e.name + "\",\"description\":\"" + e.description + "\",\"type\":\"" + e.type.ToString().ToUpper() + "\"}"; } retval = retval + buffes+ "]"; } retval = retval + "}"; } return retval; }
// Creates a GameState Message public string create(BattleMode bm, BattleModeUI bmUI, bool whitesTurn) { BMPlayer leftPlayer= (BMPlayer)leftPlayerField.GetValue(bm); string leftPlayerName = leftPlayer.name; //string blackPlayerName = ((string)typeof(BattleMode).GetField("rightPlayerName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm)); //TileColor activeColor = ((TileColor)typeof(BattleMode).GetField("activeColor", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm)); //int turnNumber = ((int)typeof(BattleMode).GetField("currentTurn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bm)); GameType gameType = (GameType)gameTypeField.GetValue(bm); int secondsleft = -1; if (gameType == GameType.MP_RANKED) secondsleft = 90; if (gameType == GameType.MP_QUICKMATCH) secondsleft = 60; if (gameType == GameType.MP_LIMITED) secondsleft = 90; TileColor activeColor = TileColor.white; if (!whitesTurn) activeColor = TileColor.black; PlayerAssets whiteplayer = bmUI.GetResources(true); PlayerAssets blackplayer = bmUI.GetResources(false); if (leftPlayerName == blackPlayerName) { whiteplayer = bmUI.GetResources(false); blackplayer = bmUI.GetResources(true); } //ResourceGroup whiteRessisAvail = ((ResourceGroup)typeof(BattleModeUI).GetField("leftAvailable", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI)); //ResourceGroup blackRessisAvail = ((ResourceGroup)typeof(BattleModeUI).GetField("rightAvailable", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI)); //ResourceGroup whiteRessisMax = ((ResourceGroup)typeof(BattleModeUI).GetField("leftMax", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI)); //ResourceGroup blackRessisMax = ((ResourceGroup)typeof(BattleModeUI).GetField("rightMax", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(bmUI)); string retval = ""; //{"whiteGameState":{"playerName":"Easy AI","board":{"color":"white","tiles":[{"card":{"id":7837,"typeId":127,"tradable":true,"isToken":false,"level":0},"ap":4,"ac":2,"hp":3,"position":"1,0","buffs":[{"name":"Crown of Strength","description":"Enchanted unit gains +1 Attack and +2 Health.","type":"ENCHANTMENT"}]},{"card":{"id":7834,"typeId":126,"tradable":true,"isToken":false,"level":0},"ap":1,"ac":2,"hp":2,"position":"1,1"},{"card":{"id":7838,"typeId":127,"tradable":true,"isToken":false,"level":0},"ap":3,"ac":2,"hp":3,"position":"1,2"}],"idols":[10,10,0,10,9]},"assets":{"availableResources":{"DECAY":0,"ORDER":4,"ENERGY":0,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":5,"ENERGY":0,"GROWTH":0},"handSize":4,"librarySize":30,"graveyardSize":12}},"blackGameState":{"playerName":"fuj1n","board":{"color":"black","tiles":[{"card":{"id":6151538,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,1"},{"card":{"id":6151539,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,2"}],"idols":[10,6,10,10,10]},"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"handSize":3,"librarySize":26,"graveyardSize":19}},"activeColor":"black","phase":"Main","turn":26,"hasSacrificed":false,"secondsLeft":-1,"msg":"GameState"} retval = "{\"whiteGameState\":{\"playerName\":\"" + whitePlayerName + "\",\"board\":{\"color\":\"white\",\"tiles\":["; //get cards: retval = retval + this.getTiles(bm, true); //],"idols":[10,10,0,10,9]}, //get white idols retval = retval + "],\"idols\":[" + this.whiteIdols[0] + "," + this.whiteIdols[1] + "," + this.whiteIdols[2] + "," + this.whiteIdols[3] + "," + this.whiteIdols[4] + "]},"; //board finished //"assets":{"availableResources":{"DECAY":0,"ORDER":4,"ENERGY":0,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":5,"ENERGY":0,"GROWTH":0}, retval = retval + "\"assets\":{\"availableResources\":{\"DECAY\":" + whiteplayer.availableResources.DECAY + ",\"ORDER\":" + whiteplayer.availableResources.ORDER + ",\"ENERGY\":" + whiteplayer.availableResources.ENERGY + ",\"GROWTH\":" + whiteplayer.availableResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.availableResources.SPECIAL + "},"; retval = retval + "\"outputResources\":{\"DECAY\":" + whiteplayer.outputResources.DECAY + ",\"ORDER\":" + whiteplayer.outputResources.ORDER + ",\"ENERGY\":" + whiteplayer.outputResources.ENERGY + ",\"GROWTH\":" + whiteplayer.outputResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.outputResources.SPECIAL + "},"; //"handSize":4,"librarySize":30,"graveyardSize":12}}, retval = retval + "\"handSize\":" + whiteplayer.handSize + ",\"librarySize\":" + whiteplayer.librarySize +",\"graveyardSize\":" + whiteplayer.graveyardSize +"}},"; //black //"blackGameState":{"playerName":"Easy AI","board":{"color":"black","tiles":[{"card":{"id":6151538,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,1"},{"card":{"id":6151539,"typeId":68,"tradable":false,"isToken":false,"level":0},"ap":5,"ac":1,"hp":4,"position":"2,2"} retval = retval + "\"blackGameState\":{\"playerName\":\"" + blackPlayerName + "\",\"board\":{\"color\":\"black\",\"tiles\":["; retval = retval + this.getTiles(bm, false); // ],"idols":[10,6,10,10,10]}, retval = retval + "],\"idols\":[" + this.blackIdols[0] + "," + this.blackIdols[1] + "," + this.blackIdols[2] + "," + this.blackIdols[3] +"," + this.blackIdols[4] + "]},"; //board finished //"assets":{"availableResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0},"outputResources":{"DECAY":0,"ORDER":0,"ENERGY":6,"GROWTH":0}, retval = retval + "\"assets\":{\"availableResources\":{\"DECAY\":" + blackplayer.availableResources.DECAY + ",\"ORDER\":" + blackplayer.availableResources.ORDER + ",\"ENERGY\":" + blackplayer.availableResources.ENERGY + ",\"GROWTH\":" + blackplayer.availableResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.availableResources.SPECIAL + "},"; retval = retval + "\"outputResources\":{\"DECAY\":" + blackplayer.outputResources.DECAY + ",\"ORDER\":" + blackplayer.outputResources.ORDER + ",\"ENERGY\":" + blackplayer.outputResources.ENERGY + ",\"GROWTH\":" + blackplayer.outputResources.GROWTH + ",\"SPECIAL\":" + whiteplayer.outputResources.SPECIAL + "},"; //"handSize":3,"librarySize":26,"graveyardSize":19}}, retval = retval + "\"handSize\":" + blackplayer.handSize + ",\"librarySize\":" + blackplayer.librarySize + ",\"graveyardSize\":" + blackplayer.graveyardSize + "}},"; //"activeColor":"black","phase":"Main","turn":26,"hasSacrificed":false,"secondsLeft":-1,"msg":"GameState"} retval = retval + "\"activeColor\":\"" + activeColor.ToString() +"\",\"phase\":\"Main\",\"turn\":"+ this.turnnumber + ",\"hasSacrificed\":false,\"secondsLeft\":" + secondsleft + ",\"msg\":\"GameState\"}"; return retval; }
public void setBm(BattleMode b) { this.bttlmd = b; }
public override bool BeforeInvoke(InvocationInfo info, out object returnValue) { // we can obtain the BattleMode instance from this call //writetxtinchat(info.targetMethod); /*if (info.targetMethod.Equals("runEffect")) { EffectMessage currentEffect = (EffectMessage)typeof(BattleMode).GetField("currentEffect", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); if (currentEffect == null) { List<EffectMessage> effectListArr = (List<EffectMessage>)typeof(BattleMode).GetField("effectListArr", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); if (effectListArr.Count != 0) { int replayNexts = (int)typeof(BattleMode).GetField("replayNexts", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); if (replayNexts > 0) { // replayNexts--; EffectMessage effectMessage = effectListArr[0]; currentEffect = effectMessage; string type = effectMessage.type; if (type.Equals("TurnBegin")) { writetxtinchat("beginn"); } } } } }*/ if (info.targetMethod.Equals("handleMessage")) { if (bm == null) { bm = (BattleMode)info.target; } Message m = (Message)info.arguments[0]; if (m is NewEffectsMessage && this.onoroff == 1) { //writetxtinchat(m.getRawText()); if (m.getRawText().Contains("EndGame")) { //game zuende this.stopmusic = 1; this.myTimer.Stop(); } } if (m is NewEffectsMessage && this.onoroff==1) { //writetxtinchat(m.getRawText()); if (m.getRawText().Contains("ResourcesUpdate") && this.myturnbegins == 1) { this.myturnbegins = 0; mciSendString("stop MediaFiles", null, 0, IntPtr.Zero); mciSendString("close MediaFiles", null, 0, IntPtr.Zero); mciSendString("open \"" + this.startmusic + "\" type mpegvideo alias MediaFiles", null, 0, IntPtr.Zero); mciSendString("play MediaFiles", null, 256, IntPtr.Zero); this.myTimer.Interval = 1000 * (this.roundTime - (float)this.playearlier); //writetxtinchat((this.roundTime - (float)this.playearlier).ToString()); this.myTimer.Enabled = true; this.myTimer.Start(); // have to load it here, dont know why(otherwise cant load / play the file in ontimedevent) mciSendString("open \"" + this.endmusic + "\" type mpegvideo alias MediaFilet", null, 0, IntPtr.Zero); mciSendString("close MediaFilet", null, 0, IntPtr.Zero); //Console.WriteLine("TIMER start"); } if (m.getRawText().Contains("TurnBegin")) { //get turninfo form m string[] lol = Regex.Split(m.getRawText(), "\"turn\":"); string[] lol2 = Regex.Split(lol[1], "}"); //writetxtinchat("Turn"+lol2[0]); this.stopmusic = 1; this.myTimer.Stop(); if (m.getRawText().Contains(owncolor)) { // OWN TURN! //writetxtinchat("own turn"); //AudioScript audio = (AudioScript)typeof(BattleMode).GetField("audioScript", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); //audio.PlaySFX("Sounds/hyperduck/fanfare_tier_03"); this.myturnbegins = 1; } } } } if (info.targetMethod.Equals("handleMessage")) { if (bm == null) { bm = (BattleMode)info.target; } Message m = (Message)info.arguments[0]; if (m is GameInfoMessage) // get own color and roundtimer (= 90 i know :D) { GameInfoMessage gm = (GameInfoMessage)m; if (new GameType(gm.gameType).isMultiplayer()) // just multiplayer matches { writetxtinchat("Soundnotify on"); this.onoroff = 1; string[] lol = Regex.Split(m.getRawText(), "\"color\":\""); string[] lol2 = Regex.Split(lol[1], "\""); this.owncolor = lol2[0]; //writetxtinchat(this.owncolor); string[] lol3 = Regex.Split(m.getRawText(), "\"roundTimerSeconds\":"); string[] lol4 = Regex.Split(lol3[1], ","); this.roundTime = (float)Convert.ToDouble(lol4[0]); this.myTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); //writetxtinchat(this.startmusic); //writetxtinchat(this.endmusic); } else { writetxtinchat("Soundnotify off (singleplayer)"); this.onoroff = 0; /*string[] lol = Regex.Split(m.getRawText(), "\"color\":\""); string[] lol2 = Regex.Split(lol[1], "\""); this.owncolor = lol2[0]; //writetxtinchat(this.owncolor); string[] lol3 = Regex.Split(m.getRawText(), "\"roundTimerSeconds\":"); string[] lol4 = Regex.Split(lol3[1], ","); this.roundTime = (float)Convert.ToDouble(lol4[0]); this.myTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);*/ } } } returnValue = null; return false; }
public void setbm(BattleMode b) { this.bm = b; }
public bool Validate(BattleMode battleMode) { if (this.battleMode == null || this.handManager == null) { Initialize (battleMode); return true; } return false; }
public override void AfterInvoke (InvocationInfo info, ref object returnValue) { if (info.target is BattleMode && info.targetMethod.Equals("forceRunEffect")) { if (tpStatsupdate != null) { Unit statsupdate = this.bm.getUnit(tpStatsupdate); if (statsupdate != null) { updateMoveUnit(statsupdate, statsupdate.getBuffs(), statsupdate.getActiveAbilities(), statsupdate.getName(), statsupdate.getTilePosition()); } tpStatsupdate = null; } EffectMessage currentEffect = (EffectMessage)info.arguments[0]; string type = currentEffect.type; if (type == "MoveUnit") { this.resetMoveAllUnits(); } if (type == "SummonUnit") { EMSummonUnit cef = (EMSummonUnit)currentEffect; Unit un = this.bm.getUnit(cef.target); this.updateMoveUnit(un, new List<EnchantmentInfo>(), cef.card.getActiveAbilities(), cef.card.getName(), cef.target); } if (type == "TeleportUnits") { this.resetMoveAllUnits(); } } if (info.target is BattleMode && info.targetMethod.Equals("toggleUnitStats")) { Boolean showUnitStats= (Boolean)typeof(BattleMode).GetField ("showUnitStats", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info.target); Allenchlist.Clear(); this.showall = showUnitStats; if (showUnitStats == true) { MethodInfo mi = typeof(BattleMode).GetMethod("getAllUnitsCopy", BindingFlags.NonPublic | BindingFlags.Instance); foreach (Unit current in (List<Unit>)mi.Invoke(this.bm,null)) { List<EnchantmentInfo> enchants = current.getBuffs(); //Tile component = ((BattleMode)info.target).getTileFromUnit(current); Tile component = ((BattleMode)info.target).getTile(current.getTilePosition()); this.Allenchantcreator(enchants, component, true); } } } if (info.target is Unit && info.targetMethod.Equals("renderUnit")) { if (bm == null) return; Unit current = (Unit)info.target; List<EnchantmentInfo> enchants = current.getBuffs(); if (enchants.Count > 0) { //Tile component = ((BattleMode)bm).getTileFromUnit(current); Tile component = ((BattleMode)bm).getTile(current.getTilePosition()); Tile.SelectionType marker = (Tile.SelectionType)mrktpe.GetValue(component); if (marker != Tile.SelectionType.Hover) { Material buffmat = (Material)this.buffMaterialInfo.GetValue(info.target); buffmat.SetColor("_Color", ColorUtil.FromInts(255, 0, 0, 220)); buffmat.color = new Color(1.0f, 0.0f, 0.0f, 0.7f); //current.renderer.material.color = new Color(1.0f, 0.5f, 0.5f, 0.7f); //GameObject refer = (GameObject)reftile.GetValue(component); //refer.renderer.material.color = new Color(1.0f, 0f, 0f, 0.4f); //GameObject to = (GameObject)tileover.GetValue(component); //to.renderer.material.color = new Color(1.0f, 0f, 0f, 0.4f); //component.getReference().renderer.material.color = new Color(1f, 0f, 0f, 0.4f); } } } if (info.target is BattleMode && info.targetMethod.Equals("Update")) { if (Input.GetKeyDown(KeyCode.M)) { foreach (Unit u in this.bm.getUnitsFor(TileColor.white)) { showMoveOfUnit(u); } foreach (Unit u in this.bm.getUnitsFor(TileColor.black)) { showMoveOfUnit(u); } } if (Input.GetKeyUp(KeyCode.M)) { foreach (Unit u in this.bm.getUnitsFor(TileColor.white)) { int v = (int)attackcounterinfo.GetValue(u); u.setAttackCounter(v - 1); u.setAttackCounter(v); } foreach (Unit u in this.bm.getUnitsFor(TileColor.black)) { int v = (int)attackcounterinfo.GetValue(u); u.setAttackCounter(v - 1); u.setAttackCounter(v); } } } if (info.target is BattleMode && info.targetMethod.Equals("OnGUI")) { if (bm == null) { bm = (BattleMode)info.target; } if (Input.GetMouseButtonDown(0) && this.currentHover.color != TileColor.unknown) { //mouse pressed! this.calculateEnemyLobbers(this.currentHover.color.otherColor()); //Console.WriteLine("moves:###############################"); //printMove(TileColor.white); //printMove(TileColor.black); } if (showall == true && this.allwayson==true) { Allenchlist.Clear(); foreach (Unit current in (List<Unit>)mi.Invoke(this.bm, null)) { List<EnchantmentInfo> enchants = current.getBuffs(); //Tile component = ((BattleMode)info.target).getTileFromUnit(current); Tile component = ((BattleMode)info.target).getTile(current.getTilePosition()); this.Allenchantcreator(enchants, component, true); } foreach (var item in Allenchlist) { Rect position = new Rect(item.posx, item.posy, picx, picy); GUI.DrawTexture(position, enchantslib[item.name]); } } else { if (showpicture == true) { foreach (var item in enchlist) { Rect position = new Rect(item.posx, item.posy, picx, picy); GUI.DrawTexture(position, enchantslib[item.name]); } } } /* foreach (Unit current in (List<Unit>)mi.Invoke(this.bm, null)) { //current.renderer.material.color = new Color(1f, 1f, 1f, 1f); Material buffmat = (Material)this.buffMaterialInfo.GetValue(current); Console.WriteLine("#clolor12" + buffmat.GetColor("_Color")); buffmat.SetColor("_Color", ColorUtil.FromHex24(16777173u)); List<EnchantmentInfo> enchants = current.getBuffs(); Tile component = ((BattleMode)info.target).getTileFromUnit(current); if (enchants.Count > 0) { Tile.SelectionType marker = (Tile.SelectionType)mrktpe.GetValue(component); if (marker != Tile.SelectionType.Hover) { //current.renderer.material.color = new Color(1.0f, 0.5f, 0.5f, 0.7f); buffmat.SetColor("_Color", ColorUtil.FromInts(255,0,0,220)); buffmat.color = new Color(1.0f, 0.0f, 0.0f, 0.7f); current.renderer.material.color = new Color(1.0f, 0.0f, 0.0f, 0.7f); Console.WriteLine("#clolorrrrr" + buffmat.GetColor("_Color")); //GameObject refer = (GameObject)reftile.GetValue(component); //refer.renderer.material.color = new Color(1.0f, 0f, 0f, 0.4f); //GameObject to = (GameObject)tileover.GetValue(component); //to.renderer.material.color = new Color(1.0f, 0f, 0f, 0.4f); //component.getReference().renderer.material.color = new Color(1f, 0f, 0f, 0.4f); } } }*/ } if (info.target is BattleMode && info.targetMethod.Equals("tileOver")) { showpicture = true; TilePosition tilepos = (TilePosition)info.arguments[0]; this.currentHover.color = tilepos.color; this.currentHover.row = tilepos.row; this.currentHover.column = tilepos.column; //Unit unitFromTile = ((BattleMode)info.target).getUnitFromTile(component); Unit unitFromTile = ((BattleMode)info.target).getUnit(tilepos); Tile component = ((BattleMode)info.target).getTile(tilepos); enchlist.Clear(); if (unitFromTile != null) { List<EnchantmentInfo> enchants= unitFromTile.getBuffs(); this.Allenchantcreator(enchants,component, false); } } if (info.target is BattleMode && info.targetMethod.Equals("tileOut")) { showpicture = false; this.currentHover.color = TileColor.unknown; } if (info.target is BattleMode && info.targetMethod.Equals("markMoveTile")) { TilePosition tilepos =(TilePosition)info.arguments[1]; Tile tile = this.bm.getTile(tilepos); int bad = 0; foreach (TilePosition tp in this.enemyLobbers) { if (tilepos.Equals(tp)) { bad++; } } if (bad>=1) { //Console.WriteLine("bad spottet " + tilepos); GameObject to = (GameObject)tileover.GetValue(tile); GameObject refer = (GameObject)reftile.GetValue(tile); GameObject taf = (GameObject)targetAnimFront.GetValue(tile); GameObject tab = (GameObject)targetAnimBack.GetValue(tile); GameObject car = (GameObject)chargeAnim.GetValue(tile); refer.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); to.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); if (taf != null) taf.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); if (tab != null) tab.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); if (car != null) car.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); } } if (this.mark && info.target is Tile && info.targetMethod.Equals("markInternal")) { TilePosition tpp = ((Tile)info.target).tilePosition(); Tile tile = (Tile)info.target; int bad = 0; if (enemyLobbers.Count >= 1 && enemyLobbers[0].color == tpp.color && ((Tile.SelectionType)info.arguments[0]) == Tile.SelectionType.None) { //this.mark = false; return; } foreach (TilePosition tp in this.enemyLobbers) { if (tpp.Equals(tp)) { bad++; } } if (bad >= 1) { //Console.WriteLine("bad spottet " + tpp); GameObject to = (GameObject)tileover.GetValue(tile); GameObject refer = (GameObject)reftile.GetValue(tile); GameObject taf = (GameObject)targetAnimFront.GetValue(tile); GameObject tab = (GameObject)targetAnimBack.GetValue(tile); refer.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); to.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); if (taf != null) taf.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); if (tab != null) tab.renderer.material.color = new Color(1.0f, 0f, 0f, 0.2f * bad); } } return; }
public BattleModeWrapper(BattleMode battleMode) { Initialize (battleMode); }