// Use this for initialization void Start() { // battleScript = GameObject.FindObjectOfType <BattleScript>(); //接続していない state = Status.DISCONNECTED; if (netMode == NetMode.NODE) { //Node.js SocketOptions options = new SocketOptions(); options.AutoConnect = false; //ネームスペースわけ Manager = new SocketManager(new System.Uri(url), options); Socket pvp = Manager.GetSocket("/pvp"); Socket news = Manager.GetSocket("/news"); //エラー処理 pvp.On(SocketIOEventTypes.Error, (socket, packet, args) => Debug.LogError(string.Format("Error: {0}", args [0].ToString()))); news.On(SocketIOEventTypes.Error, (socket, packet, args) => Debug.LogError(string.Format("Error: {0}", args [0].ToString()))); // pvp.On("OnMatched", OnMatched); pvp.On("OnJoin", OnJoin); Manager.Open(); } else { } }
public void EmptyScriptTest() { var script = new BattleScript(); // empty sub-scripts should each contain exactly 1 instruction (return) Assert.NotNull(script.Init); Assert.NotEmpty(script.Init); Assert.Equal(0, script.Init[0].Op.Code); Assert.NotNull(script.Execute); Assert.NotEmpty(script.Execute); Assert.Equal(0, script.Execute[0].Op.Code); Assert.NotNull(script.Counter); Assert.NotEmpty(script.Counter); Assert.Equal(0, script.Counter[0].Op.Code); Assert.NotNull(script.Death); Assert.NotEmpty(script.Death); Assert.Equal(0, script.Death[0].Op.Code); Assert.NotNull(script.PreCounter); Assert.NotEmpty(script.PreCounter); Assert.Equal(0, script.PreCounter[0].Op.Code); }
// Use this for initialization void Start() { player = FindObjectOfType <playerScript>(); battle = FindObjectOfType <BattleScript>(); var count = playerStats.Instance.playerMoves.Count; moves = playerStats.Instance.playerMoves; for (var i = 0; i < count; i++) { fightOptions[i].GetComponent <UnityEngine.UI.Text>().text = playerStats.Instance.playerMoves[i].Name; } }
public MonsterAI(byte[] data) : this() { using (var stream = new MemoryStream(data)) using (var reader = new BinaryReader(stream)) { var subSections = reader.ReadUInt32(); var aiOffset = reader.ReadUInt32(); var textIndexOffset = reader.ReadUInt32(); var textOffset = reader.ReadUInt32(); // extract battle AI script stream.Position = aiOffset; var aiLength = textIndexOffset - aiOffset; Scripts = new BattleScript(reader.ReadBytes((int)aiLength)); // extract text strings stream.Position = textIndexOffset; var textOffsets = new List <uint>(); var textLengths = new List <uint>(); for (int i = 0; i < (textOffset - textIndexOffset) / 2; i++) { var newOffset = reader.ReadUInt16(); if (i > 0) { // use this string's offset to fill in how long the previous string was var prevOffset = textOffsets.Last(); if (newOffset < prevOffset) { break; } textLengths.Add(newOffset - prevOffset); } textOffsets.Add(newOffset); } // final string ends at EOF if (textOffsets.Count > 0) { textLengths.Add((uint)stream.Length - (textOffset + textOffsets.Last())); } // decode strings for (int i = 0; i < textOffsets.Count; i++) { stream.Position = textOffset + textOffsets[i]; var newText = reader.ReadBytes((int)textLengths[i]); this.Strings.Add(FF8String.Decode(newText)); } } }
private void Awake() { MM = FindObjectOfType <MonsterManager>(); An = GetComponent <Animator>(); if (Application.loadedLevelName == "StepCounter") { pb = FindObjectOfType <ParallaxBackground>(); } if (Application.loadedLevelName == "Battle") { BS = FindObjectOfType <BattleScript>(); } }
private void OnTriggerStay(Collider collision) { if (collision.gameObject.transform.parent) { if (collision.gameObject.transform.parent.tag == "Battle") { if (StaticClasses.CharControllerVelocity != false) { if (StaticClasses.IsInBattle == false && currentMonsterOnPlayer.health > 0) { if (currentMonsterOnPlayer.monsterMoves[0] == null && currentMonsterOnPlayer.monsterMoves[1] == null) { print("Your monster doesn't have any moves!"); } else { float randomNumber = Random.Range(0f, 100f); if (randomNumber < 0.5f) { BattleScript battleScript = transform.parent.GetComponent <BattleScript>(); string WhatTypeOfMonsters = collision.gameObject.tag; List <int> TypeOfMonstersList = typeOfMonsters.FindType(WhatTypeOfMonsters); int MinMonsterLevel = Mathf.Clamp(currentMonsterOnPlayer.level - 2, 1, int.MaxValue); int MaxMonsterLevel = Mathf.Clamp(currentMonsterOnPlayer.level + 2, 1, int.MaxValue); print("Min Monster Level = " + MinMonsterLevel + " | Max Monster Level = " + MaxMonsterLevel); int RandomNumberLevel = Random.Range(MinMonsterLevel, MaxMonsterLevel + 1); print("Monster Level = " + RandomNumberLevel); int RandomNumber = Random.Range(1, 101); if (RandomNumber < StaticClasses.BossChance) { battleScript.Battle(TypeOfMonstersList[Random.Range(0, TypeOfMonstersList.Count - 1)], currentMonsterOnPlayer.level + 10, true); } else { battleScript.Battle(TypeOfMonstersList[Random.Range(0, TypeOfMonstersList.Count - 1)], RandomNumberLevel, false); } StaticClasses.IsInBattle = true; } } } else { //Already in battle or monster is at no health. } } } } }
// Use this for initialization public virtual void Start() { hp = Random.Range(20, 40); str = Random.Range(1, 5); speed = Random.Range(1, 20); sprite = GetComponent <OTSprite>(); script = (BattleScript)Camera.mainCamera.GetComponent("BattleScript"); if (!script) { Debug.Log("dang"); } damagePrefab = Resources.Load("DamageText", typeof(Transform)) as Transform; }
public void OnChecked() { string result = ClckButton.txtTempt.GetComponent <Text>().text; // get value txtTemp in ClckButton and //start to check in lsttmpPlay Debug.Log(VSReadyStart.lsttmpPlay[2]); //ClckButton.lstCheck.Clear(); for (int k = 0; k < VSReadyStart.lsttmpPlay.Count; k++) { if (result == VSReadyStart.lsttmpPlay[k]) { for (int b = 0; b < result.Length; b++) { GameObject btnClear = GameObject.Find(result[b].ToString()); btnClear.SetActive(false); } score += 1; // add score txtScoreB.GetComponent <Text>().text = score.ToString(); // assigned score --> textScore VSReadyStart.qty -= 1; // decrease qty --1 VSReadyStart.txtQty.GetComponent <Text>().text = VSReadyStart.qty.ToString(); // assigned qty --> textQty ClckButton.txtTempt.GetComponent <Text>().text = ""; // reset txtTempt } else { ClckButton.txtTempt.GetComponent <Text>().text = ""; // reset txtTempt } } if (VSReadyStart.qty == 0) { BattleScript elopoint = new BattleScript(); WWWForm form = new WWWForm(); Time.timeScale = 0; //set out game when qty word end. form.AddField("IdUser", CheckUserScript.userID); form.AddField("Win", 1); form.AddField("Lost", 0); form.AddField("EloPoint", elopoint.Cal_EloPoint_Win(HomeScript.elo).ToString()); StartCoroutine(callAPiUpdateWinLose(form)); } }
void SetControlsEnabled(GameObject playerObject, bool enabled) { BaseMovement movementScript = playerObject.GetComponent <BaseMovement>(); BattleScript combatScript = playerObject.GetComponent <BattleScript>(); ThirdPersonCamera cameraScript = Camera.main.GetComponent <ThirdPersonCamera>(); if (cameraScript != null) { cameraScript.enabled = enabled; } if (movementScript != null) { movementScript.enabled = enabled; } if (combatScript != null) { combatScript.enabled = enabled; } }
void Update() { time -= Time.deltaTime; txtTime.text = time.ToString("F2"); if (time == 0) { Time.timeScale = 0; BattleScript elopoint = new BattleScript(); WWWForm form = new WWWForm(); form.AddField("IdUser", CheckUserScript.userID); form.AddField("Win", 0); form.AddField("Lost", 1); form.AddField("EloPoint", elopoint.Cal_EloPoint_Lose(HomeScript.elo).ToString()); StartCoroutine(callAPiUpdateWinLose(form)); } }
public void SetupBoard(Board board) { Bscript = GetComponent <BattleScript>(); Box = GetComponent <DialogueBox>(); DropScript = GetComponent <PromotionDropdown>(); playerExp[0] = 0; playerExp[1] = 1; //createBlueP/Player1 mBlueUnits = CreateUnits(P1Color, Player1Appearance, board, P1RoyaltySetup); //createRedUnits/Player2 mRedUnits = CreateUnits(P2Color, Player2Appearance, board, P2RoyaltySetup); PlaceUnits(1, 0, mBlueUnits, board); PlaceUnits(6, 7, mRedUnits, board); //blueGoesFirst //blueGoesFirst SwitchSides(P2Color); //may have to fix this ResetBonuses(); CrossArrowAnimations(); blocker.gameObject.transform.SetAsLastSibling(); }
/// <summary> /// Loads up a battle for the player to view. /// </summary> /// <param name="battle"></param> public void LoadBattleMenu(BattleScript battle) { CloseMenu("battle"); SetAllInactive(); var pageo = Instantiate(PageMenuObj, Canvas.transform); var page = pageo.GetComponentInChildren <PageMenu>(); var text = new List <PageObjectDef>(); text.Add(new PageObjectDef() { name = "battle", text = $"Battle At {battle.Location}" }); foreach (var entity in battle.Entities) { text.Add(new UpdateTextDef() { name = $"battle{entity.Id}", text = "", UpdateText = () => { if (entity == null) { return("Wreckage"); } if (entity.Battle != battle) { return($"{entity.name}: Fled the field"); } return($"{entity.name} : {entity.Type} {Environment.NewLine}" + $"H:{entity.HP}/{entity.MaxHP} A:{entity.Armor}/{entity.MaxArmor} S:{entity.Shields}/{entity.MaxShields}{Environment.NewLine}"); } }); } page.Close = () => { CloseMenu("battle"); }; page.Populate(text); Menus.Add("battle", page); }
private void Start() { ui = FindObjectOfType <UIManager>(); bs = FindObjectOfType <BattleScript>(); es = FindObjectOfType <PedometerU.Tests.ExploreStep>(); counter1 = counter2 = counter3 = 0; Scene currentScene = SceneManager.GetActiveScene(); string sceneName = currentScene.name; if (sceneName == "StepCounter" || sceneName == "Battle") { this.RequestBanner(); } this.RequestInterstitial(); videoAd = RewardBasedVideoAd.Instance; // Called when an ad request has successfully loaded. videoAd.OnAdLoaded += HandleRewardBasedVideoLoaded; // Called when an ad request failed to load. videoAd.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad; // Called when an ad is shown. videoAd.OnAdOpening += HandleRewardBasedVideoOpened; // Called when the ad starts to play. videoAd.OnAdStarted += HandleRewardBasedVideoStarted; // Called when the user should be rewarded for watching a video. videoAd.OnAdRewarded += HandleRewardBasedVideoRewarded; // Called when the ad is closed. videoAd.OnAdClosed += HandleRewardBasedVideoClosed; // Called when the ad click caused the user to leave the application. videoAd.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication; this.RequestVideo(); videoAdClosed = false; }
public void EncodingTest(byte opcode, short[] args) { // construct a script with a populated init sub-script & run it through the encoder var script = new BattleScript(); script.Init.Insert(0, new Instruction(Instruction.OpCodes[opcode], args)); script = new BattleScript(script.Encode()); // added instruction should still be intact Assert.NotNull(script.Init); Assert.NotEmpty(script.Init); Assert.Equal(opcode, script.Init[0].Op.Code); Assert.Equal(args.Length, script.Init[0].Args.Length); for (int i = 0; i < args.Length; i++) { Assert.Equal(args[i], script.Init[0].Args[i]); } Assert.Equal(0, script.Init[1].Op.Code); // everything else should be the same as the empty script Assert.NotNull(script.Execute); Assert.NotEmpty(script.Execute); Assert.Equal(0, script.Execute[0].Op.Code); Assert.NotNull(script.Counter); Assert.NotEmpty(script.Counter); Assert.Equal(0, script.Counter[0].Op.Code); Assert.NotNull(script.Death); Assert.NotEmpty(script.Death); Assert.Equal(0, script.Death[0].Op.Code); Assert.NotNull(script.PreCounter); Assert.NotEmpty(script.PreCounter); Assert.Equal(0, script.PreCounter[0].Op.Code); }
// Use this for initialization void Start() { textmeshPro = this.gameObject.GetComponent <TextMeshProUGUI>(); bs = GameObject.FindGameObjectWithTag("GameController").GetComponent <BattleScript>(); }
void Start() { battlemanager = GameObject.FindGameObjectWithTag("GameController").GetComponent <BattleScript>(); gamemanager = GameObject.FindGameObjectWithTag("GameController").GetComponent <manager>(); }
void Start() { bs = gameObject.GetComponent <BattleScript>(); rs = gameObject.GetComponent <RestScript>(); es = gameObject.GetComponent <EventScript>(); ss = gameObject.GetComponent <ShopScript>(); bss = gameObject.GetComponent <BossScript>(); currentLevel = 0; stageHeight = 8; stageLength = 3; Levels = new GameObject[stageHeight + 1, stageLength]; NodeTypes = new int[stageHeight - 1, stageLength]; //Decide what node type is on each point for (int y = 0; y < stageHeight - 1; y++) { bool empty = false; for (int x = 0; x < stageLength; x++) { //maximum one empty per row if (!empty) { NodeTypes[y, x] = Random.Range(0, 101); } else { NodeTypes[y, x] = Random.Range(21, 101); } if (NodeTypes[y, x] < 11) { empty = true; } } } //Generate the nodes for (int y = 0; y < stageHeight - 1; y++) { for (int x = 0; x < stageLength; x++) { switch (NodeTypes[y, x]) { case int n when n <= 70 && n >= 21: Levels[y, x] = Instantiate(BattleNode, new Vector3(0, 0, 0), Quaternion.identity); bs.LinkBattleNode(Levels[y, x].GetComponent <Button>()); break; case int n when n <= 80 && n >= 71: Levels[y, x] = Instantiate(EventNode, new Vector3(0, 0, 0), Quaternion.identity); es.LinkEventNode(Levels[y, x].GetComponent <Button>()); break; case int n when n <= 90 && n >= 81: Levels[y, x] = Instantiate(RestNode, new Vector3(0, 0, 0), Quaternion.identity); rs.LinkRestNode(Levels[y, x].GetComponent <Button>()); break; case int n when n <= 100 && n >= 91: Levels[y, x] = Instantiate(ShopNode, new Vector3(0, 0, 0), Quaternion.identity); ss.LinkShopNode(Levels[y, x].GetComponent <Button>()); break; default: Levels[y, x] = Instantiate(EmptyNode, new Vector3(0, 0, 0), Quaternion.identity); break; } Levels[y, x].gameObject.name = "Node" + y + x; Levels[y, x].transform.SetParent(NodeContainer.transform); Levels[y, x].transform.SetPositionAndRotation((Levels[y, x].transform.parent.position + new Vector3((x * 420) - 420, (y * 600) - 2400, 0)), Quaternion.identity); } } //Rest for (int x = 0; x < stageLength; x++) { Levels[stageHeight - 1, x] = Instantiate(RestNode, new Vector3(0, 0, 0), Quaternion.identity); Levels[stageHeight - 1, x].gameObject.name = "Node" + (stageHeight - 1) + x; Levels[stageHeight - 1, x].transform.SetParent(NodeContainer.transform); Levels[stageHeight - 1, x].transform.SetPositionAndRotation((Levels[(stageHeight - 1), x].transform.parent.position + new Vector3((x * 420) - 420, ((stageHeight - 1) * 600) - 2400, 0)), Quaternion.identity); rs.LinkRestNode(Levels[stageHeight - 1, x].GetComponent <Button>()); } //Boss Levels[stageHeight, 1] = Instantiate(BossNode, new Vector3(0, 0, 0), Quaternion.identity); Levels[stageHeight, 1].gameObject.name = "Node" + stageHeight + "1"; Levels[stageHeight, 1].transform.SetParent(NodeContainer.transform); Levels[stageHeight, 1].transform.SetPositionAndRotation((Levels[stageHeight, 1].transform.parent.position + new Vector3((1 * 420) - 420, (stageHeight * 600) - 2400, 0)), Quaternion.identity); Levels[stageHeight, 1].GetComponent <Button>().interactable = false; bss.LinkBossNode(Levels[stageHeight, 1].GetComponent <Button>()); //Disable nodes above first row for (int y = 1; y < stageHeight; y++) { for (int x = 0; x < stageLength; x++) { Levels[y, x].GetComponent <Button>().interactable = false; } } //connecting lines? Not sure yet how to do //for (int y = 0; y < 2; y++) //{ // for (int x = 0; x < 3; x++) // { // } //} }
//public Camera battleCam, regularCam; // Use this for initialization void Start() { theBattle = FindObjectOfType <BattleScript>(); player = FindObjectOfType <playerScript>(); }
// Start is called before the first frame update void Start() { audio = GetComponent <AudioSource>(); bs = managerBattle.GetComponent <BattleScript>(); }
// Use this for initialization void Start() { instance = this; EnemyTurn_ = false; }