Beispiel #1
0
    public override TreeNode MakeDecision(BoardData p_boardData)
    {
        Tiles[,] t_tiles = p_boardData.GetTiles();
        int t_nonEmptyTiles = 0;

        for (int t_row = 0; t_row < t_tiles.GetLength(0); t_row++)
        {
            for (int t_column = 0; t_column < t_tiles.GetLength(1); t_column++)
            {
                if (t_tiles[t_row, t_column] != Tiles.Empty)
                {
                    ++t_nonEmptyTiles;
                }
            }
        }

        if (t_nonEmptyTiles != m_amountToCompare)
        {
            return(m_falseNode);
        }
        else
        {
            return(m_trueNode);
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        double evenTile;

        map = new Tiles[width, height];

        //Avec des FOR ?
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                map[x, y] = new Tiles();
                evenTile  = (x + y) / 2.0;
                if (System.Math.Truncate(evenTile) == evenTile)
                {
                    // Debug.Log("evenTile : " + evenTile + " " + System.Math.Truncate(evenTile));
                    map[x, y].floor = 1;
                }
            }
        }

        map[4, 0].rightWall = 1;
        map[4, 1].rightWall = 1;
        map[4, 2].rightWall = 1;
        map[4, 4].rightWall = 1;
        map[4, 5].rightWall = 1;
    }
Beispiel #3
0
    public Vector2?FindNearEmptyPosition(Vector2 currentPosition, int tilesAround)
    {
        //tilesAround représente le rayon du carré autour duquel on cherche

        Tiles[,] map = GetMap();
        List <Vector2> tilesOk = new List <Vector2>();

        //ne fonctionne que pour la room 00 : prendre en compte world bottom left... du grid

        int x = (int)currentPosition.x;
        int y = (int)currentPosition.y;

        for (int i = -tilesAround; i < tilesAround; i++)
        {
            for (int j = -tilesAround; j < tilesAround; j++)
            {
                if ((x - i) >= 0 && (x - i) < map.GetLength(0) && (y + j) >= 0 && (y + j) < map.GetLength(1))
                {
                    if (map[x + i, y + j] == Tiles.Floor)
                    {
                        tilesOk.Add(GetRect().position + new Vector2(x + i, y + j));
                    }
                }
            }
        }

        if (!(tilesOk.Count > 0))
        {
            return(null);
        }
        else
        {
            return(tilesOk[Random.Range(0, tilesOk.Count)]);
        }
    }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            x             = (int)slrXSize.Value;
            y             = (int)slrYSize.Value;
            timerSpeed    = 1000 / (int)slrSPeed.Value;
            time.Interval = new TimeSpan(0, 0, 0, 0, timerSpeed);
            time.Tick    += new EventHandler(tickMethod);

            grdGame.Rows    = x;
            grdGame.Columns = y;

            gameTiles = new Tiles[x, y];
            for (int i = 0; i < x; i++)
            {
                for (int b = 0; b < y; b++)
                {
                    Tiles tile = new Tiles(false, i, b);

                    gameTiles[i, b] = tile;
                }
            }
            foreach (Tiles t in gameTiles)
            {
                t.FindNeighbor(gameTiles);
                grdGame.Children.Add(t.rec);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            _tileses = GetTiles();
            base.Initialize();
        }
Beispiel #6
0
        private Tiles[,] AddAllTerrainTypes(Tiles[,] tiles, TileConstants c, Random randObj)
        {
            for (int x = 0; x < c.TilesPerRow; x++)
            {
                for (int y = 0; y < c.TilesPerRow; y++)
                {
                    // Thorns and rocks will be removed until their art is revised

                    int val = randObj.Next(0, 100);
                    if (val >= 0 && val <= 11)
                    {
                        tiles[x, y] = MatchTile(2);
                    }
                    else if (val > 17 && val <= 55)
                    {
                        tiles[x, y] = MatchTile(5);
                    }
                    else if (val > 55 && val <= 100)
                    {
                        tiles[x, y] = MatchTile(6);
                    }
                    else
                    {
                        tiles[x, y] = MatchTile(5);
                    }
                }
            }

            return(tiles);
        }
    private void GenerateMapMesh()
    {
        foreach (var room in rooms)
        {
            room.container = new GameObject("room-" + rooms.IndexOf(room));

            if (room.parent == null)
            {
                room.container.transform.parent = GameObject.Find(mapHolderName).transform;
            }
            else
            {
                room.container.transform.parent = room.parent.container.transform;
            }


            Tiles[,] map = room.GetMap();
            Rect roomRect = room.GetRect();

            room.container.transform.position = roomRect.position;


            //Add & Texturise Mesh
            //On différencie le contenu en fonction des tilestype pour obtenir des mesh moins gros. (limit 85000 vertices)
            //Wall
            GameObject meshGameObject = GenerateMesh(room.container, map, roomRect.position, Tiles.Wall, TagName.Wall);
            AddColliders(meshGameObject, map);
            GenerateMapConnectivity(room.container, room);

            //Floor
            GenerateMesh(room.container, map, roomRect.position, Tiles.Floor, TagName.Floor);
            GenerateMesh(room.container, map, roomRect.position, Tiles.RoomEnter, TagName.Floor);
            GenerateMesh(room.container, map, roomRect.position, Tiles.RoomExit, TagName.Floor);
        }
    }
        private void btnSetSize_Click(object sender, RoutedEventArgs e)
        {
            x = (int)slrXSize.Value;
            y = (int)slrYSize.Value;

            grdGame.Children.Clear();
            grdGame.Rows    = x;
            grdGame.Columns = y;

            gameTiles = new Tiles[x, y];
            for (int i = 0; i < x; i++)
            {
                for (int b = 0; b < y; b++)
                {
                    Tiles tile = new Tiles(false, i, b);
                    gameTiles[i, b] = tile;
                }
            }

            foreach (Tiles t in gameTiles)
            {
                t.FindNeighbor(gameTiles);
                grdGame.Children.Add(t.rec);
            }
        }
Beispiel #9
0
 void Start()
 {
     rooms     = new List <Rect>();//房间的数组进行初始化
     map       = new Tiles[width, height];
     _regions  = new int[width, height];
     mapParent = GameObject.FindGameObjectWithTag("mapParent").transform;//获得tag为mapParent的物体
     Generate();
 }
Beispiel #10
0
 public void InitializeLayers(Tiles[,] board)
 {
     layers = new Queue <Layer>();
     layers.Enqueue(new ConvolutionalLayer());
     layers.Enqueue(new PoolingLayer());
     layers.Enqueue(new FlatteningLayer(board));
     layers.Enqueue(new OutputLayer());
 }
        public void switchRoom(Room room, Direction exitDirection)
        {
            int tRoomID = this.room.ROOMID();

            this.room = room;
            p1.setPos(room.getEntrancePos(exitDirection));
            p1.setFaceAwayFrom(exitDirection);
            grid = room.getTilesForRender();
        }
Beispiel #12
0
    public BoardData GetNewBoard(Move p_move)
    {
        Players t_newPlayer = CurrentPlayer ^ Players.AI; // Tricky way to get the opposite player

        Tiles[,] t_newBoardTiles = m_boardTiles.Clone() as Tiles[, ];
        t_newBoardTiles[p_move.Row, p_move.Column] = CurrentPlayerTile;

        return(new BoardData(t_newPlayer, t_newBoardTiles, HumanTile));
    }
    //Constructor called with the number of units as a parameter
    public Map(int unitN, int buildingN, int mHight, int mWidth)
    {
        unitNum     = unitN;
        buildingNum = buildingN;

        mapHeight = mHight;
        mapWidth  = mWidth;

        mapTiles = new Tiles[mapWidth, mapHeight];
    }
Beispiel #14
0
 public BoardData(Players p_player, Tiles p_humanTile = m_defaultHumanTile)
 {
     InitializePlayersTiles(p_player, p_humanTile);
     m_boardTiles = new Tiles[3, 3]
     {
         { Tiles.Empty, Tiles.Empty, Tiles.Empty },
         { Tiles.Empty, Tiles.Empty, Tiles.Empty },
         { Tiles.Empty, Tiles.Empty, Tiles.Empty }
     };
 }
Beispiel #15
0
        protected virtual Tiles[,] SetDoorPositions(Random randObj, Tiles[,] tiles, TileConstants C)
        {
            (int, int)entry = CalculateDoorPositions(randObj, C);
            tiles[entry.Item1, entry.Item2] = MatchTileID(3);

            (int, int)exit = CalculateDoorPositions(randObj, C);
            tiles[exit.Item1, exit.Item2] = MatchTileID(4);

            return(tiles);
        }
Beispiel #16
0
    /// <summary>
    /// Retourne les tiles de la map.
    /// </summary>
    public Tiles[,] GetMap()
    {
        if (map != null)
        {
            return(map);
        }

        //Génère une map avec juste les bordures.
        map = GetSimpleMap();
        //Place tunnel avec la map et juste des bordures.
        PlaceTunnels();
        //Remplit la map avec que des murs
        MapUtils.Set(map, 1, 1, width - 1, height - 1, Tiles.Wall);

        //Places Childs Rooms
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                foreach (var childRoom in childs)
                {
                    if (childRoom.rect.Contains(new Vector2(x, y)))
                    {
                        map[x, y]        = Tiles.Floor;
                        childRoom.placed = true;
                    }
                }
            }
        }
        childs.RemoveAll(m => !m.placed);

        //Disform child rooms by adding somes irregularities on sides
        foreach (var room in childs)
        {
            List <Vector2> irregularities = GetSomeIrregularitites(room.rect);
            foreach (var irregularity in irregularities)
            {
                map[(int)(room.rect.x + irregularity.x), (int)(room.rect.y + irregularity.y)] = Tiles.Wall;
            }
        }


        //PLaces Tunnels
        foreach (var tunnel in tunnels)
        {
            int tunnelSize = Random.Range(3, 5);

            foreach (var tunnelCell in tunnel)
            {
                MapUtils.Set(map, (int)(tunnelCell.x - tunnelSize / 2), (int)(tunnelCell.y - tunnelSize / 2), tunnelSize, tunnelSize, Tiles.Floor);
            }
        }

        return(map);
    }
Beispiel #17
0
 void Start()
 {
     goals      = FindObjectOfType <GoalManager>();
     find       = FindObjectOfType <FindMatches>();
     score      = FindObjectOfType <ScoreSystem>();
     blankTiles = new bool[width, height];
     breakables = new Tiles[width, height];
     allDots    = new  GameObject[width, height];
     SetUp();
     currentState = GameState.pause;
 }
Beispiel #18
0
        public int Width; //The width of the map

        #endregion Fields

        #region Constructors

        /// <summary>Creates a Map with the dimensions specified</summary>
        /// <param name="Width">The width of the map.</param>
        /// <param name="Height">The Height of the map.</param>
        public Map(int Width,int Height)
        {
            this.Height = Height;
            this.Width = Width;
            info = new Tiles[Width, Height];
            for (int i = 0; i < Width; i++)
                for (int j = 0; j < Height; j++)
                    info[i, j] = Tiles.Unknown;
            Ships = new List<Ship.Ship>();
            EPlanes = new List<Plane.Plane>();
        }
Beispiel #19
0
        public Location(int id, string name, string description, Random randObj)
        {
            ID          = id;
            Name        = name;
            Description = description;

            TileConstants C = new TileConstants();

            Tiles[,] tiles = GenerateTiles(randObj, C);
            TileGrid       = SetDoorPositions(randObj, tiles, C);
        }
Beispiel #20
0
        public Wall()
        {
            pole = new PictureBox[13, 13];

            tiles = new Tiles[26, 26];

            for (int y = 0; y < 13; y++)
            {
                for (int x = 0; x < 13; x++)
                {
                    Bitmap   bmp = new Bitmap(20, 20);
                    Graphics g   = Graphics.FromImage(bmp);

                    if (r.Next(100) < 30)
                    {
                        pole[x, y] = new PictureBox()
                        {
                            BackColor = System.Drawing.Color.Red,
                            Image     = imgEmpty,
                        };

                        if (
                            ((x == 0 || x == 6 || x == 12) && (y == 0))
                            ||
                            (x == 4 && y == 12)
                            ||
                            (x == 6 && y == 12)
                            )
                        {
                            pole[x, y].BackColor = System.Drawing.Color.Blue;
                        }
                    }
                    else
                    {
                        pole[x, y] = new PictureBox()
                        {
                            BackColor = System.Drawing.Color.Blue,
                            Image     = imgEmpty,
                        };
                    }

                    if (
                        ((x == 5 || x == 6 || x == 7) && (y == 11))
                        ||
                        ((x == 5 || x == 7) && (y == 12))
                        )
                    {
                        pole[x, y].BackColor = System.Drawing.Color.Red;
                    }
                }
            }

            CreateTiles();
        }
Beispiel #21
0
    public TilesPattern(int sizeX, int sizeY, Tiles tileType)
    {
        pattern = new Tiles[sizeX, sizeY];

        for (int i = 0; i < sizeX; i++)
        {
            for (int j = 0; j < sizeY; j++)
            {
                pattern[i, j] = tileType;
            }
        }
    }
Beispiel #22
0
        private Tiles[,] FillAllTilesWithField(Tiles[,] tiles, TileConstants c)
        {
            for (int x = 0; x < c.TilesPerRow; x++)
            {
                for (int y = 0; y < c.TilesPerRow; y++)
                {
                    tiles[x, y] = MatchTile(5);
                }
            }

            return(tiles);
        }
Beispiel #23
0
    public Map(int UnitN, int MapH, int MapW)
    {
        mapHeight = MapH;
        mapWidth  = MapW;
        mapTiles  = new Tiles[mapWidth, mapHeight];

        buildingMap = new buildings[mapWidth, mapHeight];
        uniMap      = new Unit[mapWidth, mapHeight];
        map         = new string[mapWidth, mapHeight];

        BuildingNum = UnitN;
    }
 /// <summary>
 /// Clear the map
 /// </summary>
 private void InitMap()
 {
     ClearTilemap();
     map = new Tiles[DungeonLevel.Width, DungeonLevel.Height];
     for (int y = 0; y < DungeonLevel.Height; y++)
     {
         for (int x = 0; x < DungeonLevel.Width; x++)
         {
             map[x, y] = Tiles.voidTile;
         }
     }
 }
Beispiel #25
0
    public static int[,] ConvertMap(Tiles[,] map)
    {
        int[,] convertedMap = new int[map.GetLength(0), map.GetLength(1)];

        for (int i = 0; i < map.GetLength(0); i++)
        {
            for (int j = 0; j < map.GetLength(1); j++)
            {
                convertedMap[i, j] = (int)map[i, j];
            }
        }
        return(convertedMap);
    }
Beispiel #26
0
        //evaluasi papan di akhir depth
        int evaluate(Tiles[,] maps)
        {
            int value = 0;

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    value += get_value(maps[i, j].Value);
                }
            }
            return(value);
        }
Beispiel #27
0
        private void InitializeTiles()
        {
            Tiles = new Tiles[7, 7];

            // blank board
            for (int r = 0; r < 7; r++)
            {
                for (int c = 0; c < 7; c++)
                {
                    Tiles[r, c] = Drop7.Tiles.Empty;
                }
            }
        }
    private GameObject GenerateMesh(GameObject container, Tiles[,] map, Vector2 position, Tiles tileType, string tag)
    {
        GameObject meshContainer = new GameObject("mesh-tiles-" + tileType.ToString());

        meshContainer.tag = tag;
        meshContainer.transform.parent = container.transform;
        //Generate Mesh
        MeshFilter   meshFilter   = meshContainer.AddComponent <MeshFilter>();
        MeshRenderer meshRenderer = meshContainer.AddComponent <MeshRenderer>();

        Mesh mesh = MeshGenerator.GenerateSquaredMesh(MapUtils.ConvertMap(map), 1, (int)tileType);

        meshFilter.mesh = mesh;
        meshFilter.transform.position = position;

        //Texturise mesh
        int size = 55;

        Texture2D texture = new Texture2D(size * map.GetLength(0), size * map.GetLength(1));

        //List<Color[]> tilesTextures = new List<Color[]>();
        //foreach (var tileTexture in textures)
        //{
        //    tilesTextures.Add(tileTexture.GetPixels(0, 0, size, size));
        //}

        for (int x = 0; x < map.GetLength(0); x++)
        {
            for (int y = 0; y < map.GetLength(1); y++)
            {
                if (map[x, y] == tileType)
                {
                    string textureForTile = MapUtils.GetTileSpriteName(map, x, y);
                    texture.SetPixels(x * size, y * size, size, size, mapTextures[textureForTile].GetPixels());
                    //texture.SetPixels(x * size, y * size, size, size, tilesTextures[Random.Range(0, tilesTextures.Count)]);
                }
            }
        }

        texture.filterMode = FilterMode.Point;
        texture.wrapMode   = TextureWrapMode.Clamp;
        texture.Apply();

        Material material = new Material(Shader.Find("Sprites/Diffuse"));

        material.color       = Color.white;
        material.mainTexture = texture;

        meshRenderer.material = material;
        return(meshContainer);
    }
Beispiel #29
0
    public Grid(Tiles[,] map, Vector2 worldBottomLeft)
    {
        grid = new Node[map.GetLength(0), map.GetLength(1)];
        this.worldBottomLeft = worldBottomLeft;

        for (int x = 0; x < map.GetLength(0); x++)
        {
            for (int y = 0; y < map.GetLength(1); y++)
            {
                Vector2 worldPoint = worldBottomLeft + new Vector2(x + 0.5f, y + 0.5f);
                grid[x, y] = new Node(map[x, y] != Tiles.Wall, worldPoint, x, y);
            }
        }
    }
Beispiel #30
0
        private double[,] ConvertBoardFromTiles(Tiles[,] board)
        {
            var convertedBoard = new double[7, 7];

            for (int r = 0; r < 7; r++)
            {
                for (int c = 0; c < 7; c++)
                {
                    convertedBoard[r, c] = (double)board[r, c];
                }
            }

            return(convertedBoard);
        }
Beispiel #31
0
        private Tiles[,] ClearSurroundingImpassableTiles(int x, int y, Tiles[,] tiles, TileConstants C, Tiles desired)
        {
            int right = x + 1;

            if (x == (C.TilesPerRow - 1))
            {
                right = C.TilesPerRow - 1;
            }

            int left = x - 1;

            if (x == 0)
            {
                left = 0;
            }

            int above = y - 1;

            if (y == 0)
            {
                above = 0;
            }

            int below = y + 1;

            if (y == (C.TilesPerRow - 1))
            {
                below = C.TilesPerRow - 1;
            }

            if (tiles[right, y].Passable == false)
            {
                tiles[right, y] = desired;
            }
            else if (tiles[left, y].Passable == false)
            {
                tiles[left, y] = desired;
            }
            else if (tiles[x, below].Passable == false)
            {
                tiles[x, below] = desired;
            }
            else if (tiles[x, above].Passable == false)
            {
                tiles[x, above] = desired;
            }

            return(tiles);
        }
 public void Init()
 {
     tiles = new Tiles[3, 3];
     this.spacing.X = 80;
     this.spacing.Y = 80;
     for (int i = 0; i < 3; i++) {
         for (int j = 0; j < 3; j++) {
             this.setTexture(i, j, m_parent.blank_texture);
             this.tiles[i, j].position.X = this.spacing.X + (this.tiles[i, j].texture.Width * i);
             this.tiles[i, j].position.Y = this.spacing.Y + (this.tiles[i, j].texture.Height * j);
             this.tiles[i, j].state = tileStates.empty;
         }
     }
     this.mouseCurrent = new MouseState();
     this.mousePrevious = new MouseState();
     this.font_vec = new Vector2();
     m_parent.currentGameState = Game1.gameStates.GAME_PROG;
 }
 public GameObjectsStore(List<Tiles> tileStore, Tiles[,] tileMap, int[,] tileMapOrigin, Player player, Texture2D[] backgrounds, List<Elements> elementStore)
 {
     this.tileStore = tileStore;
     this.tileMap = tileMap;
     this.tileMapOrigin = tileMapOrigin;
     this.player = player;
     this.backgrounds = backgrounds;
     this.elementStore = elementStore;
 }
Beispiel #34
0
        protected override void LoadContent()
        {
            //Old mouse state
            oldMouseState = Mouse.GetState();

            //Initial selected skill **move or replace**
            skillSelected = "right";
            setSkill = 1;

            //Row and column of tiles
            tileRows = 5;
            tileColumns = 9;
            tileRowSet = false;

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Fonts
            Font = Content.Load<SpriteFont>("Font");
            skillHotkeysFont = Content.Load<SpriteFont>("skillHotkeysFont");

            //Starting game status
            gameStatus = "playing";

            //Level 1
            level1 = level1.create(level1, screenWidth, screenHeight);

            //Setup UI
            menu = menu.setupMenu(level1.rectangle.X, level1.rectangle.Y, level1.bkgWidth, level1.bkgHeight);
            menu.image = Content.Load<Texture2D>("ui");

            topBar = topBar.setupTopBar(level1.rectangle.X, level1.rectangle.Y, level1.bkgWidth, level1.bkgHeight);
            topBar.image = Content.Load<Texture2D>("topBar");

            moneySign = moneySign.setupMoneySign(topBar.rectangle.X, topBar.rectangle.Y, level1.bkgWidth);
            moneySign.image = Content.Load<Texture2D>("dollarSign");
            cash.setLocation(moneySign.rectangle.X, moneySign.rectangle.Y);

            mouse.image = Content.Load<Texture2D>("arrowPointer");

            //Setup Tiles
            tiles.setupTiles(250, 10, 100, 100, screenWidth, screenHeight);
            tileArray = tiles.get();
            tiles.image = Content.Load<Texture2D>("skillOverlay");

            //Setup Skills
            setupSkills.setupSkills(menu.rectangle.X, menu.rectangle.Y, menu.rectangle.Height, menu.rectangle.Width);
            skills = setupSkills.getSkillsList();
            setupSkills.placeSkills(skills);
            chosenSkills = setupSkills.getChosenSkillsList();
            setupSkills.setupSkillHotkeys(skills);
            skillHotkeys = setupSkills.getSkillHotkeys();

            //Setup Hotkeys **change when adding user input for settings**
            setupHotkey.setupHotkeys();
            hotkeys = setupHotkey.getHotkeys();

            //Setup Skill Images
            for (int i = 0; i < chosenSkills.Count; i++)
            {
                chosenSkills[i].image = Content.Load<Texture2D>("skillButtons");
            }
        }
Beispiel #35
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) || GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed )
                this.Exit();

            if (gameStatus == "playing")
            {
                //Testing Stuff

                //Update Hotkey Selected Skill
                hotkeys[0].update();
                setSkill = hotkeys[0].getSkillSelected();

                //Mouse Click
                if (mouseStatus.LeftButton == ButtonState.Pressed && Mouse.GetState() != oldMouseState)
                {
                    setSkill -= 1;
                    for (int i = 0; i < 1; i++)
                    {
                        if (!tileArray[Convert.ToInt32(tiles.tileMouseOver.X), Convert.ToInt32(tiles.tileMouseOver.Y)].skillOnTile && chosenSkills[setSkill].type != "remove")
                        {
                            if ((cash.getTotalMoney() - chosenSkills[setSkill].cost) >= 0)
                            {
                                skillsPlacedOnBoard.Add(tiles.placeSkillOnTile(Convert.ToInt32(tiles.tileMouseOver.X), Convert.ToInt32(tiles.tileMouseOver.Y), setSkill + 1));
                                cash.removeCash(chosenSkills[setSkill].cost);

                                for (int j = 0; j < skillsPlacedOnBoard.Count; j++)
                                {
                                    if (skillsPlacedOnBoard[j].image == null)
                                        skillsPlacedOnBoard[j].image = Content.Load<Texture2D>("skillOverlay");
                                }
                            }
                        }
                        if (chosenSkills[setSkill].type == "remove" && ((cash.getTotalMoney() - chosenSkills[setSkill].cost) >= 0))
                        {
                            cash.removeCash(chosenSkills[setSkill].cost);
                        }
                    }
                }

                //Update List for tiles with skills on them
                tileArray = tiles.get();

                //Set Mouse Location
                mouseStatus = Mouse.GetState();
                mouse.setLocation(mouseStatus.X, mouseStatus.Y);
                mouseLocation = new Vector2(mouse.rectangle.X, mouse.rectangle.Y);

                //Calculate tile mouse is over
                tiles.placeOverlay(mouseLocation);
                tiles.setRectangle(Convert.ToInt32(tiles.tileMouseOver.X), Convert.ToInt32(tiles.tileMouseOver.Y), 90, 90);
                tiles.setDrawRectangle(setSkill);

                //Setup Level 1
                level1.backgroundImage = Content.Load<Texture2D>("background");

                //Money
                cash.update(actualGameTime);

                //Spawn Enemies
                if (actualGameTime == 15)
                {
                    enemies.Add(makeEnemy.spawn(makeEnemy, tiles.tileArray[0, 2].x, tiles.tileArray[0, 2].y, actualGameTime));
                }

                //Add images to enemies
                for (int i = 0; i < enemies.Count; i++)
                {
                    if (enemies[i].texture == "normal")
                    {
                        enemies[i].image = Content.Load<Texture2D>("enemy");
                    }
                }

                //Enemey starts walking after short pause(after spawn)
                for (int i = 0; i < enemies.Count; i++)
                {
                    if (enemies[i].status == "spawn")
                    {
                        if (enemies[i].spawnTime + 15 < actualGameTime)
                        {
                            enemies[i].status = "moving";
                            enemies[i].xVelocity = 1;
                        }
                    }
                }

            }

            //Update Enemies
            for (int i = 0; i < enemies.Count; i++)
            {
                enemies[i].update(actualGameTime);
            }

            //Adjust Game Timer
            gameTimer += .000001f;
            actualGameTime = (int)(gameTimer * 100000f);
            base.Update(gameTime);

            //Update old mouse status
            oldMouseState = Mouse.GetState();
        }
Beispiel #36
0
    void GenMap()
    {
        /*int[,] intLevel = new int[,] {  { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 4, 1, 1, 4, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 2, 2, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 1, 1, 0, 0, 0, 5, 5, 0, 2, 2, 0, 5, 5, 0, 0, 0, 1, 1,},
                                        { 3, 1, 0, 0, 0, 5, 5, 0, 2, 2, 0, 5, 5, 0, 0, 0, 1, 3,},
                                        { 1, 1, 0, 0, 0, 5, 5, 0, 2, 2, 0, 5, 5, 0, 0, 0, 1, 1,},
                                        { 0, 0, 0, 0, 0, 5, 5, 4, 1, 1, 4, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                        { 0, 0, 0, 0, 0, 5, 5, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0,},
                                         };*/
        int[,] intLevel = LoadLevelFromFile ("test");
            level = new Tiles[intLevel.GetLength(0), intLevel.GetLength(1)];
            for (int i = 0; i < intLevel.GetLength(0); i++)
            {
                for (int j = 0; j < intLevel.GetLength(1); j++)
                {
                    level[i, j] = (Tiles)intLevel[i, j];
                }
            }

        n = level.GetLength(0);
        m = level.GetLength(1);
        float width = m * 0.16f;
        float height = n * 0.16f;
        TankControl.maxX = (width * 2) - 0.24f;
        TankControl.maxY = (height * 2) - 0.24f;

        //Camera.main.GetComponent<CameraScript>().adjustCamera();

        BuildLevel(level);
    }
Beispiel #37
0
	private void GenerateTilesMaze ()
	{

		Labyrinth = new GameObject ("Labyrinth");
		Labyrinth.tag = "Labyrinth";
		Labyrinth.transform.position = new Vector3 (0,0,0);


		tilesArray = new Tiles[mazeArray.GetLength (0), mazeArray.GetLength (1)];
		float xLength = WallTile.GetComponent<Renderer> ().bounds.size.x;
		float yLength = WallTile.GetComponent<Renderer> ().bounds.size.z;
		for (int i = 0; i <= mazeArray.GetLength(0)-1; i++) {
			for (int j = 0; j <= mazeArray.GetLength(1)-1; j++) {
				
				if (mazeArray [i, j] == 1 || j  <= 0 || i + 1 >= mazeArray.GetLength (0) || j + 1 >= mazeArray.GetLength (1) || i  <= 0) {
					tilesArray [i, j] = Tiles.BlockTile;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (WallTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.parent = Labyrinth.transform;
				}
				//T Tiles (middle Part gives Direction)
				else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.TTileN;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (TTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 270, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 1) {
					tilesArray [i, j] = Tiles.TTileE;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (TTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 0, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.TTileS;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (TTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 90, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.TTileW;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (TTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 180, 0);
					wallTest.transform.parent = Labyrinth.transform;
				}
				//I Tiles
				else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 1) {
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (ITile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 0, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.ITileH;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (ITile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 90, 0);
					wallTest.transform.parent = Labyrinth.transform;
				}
				//L Tiles
				else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 1) {
					tilesArray [i, j] = Tiles.LTileN;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (LTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 90, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 1) {
					tilesArray [i, j] = Tiles.LTileE;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (LTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 180, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.LTileS;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (LTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 270, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 0) {
					//richtig
					tilesArray [i, j] = Tiles.LTileW;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (LTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 0, 0);
					wallTest.transform.parent = Labyrinth.transform;
				}
				//X Tile
				else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 0) {
					tilesArray [i, j] = Tiles.XTile;
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = Instantiate (XTile) as GameObject;
					wallTest.transform.position = position;
					wallTest.transform.parent = Labyrinth.transform;
				}
				//End Start Goal Tiles
				else if (mazeArray [i, j + 1] == 0 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 1) {
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = null;
					if(!startSet){
						wallTest = Instantiate (StartTile) as GameObject;
						startSet = true;
						tilesArray [i, j] = Tiles.StartingTile;
					} else if (!goalSet) {
						wallTest = Instantiate (EndTile) as GameObject;
						goalSet = true;
						tilesArray [i, j] = Tiles.GoalTile;
					} else {
						wallTest = Instantiate (DeadendTile) as GameObject;
						tilesArray [i, j] = Tiles.EndTileN;
					}
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 0, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 0 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 1) {
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = null;
					if(!startSet){
						wallTest = Instantiate (StartTile) as GameObject;
						startSet = true;
						tilesArray [i, j] = Tiles.StartingTile;
					} else if (!goalSet) {
						wallTest = Instantiate (EndTile) as GameObject;
						goalSet = true;
						tilesArray [i, j] = Tiles.GoalTile;
					} else {
						wallTest = Instantiate (DeadendTile) as GameObject;
						tilesArray [i, j] = Tiles.EndTileE;
					}
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 90, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 0 && mazeArray [i - 1, j] == 1) {
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = null;
					if(!startSet){
						wallTest = Instantiate (StartTile) as GameObject;
						startSet = true;
						tilesArray [i, j] = Tiles.StartingTile;
					} else if (!goalSet) {
						wallTest = Instantiate (EndTile) as GameObject;
						goalSet = true;
						tilesArray [i, j] = Tiles.GoalTile;
					} else {
						wallTest = Instantiate (DeadendTile) as GameObject;
						tilesArray [i, j] = Tiles.EndTileS;
					}
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 180, 0);
					wallTest.transform.parent = Labyrinth.transform;
				} else if (mazeArray [i, j + 1] == 1 && mazeArray [i + 1, j] == 1 && mazeArray [i, j - 1] == 1 && mazeArray [i - 1, j] == 0) {
					Vector3 position = new Vector3 (i*xLength, 0, j*yLength);
					GameObject wallTest = null;
					if(!startSet){
						wallTest = Instantiate (StartTile) as GameObject;
						startSet = true;
						tilesArray [i, j] = Tiles.StartingTile;
					} else if (!goalSet) {
						wallTest = Instantiate (EndTile) as GameObject;
						goalSet = true;
						tilesArray [i, j] = Tiles.GoalTile;
					} else {
						wallTest = Instantiate (DeadendTile) as GameObject;
						tilesArray [i, j] = Tiles.EndTileW;
					}
					wallTest.transform.position = position;
					wallTest.transform.Rotate (0 , 270, 0);
					wallTest.transform.parent = Labyrinth.transform;
				}
			}
		}


		
		// Destroy this Component after Maze is Build
		if (Application.isPlaying) {
			Destroy (this);
		} else {
			DestroyImmediate (this);		
		}
	}