Beispiel #1
0
 public int IndexOf(Bomb p)
 {
     return(playerList.IndexOf(p));
 }
Beispiel #2
0
        public Boolean Moving(System.Windows.Forms.KeyPressEventArgs e,
                              Soils soilList, Stones stoneList, Bombs bombList)
        {
            if ((e.KeyChar.ToString() == "p") || (e.KeyChar.ToString() == "ç"))
            {
                BombNowCreate = true;
                if ((myDirection == Direction.Left) &&
                    (Map.GetItem(this.TOP / 25, this.LEFT / 25 - 1) == ItemName.Null))//left
                {
                    Bomb currentBomb = new Bomb(left / 25 - 1, top / 25);
                    bombList.AddPlayer(currentBomb);

                    Map.SetItem(this.TOP / 25, this.LEFT / 25 - 1, ItemName.Bomb);
                    Map.SetInd(this.TOP / 25, this.LEFT / 25 - 1, bombList.IndexOf(currentBomb));
                }
                if ((myDirection == Direction.Right) &&
                    (Map.GetItem(this.TOP / 25, this.LEFT / 25 + 1) == ItemName.Null))//right
                {
                    Bomb currentBomb = new Bomb(left / 25 + 1, top / 25);
                    bombList.AddPlayer(currentBomb);

                    Map.SetItem(this.TOP / 25, this.LEFT / 25 + 1, ItemName.Bomb);
                    Map.SetInd(this.TOP / 25, this.LEFT / 25 + 1, bombList.IndexOf(currentBomb));
                }
                if ((myDirection == Direction.Up) &&
                    (Map.GetItem(this.TOP / 25 - 1, this.LEFT / 25) == ItemName.Null))//up
                {
                    Bomb currentBomb = new Bomb(left / 25, top / 25 - 1);
                    bombList.AddPlayer(currentBomb);

                    Map.SetItem(this.TOP / 25 - 1, this.LEFT / 25, ItemName.Bomb);
                    Map.SetInd(this.TOP / 25 - 1, this.LEFT / 25, bombList.IndexOf(currentBomb));
                }
                if ((myDirection == Direction.Down) &&
                    (Map.GetItem(this.TOP / 25 + 1, this.LEFT / 25) == ItemName.Null))  //down
                {
                    Bomb currentBomb = new Bomb(left / 25, top / 25 + 1);
                    bombList.AddPlayer(currentBomb);

                    Map.SetItem(this.TOP / 25 + 1, this.LEFT / 25, ItemName.Bomb);
                    Map.SetInd(this.TOP / 25 + 1, this.LEFT / 25, bombList.IndexOf(currentBomb));
                }
                return(false);
            }
            else if ((e.KeyChar.ToString() == "a") || (e.KeyChar.ToString() == "ô"))
            {
                RemoveLeftSoil(soilList);
                if ((Map.GetItem(this.TOP / 25, this.LEFT / 25 - 1) == ItemName.Stone) &&
                    (Map.GetItem(this.TOP / 25, this.LEFT / 25 - 2) == ItemName.Null))             //left stone
                {
                    foreach (Stone st in stoneList)
                    {
                        if ((st.LEFT == this.LEFT - 25) && (st.TOP == this.TOP))
                        {
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Null);
                            st.LEFT -= 25;
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Stone);
                        }
                    }
                }
                else if ((Map.GetItem(this.TOP / 25, this.LEFT / 25 - 1) == ItemName.Bomb) &&
                         (Map.GetItem(this.TOP / 25, this.LEFT / 25 - 2) == ItemName.Null))        //left bomb
                {
                    foreach (Bomb st in bombList)
                    {
                        if ((st.LEFT == this.LEFT - 25) && (st.TOP == this.TOP))
                        {
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Null);
                            st.LEFT -= 25;
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Bomb);
                        }
                    }
                }
                if (Map.GetItem(this.TOP / 25, this.LEFT / 25 - 1) == ItemName.Null)         //left
                {
                    left       -= size;
                    player      = new Bitmap("PlayerLeft.bmp");
                    myDirection = Direction.Left;
                    return(true);
                }
            }
            else if ((e.KeyChar.ToString() == "d") || (e.KeyChar.ToString() == "â"))
            {
                RemoveRightSoil(soilList);
                if ((Map.GetItem(this.TOP / 25, this.LEFT / 25 + 1) == ItemName.Stone) &&
                    (Map.GetItem(this.TOP / 25, this.LEFT / 25 + 2) == ItemName.Null))             //left stone
                {
                    foreach (Stone st in stoneList)
                    {
                        if ((st.LEFT == this.LEFT + 25) && (st.TOP == this.TOP))
                        {
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Null);
                            st.LEFT += 25;
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Stone);
                        }
                    }
                }
                else if ((Map.GetItem(this.TOP / 25, this.LEFT / 25 + 1) == ItemName.Bomb) &&
                         (Map.GetItem(this.TOP / 25, this.LEFT / 25 + 2) == ItemName.Null))        //left bomb
                {
                    foreach (Bomb st in bombList)
                    {
                        if ((st.LEFT == this.LEFT + 25) && (st.TOP == this.TOP))
                        {
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Null);
                            st.LEFT += 25;
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Bomb);
                        }
                    }
                }
                if (Map.GetItem(this.TOP / 25, this.LEFT / 25 + 1) == ItemName.Null)         //right
                {
                    left       += size;
                    player      = new Bitmap("PlayerRight.bmp");
                    myDirection = Direction.Right;
                    return(true);
                }
            }
            else if ((e.KeyChar.ToString() == "w") || (e.KeyChar.ToString() == "ö"))
            {
                RemoveUpSoil(soilList);
                if (Map.GetItem(this.TOP / 25 - 1, this.LEFT / 25) == ItemName.Null)         //up
                {
                    top        -= size;
                    player      = new Bitmap("PlayerUp.bmp");
                    myDirection = Direction.Up;
                    return(true);
                }
            }
            else if ((e.KeyChar.ToString() == "s") || (e.KeyChar.ToString() == "û"))
            {
                RemoveDownSoil(soilList);
                if (Map.GetItem(this.TOP / 25 + 1, this.LEFT / 25) == ItemName.Null)            //down
                {
                    top        += size;
                    player      = new Bitmap("PlayerDown.bmp");
                    myDirection = Direction.Down;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
 public void AddPlayer(Bomb p)
 {
     playerList.Add(p);
 }