Ejemplo n.º 1
0
        public Game(Random random, Rectangle formArea)
        {
            this.formArea = formArea;
            this.random   = random;

            // Se crea un objeto con una Lista de Estrellas con su posición y el color
            stars = new StarMaker(random, formArea);

            // Crea los labels en la posición del rectangulo
            scoreLocation = new PointF((formArea.Left + 5.0F), (formArea.Top + 5.0F));
            livesLocation = new PointF((formArea.Right - 120.0F), (formArea.Top + 5.0F));
            waveLocation  = new PointF((formArea.Left + 5.0F), (formArea.Top + 25.0F));

            // Crea el objeto nave en el punto de la localización del rectangulo
            playerShip = PlayerShip.Instance;
            playerShip.InitValues(formArea,
                                  new Point((formArea.Width / 2), (formArea.Height - 50)));

            // Creación de las listas
            playerShots  = new List <Shot>();
            invaderShots = new List <Shot>();
            invaders     = new List <Invader>();

            // Siguiente nivel
            nivel = new Level(invaders);
            nivel.nextWave();
            //nextWave();
        }
Ejemplo n.º 2
0
    public override bool CheckKineticPowerCanBeUsed(Vector2Int originCellNum, bool isRight)
    {
        // スタック中は動けないのでtrueを戻す
        if (CheckFlag(LANDSTAR_STAT.STUCKED))
        {
            return(true);
        }
        var starMaker = StarMaker.Instance;
        var direction = StarMaker.GetDirection(originCellNum, CellNum);

        Vector2Int cp0 = CellNum;
        Vector2Int cp1 = CellNum;



        // チェックするコマを算出.
        if (isRight)
        {
            if (direction == Direction.Right)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Bottom);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.LeftBottom);
            }
            else if (direction == Direction.RightTop)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Bottom);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Bottom);
            }
            else if (direction == Direction.Top)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Right);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.RightBottom);
            }
            else if (direction == Direction.LeftTop)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Right);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Right);
            }
            else if (direction == Direction.Left)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Top);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.RightTop);
            }
            else if (direction == Direction.LeftBottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Top);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Top);
            }
            else if (direction == Direction.Bottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Left);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.LeftTop);
            }
            else if (direction == Direction.RightBottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Left);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Left);
            }
            else
            {
                return(false); // この条件に正であることはありえない.
            }
        }
        else
        {
            if (direction == Direction.Right)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Top);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.LeftTop);
            }
            else if (direction == Direction.RightTop)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Left);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Left);
            }
            else if (direction == Direction.Top)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Left);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.LeftBottom);
            }
            else if (direction == Direction.LeftTop)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Bottom);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Bottom);
            }
            else if (direction == Direction.Left)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Bottom);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.RightBottom);
            }
            else if (direction == Direction.LeftBottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Right);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Right);
            }
            else if (direction == Direction.Bottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Right);
                cp1 += StarMaker.GetDifferenceByDirection(Direction.RightTop);
            }
            else if (direction == Direction.RightBottom)
            {
                cp0 += StarMaker.GetDifferenceByDirection(Direction.Top);
                cp1  = cp0 + StarMaker.GetDifferenceByDirection(Direction.Top);
            }
            else
            {
                return(false); // この条件に正であることはありえない.
            }
        }


        // マップ領域内かチェック
        if (!(starMaker.CheckLimitOfMap(cp0) && starMaker.CheckLimitOfMap(cp1)))
        {
            return(false);
        }

        // 絶対にtrueなパターンのチェック
        if (starMaker.GetStar(cp0, StarType.BlackHole)) // 先1マス目がブラックホール
        {
            return(true);
        }

        // 移動経路に邪魔する要素があるかチェック
        if (0 < starMaker.GetStarList(cp0, StarType.Rock).Count) // 先1マスにRockがある
        {
            return(false);
        }
        else if (starMaker.GetStarList(cp0, StarType.Land).Exists(obj => obj.GetComponent <LandStarController>().CheckFlag(LANDSTAR_STAT.STUCKED)) || // いずれのマスにミルキーウェイにつかまっているLandがある
                 starMaker.GetStarList(cp1, StarType.Land).Exists(obj => obj.GetComponent <LandStarController>().CheckFlag(LANDSTAR_STAT.STUCKED)))
        {
            return(false);
        }
        else if (starMaker.GetStarList(cp0, StarType.Land).Exists(obj => !obj.GetComponent <LandStarController>().CheckFlag(LANDSTAR_STAT.STUCKED)) && // 1マス先に動けるLandがいて、2マス先にミルキーウェイがある.
                 0 < starMaker.GetStarList(cp1, StarType.MilkyWay).Count)
        {
            return(false);
        }

        return(true);
    }