Inheritance: WeaponFire
コード例 #1
0
    void Start()
    {
        minescript = GameObject.Find ("ClickBoxVein").GetComponent<Mine> ();
        uiscript = GameObject.Find ("UIManager").GetComponent<UIManagerScript> ();

        StartCoroutine (DeathTimer ());
    }
コード例 #2
0
        public void TestDetonate1WithAllMinesInsideFieldDoesNotDetonateUnnecessaryCells()
        {
            int n = 5;
            IGameboard board = this.GenerateGameboard(n);
            board[1, 1] = new Mine(MineRadius.MineRadiusOne);
            board.Detonate(new Position(1, 1));
            bool patternOneDetonatesMoreThanFiveCells = false;
            int i = 0;
            int j = 0;
            for (; i < n; i++)
            {
                for (; j < n; j++)
                {
                    if (
                        ((i != 1 && j != 1) &&
                            (i != 0 && j != 0) &&
                            (i != 0 && j != 2) &&
                            (i != 2 && j != 2) &&
                            (i != 2 && j != 0))
                            && board[i, j].Exploded)
                    {
                        patternOneDetonatesMoreThanFiveCells = true;
                        break;
                    }
                }

                if (patternOneDetonatesMoreThanFiveCells)
                {
                    break;
                }
            }

            Assert.IsFalse(patternOneDetonatesMoreThanFiveCells, String.Format("Mine at {0}, {1} was detonated.", i, j));
        }
コード例 #3
0
        public void TestDetonate1With2MinesInsideFieldDoesNotDetonateUnnecessaryCells()
        {
            int n = 5;
            IGameboard board = this.GenerateGameboard(n);
            board[0, 0] = new Mine(MineRadius.MineRadiusOne);
            board.Detonate(new Position(0, 0));
            int i = 0;
            int j = 0;
            bool moreThanOneCellIsDetonated = false;
            for (; i < n; i++)
            {
                for (; j < n; j++)
                {
                    if (i != 0 && j != 0 && i != 1 && j != 1 && !board[i, j].Exploded)
                    {
                        moreThanOneCellIsDetonated = true;
                        break;
                    }
                }

                if (moreThanOneCellIsDetonated)
                {
                    break;
                }
            }

            Assert.IsFalse(moreThanOneCellIsDetonated, String.Format("Cell at {0}, {1} was detonated", i, j));
        }
コード例 #4
0
        /// <summary>Takes the remaining content of the stream and deserialze it into the instance.</summary>
        public static Mine.Nullables.MyMessageV1 Deserialize(Stream stream, Mine.Nullables.MyMessageV1 instance)
        {
            while (true)
            {
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    break;
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 Varint
                    case 8:
                        instance.FieldA = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        if (instance.PreservedFields == null)
                            instance.PreservedFields = new List<global::SilentOrbit.ProtocolBuffers.KeyValue>();
                        instance.PreservedFields.Add(new global::SilentOrbit.ProtocolBuffers.KeyValue(key, global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadValueBytes(stream, key)));
                        break;
                }
            }

            return instance;
        }
コード例 #5
0
        public void TestDetonate1With2MinesInsideFieldDetonates2Cells()
        {
            IGameboard board = this.GenerateGameboard(5);
            board[0, 0] = new Mine(MineRadius.MineRadiusOne);
            board.Detonate(new Position(0, 0));
            bool twoCellsAreDetonated = board[0, 0].Exploded && board[1, 1].Exploded;

            Assert.IsTrue(twoCellsAreDetonated);
        }
コード例 #6
0
        protected override Location CreateLocation(string locationTypeString, string locationName)
        {
            Location location = null;

            switch (locationTypeString)
            {
                case "forest": location = new Forest(locationName); break;
                case "mine": location = new Mine(locationName); break;
                default: return base.CreateLocation(locationTypeString, locationName);
            }

            return location; 
        }
コード例 #7
0
ファイル: Explosion.cs プロジェクト: TeamXenon/BattleField
 private static void ExplosionFive(char[,] field, Mine mine)
 {
     for (int row = mine.X - 2; row <= mine.X + 2; row++)
     {
         for (int col = mine.Y - 2; col <= mine.Y + 2; col++)
         {
             if (IsInsideField(field, row, col))
             {
                 field[row, col] = DetonatedCell;
             }
         }
     }
 }
コード例 #8
0
        public void TestDetonate1WithAllMinesInsideFieldDetonates5Cells()
        {
            IGameboard board = this.GenerateGameboard(5);
            board[1, 1] = new Mine(MineRadius.MineRadiusOne);
            board.Detonate(new Position(1, 1));
            bool patternOneDetonatesFiveCells =
                    board[1, 1].Exploded &&
                    board[0, 0].Exploded &&
                    board[0, 2].Exploded &&
                    board[2, 2].Exploded &&
                    board[2, 0].Exploded;

            Assert.IsTrue(patternOneDetonatesFiveCells);
        }
コード例 #9
0
ファイル: MineManager.cs プロジェクト: CyberCRI/Hero.Coli
	//public void resetSelectedMine(float id, GameObject target)
  public static void resetSelectedMine(Mine mine)
	{
    GameObject target = mine.gameObject;
		float x = target.transform.position.x; 
		float z = target.transform.position.z;
	
		iTween.Stop(target, true);
		Destroy(target);

		GameObject go = (GameObject)Instantiate(_instance.mine, new Vector3(x,0,z),Quaternion.identity);
    Mine newMine = (Mine)go.GetComponent<Mine>();
    newMine.mineName = mine.mineName;

		detonatedMines--;

    if (isReseting && detonatedMines == 0)
    {
      isReseting = false;
    }
  }
コード例 #10
0
        internal static void MakeSureMineHasAccessToVillage(Labyrinth labyrinth, Mine mine, Village village)
        {
            int xFrom, yFrom, xTo, yTo;

            if (mine.LabyrinthCorX >= village.LabyrinthCorX)
            {
                xFrom = village.LabyrinthCorX;
                xTo = mine.LabyrinthCorX;
            }
            else
            {
                xFrom = mine.LabyrinthCorX;
                xTo = village.LabyrinthCorX;
            }

            if (mine.LabyrinthCorY >= village.LabyrinthCorY)
            {
                yFrom = village.LabyrinthCorY;
                yTo = mine.LabyrinthCorY;
            }
            else
            {
                yFrom = mine.LabyrinthCorY;
                yTo = village.LabyrinthCorY;
            }

            for (int i = xFrom; i <= xTo; i++)
            {
                labyrinth.Remove(i, yFrom);
                labyrinth.Remove(i, yTo);
            }

            for (int k = yFrom; k <= yTo; k++)
            {
                labyrinth.Remove(xTo, k);
                labyrinth.Remove(xFrom, k);
            }
        }
コード例 #11
0
ファイル: Explosion.cs プロジェクト: TeamXenon/BattleField
        public static void Explode(char[,] field, Mine mine)
        {
            char mineType = field[mine.X, mine.Y];

            switch (mineType)
            {
                case '1':
                    ExplosionOne(field, mine);
                    break;
                case '2':
                    ExplosionTwo(field, mine);
                    break;
                case '3':
                    ExplosionThree(field, mine);
                    break;
                case '4':
                    ExplosionFour(field, mine);
                    break;
                case '5':
                    ExplosionFive(field, mine);
                    break;
            }
        }
コード例 #12
0
ファイル: Explosion.cs プロジェクト: TeamXenon/BattleField
        private static void ExplosionFour(char[,] field, Mine mine)
        {
            for (int row = mine.X - 2; row <= mine.X + 2; row++)
            {
                for (int col = mine.Y - 2; col <= mine.Y + 2; col++)
                {
                    bool isInUpperLeftCorner = row == mine.X - 2 && col == mine.Y - 2;
                    bool isInBottomLeftCorner = row == mine.X - 2 && col == mine.Y + 2;
                    bool isInUpperRightCorner = row == mine.X + 2 && col == mine.Y - 2;
                    bool isInBottomRightCorner = row == mine.X + 2 && col == mine.Y + 2;

                    if (isInUpperLeftCorner || isInBottomLeftCorner || isInUpperRightCorner || isInBottomRightCorner)
                    {
                        continue;
                    }

                    if (IsInsideField(field, row, col))
                    {
                        field[row, col] = DetonatedCell;
                    }
                }
            }
        }
コード例 #13
0
ファイル: MineTests.cs プロジェクト: TeamXenon/BattleField
 public void MineConstrustor_MustThrowExceptionYIsNegative()
 {
     Mine invalidMine = new Mine(5, -7);
 }
コード例 #14
0
ファイル: MineTests.cs プロジェクト: TeamXenon/BattleField
 public void MineConstrustor_MustThrowExceptionYIsBiggerThan10()
 {
     Mine invalidMine = new Mine(5, 12);
 }
コード例 #15
0
ファイル: MineTests.cs プロジェクト: TeamXenon/BattleField
 public void MineConstrustor_MustThrowExceptionXIsNegative()
 {
     Mine invalidMine = new Mine(-2, 2);
 }
コード例 #16
0
ファイル: MineTests.cs プロジェクト: TeamXenon/BattleField
 public void MineConstrustor_CreateNewMine()
 {
     Mine mine = new Mine(2, 6);
     Assert.AreEqual(2, mine.X);
     Assert.AreEqual(6, mine.Y);
 }
コード例 #17
0
        public void TestDetonate4WithAllMinesInsideFieldDoesNotDetonateUnnecessaryCells()
        {
            int n = 9;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(4, 4);
            board[4, 4] = new Mine(MineRadius.MineRadiusFour);
            board.Detonate(position);
            bool moreThan21CellsAreDetonated = false;
            int i = 0;
            int j = 0;
            for (; i < n; i++)
            {
                for (; j < n; j++)
                {
                    if (!((2 <= i) && (i <= 6) && (2 <= j) && (j <= 6)) ||
                            (i == 2 && j == 2) ||
                            (i == 2 && j == 6) ||
                            (i == 6 && j == 6) ||
                            (i == 6 && j == 2))
                    {
                        if (board[i, j].Exploded)
                        {
                            moreThan21CellsAreDetonated = false;
                            break;
                        }
                    }
                }

                if (!moreThan21CellsAreDetonated)
                {
                    break;
                }
            }

            Assert.IsFalse(moreThan21CellsAreDetonated);
        }
コード例 #18
0
 /// <summary>Helper: put the buffer into a MemoryStream before deserializing</summary>
 public static Mine.Nullables.MyMessageV1 Deserialize(byte[] buffer, Mine.Nullables.MyMessageV1 instance)
 {
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
コード例 #19
0
 public void RemoveMine(Mine mine)
 {
     _mines.Remove(mine);
 }
コード例 #20
0
ファイル: GameEngine.cs プロジェクト: bvanderdrift/EpicGrip
        public static void DropMine(Car sender)
        {
            Mine tempMine = new Mine();
            if (sender.LastFire >= tempMine.ReloadTime)
            {
                tempMine.Initialize();
                tempMine.LoadContent();

                mines.Add(tempMine);
                mines[mines.Count - 1].Drop(sender.Position, sender.Driver);

                //Set the last fire to 0
                sender.LastFire = 0;
            }
        }
コード例 #21
0
        public void TestDetonate3WithAllMinesInsideFieldDoesNotDetonateUnnecessaryCells()
        {
            int n = 9;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(4, 4);
            board[4, 4] = new Mine(MineRadius.MineRadiusThree);
            board.Detonate(position);
            bool moreThanThirteenCellsDetonated = false;
            int i = 0;
            int j = 0;
            for (; i < n; i++)
            {
                for (; j < n; j++)
                {
                    if (!((3 <= i) && (i <= 5) && (3 <= j) && (j <= 5)) &&
                        (i != 2 && j != 4) &&
                        (i != 4 && j != 6) &&
                        (i != 6 && j != 4) &&
                        (i != 2 && j != 2))
                    {
                        if (board[i, j].Exploded)
                        {
                            moreThanThirteenCellsDetonated = true;
                            break;
                        }
                    }
                }

                if (moreThanThirteenCellsDetonated)
                {
                    break;
                }
            }

            Assert.IsFalse(moreThanThirteenCellsDetonated, String.Format("A cell was detonated at {0}, {1}", i, j));
        }
コード例 #22
0
        public void TestDetonate4With8MinesInsideFieldDetonates8Cells()
        {
            int n = 7;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(0, 6);
            board[0, 6] = new Mine(MineRadius.MineRadiusFour);
            board.Detonate(position);
            bool cellsAreDetonated =
                    board[0, 4].Exploded == board[0, 5].Exploded &&
                    board[0, 5].Exploded == board[0, 6].Exploded &&
                    board[0, 6].Exploded == board[1, 4].Exploded &&
                    board[1, 4].Exploded == board[1, 5].Exploded &&
                    board[1, 5].Exploded == board[1, 6].Exploded &&
                    board[1, 6].Exploded == board[2, 5].Exploded &&
                    board[2, 5].Exploded == board[2, 6].Exploded &&
                    board[2, 6].Exploded == true;

            Assert.IsTrue(cellsAreDetonated);
        }
コード例 #23
0
        public void TestDetonate5WithAllMinesInsideFieldDoesNotDetonateUnnecessaryCells()
        {
            int n = 9;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(4, 4);
            board[4, 4] = new Mine(MineRadius.MineRadiusFive);
            board.Detonate(position);
            bool cellsAreDetonated = false;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (!((2 <= i) && (i <= 6) && (2 <= j) && (j <= 6)))
                    {
                        if (board[i, j].Exploded)
                        {
                            cellsAreDetonated = true;
                            break;
                        }
                    }
                }

                if (cellsAreDetonated)
                {
                    break;
                }
            }

            Assert.IsFalse(cellsAreDetonated);
        }
コード例 #24
0
        public void TestDetonate5WithAllMinesInsideFieldDetonates25Cells()
        {
            int n = 9;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(4, 4);
            board[4, 4] = new Mine(MineRadius.MineRadiusFive);
            board.Detonate(position);
            bool cellsAreDetonated = true;
            for (int i = 2; i <= 6; i++)
            {
                for (int j = 2; j <= 6; j++)
                {
                    if (!board[i, j].Exploded)
                    {
                        cellsAreDetonated = false;
                        break;
                    }
                }

                if (!cellsAreDetonated)
                {
                    break;
                }
            }

            Assert.IsTrue(cellsAreDetonated);
        }
コード例 #25
0
ファイル: Score.cs プロジェクト: sunears/turnt-octo-tribble
    private int previousScore = 0; // The score in the previous frame.

    #endregion Fields

    #region Methods

    void Awake()
    {
        // Setting up the reference.
        playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
        mine = GameObject.Find ("mine").GetComponent<Mine> ();
    }
コード例 #26
0
        public void TestDetonate3With6MinesInsideFieldDetonates6Cells()
        {
            int n = 7;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(6, 6);
            board[6, 6] = new Mine(MineRadius.MineRadiusThree);
            board.Detonate(position);
            bool cellsAreDetonated =
                    board[4, 6].Exploded == board[5, 5].Exploded &&
                    board[5, 5].Exploded == board[5, 6].Exploded &&
                    board[5, 6].Exploded == board[6, 4].Exploded &&
                    board[6, 4].Exploded == board[6, 5].Exploded &&
                    board[6, 5].Exploded == board[6, 6].Exploded &&
                    board[6, 6].Exploded == true;

            Assert.IsTrue(cellsAreDetonated);
        }
コード例 #27
0
        /// <summary>Read the VarInt length prefix and the given number of bytes from the stream and deserialze it into the instance.</summary>
        public static Mine.MyMessageV1 DeserializeLengthDelimited(Stream stream, Mine.MyMessageV1 instance)
        {
            long limit = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt32(stream);
            limit += stream.Position;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new InvalidOperationException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 1 Varint
                    case 8:
                        instance.FieldA = (int)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new InvalidDataException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        if (instance.PreservedFields == null)
                            instance.PreservedFields = new List<global::SilentOrbit.ProtocolBuffers.KeyValue>();
                        instance.PreservedFields.Add(new global::SilentOrbit.ProtocolBuffers.KeyValue(key, global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadValueBytes(stream, key)));
                        break;
                }
            }

            return instance;
        }
コード例 #28
0
ファイル: CardFactory.cs プロジェクト: esfdk/BDSADominion
        /// <summary>
        /// Creates a new card based on how many cards have already been made.
        /// </summary>
        /// <param name="card">
        /// The name of the card to be created.
        /// </param>
        /// <returns>
        /// The new created card.
        /// </returns>
        public static Card CreateCard(CardName card)
        {
            Contract.Requires(card != CardName.Backside & card != CardName.Empty);

            Contract.Ensures(Contract.Result<Card>().Name == card);

            Card c;
            switch (card)
            {
                case CardName.Copper:
                    c = new Copper();
                    break;
                case CardName.Silver:
                    c = new Silver();
                    break;
                case CardName.Gold:
                    c = new Gold();
                    break;
                case CardName.Curse:
                    c = new Curse();
                    break;
                case CardName.Estate:
                    c = new Estate();
                    break;
                case CardName.Duchy:
                    c = new Duchy();
                    break;
                case CardName.Province:
                    c = new Province();
                    break;
                case CardName.Gardens:
                    c = new Gardens();
                    break;
                case CardName.Cellar:
                    c = new Cellar();
                    break;
                case CardName.Chapel:
                    c = new Chapel();
                    break;
                case CardName.Chancellor:
                    c = new Chancellor();
                    break;
                case CardName.Village:
                    c = new Village();
                    break;
                case CardName.Woodcutter:
                    c = new Woodcutter();
                    break;
                case CardName.Workshop:
                    c = new Workshop();
                    break;
                case CardName.Feast:
                    c = new Feast();
                    break;
                case CardName.Moneylender:
                    c = new Moneylender();
                    break;
                case CardName.Remodel:
                    c = new Remodel();
                    break;
                case CardName.Smithy:
                    c = new Smithy();
                    break;
                case CardName.ThroneRoom:
                    c = new ThroneRoom();
                    break;
                case CardName.CouncilRoom:
                    c = new CouncilRoom();
                    break;
                case CardName.Festival:
                    c = new Festival();
                    break;
                case CardName.Laboratory:
                    c = new Laboratory();
                    break;
                case CardName.Library:
                    c = new Library();
                    break;
                case CardName.Market:
                    c = new Market();
                    break;
                case CardName.Mine:
                    c = new Mine();
                    break;
                case CardName.Adventurer:
                    c = new Adventurer();
                    break;
                case CardName.Bureaucrat:
                    c = new Bureaucrat();
                    break;
                case CardName.Militia:
                    c = new Militia();
                    break;
                case CardName.Spy:
                    c = new Spy();
                    break;
                case CardName.Thief:
                    c = new Thief();
                    break;
                case CardName.Witch:
                    c = new Witch();
                    break;
                case CardName.Moat:
                    c = new Moat();
                    break;
                default:
                    throw new NotImplementedException("Tried to create a card that was not implemented when CardFactory was last updated.");
            }

            c.Initialize(card, CardsMade[card]);
            CardsMade[card] += 1;
            createdCards.Add(c, true);
            return c;
        }
コード例 #29
0
ファイル: Enemy.cs プロジェクト: jinopapo/dominion
 internal override void ShowCard(string s,int x,int y)
 {
     PlayCard a = new PlayCard();
     switch (s)
     {
         case "銅貨":
             a = new Cooper(ShowField, ShowHand, this);
             break;
         case "銀貨":
             a = new Silver(ShowField, ShowHand, this);
             break;
         case "金貨":
             a = new Gold(ShowField, ShowHand, this);
             break;
         case "屋敷":
             a = new Mansion(ShowField, ShowHand, this);
             break;
         case "公領":
             a = new Landtag(ShowField, ShowHand, this);
             break;
         case "属州":
             a = new Province(ShowField, ShowHand, this);
             break;
         case "地下貯蔵庫":
             a = new UndergroundRepository(ShowField, ShowHand, this);
             break;
         case "市場":
             a = new Market(this);
             break;
         case "民兵":
             a = new Militia(ShowField, ShowHand, this);
             break;
         case "鉱山":
             a = new Mine(ShowField, ShowHand, this);
             break;
         case "堀":
             a = new Moat(this);
             break;
         case "鍛冶屋":
             a = new Smithy(this);
             break;
         case "村":
             a = new Village(this);
             break;
         case "木こり":
             a = new Woodcutter(this);
             break;
         case "改築":
             a = new Remodel(this);
             break;
         case "工房":
             a = new Workshop(this);
             break;
     }
     a.Location = new System.Drawing.Point(x,y);
     a.Size = new System.Drawing.Size(70, 110);
     a.Name = s;
     a.SizeMode = PictureBoxSizeMode.StretchImage;
     a.Image = global::dominion.Properties.Resources.back;
     form1.Controls.Add(a);
     a.BringToFront();
     ShowHand.Add(a);
     a.ChangePointPara(880 + 20 * ShowHand.Count, 10 + 120 * num);
     for (int i = 0; i < ShowHand.Count; i++)
     {
         ShowHand[i].Refresh();
     }
     ShowDeck.Refresh();
 }
コード例 #30
0
        public void TestDetonate4WithAllMinesInsideFieldDetonates21Cells()
        {
            int n = 7;
            IGameboard board = this.GenerateGameboard(n);
            Position position = new Position(3, 3);
            board[3, 3] = new Mine(MineRadius.MineRadiusFour);
            board.Detonate(position);
            bool cellsAreDetonated = true;
            for (int i = 2; i <= 4; i++)
            {
                for (int j = 1; j <= 5; j++)
                {
                    if (!board[i, j].Exploded)
                    {
                        cellsAreDetonated = false;
                        break;
                    }
                }

                if (!cellsAreDetonated)
                {
                    break;
                }
            }

            cellsAreDetonated = cellsAreDetonated &&
                    board[1, 2].Exploded == board[1, 3].Exploded &&
                    board[1, 3].Exploded == board[1, 4].Exploded &&
                    board[1, 4].Exploded == board[5, 2].Exploded &&
                    board[5, 2].Exploded == board[5, 3].Exploded &&
                    board[5, 3].Exploded == board[5, 4].Exploded &&
                    board[5, 4].Exploded == true;

            Assert.IsTrue(cellsAreDetonated);
        }