コード例 #1
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            int stringWidth = (int)(Font().MeasureString(text).X) + 2;    // +2 for good Karma.

            // Create the diffuse texture.
            int width  = margin.X + stringWidth;
            int height = margin.Y + Font().LineSpacing;

            if (checkbox)
            {
                width += UIGridTextListElement.Checkbox.Width + UIGridTextListElement.Margin.X;
            }

            if (BokuGame.RequiresPowerOf2)
            {
                width  = MyMath.GetNextPowerOfTwo(width);
                height = MyMath.GetNextPowerOfTwo(height);
            }

            diffuse = new RenderTarget2D(device,
                                         width, height,
                                         false, // Mip levels
                                         SurfaceFormat.Color,
                                         DepthFormat.None);
            InGame.GetRT("TextLine", diffuse);

            RefreshTexture();
        }
コード例 #2
0
ファイル: Ball.cs プロジェクト: CorruptData/Breakout
    public void Update(InGame world, int ms)
    {
        if (!Paused)
        {
            //Break movements into small steps for edge collision.
            int steps = (int)Speed + 1;
            DontBeMadTimer -= (double)ms / 1000;
            for (int step = 0; step != steps; step++)
            {

                //Move the ball based on the angle.
                PositionX += (Math.Cos(Theta) * Speed) / steps;
                PositionY += (Math.Sin(Theta) * Speed) / steps;

                //check for collision with the world.
                if (WorldCollide(world))
                    return;
                //check for collision with the paddle.
                PaddleCollide(world);
                //Check for collision with bricks.
                BounceBallOffBricks(world);
            }
        }else //If the ball is being held after death,
        {
            //roll the Pause Timer.
            PauseTimer -= (double)ms/1000;
            //Has the Pause Timer expired?
            if (PauseTimer <= 0)
                //The ball is released.
                Paused = false;
        }
    }
コード例 #3
0
        protected void CacheLineNumberTexture()
        {
            Texture2D texture;
            const int textureSize = 64;

            RenderTarget2D rt = UI2D.Shared.RenderTarget64_64;

            InGame.SetRenderTarget(rt);
            SpriteBatch batch = UI2D.Shared.SpriteBatch;

            InGame.Clear(Color.Transparent);

            // Draw line number
            string text = lineNumber.ToString();
            // Center line number horizontally on rt.
            Vector2 pos = new Vector2((rt.Width - UI2D.Shared.GetGameFontLineNumbers().MeasureString(text).X) / 2.0f, 0.0f);

            batch.Begin();
            batch.DrawString(UI2D.Shared.GetGameFontLineNumbers(), text, pos, Color.Black);
            batch.End();

            InGame.RestoreRenderTarget();

            // Copy rendertarget result into texture.
            texture = new Texture2D(BokuGame.bokuGame.GraphicsDevice, textureSize, textureSize, false, SurfaceFormat.Color);
            int[] data = new int[textureSize * textureSize];
            rt.GetData <int>(data);
            texture.SetData <int>(data);

            rtLineNumber.Add(texture);
            Debug.Assert(this.lineNumber <= rtLineNumber.Count);
        }
コード例 #4
0
ファイル: UI.cs プロジェクト: kimhwi9202/crown_temp
    /// <summary>
    /// 로비에서 게임화면으로 전환
    /// </summary>
    /// <param name="eGameName">Name of the e game.</param>
    public void LobbyToGame(eGameList eGameName)
    {
        SOUND.I.PlayStop(DEF.SND.lobby_bgm);

        loadGame           = eGameName;
        Main.I.CurrentView = eView.Game;

        string     prefabGameName = DEF.GetGamePrefabName(loadGame);
        GameObject obj            = BUNDLE.I.LoadAsset <GameObject>(prefabGameName);

        if (obj)
        {
            GameObject go = GameObject.Instantiate(obj);
            go.name = prefabGameName;
            go.transform.SetParent(this.gameObject.transform);
            SOUND.I.LoadAssetBundleAudioClipsPackage(DEF.GetGameBundleName(loadGame));

            GameMain        = go.gameObject.GetComponent <InGame>();
            GameMain.gameId = eGameName;
            GameMain.Init();

            Main.I.AppsFlyerEvent(AFInAppEvents.GAME, AFInAppEvents.GAME_SELECT, eGameName.ToString());
        }

        if (Lobby.I != null)
        {
            Lobby.I.LobbyToGame();
        }
        Coins.LobbyToGame();
        Game.LobbyToGame();
        BroadCast.LobbyToGame();
    }
コード例 #5
0
 public BussinessLogic(ApplicationDbContext db, IHttpContextAccessor hca)
 {
     _db         = db;
     _session    = hca.HttpContext.Session;
     _hca        = hca;
     CurrentGame = LoadGameState(GetUserId());
 }
コード例 #6
0
        }   // end of TextLine c'tor

        /// <summary>
        /// Renders the text string into the texture.
        /// </summary>
        private void RefreshTexture()
        {
            InGame.SetRenderTarget(diffuse);
            InGame.Clear(Color.Transparent);

            Point position = UIGridTextListElement.Margin;

            // Render the checkbox if needed.
            if (checkbox)
            {
                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();
                Vector2         size = new Vector2(40.0f, 40.0f);
                quad.Render(UIGridTextListElement.Checkbox, new Vector2(position.X, position.Y), size, @"TexturedRegularAlpha");
                position.X += (int)size.X;
            }

            // Render the text.
            SpriteBatch batch = UI2D.Shared.SpriteBatch;

            batch.Begin();
            TextHelper.DrawStringWithShadow(Font, batch, position.X, position.Y, text, Color.White, Color.Black, false);
            batch.End();

            // Restore backbuffer.
            InGame.RestoreRenderTarget();

            Size = new Vector2(diffuse.Width, diffuse.Height);
        }   // end of TextLine RefreshTexture()
コード例 #7
0
ファイル: Main.cs プロジェクト: leelaoke/btd6_mods
 internal static bool Prefix(ref InGame __instance)
 {
     Console.WriteLine("Victory! Your time was: " + timer + " seconds!");
     round = defaultRound;
     timer = 0;
     return(true);
 }
コード例 #8
0
    public void StartGame()
    {
        //GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "game");
        foreach (CharecterSelection item in charecterSelection)
        {
            //item.charecter.SetActive(false);
            item.charecter.transform.localScale = Vector3.zero;
            item.charecter.transform.GetChild(0).transform.GetChild(0).GetComponent <StopObjectFromRotating>().enabled = false;
        }
        int indexofCurrectCharecter = PlayerPrefs.GetInt("CurrentActiveCharecter", 0);

        charecterSelection[indexofCurrectCharecter].charecter.transform.DOScale(1, 0.5f);
        charecterSelection[indexofCurrectCharecter].charecter.transform.GetChild(0).transform.GetChild(0).GetComponent <StopObjectFromRotating>().enabled = true;
        Player.instance.degree = charecterSelection[indexofCurrectCharecter].directions;
        gameStarted            = true;
        camPosition            = GameCam.transform.position;
        orthoSize     = GameCam.fieldOfView;
        camScaleValue = GameCam.transform.localScale.x;
        BgScaleValue  = BG.transform.localScale.x;
        print(BgScaleValue);
        MainMenu.SetActive(false);
        powerupFillImage.fillAmount = 0;
        Time.timeScale = 1;
        InGame.SetActive(true);
        StartCoroutine(Spawn(TimeGap));
    }
コード例 #9
0
 public void SetUp(InGame gameMode)
 {
     coinEvent.AddListener(gameMode.CoinCollected);
     dieEvent.AddListener(gameMode.GameOver);
     damageEvent.AddListener(gameMode.DamageTaken);
     target = gameMode.PlayerTarget.transform;
 }
コード例 #10
0
 public void Continue()
 {
     gameStarted = true;
     StopAllCoroutines();
     continueButton.SetActive(false);
     slider.transform.DOLocalMoveX(sliderStartingX, 0.5f);
     CancelInvoke("DeActivateSlowMotion");
     UIPop.instance.Continue();
     StopAllCoroutines();
     powerupFillImage.fillAmount = 0;
     GameOver.SetActive(false);
     InGame.SetActive(true);
     foreach (GameObject item in createdPuzzel)
     {
         ReassignSpawnedCount(item.transform.GetChild(0).GetComponent <Puzzle>().indexofpuzzle);
         enemyCount += 1;
         Destroy(item);
     }
     DeActivateSlowMotion();
     createdPuzzel.Clear();
     Player.instance.isDead = false;
     Player.instance.puzzle.transform.DORotate(new Vector3(0, 0, 0), 0.1f).OnComplete(() =>
     {
         Player.instance.isReady      = true;
         Player.instance.currentAngle = 0;
         Player.instance.UpdateStatuesofPlayer();
         Player.instance.isClose = false;
         gameOver = false;
     });
     StartCoroutine(Spawn(TimeGap));
     OnIdleAnimation();
     DeactivareContinue();
 }
コード例 #11
0
 private void Awake()
 {
     instance     = this;
     init         = new Init(this);
     inGame       = new InGame(this);
     stateMachine = new StateMachine <GameLogic>(init);
 }
コード例 #12
0
 public void gameStart()
 {
     Time.timeScale = 1;
     JoyStick.SetActive(true);
     HP.SetActive(true);
     Panel.SetActive(false);
     InGame.SetActive(true);
 }
コード例 #13
0
        /// <summary>
        /// (Cross-Game compatible) Get's all Bloons on the map
        /// </summary>
        /// <param name="inGame"></param>
        /// <returns></returns>
        public static List <Bloon> GetBloons(this InGame inGame)
        {
#if BloonsTD6
            return(inGame.GetFactory <Bloon>().all.ToList());
#elif BloonsAT
            return(inGame.GetSimulation().bloonManager.GetBloons().ToList());
#endif
        }
コード例 #14
0
ファイル: Player2.cs プロジェクト: huihuiboy/GameJam
 // Start is called before the first frame update
 void Start()
 {
     My_aniT = GetComponent <Animator>();
     shoo    = GameObject.Find("shoot").GetComponent <shoot>();
     ig      = GameObject.Find("inGameManager").GetComponent <InGame>();
     atk     = killrange.GetComponent <attackrange>();
     r2d     = GetComponent <Rigidbody2D>();
 }
コード例 #15
0
        /// <summary>
        /// (Cross-Game compatible) Get's the UnityToSimulation for this game
        /// </summary>
        /// <param name="inGame"></param>
        /// <returns></returns>
        public static UnityToSimulation GetUnityToSimulation(this InGame inGame)
        {
#if BloonsTD6
            return(inGame.bridge);
#elif BloonsAT
            return(inGame.Simulation);
#endif
        }
コード例 #16
0
        internal static void Prefix(InGame __instance)
        {
            IGameInstance gameInstance = NGameInstance.GetGame();
            int           currentRound = __instance.bridge.simulation.GetSpawnedRound();
            var           o            = new GameEvents.RoundEndEvent(gameInstance, currentRound); //Create RoundEndEvent instance

            EventRegistry.instance.DispatchEvent(ref o);                                           //Dispatch it
        }
コード例 #17
0
        /// <summary>
        /// (Cross-Game compatible) Get's all AbilityToSimulations currently in the game
        /// </summary>
        /// <param name="inGame"></param>
        /// <returns></returns>
        public static List <AbilityToSimulation> GetAbilities(this InGame inGame)
        {
#if BloonsTD6
            return(inGame.GetUnityToSimulation()?.GetAllAbilities(false)?.ToList());
#elif BloonsAT
            return(inGame.GetUnityToSimulation()?.GetAllAbilities()?.ToList());
#endif
        }
コード例 #18
0
ファイル: Player.cs プロジェクト: huihuiboy/GameJam
 // Start is called before the first frame update
 void Start()
 {
     My_aniT    = GetComponent <Animator>();
     ig         = GameObject.Find("inGameManager").GetComponent <InGame>();
     atk        = killrange.GetComponent <attackrange>();
     r2d        = GetComponent <Rigidbody2D>();
     currenTime = coolingTime;
 }
コード例 #19
0
 void Awake()
 {
     _instance = this;
     Menu.SetActive(false);
     Levels.SetActive(false);
     InGame.SetActive(false);
     Staff.SetActive(false);
     Back.SetActive(false);
 }
コード例 #20
0
        /// <summary>
        /// (Cross-Game compatible) Returns the difficulty of this game
        /// </summary>
        /// <param name="inGame"></param>
        /// <returns></returns>
        public static Difficulty GetDifficulty(this InGame inGame)
        {
#if BloonsTD6
            return((Difficulty)Enum.Parse(typeof(Difficulty), inGame.SelectedDifficulty));
#elif BloonsAT
            var difficulty = inGame.Simulation.GetDifficulty();
            return((Difficulty)Enum.Parse(typeof(Difficulty), difficulty.ToString()));
#endif
        }
コード例 #21
0
        /// <summary>
        /// Spawn bloons in game
        /// </summary>
        /// <param name="inGame"></param>
        /// <param name="round"></param>
        public static void SpawnBloons(this InGame inGame, int round)
        {
            GameModel model = inGame.GetGameModel();

            int index = (round < 100) ? round - 1 : round - 100;
            Il2CppReferenceArray <BloonEmissionModel> emissions = (round < 100) ? model.GetRoundSet().rounds[index].emissions : model.freeplayGroups[index].bloonEmissions;

            inGame.SpawnBloons(emissions);
        }
コード例 #22
0
        }   // TwitchedOrientation()

        public void RenderToTexture()
        {
            dirty = false;

            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            InGame.SetRenderTarget(rt);
            InGame.Clear(Color.Black);

            ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

            // Render the thumbnail.
            if (Thumbnail != null)
            {
                // Figure out how much of the thumbnail to crop off since the tiles are square.
                int crop = (Thumbnail.Width - Thumbnail.Height) / 2;

                try
                {
                    quad.Render(Thumbnail, new Vector2(-crop, 0.0f), new Vector2(rt.Width + crop, rt.Height), @"TexturedNoAlpha");
                }
                catch
                {
                    // At this point what has probably happened is that the thumbnail data has been lost or corrupted
                    // so we need to force it to reload and then set the dirty flag on this element so the rt is redone.

                    // Note:  for now setting dirty to true is commented out since it won't cause the thumbnail texture to
                    // reload and just causes perf to die.  Probably related to bug #2221

                    //dirty = true;
                }
            }

            // Render the title.
            {
                const int kTextMargin = 10;
                const int kTextPosY   = 150;

                string  title     = TextHelper.AddEllipsis(Font, Title, rt.Width - kTextMargin * 2);
                Vector2 titleSize = Font().MeasureString(title);

                // Render the title background.
                quad.Render(
                    new Vector4(0, 0, 0, 0.25f),
                    new Vector2(0, kTextPosY),
                    new Vector2(rt.Width, titleSize.Y));

                // Render the title text.
                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                batch.Begin();
                TextHelper.DrawString(Font, title, new Vector2((rt.Width - titleSize.X) / 2f, kTextPosY), textColor);
                batch.End();
            }

            InGame.RestoreRenderTarget();
        }   // end of UIGridLevelElement RenderToTexture()
コード例 #23
0
        /// <summary>
        /// (Cross-Game compatible) Gets all objects of type T. Does this by returning all objects created by the Factory of type T
        /// </summary>
        /// <typeparam name="T">The type of items you want</typeparam>
        public static List <T> GetAllObjectsOfType <T>(this InGame inGame) where T : RootObject, new()
        {
            var factory = inGame.GetMainFactory()?.GetFactory <T>();

#if BloonsTD6
            return(factory?.all?.ToList());
#elif BloonsAT
            return(factory?.active?.ToList());
#endif
        }
コード例 #24
0
        public InGame LoadGameState(string key)
        {
            InGame result = _session.Get <InGame>(key);

            if (typeof(InGame).IsClass && result == null)
            {
                result = (InGame)Activator.CreateInstance(typeof(InGame));
            }
            return(result);
        }
コード例 #25
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            // Create the diffuse texture.
            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridModularPictureListElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
コード例 #26
0
        /// <summary>
        /// Get the game object that owns all InGame UI elements
        /// </summary>
        /// <param name="inGame"></param>
        /// <returns></returns>
        public static GameObject GetInGameUI(this InGame inGame)
        {
            Scene scene = SceneManager.GetSceneByName("InGameUi");
            Il2CppReferenceArray <GameObject> rootGameObjects = scene.GetRootGameObjects();

            const int  uiIndex = 1;
            GameObject ui      = rootGameObjects[uiIndex];

            return(ui);
        }
コード例 #27
0
        }   // end of UnloadContent()

        public static void DeviceReset(GraphicsDevice device)
        {
            // Recreate rendertarget.
            InGame.RelRT("TutorialRT", rt);
            BokuGame.Release(ref rt);

            CreateRenderTarget();

            modalDisplay.DeviceReset(device);
        }   // end of DeviceReset()
コード例 #28
0
        /// <summary>
        /// (Cross-Game compatible) Get all TowerToSimulations
        /// </summary>
        /// <param name="inGame"></param>
        /// /// <param name="name">Optionally only get Towers whose TowerModel name is this paramater</param>
        /// <returns></returns>
        public static List <TowerToSimulation> GetAllTowerToSim(this InGame inGame, string name = null)
        {
            var towerToSims = inGame.GetUnityToSimulation()?.GetAllTowers()?.ToList();

            if (!string.IsNullOrEmpty(name))
            {
                towerToSims = towerToSims?.FindAll(tower => tower.Def.name == name);
            }

            return(towerToSims);
        }
コード例 #29
0
    public void Calculate()
    {
        InGame inGame2 = inGame.GetComponent <InGame>();
        int    x       = 1;

        if (isTWo)
        {
            x = 2;
        }
        inGame2.calculate(x);
    }
コード例 #30
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            const int dpi = 96;
            int       w   = (int)(dpi * 2.0f);
            int       h   = (int)(dpi * 2.0f);

            rt = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridLevelElement", rt);

            dirty = true;   // Ensure a refresh of the texture.
        }
コード例 #31
0
        /// <summary>
        /// (Cross-Game compatible) Get every Tower that has been created through the Tower Factory
        /// </summary>
        /// <param name="inGame"></param>
        /// <param name="name">Optionally only get Towers whose TowerModel name is this paramater</param>
        /// <returns></returns>
        public static List <Tower> GetTowers(this InGame inGame, string name = null)
        {
            var towers = inGame.GetAllObjectsOfType <Tower>();

            if (!string.IsNullOrEmpty(name))
            {
                towers = towers?.FindAll(tower => tower.towerModel.name == name);
            }

            return(towers);
        }
コード例 #32
0
ファイル: CameraMove.cs プロジェクト: penspanic/SnowRun
    void Awake()
    {
        uiMgr = GameObject.FindObjectOfType<UIManager>();
        inGame = GameObject.FindObjectOfType<InGame>();

        Quaternion mapRotation = Quaternion.Euler(-30, 0, 0);
        GameObject temp = new GameObject();
        dirVec = Vector3.one;
        temp.transform.rotation = mapRotation;
        dirVec = temp.transform.forward * -1;
        Destroy(temp);

        forwardVec = transform.forward;
    }
コード例 #33
0
ファイル: Paddle.cs プロジェクト: CorruptData/Breakout
 public void Update(InGame world, Microsoft.Xna.Framework.Input.KeyboardState ks)
 {
     //Checking for input.
     if (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) && (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)))
     {
     }
     else if ((ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) && (PositionX > 0))
     {
         PositionX -= Speed;
         //The paddle can't go off the left side of the screen.
         if (PositionX < 0)
             PositionX = 0;
     }
     else if ((ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))&& (PositionX < Breakout.StageWidth - Width))
     {
         PositionX += Speed;
         //The paddle can't go beyond the right side of the stage.
         if (PositionX > Breakout.StageWidth - Width)
             //If we try, We are set next to the edge.
             PositionX = Breakout.StageWidth - Width;
     }
 }
コード例 #34
0
ファイル: Shop.cs プロジェクト: penspanic/SnowRun
    void Awake()
    {
        uiMgr = GameObject.FindObjectOfType<UIManager>();
        gameMgr = GameObject.FindObjectOfType<GameManager>();
        inGame = GameObject.FindObjectOfType<InGame>();
        objectsParent = GameObject.Find("Objects Parent");
        parentCenter = objectsParent.transform.position;
        parentCenter.x = 0;

        prefabList = new List<Player>(Resources.LoadAll<Player>("Object/Character"));
        prefabList.Sort(); // Sort by Player's IComparable implement

        originalColors = new Color[prefabList.Count][];

        int i = 0;

        foreach (Player eachPrefab in prefabList)
        {
            Vector3 createPos = new Vector3();
            float angle = 20 * i * Mathf.Deg2Rad;
            createPos.x = parentCenter.x + Mathf.Sin(angle) * characterCircleRad;
            createPos.z = parentCenter.z - Mathf.Cos(angle) * characterCircleRad / 2;

            GameObject newCharacter = Instantiate(eachPrefab.gameObject);
            newCharacter.transform.localPosition = createPos;

            newCharacter.transform.SetParent(objectsParent.transform, false);
            Destroy(newCharacter.GetComponent<Player>());
            Destroy(newCharacter.GetComponent<Rigidbody>());

            Renderer[] renderers = newCharacter.GetComponentsInChildren<Renderer>();

            originalColors[i] = new Color[renderers.Length];
            for (int j = 0; j < renderers.Length; j++)
                originalColors[i][j] = renderers[j].material.color;
            characterList.Add(newCharacter);
            i++;
        }
    }
コード例 #35
0
 void convertCustomProperties( SerializableDictionary old, InGame.CustomProperties @new )
 {
     old.ForEach(
         pair =>
             @new.Add(
                 pair.Key, new InGame.CustomProperty( pair.Value.name, pair.Value.value, pair.Value.type, pair.Value.description ) ) ) ;
 }
コード例 #36
0
ファイル: GUI.cs プロジェクト: CorruptData/Breakout
 public void Update(InGame world, KeyboardState ks)
 {
 }
コード例 #37
0
ファイル: ClearTunnelHandler.cs プロジェクト: XF9/Fenrir
 /// <summary>
 /// Create the handler
 /// </summary>
 /// <param name="Scene"></param>
 public ClearTunnelHandler(InGame.Components.Scene Scene)
 {
     this.helper = new Marker(MarkerType.Info, new Microsoft.Xna.Framework.Point());
     this.scene = Scene;
 }
コード例 #38
0
ファイル: GS.cs プロジェクト: WJLiddy/CastleSpire
    public static void Update(int ms, Microsoft.Xna.Framework.Input.KeyboardState ks, GamePadState[] gs)
    {
        SlimDX.DirectInput.JoystickState[] joyStates = ControllerManager.GetState();

        for (int i = 0; i != 4; i++)
        {
            if (Inputs[i] is KeyboardInput)
                ((KeyboardInput)Inputs[i]).Update(ks);
        }

        State newState;
        switch (GState)
        {
            case State.Title:
                newState = Title.Update(ms,ks);
                if (newState == State.CharSelect)
                {
                    GState = State.CharSelect;
                    CharSelect = new CharSelect();
                }
                break;

            case State.CharSelect:

                newState = CharSelect.Update(ms);
               if (newState == State.InGame)
               {
                    GState = State.InGame;
                    InGame = new InGame(CharSelect.CharacterSelect);
               }
                break;

            case State.InGame:

                newState = InGame.Update(ms);
                if (newState == State.Title)
                {
                }
                break;
        }
    }
コード例 #39
0
ファイル: AStar.cs プロジェクト: hompoth/FlingWhale
	//GameObject player;
	
	void Start() {
		grid = GetComponent<MapGeneration>();
		ingame = GetComponent<InGame> ();
		seeker = Vector3.zero;//player.transform.position;
	}
コード例 #40
0
ファイル: Ball.cs プロジェクト: CorruptData/Breakout
    void BallOut(InGame world)
    {
        if (BallsLeft > 0)
            //Number of balls avaliable is lessened
            BallsLeft--;
        else
            Dead = true;
            //Game Over!

        //Remove a ball from the list
        world.OutOfBounds.AddLast(this);
    }
コード例 #41
0
ファイル: Ball.cs プロジェクト: CorruptData/Breakout
    void BounceBallOffBricks(InGame world)
    {
        foreach (Brick br in world.Bricks)
        {
            //See if the ball is touching any of the bricks.
            if ((br.BrickLive) && InGame.Collide((int)PositionX, (int)PositionY, Size, Size, br.PositionX, br.PositionY, br.Width, br.Height))
            {
                //Now check if the collision is on the top or bottom,
                if ((TopCollide(br)) || BottomCollide(br))
                    //If so, then reflect the Y direction of the ball.
                    FlipThetaY();
                //Otherwise, it can be assumed it hit on one of the sides,
                else
                    //and we can reflect the X direction.
                    FlipThetaX();

                //Get points
                switch (br.BrickType)
                {
                    case ("normal"):
                        Points++;
                        break;

                    case ("blue"):
                        Points += 2;
                        break;
                }
                //Kill the brick.
                br.BrickLive = false;
                //Play the hit sound.
                SoundManager.Play("hit.wav");
                //Reset the fun stuff.
                DontBeMadTimer = DontBeMadTimerDefault;
                //It is assumed you can only hit one brick at a time.
                //This SHOULD be looked into, but I probably won't.
                return;
            }
        }
    }
コード例 #42
0
ファイル: Ball.cs プロジェクト: CorruptData/Breakout
    void PaddleCollide(InGame world)
    {
        if (InGame.Collide((int)PositionX, (int)PositionY + Size - 1, Size, 1, (int)world.Player.PositionX, world.Player.PositionY, world.Player.Width, 1) && Math.Sin(Theta) > 0)
        {
            Theta = (((PositionX + (Size / 2) + -world.Player.PositionX) / (world.Player.Width)) + -1) * MaxReflect;

            DontBeMadTimer = DontBeMadTimerDefault;
        }
    }
コード例 #43
0
ファイル: Ball.cs プロジェクト: CorruptData/Breakout
 bool WorldCollide(InGame world)
 {
     //check for vertical world collision
     if ((PositionX <= 0) || (PositionX + Size >= Breakout.StageWidth))
         //Hit a side! Reflect the x direction of the ball.
         FlipThetaX();
     //check for horizontal world collision
     if (PositionY <= 0)
         //Hit the top! Reflect the y direction of the ball.
         FlipThetaY();
     else if (PositionY > Breakout.BaseHeight)
         //if the ball is off the borrom, then it dies.
         BallOut(world);
     return PositionY > Breakout.BaseHeight;
 }
コード例 #44
0
ファイル: Breakout.cs プロジェクト: CorruptData/Breakout
    protected override void AD2Logic(int ms, KeyboardState keyboardState, GamePadState[] gamePadState)
    {
        //Kill the program if escape is pressed.
        if (keyboardState.IsKeyDown(Keys.Escape))
            Exit();

        State newState;
        //See what state the game is in.
        switch (GameState)
        {
            //Title screen!
            case State.Title:
                newState = T.Update(keyboardState);
                //If the title screen says move on to the game,
                if (newState == State.InGame)
                {
                    //Kill title screen sounds,
                    SoundManager.Stop();
                    //and let the games begin!
                    GameState = State.InGame;
                    Game = new InGame();
                }
                break;

            //Playing the Game!
            case State.InGame:
                newState = Game.Update(ms, keyboardState);
                //Check to see if the Game's state has returned to the title screen
                if (newState == State.Title)
                {
                    //Kill the game's sounds.
                    SoundManager.Stop();
                    //Go back to the title screen.
                    GameState = State.Title;
                    T = new Title();
                }
                break;
        }
    }