コード例 #1
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestChangeMeepleNegativeStartField()
        {
            GameTable       gameTable  = _hub.GetGeneratedGameTable(TableId);
            PlayerFieldArea greenArea  = gameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Green);
            PlayerFieldArea blueArea   = gameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue);
            StandardField   startField = greenArea.Fields[10] as StandardField;
            StartField      endField   = greenArea.Fields.Find(field => field.FieldType.Contains("StartField")) as StartField;
            Meeple          meeple1    = greenArea.Meeples[0];
            Meeple          meeple2    = blueArea.Meeples[0];

            meeple2.IsStartFieldBlocked = true;
            startField.CurrentMeeple    = meeple1;
            endField.CurrentMeeple      = meeple2;
            MeepleMove meepleMove = new MeepleMove()
            {
                Meeple          = meeple1,
                MoveDestination = endField
            };
            CardMove cardMove = new CardMove()
            {
                Card = _cardChange,
                SelectedAttribute = CardAttributeChangePlace
            };

            Assert.AreEqual(false, Validation.ValidateMove(meepleMove, cardMove));
        }
コード例 #2
0
    public MeepleSelectionButton Init(Meeple meeple)
    {
        this.meeple = meeple;
        GetComponentInChildren <Text>().text = meeple.Label;

        return(this);
    }
コード例 #3
0
ファイル: CastleArea.cs プロジェクト: cstamas91/Carcassonne
 /// <summary>Elhelyezi a kapott figurát a konstrukción.</summary>
 /// <param name="meeple">Elhelyezendő figura.</param>
 public void AddMeeple(Meeple meeple)
 {
     if (!IsFinished && meeples.Count == 0)
         meeples.Add(meeple);
     else
         throw new InvalidOperationException();
 }
コード例 #4
0
ファイル: Validation.cs プロジェクト: innerjoin/dog2go
 public static bool ProveChangePlace(Meeple moveMeeple, MoveDestinationField destinationField)
 {
     if (moveMeeple == null || destinationField.CurrentMeeple == null)
     {
         return(false);
     }
     if (IsSameColorCode(moveMeeple.ColorCode, destinationField.CurrentMeeple.ColorCode))
     {
         return(false);
     }
     if (IsSimpleInvalidChangeField(destinationField) || IsSimpleInvalidChangeField(moveMeeple.CurrentPosition))
     {
         return(false);
     }
     if (IsStandardField(destinationField) && !IsStandardField(moveMeeple.CurrentPosition))
     {
         return(IsValidStartField(moveMeeple.CurrentPosition));
     }
     if (!IsStandardField(destinationField) && IsStandardField(moveMeeple.CurrentPosition))
     {
         return(IsValidStartField(destinationField));
     }
     if (!(IsStandardField(moveMeeple.CurrentPosition) && IsStandardField(destinationField)))
     {
         return(IsValidStartField(destinationField) && IsValidStartField(moveMeeple.CurrentPosition));
     }
     return(true);
 }
コード例 #5
0
ファイル: SceneHandler.cs プロジェクト: Holdi601/Carawayne
    public static void positionAndParent_Meeple(GameObject Meeple, HexaPos position)
    {
        GameObject par  = GameObject.Find("MeepleCollection");
        GameObject fath = new GameObject(Meeple.GetComponent <Meeple>().meepleName);

        fath.transform.localScale = par.transform.lossyScale;
        fath.transform.position   = par.transform.position;


        Meeple.transform.localScale       = par.transform.lossyScale;
        Meeple.transform.position         = par.transform.position;
        Meeple.transform.localEulerAngles = new Vector3(0, 180, 0);

        //Meeple.transform.Translate(new Vector3(0, 0.4f, 0), Space.Self);
        fath.transform.parent   = par.transform;
        Meeple.transform.parent = fath.transform;
        setMeeplePos(Meeple, position);

        Meeple mip = Meeple.GetComponent <Meeple>();

        if (mip.GetType().IsSubclassOf(typeof(Companion)))
        {
            Companion c = Meeple.GetComponent <Companion>();
            if (c.GetType().Name != "PackAnimal")
            {
                c.setFoodPackages_hpBar();
            }
        }
    }
コード例 #6
0
ファイル: RoadArea.cs プロジェクト: cstamas91/Carcassonne
        public override void AddMeeple(Meeple meeple, SubArea subArea)
        {
            if (meeples.Count > 0)
                throw new InvalidOperationException();

            meeples.Add(meeple);
        }
コード例 #7
0
	public void DeselectMeeple() {
		if (selectedMeeple) {
			selectedMeeple.OnHoverLeave();
			selectedMeeple = null;
		};
		ViewNodeDetails(selectedNode);
	}
コード例 #8
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestChangeMeeplePositive()
        {
            GameTable       gameTable  = _hub.GetGeneratedGameTable(TableId);
            PlayerFieldArea greenArea  = gameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Green);
            PlayerFieldArea blueArea   = gameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue);
            StandardField   startField = greenArea.Fields[10] as StandardField;
            StandardField   endField   = greenArea.Fields[14] as StandardField;
            Meeple          meeple1    = greenArea.Meeples[0];
            Meeple          meeple2    = blueArea.Meeples[0];

            startField.CurrentMeeple = meeple1;
            endField.CurrentMeeple   = meeple2;
            MeepleMove meepleMove = new MeepleMove()
            {
                Meeple          = meeple1,
                MoveDestination = endField
            };
            CardMove cardMove = new CardMove()
            {
                Card = _cardJoker,
                SelectedAttribute = CardAttributeChangePlace
            };

            Assert.AreEqual(true, Validation.ValidateMove(meepleMove, cardMove));
        }
コード例 #9
0
 public void Activate(Meeple meeple)
 {
     if (!isActive)
     {
         Initiate(meeple);
     }
 }
コード例 #10
0
    public void AddMeeple(Meeple meeple)
    {
        meeples.Add(meeple);
        Transform slot = GetSlot();

        meeple.transform.parent        = slot;
        meeple.transform.localPosition = Vector3.zero;
    }
コード例 #11
0
ファイル: Player.cs プロジェクト: GLorenz/MMP1
 protected override void CreateMeeples()
 {
     for (int i = 0; i < 2; i++)
     {
         Meeple newMeep = new Meeple(this, new Rectangle(0, 0, Board.Instance().boardUnit, Board.Instance().boardUnit), UID + "_meeple" + i, meepidx: i);
         newMeep.Create();
     }
 }
コード例 #12
0
        public Meeple AddMeeple(Location location)
        {
            GameObject meepleObj = Object.Instantiate(meeplePrefab, transform);
            Meeple     meeple    = meepleObj.GetComponent <Meeple>();

            location.AddMeeple(meeple);

            return(meeple);
        }
コード例 #13
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveLeaveKennelEmptyDestinationField()
        {
            Meeple meeple  = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Green);

            meeple.CurrentPosition = new KennelField(2);
            StartField field2 = new StartField(3, ColorCode.Blue);

            Assert.AreEqual(true, Validation.ProveLeaveKennel(meeple, field2));
        }
コード例 #14
0
ファイル: CardServices.cs プロジェクト: innerjoin/dog2go
        public bool ProveLeaveKennel(List <Meeple> myMeeples)
        {
            if (myMeeples == null)
            {
                return(false);
            }
            List <Meeple> proveMeeples     = myMeeples.FindAll(meeple => meeple.CurrentPosition.FieldType.Contains("KennelField"));
            Meeple        proveStartMeeple = myMeeples.Find(startMeeple => startMeeple.CurrentPosition.FieldType.Contains("StartField") && !Validation.IsValidStartField(startMeeple.CurrentPosition));

            return(proveMeeples.Count > 0 && proveStartMeeple == null);
        }
コード例 #15
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestCanMoveToEndFieldsBug340()
        {
            GameTable table  = MakeInitialGameTable;
            Meeple    meeple = new Meeple(new KennelField(77), ColorCode.Yellow)
            {
                IsStartFieldBlocked = false
            };
            StandardField standardField = (StandardField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Yellow).Fields[0];

            standardField.CurrentMeeple = meeple;
            Assert.AreEqual(true, Validation.CanMoveToEndFields(standardField, 5, meeple.ColorCode));
        }
コード例 #16
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveLeaveKennelNotSameColor()
        {
            Meeple meeple  = new Meeple(new KennelField(1), ColorCode.Red);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Green);

            meeple.CurrentPosition = new KennelField(2);
            StartField field2 = new StartField(3, ColorCode.Blue)
            {
                CurrentMeeple = meeple2
            };

            Assert.AreEqual(false, Validation.ProveLeaveKennel(meeple, field2));
        }
コード例 #17
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveChangePlaceEndFieldSameColorMeeple()
        {
            Meeple meeple  = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Blue);

            meeple.CurrentPosition = new EndField(2);
            EndField field2 = new EndField(3)
            {
                CurrentMeeple = meeple2
            };

            Assert.AreEqual(false, Validation.ProveChangePlace(meeple, field2));
        }
コード例 #18
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveChangePlaceStandardField()
        {
            Meeple meeple  = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Green);

            meeple.CurrentPosition = new StandardField(2);
            StandardField field2 = new StandardField(3)
            {
                CurrentMeeple = meeple2
            };

            Assert.AreEqual(true, Validation.ProveChangePlace(meeple, field2));
        }
コード例 #19
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestHasBlockedFieldBackwardsFromStart()
        {
            GameTable table = MakeInitialGameTable;
            //Meeple meeple = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Blue)
            {
                IsStartFieldBlocked = true
            };
            StartField startField = (StartField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields.Find(field => field.FieldType.Contains("StartField"));

            startField.CurrentMeeple = meeple2;
            Assert.AreEqual(false, Validation.HasBlockedField(startField, -4));
        }
コード例 #20
0
ファイル: GameServicesTest.cs プロジェクト: innerjoin/dog2go
        public void TestUpdateMeeplePositionNoMeepleMove()
        {
            GameTable            table        = MakeInitialGameTable;
            PlayerFieldArea      redArea      = table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Red);
            Meeple               redMeeple    = redArea.Meeples.First();
            MoveDestinationField currentField = redArea.Fields.Find(field => field.FieldType.Contains("StartField"));

            currentField.CurrentMeeple = redMeeple;
            MoveDestinationField moveField   = redArea.Fields.Find(field => field.FieldType.Contains("StandardField"));
            GameTable            notModified = table;

            GameTableService.UpdateMeeplePosition(null, table, false);
            Assert.AreEqual(table, notModified);
        }
コード例 #21
0
ファイル: CardServicesTest.cs プロジェクト: innerjoin/dog2go
        public void TestGetOpenMeeples()
        {
            GameTable     actualGameTable = MakeInitialGameTable;
            List <Meeple> myMeeples       =
                actualGameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Meeples;
            Meeple meeple = myMeeples.First();

            meeple.IsStartFieldBlocked = false;
            meeple.CurrentPosition     =
                actualGameTable.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields[7];
            List <Meeple> openMeeples = GameTableService.GetOpenMeeples(myMeeples);

            Assert.AreEqual(1, openMeeples.Count);
        }
コード例 #22
0
            /**
             * places meeple in current structure, then triggers meeple own placement
             */
            public void PlaceMeeple(Tile tile, Meeple meeple)
            {
                if (!this.ComponentTiles.Contains(tile))
                {
                    throw new Exception("Tile not in Component tiles");
                }
                if (this.MeepleList.Count != 0)
                {
                    //throw new Exception("Meeple is not alone in structure");
                    return;
                }

                this.MeepleList.Add(meeple);
                meeple.PlaceMeeple(tile, this.StructureId);
            }
コード例 #23
0
        private static Meeple SetBackToKennelField(GameTable actualGameTable, Meeple moveDestinationMeeple)
        {
            if (moveDestinationMeeple == null)
            {
                return(null);
            }
            foreach (KennelField kennelField in actualGameTable.PlayerFieldAreas.Select(area => area.KennelFields.Find(
                                                                                            field => field.CurrentMeeple == null && area.ColorCode == moveDestinationMeeple.ColorCode)).Where(kennelField => kennelField != null))
            {
                moveDestinationMeeple.CurrentFieldId  = kennelField.Identifier;
                moveDestinationMeeple.CurrentPosition = kennelField;
                kennelField.CurrentMeeple             = moveDestinationMeeple;
            }

            return(moveDestinationMeeple);
        }
コード例 #24
0
ファイル: GameServicesTest.cs プロジェクト: innerjoin/dog2go
        public void TestUpdateMeeplePositionCorrectlyInitialized()
        {
            GameTable            table        = MakeInitialGameTable;
            PlayerFieldArea      redArea      = table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Red);
            Meeple               redMeeple    = redArea.Meeples.First();
            MoveDestinationField currentField = redArea.Fields.Find(field => field.FieldType.Contains("StartField"));

            currentField.CurrentMeeple = redMeeple;
            MoveDestinationField moveField = redArea.Fields.Find(field => field.FieldType.Contains("StandardField"));

            GameTableService.UpdateMeeplePosition(new MeepleMove()
            {
                Meeple = redMeeple, MoveDestination = moveField
            }, table, false);
            Assert.AreEqual(moveField, table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Red).Fields.Find(field => field.CurrentMeeple == redMeeple));
        }
コード例 #25
0
        public override int GetHashCode()
        {
            var result = 0;

            if (null != Player)
            {
                result += Player.GetHashCode();
            }
            if (null != Meeple)
            {
                result += Meeple.GetHashCode();
            }
            result += RequestType.GetHashCode();
            result += Options.Sum(o => o.GetHashCode());
            return(result);
        }
コード例 #26
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveLeaveKennelBlockedStartField()
        {
            Meeple meeple  = new Meeple(new KennelField(1), ColorCode.Red);
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Green)
            {
                IsStartFieldBlocked = true
            };

            meeple.CurrentPosition = new KennelField(2);
            StartField field2 = new StartField(3, ColorCode.Red)
            {
                CurrentMeeple = meeple2
            };

            Assert.AreEqual(false, Validation.ProveLeaveKennel(meeple, field2));
        }
コード例 #27
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveValueCardStandardFieldOverStartNotBlocked()
        {
            GameTable table   = MakeInitialGameTable;
            Meeple    meeple  = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple    meeple2 = new Meeple(new KennelField(2), ColorCode.Blue)
            {
                IsStartFieldBlocked = false
            };
            StartField startField = (StartField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields.Find(field => field.FieldType.Contains("StartField"));

            startField.CurrentMeeple = meeple2;
            StandardField standardField = (StandardField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields.Find(field => field.FieldType.Contains("StandardField"));

            standardField.CurrentMeeple = meeple;
            Assert.AreEqual(true, Validation.ProveValueCard(meeple, (StartField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields[4], 4));
        }
コード例 #28
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestCanNotMoveToEndFields()
        {
            GameTable table   = MakeInitialGameTable;
            Meeple    meeple  = new Meeple(new KennelField(1), ColorCode.Blue);
            Meeple    meeple2 = new Meeple(new KennelField(2), ColorCode.Blue)
            {
                IsStartFieldBlocked = true
            };
            StartField startField = (StartField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields.Find(field => field.FieldType.Contains("StartField"));

            startField.CurrentMeeple = meeple2;
            StandardField standardField =
                (StandardField)table.PlayerFieldAreas.Find(area => area.ColorCode == ColorCode.Blue).Fields[7];

            standardField.CurrentMeeple = meeple;
            Assert.AreEqual(false, Validation.CanMoveToEndFields(standardField, 8, meeple.ColorCode));
        }
コード例 #29
0
ファイル: Validation.cs プロジェクト: innerjoin/dog2go
        public static bool ProveLeaveKennel(Meeple moveMeeple, MoveDestinationField destinationField)
        {
            if (!moveMeeple.CurrentPosition.FieldType.Contains("KennelField"))
            {
                return(false);
            }
            if (!destinationField.FieldType.Contains("StartField"))
            {
                return(false);
            }
            StartField startField = destinationField as StartField;

            if (startField != null && !IsSameColorCode(startField.ColorCode, moveMeeple.ColorCode))
            {
                return(false);
            }
            return(destinationField.CurrentMeeple == null || IsValidStartField(destinationField));
        }
コード例 #30
0
    private void Initiate(Meeple meeple)
    {
        this.meeple = meeple;
        this.start  = meeple.standingOn;
        startCenter = start.Position.Center.ToVector2();
        curArrow    = new ArrowAnimatable(start.Position, "movementarrow", start.ZPosition + 1);
        CommandQueue.Queue(new AddToBoardCommand(curArrow));

        // build direction vectors to each connected field
        directions = new Vector2[start.connectedFields.Count];
        for (int i = 0; i < directions.Length; i++)
        {
            directions[i] = start.connectedFields[i].Position.Center.ToVector2() - startCenter;
            directions[i].Normalize();
        }

        isActive  = true;
        initiated = DateTime.Now;
    }
コード例 #31
0
ファイル: Validation.cs プロジェクト: innerjoin/dog2go
        public static bool ProveValueCard(Meeple moveMeeple, MoveDestinationField destinationField, int value)
        {
            MoveDestinationField currentPos = moveMeeple.CurrentPosition;

            if (destinationField == null)
            {
                return(false);
            }
            if (HasBlockedField(currentPos, value))
            {
                return(false);
            }
            if (destinationField.FieldType.Contains("EndField"))
            {
                return(CanMoveToEndFields(currentPos, value, moveMeeple.ColorCode));
            }
            currentPos = GetNextField(currentPos, value);
            return(currentPos?.Identifier == destinationField.Identifier);
        }
コード例 #32
0
ファイル: ValidationTest.cs プロジェクト: innerjoin/dog2go
        public void TestProveChangePlaceStartfFieldNotBlocked()
        {
            Meeple meeple = new Meeple(new KennelField(1), ColorCode.Green)
            {
                IsStartFieldBlocked = false
            };
            Meeple meeple2 = new Meeple(new KennelField(2), ColorCode.Blue)
            {
                IsStartFieldBlocked = false
            };

            meeple.CurrentPosition = new StartField(1, ColorCode.Blue);
            StartField field2 = new StartField(2, ColorCode.Green)
            {
                CurrentMeeple = meeple2
            };

            Assert.AreEqual(true, Validation.ProveChangePlace(meeple, field2));
        }
コード例 #33
0
ファイル: BaseArea.cs プロジェクト: cstamas91/Carcassonne
 public virtual void AddMeeple(Meeple meeple, SubArea subArea)
 {
 }