コード例 #1
0
        public override void Paint()
        {
            if (Registers.gameState == GameState.Running)
            {
                GAME_ENGINE.SetColor(200, 50, 0);

                drawHere = Utils.Lerp2D(origin, dest, curTime / 2);
                GAME_ENGINE.FillRectangle(drawHere.X, drawHere.Y, 5, 5);
                GAME_ENGINE.DrawLine(origin, new Vector2f(drawHere.X + 2.5f, drawHere.Y + 2.5f), 5f);

                //Explode when ,missile has reached its destination
                if (Utils.Distance(drawHere, dest) <= 1)
                {
                    if (targetID <= gameManager.GetBuildings().Count - 1)
                    {
                        explM = new Explosion(gameManager, enemySpawner, this, drawHere, gameManager.GetBuildings()[targetID], 0);
                    }
                    Console.WriteLine(string.Format("Explosions #{0}", gameManager.explosions.Count));
                    enemySpawner.EMissileDetonate(this);
                    Dispose();
                }
                curTime += GAME_ENGINE.GetDeltaTime() / 2.5f;

                //Destroy missile when out of screen
                if (Utils.Distance(drawHere, new Vector2f(Alignment.X.Left, Alignment.Y.Up)) <= 0 && Utils.Distance(drawHere, new Vector2f(Alignment.X.Right, Alignment.Y.Down)) <= 0)
                {
                    enemySpawner.EMissileDetonate(this);
                    Dispose();
                }
            }
        }
コード例 #2
0
        public override void Paint()
        {
            if (Registers.gameState == GameState.Running)
            {
                GAME_ENGINE.SetColor(0, 255, 0);

                drawHere = Utils.Lerp2D(orgin, dest, curTime);
                GAME_ENGINE.FillRectangle(drawHere.X, drawHere.Y, 5, 5);
                GAME_ENGINE.DrawLine(orgin, drawHere);
                if (Utils.Distance(drawHere, dest) <= 1)
                {
                    explM = new Explosion(gameManager, missileLauncher, this, drawHere);
                    Console.WriteLine(string.Format("Explosions #{0}", gameManager.explosions.Count));
                    missileLauncher.MissileDetonate(this);
                    Dispose();
                }
                curTime += GAME_ENGINE.GetDeltaTime() * 2f;

                if (misLocY <= 0)
                {
                    Dispose();
                }
            }
        }