예제 #1
0
파일: World.cs 프로젝트: danenespoli/delve
 public void AddPlayer()
 {
     player = new Player(this);
     player.SetPosition(new Point(10, 9 * 25));
     player.SetBackground(textures.assets["playerright"]);
     targetGrid.Children.Add(player);
     Canvas.SetZIndex(player, 99);
 }
예제 #2
0
파일: Store.cs 프로젝트: danenespoli/delve
        public static void PopulateList(Player p, ListBox l)
        {
            l.Items.Clear();

            foreach (var v in p.inventory.Items)
            {

                l.Items.Add(((Block)Engine.GetNewBlock_ofType(v.Key)).displayName + ":   " + v.Value.ToString());

            }
        }
예제 #3
0
파일: World.cs 프로젝트: danenespoli/delve
        public int CheckSide(Player player, int side)
        {
            //returns the never exceed X-point for each side of the player, or null

            int[] playerArrayLocationL = Engine.GetArrayLocation(player.Margin.Left, player.Margin.Top);
            int[] playerArrayLocationR = Engine.GetArrayLocation(player.Margin.Left + player.ActualWidth, player.Margin.Top);
            try
            {
                switch (side)
                {

                    case 0:

                        Boolean topLeft_penetrable = blockArray[playerArrayLocationL[0] - 1, playerArrayLocationL[1]].penetrable;
                        Boolean botLeft_penetrable = blockArray[playerArrayLocationL[0] - 1, playerArrayLocationL[1] + 1].penetrable;

                        if (topLeft_penetrable == false || botLeft_penetrable == false)
                        {

                            return Convert.ToInt32(Math.Abs(player.Margin.Left - (playerArrayLocationL[0] * 25)));

                        }

                        break;

                    case 1:

                        Boolean topRight_penetrable = blockArray[playerArrayLocationR[0] + 1, playerArrayLocationR[1]].penetrable;
                        Boolean botRight_penetrable = blockArray[playerArrayLocationR[0] + 1, playerArrayLocationR[1] + 1].penetrable;

                        if (topRight_penetrable == false || botRight_penetrable == false)
                        {
                            // means we can't move into the next block

                            int nextArrayLoc = playerArrayLocationR[0] + 1;
                            int rightBloc_xPx = (nextArrayLoc * 25) - 1;
                            int distance = (rightBloc_xPx - Convert.ToInt32(player.Margin.Left + player.Width)) % 25;

                            return distance;
                        }

                        break;
                }
            }
            catch
            {
                return -2;
            }
            return -1;
        }
예제 #4
0
파일: Store.cs 프로젝트: Jkoza/Delve
        public void Refuel(Player player)
        {
            //0.05 per unit of fuel
            double fuelCost = 0.05;
            double fuelToBuy = player.FuelTankCapacity - player.Fuel;

            if (player.money > fuelToBuy * fuelCost)
            {
                player.Fuel += fuelToBuy;
                player.money -= Convert.ToInt32(fuelToBuy * fuelCost);
            }
            else
            {
                player.Fuel += player.money / fuelCost;
                player.money = 0;
            }
        }
예제 #5
0
파일: Store.cs 프로젝트: danenespoli/delve
        public static void SellAllItems(Player p)
        {
            foreach (var v in p.inventory.Items)
            {

                var key = v.Key;

                var block = (Block)Engine.GetNewBlock_ofType(key);

                int blockValue = block.value;

                p.money += blockValue * v.Value;

            }

            p.inventory.Items.Clear();
            p.Cargo = 0;
        }
예제 #6
0
파일: Store.cs 프로젝트: danenespoli/delve
        public void Buy(items selectedItem, Player player)
        {
            switch (selectedItem)
            {

                case items.CargoBay: //Cargo Bay
                    if (player.money >= cargobayCost)
                    {
                        player.CargoBayCapacity += 10;

                        player.money -= Convert.ToInt32(cargobayCost);
                        cargobayCost = Math.Floor(cargobayCost * 1.5);
                    }
                    break;

                case items.FuelTank: //Fuel Tank
                    if (player.money >= fueltankCost)
                    {
                        player.FuelTankCapacity += Math.Floor(player.FuelTankCapacity * 0.5);

                        player.money -= Convert.ToInt32(fueltankCost);
                        fueltankCost = Math.Floor(fueltankCost * 1.3);
                    }
                    break;

                case items.Drill: //Drill
                    if (player.money >= drillCost &&
                        drillList.Count > 2)
                    {
                        drillList.Remove(drillList[0]);
                        player.playerDrill = drillList[0];

                        player.money -= Convert.ToInt32(drillCost);
                        drillCost = drillList[1].price;
                    }
                    break;

            }
        }
예제 #7
0
파일: World.cs 프로젝트: danenespoli/delve
        public int GetFloor(Player player)
        {
            //returns the World > BlockArray index of the nearest solid block below the player

            //get the location in the array of the left and right side of the block (since the player can be partially on multiple blocks at once)
            int[] arrayLocationL = Engine.GetArrayLocation(player.Margin.Left + 3, player.Margin.Top);
            int[] arrayLocationR = Engine.GetArrayLocation((player.Margin.Left + player.Width) - 3, player.Margin.Top);

            int floorL = 0;
            int floorR = 0;

            //finds the nearest solid block below the left side of the player
            try
            {
                for (int y = arrayLocationL[1]; y < blockArray.GetLength(1); y++)
                {

                    if (blockArray[arrayLocationL[0], y].penetrable == false)
                    {
                        floorL = y;
                        break;
                    }
                }

                //finds the nearest solid block below the right side of the player

                for (int y = arrayLocationL[1]; y < blockArray.GetLength(1); y++)
                {
                    if (blockArray[arrayLocationR[0], y].penetrable == false)
                    {
                        floorR = y;
                        break;
                    }
                }

                //returns the nearest block of the two

                if (floorL < floorR)
                {
                    return floorL;
                }
                else
                {
                    return floorR;
                }
            }
            catch
            {
                return -1;
            }
        }