|
Post by legend on May 8, 2018 4:29:07 GMT
Hey I created a menu to play the game and instead of playing it from loading the scene i request a scene change from the scene manager and load the game that way - i notice it doesn't work - anyone who reads this ever try this out- guessing its something to do with how the game is loaded in unity and is different to the way it is loaded via manual play button. its like the NPC isnt taking over and playing for whatever reason.
|
|
|
Post by Admin on May 8, 2018 14:34:47 GMT
I tried the same thing, and it worked identically to the way that it does when beginning from the game scene. I did notice that on the player's first turn that they do not draw a card and must press the "End Turn" button, but that appears to be a bug even when starting from the Game scene.
I just created a simple menu scene with a UI Button targeting this script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour {
public void OnPlayButton() { SceneManager.LoadScene ("Game"); } }
|
|
|
Post by LEgend on May 8, 2018 17:18:33 GMT
thanks ill dig around - ya same code. did some debugging cause i noticed that the AI can play its own cards but it appears that the issue is that the targetting system is bunged up for me or something ... i noticed it was stuck for him attacking so i just removed the attack() from the enemy system and it ended the turn after he put down the minion - i cant attack the minion or hero so it appears it has something to do with the targeting as i cant play spells that target the 'battlecards' ....in fact even though the spell is playable as far as mana cost goes it doesnt highlight probably because it cant find a target..even though the target is anyone and anybody it can target.... still strange though that i can load it manually and it works fine but when i do the loadscene it wonks out....guessing its something i changed (although dont think i needed to touch targetting at all) or more likely something im doing in the previous scene that is wonking it out in this scene for me .
|
|
|
Post by Legend on May 8, 2018 20:16:23 GMT
going the route as my previous scene since itt only happens when it the load scene within a callbaack method...so im guessing it has to do with async stuff since that seems to be most of where my issues stem from often.
|
|
|
Post by Legend on May 13, 2018 20:02:27 GMT
You have any issues with recreating the game by any chance? - for instance i start in the main menu then play the game and then it ends to the main menu again if i hit play it wonks out after i hit end turn to start the game and goes back to the main menu right away like it ended the game because it has game over in the console
just stuck that after the gameover log in the gameoverstate
SceneManager.LoadScene("Menu");
i am guessing when the scene ends it doesnt actually remove all the static variables and stuff so im guessing thats the issue is that its not renewed when the game is recreated or something
|
|
|
Post by Legend on May 13, 2018 20:36:06 GMT
Is there a way to be like - destroy everything unity and when i say loadscene then it spawns everything again or something? think im going to have to be like void resetGameData() { then make some clear calls.
|
|
|
Post by Admin on May 14, 2018 14:50:27 GMT
Some of the architecture may not have been clearly understood, let me see if I can clear it up... There are no static variables that are going to stick around between scene loads (that I can remember). Take another look at the "GameViewSystem" - it is a component that will live on the "Game" GameObject in the "Game" scene. This object creates an "instance" of an "IContainer" that holds all of the game systems needed for that scene. The container with its systems is created via a "static" class method, but the result of the invocation is an instance that is only kept in-scope by the "GameViewSystem" . What this means is that every time the scene loads, it should be as "fresh" as it would have been the very first time it runs. You shouldn't need to clear anything if you change scenes and come back again. This is in contrast to many other architectures you might have scene that use the Singleton pattern to hold on to their game state. Those objects usually survive scene changes, and even the entire life-cycle of the app.
|
|
|
Post by Legend on May 14, 2018 17:07:20 GMT
ya looking through the code i see that now - very nice -there has to be something that it still has a reference of cause it sees the hero at 0 health - i just tested this through the CCG 19 JSON with the simple load scene and a main menu and that is it - no change to your code besides tacking on that load scene to the gameoverstate, it definitely does just end the match on the second run through. Will let you know what i can find though
27 local -2 computer game over 30 local 30 computer
thats the debug output upon creating the game with the play button, hit the clear button to clear the console logs and then hitting end turn to start the game - it outputs that
using System.Collections; using System.Collections.Generic; using UnityEngine; using TheLiquidFire.AspectContainer;
public class VictorySystem : Aspect { public bool IsGameOver () { var match = container.GetMatch (); foreach (Player p in match.players) { Hero h = p.hero [0] as Hero; Debug.Log(h.hitPoints + " " + p.mode); if (h.hitPoints <= 0) { return true; } } return false; } }
|
|
|
Post by Legend on May 14, 2018 21:22:10 GMT
so far - looks like it has something to do with the actionsystem - more to come!
|
|
|
Post by Admin on May 14, 2018 21:48:23 GMT
Actually, I think it is my Notification Center. I must have missed unregistering for a notification somewhere and it would be able to keep everything alive. You can see this fix the issue if you add a method like this to the Notification Center:
public void Clear () { _table.Clear (); }
and invoke it before loading the Main Menu scene.
|
|
|
Post by Admin on May 14, 2018 21:50:54 GMT
It 'might' be worth it to try updating the notification center to make it a system which is an aspect on the container just like the other systems, and then this problem wouldn't be an issue. Of course, actually unregistering notifications is a good idea, and the "Clear" is not a terrible fallback.
|
|
|
Post by Legend on May 14, 2018 22:11:43 GMT
ahh ya thats it! - im going to try and see if i can make it into a system - dang singletons - statics and singletons the bane of my existence! thanks for your help!
|
|