Beispiel #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch_LayerLowest = new SpriteBatch(GraphicsDevice);
            SpriteBatch_HUD         = new SpriteBatch(GraphicsDevice);

            lvl = new Level(Content, CurrentLevel);

            ThePlayer = new Player(Content, "Player/", 15, lvl.PlayerSpawnPosition);

            MyCamera = new Camera(GraphicsDevice.Viewport, lvl, ref ThePlayer);

            ThePlayer.SetSpawnPosition(lvl.PlayerSpawnPosition);
            ThePlayer.Respawn();

            TheSoundPlayer = new SoundPlayer(Content);
            StaticSoundPlayer.SetSoundPlayer(ref TheSoundPlayer);

            TheSpawnableEffect_List = new SpawnableEffect_List(Content);
            StaticSpawnableEffect.SetSpawnableEffect_List(ref TheSpawnableEffect_List);

            TheGameHud = new GameHud(Content);
            // TODO: use this.Content to load your game content here
        }
        public void TestDragonBreathOfFireAttackSound(GameHud material)
        {
            var buttonSpecialAttack = new InteractiveButton(CreateTheme(material),
                                                            drawArea);

            AvatarSpecialAttackSoundSelector.PlaySpecialAttackSound(buttonSpecialAttack);
        }
Beispiel #3
0
    void Start()
    {
        _menu = GetComponentInChildren <GameMenu>();
        _hud  = GetComponentInChildren <GameHud>();


        _camEffects    = Camera.main.GetComponent <CameraEffects>();
        _camController = Camera.main.GetComponent <CameraController>();

        _hud.FinalScoreMode(false);
        _hud.gameObject.SetActive(false);
        _menu.Show(OnStartNewGame, null);

        _introState = new IntroState(this)
        {
            TimeInState = 5, TimeAwake = 4f
        };
        _unarmedState             = new UnarmedState(this);
        _accState                 = new AccState(this);
        _powerUpState             = new PowerUpState(this);
        _blockadesAndEnemiesState = new BlockadeAndEnemiesState(this);
        _aliensState              = new AliensState(this);
        _pauseState               = new PauseState(this);
        _aliensFinalState         = new AliensFinalState(this);

        _accState.ExitState = _unarmedState;

        Spawner = new Spawner(GamePrefabs);
        Spawner.OnRewardEvent += (reward_pts) =>
        {
            pts += reward_pts;
            _hud.SetPoints(pts);
        };
    }
Beispiel #4
0
 public GameHud getGameHUD()
 {
     if (gameHUD == null)
     {
         gameHUD = new GameHud(getBlockSelectMenu());
     }
     return(gameHUD);
 }
    public void StartGame()
    {
        bGameRunning = true;
        //enables the player
        Player.EnableCharacter();

        GameHud.GetInstance().OnCountDownFinished();
    }
Beispiel #6
0
 /// <summary>
 /// called when start play button is pressed
 /// </summary>
 void StartGame()
 {
     if (!GameStarted)
     {
         // start game, trigger events, spawn in game hud
         GameStarted = true;
         _hud        = Instantiate(_gameHudCanvasPrefab).GetComponent <GameHud>();
     }
 }
    private void Start()
    {
        Strategy = CreateStrategy(CreateRocketController());
        Strategy.StartLevel();

        Hud = (GameHud)HudBase.Instance;
        Hud.OnPauseOpened += Pause;
        Hud.OnPauseClosed += Resume;
    }
 private void Awake()
 {
     //sets up the gamemode instance
     if (instance)
     {
         Destroy(this);
     }
     instance = this;
 }
		private static Theme CreateTheme(GameHud buttonMaterial)
		{
			var material = ContentLoader.Load<Material>(buttonMaterial.ToString());
			return new Theme
			{
				Button = material,
				ButtonMouseover = material,
				ButtonDisabled = material,
				ButtonPressed = material,
			};
		}
Beispiel #10
0
    public void CleanupGame()
    {
        Destroy(_gameBoard.gameObject);
        Destroy(_battle.gameObject);

        UIManager.Instance.CloseDialog(GameHud.DIALOG_ID);
        _gameHud = null;

        _currentNodeId = null;

        SceneManager.LoadScene("Main");
    }
        private static Theme CreateTheme(GameHud buttonMaterial)
        {
            var material = ContentLoader.Load <Material>(buttonMaterial.ToString());

            return(new Theme
            {
                Button = material,
                ButtonMouseover = material,
                ButtonDisabled = material,
                ButtonPressed = material,
            });
        }
Beispiel #12
0
    public void Initialize(BattleStageData data, GameHud gameHud, GameBoard gameBoard)
    {
        _session   = new Session(data);
        _gameHud   = gameHud;
        _gameBoard = gameBoard;

        _gameBoard.OnTilesMatched += HandleOnTilesMatched;
        _gameBoard.OnTurnEnded    += HandleOnTurnEnded;

        _enemyGameObject.GetComponent <SpriteRenderer>().sprite = data.EnemySprite;

        UpdateHUD();
    }
Beispiel #13
0
    /// <summary>
    /// Init this instance.
    /// </summary>
    public void Init()
    {
        isRevived           = false;
        GameData.isBirdLive = true;
        isDieDelay          = false;
        eggRoot             = new GameObject("EggRoot");
        GameObject hudMenuObject = GameObject.FindGameObjectWithTag(Constants.TAG_GAME_HUD);

        if (hudMenuObject != null)
        {
            gameHudMenu = hudMenuObject.GetComponent <GameHud>();
        }

//		eggID = (int)BackGroundManager.Instance.GetThemeID();
        string eggName = "Egg_" + GameData.currentBirdId;

        currentEgg = Instantiate(Resources.Load("Prefabs/AllEggs/" + eggName),
                                 new Vector3(0, 20, 0), Quaternion.identity) as GameObject;
        currentEgg.name             = "EggMasterCopy";
        currentEgg.transform.parent = eggRoot.transform;

        eggCount             = 0;
        birdTransform        = transform;
        birdAnimator         = transform.GetComponent <Animator>();
        forwardMovementSpeed = Utility.GetBirdInitialSpeed();
//		Debug.Log("Witdth  = " + Screen.width +" Screen hieght = "+ Screen.height);
//		Debug.Log("forwardMovementSpeed = " + forwardMovementSpeed + "World wodth = "+  Utility.WorldWidth());
        //Adjust Speed w.r.t screen aspect ratio
        float aspectRatio    = (float)Screen.width / (float)Screen.height;
        float referenceRatio = 1280 / 800.0f;

//		Debug.Log("aspectRatio= " + aspectRatio + "  referenceRatio = "+ referenceRatio );
        if (aspectRatio < referenceRatio)
        {
//			forwardMovementSpeed = forwardMovementSpeed*(referenceRatio/aspectRatio);
//			Debug.Log("Modified forwardMovementSpeed = "+ forwardMovementSpeed);
        }
        flyingPos           = Utility.GetBirdFlyingPosition();
        menuBirdPosition    = Utility.GetBirdMenuPosition();
        transitionDirection = flyingPos - menuBirdPosition;

        gravityScale = 2.5f;           //		1.35f;
//		if(GameData.isRetry)
//		{
//			Invoke("Menu", 0.10f);
//		}
//		else
//		{
//			Invoke("Menu", 1.0f);
//		}
    }
Beispiel #14
0
    public PlayStrategy(RocketController rocketController)
    {
        RocketController = rocketController;
        RocketController.OnRocketDied += EndLevel;

        Config = GameInstance.Instance.Config;
        Camera = new FollowCamera(RocketController.Rocket.gameObject);

        Hud = (GameHud)HudBase.Instance;

        CheckpointsManager = new CheckpointsManager();
        CheckpointsManager.OnCheckpointActivated += UpdateCheckpointScore;
        CheckpointsManager.GenerateCheckpoints(Config.CheckpointsCount, Config.StartCheckpointScore, Config.CheckpointsInterval);

        State = SaveSystem.LoadState();
    }
    //Shows game over to the player.
    void GameOver(string Reason)
    {
        //set the game as not running
        bGameRunning = false;

        //if the players high score is lower then their current score, set the new high score
        if (HighScore.HighScore < distancedTraveled)
        {
            HighScore.HighScore = (int)distancedTraveled;
        }

        //Show UI to show Game Over;
        GameHud Hud = GameHud.GetInstance();

        Hud.ShowGameOver(Reason, (int)distancedTraveled, HighScore.HighScore);
    }
    /// <summary>
    /// Called after completion of a command is finished execuing until all the queued messages are processed.
    /// When no queued Actions left, it ends the turn for the Active player and clears player/turn specific data.
    /// </summary>
    private void OnActionCompletedCallback(Component sender, bool isSuccess)
    {
        if (!isSuccess)
        {
            GameHud gameHud = GuiManager.Instance.CurrentState as GameHud;
            if (gameHud != null)
            {
                gameHud.ShowPopup(sender.name + " has failed!", new Vector2(0.5f, 0.5f), Color.red);
            }
        }

        if (_queuedActions.Count > 0)
        {
            _queuedActions.Dequeue().Invoke();
        }
        else
        {
            TryGameOver();
            if (CurrentGameState == GameState.GameOver)
            {
                return;
            }
            Ability ability = sender as Ability;
            if (ability && ability.IsPassive)
            {
                return;
            }
            ResetActiveHexes();
            _selectedHex = null;
            TurnManager.Instance.EndTurn();

            while (true)
            {
                _activeUnit = TurnManager.Instance.GetActivePlayer().GetNextUnit();
                //Unit might be dead but delayed. Check IsDead.
                //If the player has not Available units we should not be here at all. (TryGameOver handles that.)
                //Therefore we don't have to check for a case of infinite-loop.
                if (!_activeUnit.IsDead)
                {
                    break;
                }
            }

            _selectedHex = _activeUnit.GetHexTile(_hexGrid);
            SelectHex(_selectedHex);
        }
    }
        /// <summary>
        /// Creates a new CubeScreen.
        /// </summary>
        /// <param name="game">Game the CubeScreen should be associated with.</param>
        /// <param name="cube">Cube the screen should display.</param>
        public CubeScreen( CubeGame game, Cube cube )
            : base(game)
        {
            Cube = cube;
            Cube.Screen = this;
            Hud = new GameHud( this );
            Camera = new Camera( Game );

            Cube.UpdateOrder = 2;

            Hud.UpdateOrder = 2;
            Hud.DrawOrder = 2;

            Camera.UpdateOrder = 2;

            Components.Add( Hud );
            Components.Add( Cube );
            Components.Add( Camera );
        }
Beispiel #18
0
    private void StartGame()
    {
        // Initialize Game HUD
        _gameHud = UIManager.Instance.OpenDialog(GameHud.DIALOG_ID) as GameHud;

        TileRecipe recipe = _recipeManager.GetRecipe(_gameTileData);

        // Create the gameboard and battle
        GameObject gameBoard = GameObject.Instantiate(_gameBoardPrefab);

        _gameBoard = gameBoard.GetComponent <GameBoard>();

        GameObject battle = GameObject.Instantiate(_battlePrefab);

        _battle = battle.GetComponent <Battle>();

        // Initialize battle manager
        _battle.Initialize(gameStageData, _gameHud, _gameBoard);

        // Initialize game board
        _gameBoard.Initialize(_gameTileData, _battle, _gameHud, recipe);
    }
Beispiel #19
0
        public override void OnInit()
        {
            base.OnInit();

            // UI생성
            this.hud = ObjectPoolManager.inst.New <GameHud>(PrefabPath.UI.GameHUD);

            this.hud.transform.position = new Vector3(0, -10000, 0);
            this.hud.Init(this.unit);

            // 카메라 초기화
            PlayerCamera.current.ResetRotation(this.unit.transform.eulerAngles);
            PlayerCamera.current.FollowUnit(this.unit.transform);
            this.aimAnimating = false;

            // 상호작용 아이콘 초기화
            this.interactionIcon = ObjectPoolManager.inst.New <InteractionIcon>(PrefabPath.UI.InteractionIcon);
            this.interactionIcon.gameObject.SetActive(false);

            // 커서 상태 잠금
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }
Beispiel #20
0
    public void LoadLevel()
    {
        string[] tmxFiles = TmxFilesLoader.GetTmxFileNames("Level*.tmx");
        var      mapData  = TiledMapParserExtended.MapParser.ReadMap(tmxFiles[0]);

        _level = new BaseLevel(_caveLevelMap, _cam);

        AddChild(_level);

        _gameHud = new GameHud(_level, _cam);

        DebugDrawBoundBox.level = _level;

        foreach (var sprite in _level.GetChildren().Where(s => s is Sprite))
        {
            DebugDrawBoundBox.AddSprite((Sprite)sprite);
        }

        foreach (var sprite in _gameHud.GetChildrenRecursive().Where(s => s is Sprite))
        {
            DebugDrawBoundBox.AddSprite((Sprite)sprite);
        }
    }
Beispiel #21
0
    public void Initialize(List <WeaponTileData> tileData, Battle battle, GameHud gameHud, TileRecipe recipe)
    {
        _equippedTileData = tileData;
        _battle           = battle;
        _gameHud          = gameHud;
        _recipe           = recipe;

        _gameHud.SetupRecipeChargeHud(this, _recipe, RecipeSkillButtonTapped);

        // 0, 0 is the bottom left corner tile
        for (int w = 0; w < BOARD_WIDTH; w++)
        {
            for (int h = 0; h < BOARD_HEIGHT; h++)
            {
                BaseTileData data = PickRandomTileData();
                // This can be done in a less dumb way later
                while (CheckForMatchAtCoordsOnInitializing(data, w, h))
                {
                    data = PickRandomTileData();
                }
                CreateTileAtCoords(data, w, h);
            }
        }
    }
Beispiel #22
0
 // Use this for initialization
 void Start()
 {
     switches = GameObject.FindGameObjectsWithTag("Switch");
     gameHud  = GameObject.Find("GameHud").GetComponent <GameHud>();
 }
 private void Start()
 {
     GMode   = GetComponent <GMode>();
     _camera = Camera.main;
     GHUD    = GetComponent <GameHud>();
 }
		public void TestDragonBreathOfFireAttackSound(GameHud material)
		{
			var buttonSpecialAttack = new InteractiveButton(CreateTheme(material),
				drawArea);
			AvatarSpecialAttackSoundSelector.PlaySpecialAttackSound(buttonSpecialAttack);
		}
Beispiel #25
0
 private void CreateHud()
 {
     _gameHud = new GameHud(ImageManager.loadSystem("IconsSpritesheet"));
     _gameHud.SetPosition(new Vector2(5, 5),
                          new Vector2(SceneManager.Instance.VirtualSize.X - 45, 5));
 }
        //----------------------//------------------------//

        public override void LoadContent()
        {
            base.LoadContent();

            var viewportSize = SceneManager.Instance.VirtualSize;

            // Camera init
            _camera = new Camera2D(SceneManager.Instance.ViewportAdapter);

            // Player init
            _player = new Player(ImageManager.loadCharacter("Player"));

            // Projectiles init
            _projectilesTextures = new Dictionary <string, Texture2D>()
            {
                { "snowball", ImageManager.loadProjectile("Snowball") },
            };
            _projectiles = new List <GameProjectile>();
            _projectilesColliderTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1);
            _projectilesColliderTexture.SetData(new Color[] { Color.Orange });

            // Enemies init
            _enemies = new List <EnemyBase>();
            var ghostTexture = ImageManager.loadCharacter("Ghost");
            var birdTexture  = ImageManager.loadCharacter("Bird");

            _ghost = new Ghost(ghostTexture);
            _bird  = new Bird(birdTexture);

            // Background init
            _backgroundTexture = ImageManager.loadScene("sceneMap", "Background");

            // Hud init
            _gameHud = new GameHud();

            // Particles init
            var particleTexture = new Texture2D(SceneManager.Instance.GraphicsDevice, 1, 1);

            particleTexture.SetData(new[] { Color.White });
            ParticlesInit(new TextureRegion2D(particleTexture));

            _blizzardTriggerPosition = new Vector2(viewportSize.X / 2 - 50.0f, -50.0f);

            // Spawn Manager init
            _enemiesSpawnManager = new EnemiesSpawnManager();
            _enemiesSpawnManager.Start();

            // Load the map
            LoadMap(MapManager.FirstMap);

            // Crystal init
            var mapSize         = new Vector2(MapManager.Instance.MapWidth, MapManager.Instance.MapHeight);
            var crystalPosition = new Vector2(mapSize.X / 2 - 48, 96);

            _crystal = new GameCrystal(crystalPosition, ImageManager.loadCharacter("Crystal"));

            // Wave Clear init
            var textWidth = SceneManager.Instance.GameFontBig.MeasureString(WaveClearText).Width;
            var x         = (viewportSize.X - textWidth) / 2;

            _waveClearInitialPosition = new Vector2(x, viewportSize.Y / 2 - 70);
            _waveClearPosition        = _waveClearInitialPosition;

            // SE init
            var ambienceSe = SoundManager.LoadSe("Ambience");

            _ambienceSei          = ambienceSe.CreateInstance();
            _ambienceSei.IsLooped = true;
            _ambienceSei.Play();

            SoundManager.StartBgm(SoundManager.BGMType.Default);
        }
    private IEnumerator ArmyBuild()
    {
        int armySize = LoadArmyData();

        //Give everyone else time to register to events.
        yield return(null);

        CurrentGameState = GameState.ArmyBuild;
        GameHud gameHud = GuiManager.Instance.CurrentState as GameHud;

        for (int i = 0; i < armySize; i++)
        {
            int     turn       = TurnManager.Instance.CurrentTurn;
            Vector2 topLeftHex =
                Camera.main.WorldToScreenPoint(_hexGrid.GetWorldPositionOfHex(_hexGrid.GetHexTileDirect(0, 0).Coord));
            Vector2 bottomRightHex =
                Camera.main.WorldToScreenPoint(
                    _hexGrid.GetWorldPositionOfHex(
                        _hexGrid.GetHexTileDirect(_hexGrid.WidthInHexes - 1, _hexGrid.HeightInHexes - 1).Coord));
            float yMax = topLeftHex.y;
            float yMin = bottomRightHex.y;
            float xMax = bottomRightHex.x;
            float xMin = topLeftHex.x;
            while (turn == TurnManager.Instance.CurrentTurn)
            {
                SelectedUnit = TurnManager.Instance.GetActivePlayer().GetNextUnit();
                _selectedUnit.gameObject.SetActive(true);
                gameHud.ShowPopup("Place Unit", new Vector2(0.5f, 0.5f), Color.white);

                Vector3 refPosition;
                Func <float, float, float> limitFunction;
                if (TurnManager.Instance.GetActivePlayer().Id % 2 == 0)
                {
                    for (int r = 0; r < _maxSpawnDistance; r++)
                    {
                        for (int q = 0; q < _hexGrid.GetRowLenght(r); q++)
                        {
                            HexTile hexTile = _hexGrid.GetHexTileDirect(q, r);
                            hexTile.HighlightTile();
                            _hexTileCache.Add(CACHE_OTHER, hexTile);
                        }
                    }
                    refPosition =
                        _hexGrid.GetWorldPositionOfHex(
                            _hexGrid.GetHexTileDirect((int)(_hexGrid.WidthInHexes / 2f), _maxSpawnDistance - 1).Coord);
                    limitFunction = Mathf.Min;
                }
                else
                {
                    for (int r = _hexGrid.HeightInHexes - _maxSpawnDistance; r < _hexGrid.HeightInHexes; r++)
                    {
                        for (int q = 0; q < _hexGrid.GetRowLenght(r); q++)
                        {
                            HexTile hexTile = _hexGrid.GetHexTileDirect(q, r);
                            hexTile.HighlightTile();
                            _hexTileCache.Add(CACHE_OTHER, hexTile);
                        }
                    }
                    refPosition =
                        _hexGrid.GetWorldPositionOfHex(
                            _hexGrid.GetHexTileDirect((int)(_hexGrid.WidthInHexes / 2f),
                                                      _hexGrid.HeightInHexes - _maxSpawnDistance).Coord);
                    limitFunction = Mathf.Max;
                }
                float xPlayerLimit = Camera.main.WorldToScreenPoint(refPosition).x;

                Transform selectedUnitTransform = _selectedUnit.transform;
                selectedUnitTransform.position = refPosition;

                //Wait until player places the Unit.
                while (_selectedUnit != null)
                {
                    Vector2 rayPos =
                        new Vector2(limitFunction(xPlayerLimit, Mathf.Clamp(Input.mousePosition.x, xMin, xMax)),
                                    Mathf.Clamp(Input.mousePosition.y, yMin, yMax));
                    Ray        ray = Camera.main.ScreenPointToRay(rayPos);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        selectedUnitTransform.position = hit.point;
                    }
                    yield return(null);
                }
                TurnManager.Instance.EndTurn();
                ResetActiveHexes();
            }
        }

        WaitForSeconds wait = new WaitForSeconds(1f);

        for (int i = 3; i >= 0; i--)
        {
            gameHud.ShowPopup(i == 0 ? "Battle!" : i.ToString(), new Vector2(0.5f, 0.5f), Color.white);
            yield return(wait);
        }

        CurrentGameState = GameState.Battle;
        _activeUnit      = TurnManager.Instance.GetActivePlayer().GetNextUnit();
        _selectedHex     = _activeUnit.GetHexTile(_hexGrid);
        SelectHex(_selectedHex);
    }
    void Awake()
    {
        Instance = this;
        DontDestroyOnLoad(this);

        if (String.IsNullOrEmpty(gameApiKey))
        {
            Debug.LogError("GAMEhud not configured.  Please set your game_api_key that you received from GAMEhud on the GAMEhud object.");
            return;
        }

        Application.RegisterLogCallback(GameHudEventQueue.UnityLog);
    }
Beispiel #29
0
 public void Initialize()
 {
     Hud = new GameHud();
 }
Beispiel #30
0
    void Awake()
    {
        Instance = this;

        _menuButton.onClick.AddListener(() => SceneChanger.Instance.RestartCurrentScene());
    }
    void Start()
    {
        _menu = GetComponentInChildren<GameMenu>();
        _hud = GetComponentInChildren<GameHud>();

        _camEffects = Camera.main.GetComponent<CameraEffects>();
        _camController = Camera.main.GetComponent<CameraController>();

        _hud.FinalScoreMode(false);
        _hud.gameObject.SetActive(false);
        _menu.Show(OnStartNewGame, null);

        _introState = new IntroState(this) { TimeInState = 5, TimeAwake = 4f };
        _unarmedState = new UnarmedState(this);
        _accState = new AccState(this);
        _powerUpState = new PowerUpState(this);
        _blockadesAndEnemiesState = new BlockadeAndEnemiesState(this);
        _aliensState = new AliensState(this);
        _pauseState = new PauseState(this);
        _aliensFinalState = new AliensFinalState(this);

        _accState.ExitState = _unarmedState;

        Spawner = new Spawner(GamePrefabs);
        Spawner.OnRewardEvent += (reward_pts) =>
        {
            pts += reward_pts;
            _hud.SetPoints(pts);
        };
    }