Inheritance: ScriptableWizard
 public Armor(Armor armor)
 {
     Name           = armor.Name;
     Description    = armor.Description;
     ArmorBonus     = armor.ArmorBonus;
     HeldInHand     = armor.HeldInHand;
     Weight         = armor.Weight;
     Value          = armor.Value;
     UnsellableItem = armor.UnsellableItem;
     _index         = armor._index;
     Image          = CreateTile.GetImageFromTileset(_index);
     _type          = armor.Type;
 }
 public Weapon(Weapon weapon)
 {
     Name           = weapon.Name;
     Description    = weapon.Description;
     HitBonus       = weapon.HitBonus;
     DamageRange    = weapon.DamageRange;
     TwoHanded      = weapon.TwoHanded;
     Weight         = weapon.Weight;
     Value          = weapon.Value;
     UnsellableItem = weapon.UnsellableItem;
     _index         = weapon._index;
     Image          = CreateTile.GetImageFromTileset(_index);
 }
Exemple #3
0
    void Start()
    {
        List <List <bool> > cells = new List <List <bool> >();

        for (int q = 0; q < width; q++)                   //for the width of the map we have given
        {
            List <bool> innerCell = new List <bool> ();   //create a new bool List for that column
            for (int w = 0; w < height; w++)              //for the height of the map we have given
            {
                innerCell.Add(false);                     //add the row and make it filled
            }
            cells.Add(innerCell);                         // add the column to the map list
        }
        for (int q = minGap + 1; q < width - minGap; q++) //For the width, minus the barrier at begining and end
        {
            for (int w = 3; w < height - 3; w++)          //for the height, minus the barrier at the top and bottom
            {
                if (Random.Range(0, spawnChance) == 1)    //if a 1 in 5 chance
                {
                    int numSolid = 0;
                    for (int e = -minGap; e <= 0; e++)                   //for minGap columns behind to this row
                    {
                        for (int r = -3; r <= 3; r++)                    //for 3 rows above to 3 rows below
                        {
                            if (cells[q + e][w + r] == true)             //if that cell is solid
                            {
                                numSolid++;                              //record it
                            }
                        }
                    }
                    if (numSolid == 0)                                               //if there are no solid blocks nearby
                    {
                        int platformLength = Random.Range(minPlatform, maxPlatform); //choose a random platform length between the min and max values
                        if (q + platformLength < width)                              //if the platform is not going to go off the edge
                        {
                            for (int e = 0; e <= platformLength; e++)                //for the length of the platform
                            {
                                cells[q + e][w] = true;                              //make it solid
                            }
                        }
                    }
                }
            }
        }
        CreateTile tiles = GetComponent <CreateTile>();

        tiles.map = cells;
        BroadcastMessage("InstantiateTiles", SendMessageOptions.DontRequireReceiver);
    }
Exemple #4
0
        private void DrawGameScreen()
        {
            int xpos = GameStatus.Player.X - 5;
            int ypos = GameStatus.Player.Y - 6;
            int z    = 0;

            for (int y = Definitions.WINDOW_Y_SIZE - 1; y >= 0; y--)
            {
                for (int x = 0; x < Definitions.WINDOW_X_SIZE; x++)
                {
                    (XAMLMap.Children[z] as Image).ToolTip = new TextBlock()
                    {
                        Text = string.Empty
                    };
                    bool tileExists = false;
                    if ((xpos + x) >= 0 && (ypos + y) >= 0 && (xpos + x) < GameStatus.CurrentMap.XSize && (ypos + y) < GameStatus.CurrentMap.YSize) //Make sure indices are in range of array
                    {
                        Tile tile = GameStatus.CurrentMap.Tiles[xpos + x, ypos + y];
                        if (tile != null)
                        {
                            ImageSource overlayedImage = tile.Image;
                            if (tile.Objects != null && tile.Objects.Count > 0)
                            {
                                for (int i = 0; i < tile.Objects.Count; i++)
                                {
                                    overlayedImage = CreateTile.Overlay(overlayedImage, tile.Objects[i].GetImage());
                                    ((XAMLMap.Children[z] as Image).ToolTip as TextBlock).Text += GetObjectTooltip(tile.Objects[i], i > 0);
                                }
                            }
                            else
                            {
                                (XAMLMap.Children[z] as Image).ToolTip = null;
                            }
                            (XAMLMap.Children[z++] as Image).Source = overlayedImage;
                            tileExists = true;
                        }
                    }
                    if (!tileExists)
                    {
                        (XAMLMap.Children[z] as Image).ToolTip  = null;
                        (XAMLMap.Children[z++] as Image).Source = CreateBlackImage();
                    }
                }
            }
        }
        public Item(Item newItem)
        {
            switch (newItem.GetType().Name)
            {
            case "Weapon":
                new Weapon(newItem as Weapon);
                break;

            case "Armor":
                new Armor(newItem as Armor);
                break;

            case "Item":
                _isGameEnderItem = newItem.IsGameEnderItem;
                Description      = newItem.Description;
                Name             = newItem.Name;
                _index           = newItem._index;
                Image            = CreateTile.GetImageFromTileset(newItem._index);
                break;

            default: break;
            }
        }
Exemple #6
0
 void Awake()
 {
     instance  = this;
     tileWidth = tile[0].transform.localScale.z;
     List_Tile = new GameObject[tileCount];
 }
Exemple #7
0
    public bool cleanUp;     //if all small clumps will be removed
    void Start()
    {
        float minCells            = (width * height) / minSize; //minimum cave size
        int   numVoid             = 0;
        List <List <bool> > cells = new List <List <bool> > (); //initalise the 2d bool List

        while (numVoid < minCells)
        {
            cells.Clear();
            for (int q = 0; q < width; q++)                                                                                                                        //for the width of the map we have given
            {
                List <bool> innerCell = new List <bool> ();                                                                                                        //create a new bool List for that column
                for (int w = 0; w < height; w++)                                                                                                                   //for the height of the map we have given
                {
                    innerCell.Add(true);                                                                                                                           //add the row and make it filled
                }
                cells.Add(innerCell);                                                                                                                              // add the column to the map list
            }
            List <List <int> > miners = new List <List <int> > ();                                                                                                 //initalise the overaching miners List
            List <int>         miner  = new List <int>();                                                                                                          //initalise the single miner list
            miner.Add(Random.Range(xBorder + 1, width - xBorder));                                                                                                 //add the x cord for the miner
            miner.Add(Random.Range(yBorder + 1, width - xBorder));                                                                                                 //add the y cord for the miner
            miner.Add(5);                                                                                                                                          //add the action for the miner
            miners.Add(miner);                                                                                                                                     //add the miner List to the overaching miners List
            while (miners.Count > 0)                                                                                                                               //while the miners List is not empty
            {
                for (int q = miners.Count - 1; q >= 0; q--)                                                                                                        //for all the miners
                {
                    int numEmpty = 0;                                                                                                                              //reset the number of empty squares around the miner
                    for (int x = -1; x <= 1; x++)                                                                                                                  //start one column behind and go until one column infront
                    {
                        for (int y = -1; y <= 1; y++)                                                                                                              //start one row above and go until one row below
                        {
                            if ((miners[q][0] + x < width - xBorder && miners[q][1] < height - yBorder) && (miners[q][0] + x > xBorder && miners[q][1] > yBorder)) //if that row is inside the borders
                            {
                                if (!cells[miners[q][0] + x][miners[q][1] + y])                                                                                    //and if it is empty
                                {
                                    numEmpty++;                                                                                                                    //increment the number of empty cells by one
                                }
                            }
                            else
                            {
                                numEmpty++;                                 //increment the number of empty cells by one
                            }
                        }
                    }
                    if (numEmpty >= deathRequire)                   //if the number of empty squares is equal to or more than the number needed to kill the miner
                    {
                        miners.RemoveAt(q);                         //kill it
                    }
                    else
                    {
                        if (miners[q][2] == 1 && miners[q][0] < width - xBorder)       // if the action is move right and we are not at the right border
                        {
                            miners[q][0]++;                                            // move right
                        }
                        else if (miners[q][2] == 2 && miners[q][1] < height - yBorder) //if the action is move down and we are not at the bottom border
                        {
                            miners[q][1]++;                                            // move down
                        }
                        else if (miners[q][2] == 3 && miners[q][1] > xBorder)          //if the action is move left and we are not at the left border
                        {
                            miners[q][0]--;                                            // move left
                        }
                        else if (miners[q][2] == 4 && miners[q][1] > yBorder)          //if the action is move up and we are not at the top border
                        {
                            miners[q][1]--;                                            //move up
                        }
                        else if (miners[q][2] == 5)
                        {
                            miners.Add(new List <int>());
                            miners[miners.Count - 1].Add(miners[q][0]);
                            miners[miners.Count - 1].Add(miners[q][1]);
                            miners[miners.Count - 1].Add(Random.Range(1, 5));     //pick a direction to move in
                        }
                        miners[q][2] = Random.Range(1, 6);                        //pick a new action
                        cells[miners[q][0]][miners[q][1]] = false;                //remove the cell the miner is on
                    }
                }
            }
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (!cells[x][y])
                    {
                        numVoid++;
                    }
                }
            }
        }
        for (int x = 1; x < width - 1; x++)      //for the width of the map
        {
            for (int y = 1; y < height - 1; y++) //for the height of the map
            {
                numVoid = 0;                     //reset the number of empty cells
                if (cells[x][y])                 //if the cell is not void
                {
                    for (int q = -1; q <= 1; q++)
                    {
                        for (int w = -1; w <= 1; w++)
                        {
                            if (!cells[x + q][y + w])                           //if the cell is not void
                            {
                                numVoid++;
                            }
                        }
                    }
                    if (hollowed && numVoid == 0)
                    {
                        cells[x][y] = false;
                    }
                    if (cleanUp && numVoid >= minCleanup)
                    {
                        cells[x][y] = false;
                    }
                }
            }
        }
        CreateTile tiles = GetComponent <CreateTile>();

        tiles.map = cells;
        BroadcastMessage("InstantiateTiles", SendMessageOptions.DontRequireReceiver);
    }
Exemple #8
0
    //private float[] starPosY={0.3f,1f,1.7f};
    //private int starIndex;
    //private float starPosX=0.7f;

    void Awake()
    {
        instance = this;
    }