Example #1
0
        public GameState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content, GraphicsDeviceManager graphics_, Dictionary <string, Song> sounds, List <Enemy> enemies,
                         List <Platform> platforms, List <DrawablObject> objects, List <Coin> coins, DrawablObject star, int level) : base(game, graphicsDevice, content, graphics_, sounds)
        {
            this.level = level.ToString();
            int h = CoinsAndHeartsManager.Load().curr.hearts;

            coinsAndHeartsManager = new CoinsAndHeartsManager(new CoinsAndHearts(0, 0, 0, h));

            //coins
            this.coins = coins;

            //font
            font = _content.Load <SpriteFont>("Fonts/font");

            //camera staff
            camera = new Camera_();

            //background
            background = _content.Load <Texture2D>("BackGrounds/Background800x480");

            //hero
            hero = new Sprite(SetHeroAnimation(), 15f)
            {
                Position = new Vector2(100, 100),
                Input    = new Input()
                {
                    Up    = Keys.Up,
                    Left  = Keys.Left,
                    Right = Keys.Right,
                },
                hasJumped = true
            };

            //bombs
            bombsList = new List <Bomb>();

            //enemies platforms and objects
            this.enemies   = enemies;
            this.platforms = platforms;
            this.objects   = objects;

            //finishing star
            this.star = star;
        }
Example #2
0
        IEnumerator _boot()
        {
            var load = new AsyncOperation();

            load = SceneManager.LoadSceneAsync("game", LoadSceneMode.Additive);
            while (!load.isDone)
            {
                yield return(null);
            }
            yield return(null);

            var die_1 = GameObject.Find("die_1").GetComponent <Die>();
            var die_2 = GameObject.Find("die_2").GetComponent <Die>();

            Game.Initialize(die_1, die_2);
            Camera_.Initialize(Camera.main);
            yield return(new WaitForSeconds(1.0f));

            GameState.To_Home();
        }
        InitializeAcademy()
        {
            base.InitializeAcademy();

            tag = "GlobalManager";
            // Debug.Log(GetLogTag() + " Initialize");

            InitGameObjectToBeRespawned();
            InitLightReinitializors();

            foreach (TagPair TagPair_ in IgnoreCollisionTagPairs)
            {
                Utils.IgnoreCollision(TagPair_.TagA, TagPair_.TagB);
            }

            // InitRamObservation();

            // if (isTurnBasedGame()) {
            //     InitTurnBasedGame();
            // }

            // initialize reference to UIPercentageBars
            foreach (UIPercentageBar UIPercentageBar_ in GameObject.FindGameObjectWithTag("TopDownCamera").
                     GetComponentsInChildren <UIPercentageBar>())
            {
                UIPercentageBars.Add(UIPercentageBar_.ID, UIPercentageBar_);
            }

            UIPercentageBars["EL"].Enable();

            // initialize reference to UIText
            foreach (UIText UIText_ in GameObject.FindGameObjectWithTag("TopDownCamera").
                     GetComponentsInChildren <UIText>())
            {
                UITexts.Add(UIText_.ID, UIText_);
            }

            UITexts["Status"].setText("Top Down Camera");

            // initialize reference to Camera
            foreach (Camera Camera_ in GetComponentsInChildren <Camera>())
            {
                string ID_;
                int    InitialCameraDepth = 0;

                if (Camera_.CompareTag("TopDownCamera"))
                {
                    ID_ = "TopDownCamera";
                    InitialCameraDepth = UpperCameraDepth;

                    if (AgentCameraDisplayMode == AgentCameraDisplayModes.All)
                    {
                        Debug.LogWarning(
                            "AgentCameraDisplayMode = AgentCameraDisplayModes.All is not recommended, as it results in camera feild that is too small and UI will be resized.");
                        Camera_.rect = new Rect(0.5f, 0f, 0.5f, 1f);
                    }
                    else if (AgentCameraDisplayMode == AgentCameraDisplayModes.Single)
                    {
                        Camera_.rect = new Rect(0f, 0f, 1f, 1f);
                    }
                    else
                    {
                        Debug.LogError("Invalid AgentCameraDisplayMode");
                    }
                }
                else if (Camera_.CompareTag("AgentCamera"))
                {
                    ID_ = Camera_.GetComponentInParent <ArenaAgent>().GetLogTag();
                    InitialCameraDepth = DownerCameraDepth;
                }
                else
                {
                    Debug.LogError(
                        "A camera in Arena should be either TopDownCamera or AgentCamera, use corresponding prefab provided in ArenaSDK/SharedPrefabs");
                    ID_ = "None";
                }

                Cameras.Add(Camera_);
                Cameras[Cameras.Count - 1].depth = InitialCameraDepth;
            }

            if (!isDebugging())
            {
                foreach (GameObject each_gameobject in GameObject.FindGameObjectsWithTag("Debug"))
                {
                    each_gameobject.SetActive(false);
                }
            }
        } // InitializeAcademy
        InitializeAcademy()
        {
            tag = "GlobalManager";
            // Debug.Log(GetLogTag() + " Initialize");

            broadcastHub.Clear();
            broadcastHub.broadcastingBrains.Add(SharedBrain);
            if (!Application.isEditor)
            {
                broadcastHub.SetControlled(SharedBrain, true);
            }

            foreach (ArenaAgent ArenaAgent_ in GetComponentsInChildren <ArenaAgent>())
            {
                ArenaAgent_.brain = SharedBrain;
            }

            base.InitializeAcademy();


            InitGameObjectToBeRespawned();
            InitLightReinitializors();

            foreach (TagPair TagPair_ in IgnoreCollisionTagPairs)
            {
                Utils.IgnoreCollision(TagPair_.TagA, TagPair_.TagB);
            }

            // InitRamObservation();

            // if (isTurnBasedGame()) {
            //     InitTurnBasedGame();
            // }

            // initialize reference of TopDownCamera
            if (GameObject.FindGameObjectWithTag("TopDownCamera") == null)
            {
                Debug.LogError("Add prefab ArenaSDK/SharedPrefabs/TopDownCamera in your game sence");
            }

            // initialize reference to UIPercentageBarsTopDownCamera
            foreach (UIPercentageBar UIPercentageBar_ in GameObject.FindGameObjectWithTag("TopDownCamera").
                     GetComponentsInChildren <UIPercentageBar>())
            {
                UIPercentageBarsTopDownCamera.Add(UIPercentageBar_.ID, UIPercentageBar_);
            }
            UIPercentageBarsTopDownCamera["Episode Length"].Enable();

            // initialize reference to UITextsTopDownCamera
            foreach (UIText UIText_ in GameObject.FindGameObjectWithTag("TopDownCamera").
                     GetComponentsInChildren <UIText>())
            {
                UITextsTopDownCamera.Add(UIText_.ID, UIText_);
            }
            UITextsTopDownCamera["Status"].setText("Top Down Camera");

            // initialize reference to VisualizationCamera
            if (GameObject.FindGameObjectWithTag("VisualizationCamera") == null)
            {
                Debug.LogError("Add prefab ArenaSDK/SharedPrefabs/VisualizationCamera in your game sence");
            }

            // initialize reference to UIPercentageBarsVisualizationCamera
            foreach (UIPercentageBar UIPercentageBar_ in GameObject.FindGameObjectWithTag("VisualizationCamera").
                     GetComponentsInChildren <UIPercentageBar>())
            {
                UIPercentageBarsVisualizationCamera.Add(UIPercentageBar_.ID, UIPercentageBar_);
            }
            UIPercentageBarsVisualizationCamera["Episode Length"].Enable();

            // initialize reference to UITextsVisualizationCamera
            foreach (UIText UIText_ in GameObject.FindGameObjectWithTag("VisualizationCamera").
                     GetComponentsInChildren <UIText>())
            {
                UITextsVisualizationCamera.Add(UIText_.ID, UIText_);
            }
            UITextsVisualizationCamera["Status"].setText("Visualization Camera");

            // initialize reference to Camera
            foreach (Camera Camera_ in GetComponentsInChildren <Camera>())
            {
                string ID_;
                int    InitialCameraDepth = 0;

                if (Camera_.CompareTag("TopDownCamera"))
                {
                    ID_ = "TopDownCamera";
                    InitialCameraDepth = UpperCameraDepth;
                    Camera_.rect       = new Rect(0f, 0f, 1f, 1f);
                }
                else if (Camera_.CompareTag("VisualizationCamera"))
                {
                    ID_ = "VisualizationCamera";
                    InitialCameraDepth = DownerCameraDepth;
                    Camera_.rect       = new Rect(0f, 0f, 1f, 1f);
                }
                else if (Camera_.CompareTag("AgentCamera"))
                {
                    ID_ = Camera_.GetComponentInParent <ArenaAgent>().GetLogTag();
                    InitialCameraDepth = DownerCameraDepth;
                }
                else
                {
                    Debug.LogError(
                        "A camera in Arena should be either TopDownCamera or VisualizationCamera or AgentCamera, use corresponding prefab provided in ArenaSDK/SharedPrefabs");
                    ID_ = "None";
                }

                Cameras.Add(Camera_);
                Cameras[Cameras.Count - 1].depth = InitialCameraDepth;
            }

            if (!isDebugging())
            {
                foreach (GameObject each_gameobject in GameObject.FindGameObjectsWithTag("Debug"))
                {
                    each_gameobject.SetActive(false);
                }
            }

            InitializeVisVecObs();
        } // InitializeAcademy