Inheritance: ObstacleBase
Exemple #1
0
 public void AddStoneToPickUpList(Stone stone)
 {
     if(!stonesInPickUpRange.Contains(stone))
     {
         stonesInPickUpRange.Add(stone);
     }
 }
Exemple #2
0
        private bool Can(Stone current, int color, Func<Stone, int, int, bool> func)
        {
            bool result = func(current, color, Direct.Top) || func(current, color, Direct.RightTop) || func(current, color, Direct.Right) ||
                func(current, color, Direct.RightBottom) || func(current, color, Direct.Bottom) || func(current, color, Direct.LeftBottom) ||
                func(current, color, Direct.Left) || func(current, color, Direct.LeftTop);

            return result;
        }
 public SetStoneGameState(PlayingBoard playingBoard, Stone nextStone, Player newPlayer)
     : base(playingBoard, nextStone, newPlayer)
 {
     if (nextStone == null)
     {
         throw new ArgumentNullException("nextStone");
     }
 }
        public void Ctor_WithANonNullPlayfieldAndANotSetNextStone_DoesNotThrowAnException()
        {
            var notSetStone = new Stone(Size.High, Surface.Flat, Color.Black, Shape.Square);

            var playfield = new PlayingBoard();
            playfield = playfield.SetStone(0, 0, this._sampleStone);
            Action call = () => Substitute.For<GameStateBase>(playfield, notSetStone, Player.One);
            call.ShouldNotThrow();
        }
 //initializes turn panels with empty stones
 public void InitializePanel(Stone[,] panel)
 {
     for (int i = 0; i < panel.GetLength(0); i++)
     {
         for (int j = 0; j < panel.GetLength(1); j++)
         {
             panel[i,j] = new Stone(i, j);
         }
     }
 }
 public void addinfo(Stone tempcard)
 {
     cards.Add(tempcard);
     tempcard.transform.parent = transform;
     tempcard.layering(false);
     if (cards.Count == 1)
         tempcard.turnit(false);
     else
         tempcard.hideit();
 }
Exemple #7
0
 void addinfo(Stone tempcard)
 {
     card = tempcard;
     tempcard.transform.parent = transform;
     iTween.MoveTo(card.gameObject, iTween.Hash("x", 0, "y", 0, "z", 0, "islocal", true,  "easeType",  "easeOutQuad", "time", 0.3f));
     engine.joker = tempcard;
     tempcard.renderer.sortingOrder = 0;
     tempcard.normal.sortingOrder = 1;
     tempcard.normalsign.sortingOrder = 1;
 }
Exemple #8
0
    IEnumerator addinfo(Stone tempcard)
    {
        cards.Add(tempcard);

        tempcard.turnit(false);
        tempcard.transform.parent = transform;
        iTween.MoveTo(cards[cards.Count - 1].gameObject, iTween.Hash("x", 0, "y", -5.0f, "z", 0, "islocal", true,  "easeType",  "easeOutQuad", "time", 0.3f));
        yield return new  WaitForSeconds(0.3f);
        tempcard.turnit(true);
    }
        public SetStoneGameState ChooseAsNextStone(Stone nextStone)
        {
            if (nextStone == null)
            {
                throw new ArgumentNullException("nextStone");
            }

            var newPlayer = this.CurrentPlayer == Player.One ? Player.Two : Player.One;
            return new SetStoneGameState(this.PlayingBoard, nextStone, newPlayer);
        }
Exemple #10
0
    public void putstone(Stone tempcard)
    {
        cards.Add(tempcard);
        tempcard.transform.parent.SendMessage("remove", tempcard);
        tempcard.transform.parent = transform;
        tempcard.renderer.enabled = true;
        tempcard.normal.enabled = true;
        tempcard.normalsign.enabled = true;
        layerit(tempcard);

        iTween.MoveTo(tempcard.gameObject, iTween.Hash("x", 0.0, "y", 0.0, "z", 0.0, "islocal", true,  "easeType",  "easeOutQuad", "time", 0.30f));
    }
Exemple #11
0
 public StonePicture(int x, int y)
 {
     stone = new Stone(x, y);
     x = stone.X;
     y = stone.Y;
     AllowDrop = true;
     MouseDown += new MouseEventHandler(MouseDowned);
     MouseUp += new MouseEventHandler(MouseUped);
     Size = new Size(stone.Size, stone.Size);
     Location = new Point(y * stone.Size, x * stone.Size);
     OnAsyncOverlayStone(EventArgs.Empty);
     Image = Picture(stone.Color);
 }
Exemple #12
0
 public int[] SetStep(Map m, Token.PlayerColor color, int[] p, int check, Control contrl, List<int[]> taken)
 {
     int[] pos = ChooseToken(m, color, taken);
     int[,] help;
     if (m.Field[pos[0], pos[1]].Tok == "stone"){
         Token.PlayerColor c = m.Field[pos[0], pos[1]].Color;
         help = new Stone(c).nextStep(m, pos);//field of information where you can move, or have to move a stone
     }
     else{
         Token.PlayerColor c = m.Field[pos[0], pos[1]].Color;
         help = new Draught(c).nextStep(m, pos);//field of information where you can move, or have to move a draught
     }
     return new int[]{-1,-1};
 }
Exemple #13
0
        private bool CanFlip(Stone current, int color, int dir)
        {
            Stone p = current[dir];
            if(!p.IsOpponent(color)) {
                return false;
            }

            do {
                p = p[dir];
            } while (p.IsOpponent(color));

            bool result = (p.Type == color);

            return result;
        }
Exemple #14
0
        public void SetSpace(BoardLocation location, Player owner, Stone stone, int height)
        {
            if (owner == Player.None)
            {
                throw new ArgumentException("owner not specified");
            }
            if (stone == Stone.None)
            {
                throw new ArgumentException("stone not specified");
            }
            if (height <= 0)
            {
                throw new ArgumentException("height not specified");
            }

            state[location.Y][location.X] = GetCode(owner, stone, height);
        }
Exemple #15
0
        public int GetTotalCount(Player player, Stone stone)
        {
            int count = 0;

            for (int y = 0; y < 9; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    int code = state[y][x];
                    if (GetOwner(code) == player && GetStone(code) == stone)
                    {
                        count++;
                    }
                }
            }
            return count;
        }
Exemple #16
0
        protected GameStateBase(PlayingBoard playingBoard, Stone nextStone, Player currentPlayer)
        {
            if (playingBoard == null)
            {
                throw new ArgumentNullException("playingBoard");
            }

            if (nextStone != null)
            {
                if (playingBoard.GetAllFields().Contains(nextStone))
                {
                    throw new ArgumentException("nextStone is already set on the playing board.", "nextStone");
                }
            }

            this._playingBoard = playingBoard;
            this._nextStone = nextStone;
            this._currentPlayer = currentPlayer;
            this._isWinState = new Lazy<bool>(() => DetectIsWinState(this));
        }
Exemple #17
0
        public Map(int n)
        {
            field = (n == 8) ? new Token[8, 8] : new Token[10, 10];//8x8 or 10x10 field is declaired

            for (int i = 0; i < field.GetLength(1); i++){//tokens are given their start positions
                if (i % 2 != 0)
                {
                    field[i, 0] = new Stone(Token.PlayerColor.Black);
                    field[i, 2] = new Stone(Token.PlayerColor.Black);
                    field[i, field.GetLength(1) - 2] = new Stone(Token.PlayerColor.White);
                    if (field.GetLength(1) == 10) field[i, field.GetLength(1) - 4] = new Stone(Token.PlayerColor.White);//4. line at a 10x10 field
                }
                if (i % 2 == 0)
                {
                    field[i, 1] = new Stone(Token.PlayerColor.Black);
                    field[i, field.GetLength(1) - 1] = new Stone(Token.PlayerColor.White);
                    field[i, field.GetLength(1) - 3] = new Stone(Token.PlayerColor.White);
                    if (field.GetLength(1) == 10) field[i, 3] = new Stone(Token.PlayerColor.Black);//4. line at a 10x10 field
                }
            }
        }
        public GameBoardViewModel()
        {
            //saving rainbow color sequence
            ColorSequence = new Dictionary<string,int>();
            ColorSequence.Add(Colors.Red, 0);
            ColorSequence.Add(Colors.Orange, 1);
            ColorSequence.Add(Colors.Yellow, 2);
            ColorSequence.Add(Colors.Green, 3);
            ColorSequence.Add(Colors.Blue, 4);
            ColorSequence.Add(Colors.Purple, 5);

            //creating triangular structures
            Triangle = new Stone[6][];
            for (int i = 0; i < Triangle.GetLength(0); i++)
			{
			    Triangle[i] = new Stone[i+1];
			}
            TriangeDictionary = new Dictionary<string, Stone>();

            //list of colors to attribute to stones
            StoneColors = new List<string>() 
            {
                Colors.Red, Colors.Red, Colors.Red, Colors.Red, Colors.Red, Colors.Red,
                Colors.Orange, Colors.Orange, Colors.Orange, Colors.Orange, Colors.Orange,
                Colors.Yellow,  Colors.Yellow, Colors.Yellow, Colors.Yellow,
                Colors.Green, Colors.Green, Colors.Green,
                Colors.Blue, Colors.Blue,
                Colors.Purple,
            };
            
            //initializing turn panels
            LeftTurnPanel = new Stone[11, 3];
            RightTurnPanel = new Stone[11, 3];
            InitializePanel(LeftTurnPanel);
            InitializePanel(RightTurnPanel);

            SelectedStones = new List<Point>();

        }
    /**
     * checks if Stone is in collider from CanHoldHookable Object
     *
     *@param stone Stone to check
     *
     * @return boolean true if the Stone is inside
     */
    public bool IsStoneInColliderOfCanHoldHookableObject(Stone stone)
    {
        var currentStonePosition = HookableObjectController.GetPositionOfHookableObject(stone);

        return(_collider2D.bounds.Contains(currentStonePosition));
    }
Exemple #20
0
 private void ThrowPickedUpStone()
 {
     if (pickedUpStone)
     {
         SoundManager.PlayThrowStoneSound(transform.position);
         GameManager.ShakeCamera(0.2f,0.3f);
         Vector3 throwForce = (mouseWorldPosition - transform.position).normalized;
         throwForce *= throwForceMultiplier * pickedUpStone.rigidbody.mass;
         pickedUpStone.networkView.RPC ("OnThrow",RPCMode.AllBuffered);
         pickedUpStone.GetNetworkView().RPC("ApplyForce",RPCMode.AllBuffered,throwForce);
         pickedUpStone = null;
     }
 }
Exemple #21
0
 public Stone(Stone g) : base(g)
 {
 }
Exemple #22
0
        public IActionResult getId(Stone stn)
        {
            var a = stn;

            return(new ObjectResult(stn));
        }
Exemple #23
0
 public Stone(Stone stone, Brush brush, Brush penColor)
 {
     this.StoneRect  = stone.StoneRect;
     this.StoneBrush = brush;
     this.StonePen   = new Pen(penColor);
 }
Exemple #24
0
 private void AddElement(Stone stone)
 {
     _stones.Add(stone);
     _movables.Add(stone);
     _destructibles.Add(stone);
 }
Exemple #25
0
 void addcard(Stone tempcard)
 {
     card = tempcard;
 }
 public void AddStone(Stone stone)
 {
     stone.MouseLeftButtonDown += StoneOnMouseLeftButtonDown;
     GameGrid.Children.Add(stone);
 }
Exemple #27
0
        /// <summary>
        /// 初期化のタイミングにフレームワークから呼び出されます
        /// </summary>
        public override void Initialize()
        {
            // インプットマネージャーの初期化
            InputManager.Initialize();

            Prince = new Player(camera);

            #region //道 glassRoadPosition

            //int glassRoadPoint = 0;
            for (int count = 0; count < 6; count++)
            { //6
                glassRoadPosition[glassRoadCount] = new Vector3(-40.0f + (20.0f * count), -10.0f, 0.0f);
                glassRoadCount++;
            }

            for (int count = 0; count < 6; count++)
            { //12
                glassRoadPosition[glassRoadCount] = new Vector3(140.0f + (20.0f * count), -10.0f, 0.0f);
                glassRoadCount++;
            }
            glassRoadPosition[glassRoadCount] = new Vector3(240, 10.0f, 0.0f); //13
            glassRoadCount++;

            for (int count = 0; count < 3; count++)
            { //16
                glassRoadPosition[glassRoadCount] = new Vector3(260 + (20.0f * count), 30.0f, 0.0f);
                glassRoadCount++;
            }

            for (int count = 0; count < 7; count++)
            { //23
                glassRoadPosition[glassRoadCount] = new Vector3(480.0f + (20.0f * count), 30.0f, 0.0f);
                glassRoadCount++;
            }

            glassRoadPosition[glassRoadCount] = new Vector3(620.0f, 10.0f, 0.0f);      //24
            glassRoadCount++;

            glassRoadPosition[glassRoadCount] = new Vector3(760.0f, -30.0f, 0.0f);     //25
            glassRoadCount++;

            for (int count = 0; count < 6; count++) //31
            {
                glassRoadPosition[glassRoadCount] = new Vector3(780.0f + (20.0f * count), 70.0f, 0.0f);
            }

            glassRoadPosition[glassRoadCount] = new Vector3(980.0f, 10.0f, 0.0f); //32
            glassRoadCount++;

            for (int i = 0; i < 5; i++) ////37
            {
                glassRoadPosition[glassRoadCount] = new Vector3(1340.0f + (20.0f * i), -390.0f, 0.0f);
                glassRoadCount++;
            }

            glassRoadPosition[glassRoadCount] = new Vector3(1360.0f, -290.0f, 0.0f);
            glassRoadCount++;           //38

            for (int i = 0; i < 7; i++) //45
            {
                glassRoadPosition[glassRoadCount] = new Vector3(1380.0f, -250.0f, 0.0f);
                glassRoadCount++;
            }

            for (int i = 0; i < 5; i++) //50
            {
                glassRoadPosition[glassRoadCount] = new Vector3(1600.0f, -290.0f, 0.0f);
                glassRoadCount++;
            }


            #endregion

            #region //崖頭 glassClifPosition
            glassClifPosition[0] = new Vector3(-40.0f, 90.0f, 0.0f);
            glassClifPosition[1] = new Vector3(80.0f, -10.00f, 0.0f);
            glassClifPosition[2] = new Vector3(320.0f, 30.0f, 0.0f);
            glassClifPosition[3] = new Vector3(400.0f, 10.0f, 0.0f);
            glassClifPosition[4] = new Vector3(620.0f, 30.0f, 0.0f);
            glassClifPosition[5] = new Vector3(640.0f, 10.0f, 0.0f);
            glassClifPosition[6] = new Vector3(900.0f, 70.0f, 0.0f);
            //こっから反対
            glassClifPosition[7]  = new Vector3(120.0f, -10.0f, 0.0f);
            glassClifPosition[8]  = new Vector3(220.0f, 10.0f, 0.0f);
            glassClifPosition[9]  = new Vector3(240.0f, 29.79f, 0.0f);
            glassClifPosition[10] = new Vector3(380.0f, 10.0f, 0.0f);
            glassClifPosition[11] = new Vector3(460.0f, 29.79f, 0.0f);
            glassClifPosition[12] = new Vector3(740.0f, -29.81f, 0.0f);
            glassClifPosition[13] = new Vector3(760.0f, 70.0f, 0.0f);
            glassClifPosition[14] = new Vector3(960.0f, 10.0f, 0.0f);

            glassClifCount = 15;

            glassClifPosition[15] = new Vector3(1440.0f, -370.0f, 0.0f);
            glassClifPosition[16] = new Vector3(1460.0f, -350.0f, 0.0f);
            glassClifPosition[17] = new Vector3(1480.0f, -330.0f, 0.0f);
            glassClifPosition[18] = new Vector3(1460.0f, -310.0f, 0.0f);
            glassClifPosition[19] = new Vector3(1380.0f, -290.0f, 0.0f);
            glassClifPosition[20] = new Vector3(1340.0f, -270.0f, 0.0f);

            glassClifCount = 21;
            #endregion

            #region //壁中身 dartClifPosition
            dartClifCount = 0;
            for (int i = 0; i < 4; i++)
            { //4
                dartClifPosition[dartClifCount] = new Vector3(-40.0f, 10.0f + (20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 5; i++)
            { //9
                dartClifPosition[dartClifCount] = new Vector3(80.0f, -30.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 7; i++)
            { //16
                dartClifPosition[dartClifCount] = new Vector3(320.0f, 10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 6; i++)
            { //22
                dartClifPosition[dartClifCount] = new Vector3(400.0f, -10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 7; i++)
            { //29
                dartClifPosition[dartClifCount] = new Vector3(640.0f, -10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }
            for (int i = 0; i < 10; i++)
            { //39
                dartClifPosition[dartClifCount] = new Vector3(900.0f, 50.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 5; i++) //44
            {
                dartClifPosition[dartClifCount] = new Vector3(120.0f, -30.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }
            for (int i = 0; i < 6; i++) //50
            {
                dartClifPosition[dartClifCount] = new Vector3(380.0f, -10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }
            for (int i = 0; i < 8; i++) //58
            {
                dartClifPosition[dartClifCount] = new Vector3(460.0f, 10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 4; i++) //62
            {
                dartClifPosition[dartClifCount] = new Vector3(740.0f, -50.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 4; i++) //66
            {
                dartClifPosition[dartClifCount] = new Vector3(760.0f, 50.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }

            for (int i = 0; i < 6; i++) //72
            {
                dartClifPosition[dartClifCount] = new Vector3(960.0f, -10.0f + (-20.0f * i), 0.0f);
                dartClifCount++;
            }


            #endregion

            #region  //石壁 stonePosition

            for (int i = 0; i < 8; i++)
            { //8
                stonePosition[stoneCount] = new Vector3(900.0f, -130.0f + (-20.0f * i), 0.0f);
                stoneCount++;
            }
            for (int i = 0; i < 4; i++)
            { //12
                stonePosition[stoneCount] = new Vector3(960.0f, -130.0f + (-20.0f * i), 0.0f);
                stoneCount++;
            }
            for (int i = 0; i < 6; i++)
            { //18
                stonePosition[stoneCount] = new Vector3(980.0f + (20.0f * i), -190.0f, 0.0f);
                stoneCount++;
            }
            for (int i = 0; i < 3; i++)
            { //21
                stonePosition[stoneCount] = new Vector3(1160.0f + (20.0f * i), -190.0f, 0.0f);
                stoneCount++;
            }

            for (int i = 0; i < 8; i++)
            {
                for (int y = 0; y < 8; y++)
                { //85
                    stonePosition[stoneCount] = new Vector3(740.0f + (20.0f * y), -130.0f + (-20.0f * i), 0.0f);
                    stoneCount++;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int y = 0; y < 12; y++)
                {//121
                    stonePosition[stoneCount] = new Vector3(980.0f + (20.0f * y), -130.0f + (-20.0f * i), 0.0f);
                    stoneCount++;
                }
            }

            stonePosition[stoneCount] = new Vector3(1160.0f, -210.0f, 0.0f);
            stoneCount++; //122

            for (int i = 0; i < 5; i++)
            {
                for (int y = 0; y < 24; y++) //242
                {
                    stonePosition[stoneCount] = new Vector3(740.0f + (20.0f * y), -290.0f + (-20.0f * i), 0.0f);
                    stoneCount++;
                }
            }

            #endregion

            #region                     //石道  stoneRoadPosition
            stoneRoadCount = 0;
            for (int i = 0; i < 6; i++) //6
            {
                stoneRoadPosition[stoneRoadCount] = new Vector3(980.0f + (20.0f * i), -270.0f, 0.0f);
                stoneRoadCount++;
            }
            for (int i = 0; i < 3; i++) //9
            {
                stoneRoadPosition[stoneRoadCount] = new Vector3(1160.0f + (20.0f * i), -270.0f, 0.0f);
                stoneRoadCount++;
            }

            #endregion

            #region //針 needle

            needleCount       = 0;
            needlePosition[0] = new Vector3(100.0f, -50.0f, 0.0f);
            needlePosition[1] = new Vector3(340.0f, -30.0f, 0.0f);
            needlePosition[2] = new Vector3(360.0f, -30.0f, 0.0f);
            needlePosition[3] = new Vector3(420.0f, -30.0f, 0.0f);
            needlePosition[4] = new Vector3(440.0f, -30.0f, 0.0f);

            needleCount = 5;            //5
            for (int i = 0; i < 4; i++) //9
            {
                needlePosition[needleCount] = new Vector3(660.0f + (20.0f * i), -50.0f, 0.0f);
                needleCount++;
            }
            for (int i = 0; i < 3; i++)  //12
            {
                needlePosition[needleCount] = new Vector3(1100.0f + (20.0f * i), -270.0f, 0.0f);
                needleCount++;
            }
            for (int i = 0; i < 11; i++)  //23
            {
                needlePosition[needleCount] = new Vector3(1000.0f + (20.0f * i), 10.0f, 0.0f);
                needleCount++;
            }

            for (int i = 0; i < 3; i++)  //26
            {
                needlePosition[needleCount] = new Vector3(920.0f + (20.0f * i), -270.0f, 0.0f);
                needleCount++;
            }

            needlePosition[needleCount] = new Vector3(940.0f, -130.0f, 0.0f);
            needleCount++; //27

            for (int i = 0; i < 3; i++)
            {
                                        //30 反転してるトゲ。
                {
                    needlePosition[needleCount] = new Vector3(1100.0f + (20.0f * i), -190.0f, 0.0f);
                    needleCount++;
                }
            }


            for (int i = 0; i < 3; i++) //33
            {
                needlePosition[needleCount] = new Vector3(1220.0f + (20.0f * i), -330.0f, 0.0f);
                needleCount++;
            }
            for (int i = 0; i < 2; i++) //35
            {
                needlePosition[needleCount] = new Vector3(1330.0f + (20.0f * i), -390.0f, 0.0f);
                needleCount++;
            }
            for (int i = 0; i < 2; i++) //37
            {
                needlePosition[needleCount] = new Vector3(1400.0f + (20.0f * i), -310.0f, 0.0f);
                needleCount++;
            }
            for (int i = 0; i < 4; i++) //41
            {
                needlePosition[needleCount] = new Vector3(1500.0f + (20.0f * i), -390.0f, 0.0f);
                needleCount++;
            }

            needlePosition[needleCount] = new Vector3(1580.0f, -270.0f, 0.0f);
            needleCount++; //42



            #endregion

            #region //土 dartPosition
            dartCount = 0;
            for (int i = 0; i < 5; i++)
            {
                for (int y = 0; y < 6; y++) //30
                {
                    dartPosition[dartCount] = new Vector3(-40.0f + (20.0f * y), -30.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }

            for (int i = 0; i < 5; i++)
            {
                for (int y = 0; y < 9; y++) //75
                {
                    dartPosition[dartCount] = new Vector3(-60.0f + (-20.0f * i), 70.0f + (-20.0f * y), 0.0f);
                    dartCount++;
                }
            }

            for (int i = 0; i < 5; i++)
            {
                for (int y = 0; y < 9; y++) //120
                {
                    dartPosition[dartCount] = new Vector3(140.0f + (20.0f * y), -30.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }

            for (int i = 0; i < 2; i++)
            {
                for (int y = 0; y < 3; y++) //126
                {
                    dartPosition[dartCount] = new Vector3(260.0f + (20.0f * y), 10.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }

            dartPosition[dartCount] = new Vector3(240.0f, -10.0f, 0.0f);
            dartCount++; //127

            for (int i = 0; i < 7; i++)
            {
                for (int y = 0; y < 7; y++) //176
                {
                    dartPosition[dartCount] = new Vector3(480.0f + (20.0f * y), 10.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }

            for (int i = 0; i < 6; i++) //182
            {
                dartPosition[dartCount] = new Vector3(620.0f, -10.0f + (-20.0f * i), 0.0f);
                dartCount++;
            }

            for (int i = 0; i < 9; i++)
            {
                for (int y = 0; y < 6; y++) //236
                {
                    dartPosition[dartCount] = new Vector3(780.0f + (20.0f * y), 50.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }

            for (int i = 0; i < 4; i++) //240
            {
                dartPosition[dartCount] = new Vector3(760.0f, -50.0f + (-20.0f * i), 0.0f);
                dartCount++;
            }

            for (int i = 0; i < 6; i++)
            {
                for (int y = 0; y < 12; y++)
                {
                    dartPosition[dartCount] = new Vector3(980.0f + (20.0f * y), -10.0f + (-20.0f * i), 0.0f);
                    dartCount++;
                }
            }


            #endregion

            #region //ゴール辺り stagePosition

            stagePosition = new Vector3(1220.0f, -450.0f, 0.0f);

            #endregion



            for (int count = 0; count < glassRoadCount; count++)
            {
                glassRoad[count] = new GlassRoad(camera);
            }

            for (int count = 0; count < glassClifCount; count++)
            {
                glassClif[count] = new GlassClif(camera);
            }
            //反対の向きのモデル
            for (int count = 7; count < glassClifCount; count++)
            {
                glassClif[count].modelRotation = new Vector3(0.0f, 180.0f, 0.0f);
            }

            for (int count = 0; count < dartClifCount; count++)
            {
                dartClif[count] = new DartClif(camera);
            }
            for (int count = 39; count < dartClifCount; count++)
            {
                dartClif[count].modelRotation = new Vector3(0.0f, 180.0f, 0.0f);
            }

            for (int count = 0; count < stoneCount; count++)
            {
                stone[count] = new Stone(camera);
            }

            for (int count = 0; count < stoneRoadCount; count++)
            {
                stoneRoad[count] = new StoneRoad(camera);
            }

            for (int count = 0; count < needleCount; count++)
            {
                needle[count] = new Needle(camera);
            }
            for (int count = 27; count < needleCount; count++)
            {
                needle[count] = new Needle(camera);
            }

            for (int count = 0; count < dartCount; count++)
            {
                dart[count] = new Dart(camera);
            }

            stage = new Stage(camera);

            base.Initialize();
        }
    public void generateStoneLists()
    {
        //generates the (invisible stones)

        stoneList = new Stone[numStonesInFeild];

        //spacing calculations
        int   stonesPerRow = numStonesInFeild / 4;
        float rowWidth     = 9;
        float gap          = rowWidth / (stonesPerRow + 1);
        float pos          = rowWidth / 2;
        float start        = rowWidth / 2 - gap;

        //FEILD STONES

        //top row, from left to right
        int c = 0;

        for (int i = 0; i < stonesPerRow; i++)
        {
            stoneList[c] = new Stone(-start + gap * i, pos, c);
            print(stoneList[c].pos);
            c++;
        }

        //right col, from top to bottem
        for (int i = stonesPerRow - 1; i >= 0; i--)
        {
            stoneList[c] = new Stone(pos, -start + gap * i, c);
            c++;
        }
        //bottem row, from right to left
        for (int i = stonesPerRow - 1; i >= 0; i--)
        {
            stoneList[c] = new Stone(-start + gap * i, -pos, c);
            c++;
        }

        //left col, from bottom to top
        for (int i = 0; i < stonesPerRow; i++)
        {
            stoneList[c] = new Stone(-pos, -start + gap * i, c);
            c++;
        }
        print("c = " + c);



        //HOME AND TARGET ROWS

        startStones = new int[numPlayers];

        startStones[0] = 24; //left middle
        startStones[1] = 10; //right middle
        homeRows       = new Stone[numPlayers][];
        targetRows     = new Stone[numPlayers][];
        homeRows[0]    = new Stone[numUnitsPerPlayer];
        homeRows[1]    = new Stone[numUnitsPerPlayer];

        targetRows[0] = new Stone[numUnitsPerPlayer];
        targetRows[1] = new Stone[numUnitsPerPlayer];

        Vector3 startPosP1 = stoneList[startStones[0]].pos;

        for (int i = 0; i < 3; i++)
        {
            //home rows: left and right "pathways" respectively //F**K IT LETS JUST HAVE THREE
            homeRows[0][i] = new Stone(-start + gap * i, 0, i);
            homeRows[1][i] = new Stone(start - gap * i, 0, i);

            //just make the target rows the same
            isWorking        = true;
            targetRows[0][i] = new Stone(-start + gap * i, 0, i);
            targetRows[1][i] = new Stone(start - gap * i, 0, i);
        }

        print("finished generating stone list");
        isWorking = true;


        addStonesToBoard();
    }
Exemple #29
0
        // Load the monster.txt drop file.
        private void LoadDropFile(bool edit)
        {
            var lines = (edit == false) ? File.ReadAllLines(Path.Combine(Settings.DropPath, String.Format("{0}.txt", listBoxMonsters.SelectedItem))) : textBoxDropList.Lines;

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith(";Gold"))
                {
                    if (lines[i + 1].StartsWith("1/"))
                    {
                        var workingLine = lines[i + 1].Split(' ');
                        GoldOdds = workingLine[0].Remove(0, 2);
                        Gold     = workingLine[2];
                        break;
                    }
                    else
                    {
                        GoldOdds = "0";
                        Gold     = "0";
                    }
                }
            }

            string[] Headers = new string[37]
            {
                ";Weapons",
                ";Armours",
                ";Helmets",
                ";Necklaces",
                ";Bracelets",
                ";Rings",
                ";Amulets",
                ";Belts",
                ";Boots",
                ";Stones",
                ";Torches",
                ";Potions",
                ";Ores",
                ";Meat",
                ";Crafting Materials",
                ";Scrolls",
                ";Gems",
                ";Mount",
                ";Books",
                ";Nothing",
                ";Script",
                ";Reins",
                ";Bells",
                ";Saddle",
                ";Ribbon",
                ";Mask",
                ";Food",
                ";Hook",
                ";Float",
                ";Bait",
                ";Finder",
                ";Reel",
                ";Fish",
                ";Quest",
                ";Awakening",
                ";Pets",
                ";Transform"
            };

            for (int i = 0; i < Headers.Length; i++)
            {
                for (int j = 0; j < lines.Length; j++)
                {
                    if (lines[j].StartsWith(Headers[i]))
                    {
                        for (int k = j + 1; k < lines.Length; k++)
                        {
                            if (lines[k].StartsWith(";"))
                            {
                                break;
                            }

                            var workingLine = lines[k].Split(' ');
                            if (workingLine.Length < 2)
                            {
                                continue;
                            }

                            var quest = "";

                            if (workingLine.Length > 2 && workingLine[2] == "Q")
                            {
                                quest = workingLine[2];
                            }

                            DropItem newDropItem = new DropItem {
                                Odds = workingLine[0], Name = workingLine[1], Quest = quest
                            };
                            switch (i)
                            {
                            case 0:
                                Weapon.Add(newDropItem);
                                break;

                            case 1:
                                Armour.Add(newDropItem);
                                break;

                            case 2:
                                Helmet.Add(newDropItem);
                                break;

                            case 3:
                                Necklace.Add(newDropItem);
                                break;

                            case 4:
                                Bracelet.Add(newDropItem);
                                break;

                            case 5:
                                Ring.Add(newDropItem);
                                break;

                            case 6:
                                Amulet.Add(newDropItem);
                                break;

                            case 7:
                                Belt.Add(newDropItem);
                                break;

                            case 8:
                                Boot.Add(newDropItem);
                                break;

                            case 9:
                                Stone.Add(newDropItem);
                                break;

                            case 10:
                                Torch.Add(newDropItem);
                                break;

                            case 11:
                                Potion.Add(newDropItem);
                                break;

                            case 12:
                                Ore.Add(newDropItem);
                                break;

                            case 13:
                                Meat.Add(newDropItem);
                                break;

                            case 14:
                                CraftingMaterial.Add(newDropItem);
                                break;

                            case 15:
                                Scrolls.Add(newDropItem);
                                break;

                            case 16:
                                Gem.Add(newDropItem);
                                break;

                            case 17:
                                Mount.Add(newDropItem);
                                break;

                            case 18:
                                Book.Add(newDropItem);
                                break;

                            case 19:
                                Nothing.Add(newDropItem);
                                break;

                            case 20:
                                Script.Add(newDropItem);
                                break;

                            case 21:
                                Reins.Add(newDropItem);
                                break;

                            case 22:
                                Bells.Add(newDropItem);
                                break;

                            case 23:
                                Saddle.Add(newDropItem);
                                break;

                            case 24:
                                Ribbon.Add(newDropItem);
                                break;

                            case 25:
                                Mask.Add(newDropItem);
                                break;

                            case 26:
                                Food.Add(newDropItem);
                                break;

                            case 27:
                                Hook.Add(newDropItem);
                                break;

                            case 28:
                                Float.Add(newDropItem);
                                break;

                            case 29:
                                Bait.Add(newDropItem);
                                break;

                            case 30:
                                Finder.Add(newDropItem);
                                break;

                            case 31:
                                Reel.Add(newDropItem);
                                break;

                            case 32:
                                Fish.Add(newDropItem);
                                break;

                            case 33:
                                Quest.Add(newDropItem);
                                break;

                            case 34:
                                Awakening.Add(newDropItem);
                                break;

                            case 35:
                                Pets.Add(newDropItem);
                                break;

                            case 36:
                                Transform.Add(newDropItem);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemple #30
0
        // Add the item to the drop list
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int.TryParse(textBoxItemOdds.Text, out int dropChance);

            if (dropChance < 1)
            {
                dropChance = 1;
            }

            string quest = QuestOnlyCheckBox.Checked ? "Q" : "";

            try
            {
                switch (tabControlSeperateItems.SelectedTab.Tag.ToString())
                {
                case "Weapon":
                    Weapon.Add(new DropItem {
                        Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Armour":
                    Armour.Add(new DropItem {
                        Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Helmet":
                    Helmet.Add(new DropItem {
                        Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Necklace":
                    Necklace.Add(new DropItem {
                        Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bracelet":
                    Bracelet.Add(new DropItem {
                        Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ring":
                    Ring.Add(new DropItem {
                        Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Amulet":
                    Amulet.Add(new DropItem {
                        Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Belt":
                    Belt.Add(new DropItem {
                        Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Boots":
                    Boot.Add(new DropItem {
                        Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Stone":
                    Stone.Add(new DropItem {
                        Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Torch":
                    Torch.Add(new DropItem {
                        Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Potion":
                    Potion.Add(new DropItem {
                        Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ore":
                    Ore.Add(new DropItem {
                        Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Meat":
                    Meat.Add(new DropItem {
                        Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "CraftingMaterial":
                    CraftingMaterial.Add(new DropItem {
                        Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance)
                    });
                    break;

                case "Scroll":
                    Scrolls.Add(new DropItem {
                        Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Gem":
                    Gem.Add(new DropItem {
                        Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Mount":
                    Mount.Add(new DropItem {
                        Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Book":
                    Book.Add(new DropItem {
                        Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Nothing":
                    Nothing.Add(new DropItem {
                        Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Script":
                    Script.Add(new DropItem {
                        Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Reins":
                    Reins.Add(new DropItem {
                        Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bells":
                    Bells.Add(new DropItem {
                        Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Saddle":
                    Saddle.Add(new DropItem {
                        Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Ribbon":
                    Ribbon.Add(new DropItem {
                        Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Mask":
                    Mask.Add(new DropItem {
                        Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Food":
                    Food.Add(new DropItem {
                        Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Hook":
                    Hook.Add(new DropItem {
                        Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Float":
                    Float.Add(new DropItem {
                        Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Bait":
                    Bait.Add(new DropItem {
                        Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Finder":
                    Finder.Add(new DropItem {
                        Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Reel":
                    Reel.Add(new DropItem {
                        Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Fish":
                    Fish.Add(new DropItem {
                        Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Quest":
                    Quest.Add(new DropItem {
                        Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Awakening":
                    Awakening.Add(new DropItem {
                        Name = listBoxAwakening.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Pets":
                    Pets.Add(new DropItem {
                        Name = listBoxPets.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;

                case "Transform":
                    Transform.Add(new DropItem {
                        Name = listBoxTransform.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest
                    });
                    break;
                }

                UpdateDropFile();
            }
            catch
            {
                //No item selected when trying to add an item to the drop
            }
        }
Exemple #31
0
        private static int Game(int rockCount, int sleepTime)
        {
            char[] rockSymbols = new char[10] { '#', '+', '&', '!', '=', '$', '~', '^', '?', '%' }; // symbols for the rocks, can be changed
            sbyte rocksSpeed = 1;
            double score = 0;
            int finalScore = 0;
            Stone[] rocks = new Stone[rockCount];

            Stone dwarf = new Stone();
            dwarf.X = Console.WindowWidth / 2;
            dwarf.Y = Console.WindowHeight - 1;

            for (int i = 0; i < rockCount; i++)
            {
                rocks[i].X = Generator.GetRandomNumber(1, Console.WindowWidth - 1);
                rocks[i].Y = Generator.GetRandomNumber(1, Console.WindowHeight - 5);
                rocks[i].Color = (ConsoleColor)Generator.GetRandomNumber(10, 14);
                rocks[i].Symbol = rockSymbols[Generator.GetRandomNumber(1, rockSymbols.Length)];
            }

            while (true)
            {
                if (rocksSpeed % 23 == 0)
                {
                    for (int i = 0; i < rockCount; i++)
                    {
                        if (rocks[i].Y == (Console.WindowHeight - 1))
                        {
                            Console.SetCursorPosition(rocks[i].X, rocks[i].Y);
                            Console.Write(" ");
                            rocks[i].X = Generator.GetRandomNumber(1, Console.WindowWidth - 1);
                            rocks[i].Y = Generator.GetRandomNumber(0, 3);
                            rocks[i].Color = (ConsoleColor)Generator.GetRandomNumber(10, 14);
                            rocks[i].Symbol = rockSymbols[Generator.GetRandomNumber(1, rockSymbols.Length)];
                        }
                        else
                        {
                            Console.SetCursorPosition(rocks[i].X, rocks[i].Y);
                            Console.Write(" ");
                            rocks[i].Y++;
                        }

                        Console.SetCursorPosition(rocks[i].X, rocks[i].Y);
                        Console.ForegroundColor = rocks[i].Color;
                        Console.Write(rocks[i].Symbol);
                    }
                }

                if (Console.KeyAvailable)
                {
                    Console.SetCursorPosition(dwarf.X - 1, dwarf.Y);
                    Console.Write("   ");
                    ConsoleKeyInfo pressedKey = Console.ReadKey();
                    if (pressedKey.Key == ConsoleKey.RightArrow)
                    {
                        dwarf.X++;
                    }
                    else if (pressedKey.Key == ConsoleKey.LeftArrow)
                    {
                        dwarf.X--;
                    }
                }

                if ((dwarf.X == Console.WindowWidth - 2) || (dwarf.X < 1))
                {
                    return finalScore * 10;
                }

                for (int i = 0; i < rockCount; i++)
                {
                    if (((dwarf.X == rocks[i].X) && (dwarf.Y == rocks[i].Y)) ||
                        ((dwarf.X == rocks[i].X - 1) && (dwarf.Y == rocks[i].Y)) ||
                        ((dwarf.X == rocks[i].X + 1) && (dwarf.Y == rocks[i].Y)))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.SetCursorPosition(dwarf.X - 1, dwarf.Y);
                        Console.Write("\\@/");
                        return finalScore * 10;
                    }
                }

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.SetCursorPosition(dwarf.X - 1, dwarf.Y);
                Console.Write("\\☺/");

                Thread.Sleep(sleepTime);
                rocksSpeed++;
                score += 0.02;
                finalScore = (int)score;
            }
        }
Exemple #32
0
 private void RemoveElement(Stone stone)
 {
     _stones.Remove(stone);
     _movables.Remove(stone);
     _destructibles.Remove(stone);
 }
Exemple #33
0
 void placeitforward(Stone tempcard, int layer)
 {
     tempcard.renderer.sortingOrder = layer;
 }
 public NetworkPacketStone(Stone stone) : base(NetworkPacketTypes.Stone, (byte)stone.Mushroom.Id, 0, stone)
 {
     AddBool(stone.Enabled);
 }
Exemple #35
0
        public void formatMsg(String msg)
        {
            String[] firstpart = msg.Split('#');
            String[] parts = firstpart[0].Split(':');

            try
            {
                String msg_format = parts[0];
                if (msg_format.Equals("I")) // game instant received
                {
                    Console.WriteLine("================================================================================\n");
                    Console.WriteLine("New Game Instant received");
                    String player = parts[1];
                    Console.WriteLine("Player: " + player);

                    this.board = new Board();
                    for (int i = 0; i < 5; i++)
                    {
                        board.players[i] = new Player("P" + i);
                    }

                    // reading brick position details
                    String brick_map = parts[2];
                    String[] bricks = brick_map.Split(';');
                    int brick_no = 1;
                    foreach (String brick in bricks)
                    {
                        String[] brick_location = brick.Split(',');
                        Brick bb = new Brick();
                        bb.setNo(brick_no);
                        bb.setPostion(int.Parse(brick_location[0]), int.Parse(brick_location[1]));
                        board.blocks[int.Parse(brick_location[0]), int.Parse(brick_location[1])] = bb;
                        brick_no++;
                    }

                    // end reading brick posiotion details

                    // reading stone position details
                    String stone_map = parts[3];
                    String[] stones = stone_map.Split(';');
                    int stone_no = 1;
                    foreach (String stone in stones)
                    {
                        String[] stone_location = stone.Split(',');
                        Stone ss = new Stone();
                        ss.setNo(stone_no);
                        ss.setPostion(int.Parse(stone_location[0]), int.Parse(stone_location[1]));
                        board.blocks[int.Parse(stone_location[0]), int.Parse(stone_location[1])] = ss;
                        stone_no++;
                    }

                    // end of reading stone position details

                    // reading water position details
                    String water_map = parts[4];
                    String[] waters = water_map.Split(';');
                    int water_no = 1;
                    foreach (String water in waters)
                    {
                        String[] water_location = water.Split(',');
                        Water ww = new Water();
                        ww.setNo(water_no);
                        ww.setPostion(int.Parse(water_location[0]), int.Parse(water_location[1]));
                        board.blocks[int.Parse(water_location[0]), int.Parse(water_location[1])] = ww;
                        water_no++;
                    }

                    // end of reading water position details

                }
                else if (msg_format.Equals("G")) // global update received
                {

                    int player_no = 1;
                    for (player_no = 1; player_no <= 5; player_no++)
                    {

                        String player_code = parts[player_no];
                        if (player_code.Substring(0, 1).Equals("P")) // this is a player sub string
                        {
                            String[] player_details = player_code.Split(';');
                            String num = Convert.ToString(player_details[0][1]);
                            int p_id = int.Parse(num);
                            String[] player_log = player_details[1].Split(',');
                            board.players[p_id].setPostion(int.Parse(player_log[0]), int.Parse(player_log[1]));
                            board.blocks[int.Parse(player_log[0]), int.Parse(player_log[1])] = board.players[p_id];
                            board.players[p_id].setDirection(int.Parse(player_details[2]));
                            board.players[p_id].setLife(int.Parse(player_details[3]));
                            board.players[p_id].setHealth(int.Parse(player_details[4]));
                            board.players[p_id].setCoins(int.Parse(player_details[5]));
                            board.players[p_id].setPoints(int.Parse(player_details[6]));

                        }
                        else
                            break;
                    }
                    String[] shots = parts[player_no].Split(';');
                    foreach (String shot in shots)
                    {
                        String[] shot_details = shot.Split(',');
                        Brick b = (Brick)board.blocks[int.Parse(shot_details[0]), int.Parse(shot_details[1])];
                        b.setDamage(int.Parse(shot_details[2]));
                        board.blocks[int.Parse(shot_details[0]), int.Parse(shot_details[1])] = b;
                        Console.WriteLine("Shot details ####  x==> " + shot_details[0] + " y ==> " + shot_details[1] + " damage level ==> " + shot_details[2]);
                    }

                }
                else if (msg_format.Equals("C")) // coin detail received
                {
                    Coinpack cp = new Coinpack();
                    String[] location = parts[1].Split(',');
                    cp.setPostion(int.Parse(location[0]), int.Parse(location[1]));
                    cp.setTime(int.Parse(parts[2]));
                    cp.setAmount(int.Parse(parts[3]));
                    board.blocks[int.Parse(location[0]), int.Parse(location[1])] = cp;
                }

                else if (msg_format.Equals("L")) // lifepack detail received
                {
                    Lifepack lp = new Lifepack();
                    String[] location = parts[1].Split(',');
                    lp.setPostion(int.Parse(location[0]), int.Parse(location[1]));
                    lp.setTime(int.Parse(parts[2]));
                    board.blocks[int.Parse(location[0]), int.Parse(location[1])] = lp;
                }
            }
            catch (Exception e)
            {

            }
        }
 // Use this for initialization
 void Start()
 {
     stone = GameObject.FindObjectOfType <Stone>();
 }
Exemple #37
0
        public JsonResult Save(StoneViewModel model)
        {
            Response response;

            try
            {
                string oldFileName = "";

                int    status  = 200;
                string message = string.Empty;
                using (var db = new KiaGalleryContext())
                {
                    if (string.IsNullOrEmpty(model.name))
                    {
                        status  = 500;
                        message = "وارد کردن نام سنگ اجباری است.";
                    }
                    else
                    {
                        if (model.id != null && model.id > 0)
                        {
                            var entity = db.Stone.Single(x => x.Id == model.id);
                            entity.Name         = model.name.Trim();
                            entity.EnglishName  = model.englishName.Trim();
                            entity.StoneType    = model.stoneType;
                            entity.Order        = model.order;
                            entity.FileName     = model.fileName?.Trim();
                            entity.Active       = model.active;
                            entity.ModifyUserId = GetAuthenticatedUserId();
                            entity.ModifyDate   = DateTime.Now;
                            entity.Ip           = Request.UserHostAddress;

                            if (!string.IsNullOrEmpty(entity.FileName) && entity.FileName != model.fileName)
                            {
                                oldFileName = entity.FileName;
                            }

                            message = "سنگ با موفقیت ویرایش شد.";
                        }
                        else
                        {
                            var entity = new Stone()
                            {
                                Name         = model.name.Trim(),
                                EnglishName  = model.englishName.Trim(),
                                StoneType    = model.stoneType,
                                Order        = model.order,
                                FileName     = model.fileName?.Trim(),
                                Active       = model.active,
                                CreateUserId = GetAuthenticatedUserId(),
                                ModifyUserId = GetAuthenticatedUserId(),
                                CreateDate   = DateTime.Now,
                                ModifyDate   = DateTime.Now,
                                Ip           = Request.UserHostAddress
                            };

                            db.Stone.Add(entity);
                            message = "سنگ با موفقیت ایجاد شد.";
                        }
                        db.SaveChanges();

                        if (!string.IsNullOrEmpty(oldFileName) && System.IO.File.Exists(Server.MapPath("~/Upload/Stone/" + oldFileName)))
                        {
                            System.IO.File.Delete(Server.MapPath("~/Upload/Stone/" + oldFileName));
                        }
                    }
                }

                response = new Response()
                {
                    status  = status,
                    message = message
                };
            }
            catch (Exception ex)
            {
                response = Core.GetExceptionResponse(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public void refreshBoard(Board b)
        {
            if (tblBoard.InvokeRequired)
            {
                refreshBoardDelegate r = new refreshBoardDelegate(refreshBoard);
                this.Invoke(r, new object[] { b });
            }
            else
            {
                if (!created)
                {
                    tblBoard.SuspendLayout();
                    this.tblBoard.ColumnCount = b.getWidth();
                    this.tblBoard.RowCount    = b.getHeight();
                    for (int i = 0; i < b.getWidth(); i++)
                    {
                        for (int j = 0; j < b.getHeight(); j++)
                        {
                            Label t = new Label();
                            Field f = b.getField(i, j);
                            Stone s = f.getStone();
                            t.Dock        = DockStyle.Fill;
                            t.AutoSize    = false;
                            t.Font        = new Font("Arial", 20);
                            t.AllowDrop   = true;
                            t.DragDrop   += new System.Windows.Forms.DragEventHandler(this.tblBoard_DragDrop);
                            t.DragEnter  += new System.Windows.Forms.DragEventHandler(this.tblBoard_DragEnter);
                            t.MouseClick += new System.Windows.Forms.MouseEventHandler(this.tblBoad_Click);
                            switch (f.getType())
                            {
                            case Field.Types.DoubleLetter:
                                t.BackColor = Color.LightSalmon;
                                break;

                            case Field.Types.DoubleWord:
                                t.BackColor = Color.LightGreen;
                                break;

                            case Field.Types.TripleLetter:
                                t.BackColor = Color.DarkSalmon;
                                break;

                            case Field.Types.TripleWord:
                                t.BackColor = Color.DarkGreen;
                                break;

                            default:
                                break;
                            }

                            if (s != null)
                            {
                                t.Text = s.letter + "(" + s.value + ")";
                            }
                            else
                            {
                                t.Text = "";
                            }
                            tblBoard.Controls.Add(t, i, j);
                        }
                    }
                    tblBoard.ResumeLayout();
                    created = true;
                }
                else
                {
                    tblBoard.SuspendLayout();
                    for (int i = 0; i < b.getWidth(); i++)
                    {
                        for (int j = 0; j < b.getHeight(); j++)
                        {
                            Field f = b.getField(i, j);
                            Stone s = f.getStone();
                            switch (f.getType())
                            {
                            case Field.Types.DoubleLetter:
                                ((Label)tblBoard.GetControlFromPosition(i, j)).BackColor = Color.LightSalmon;
                                break;

                            case Field.Types.DoubleWord:
                                ((Label)tblBoard.GetControlFromPosition(i, j)).BackColor = Color.LightGreen;
                                break;

                            case Field.Types.TripleLetter:
                                ((Label)tblBoard.GetControlFromPosition(i, j)).BackColor = Color.DarkSalmon;
                                break;

                            case Field.Types.TripleWord:
                                ((Label)tblBoard.GetControlFromPosition(i, j)).BackColor = Color.DarkGreen;
                                break;

                            default:
                                break;
                            }

                            if (s != null)
                            {
                                ((Label)tblBoard.GetControlFromPosition(i, j)).Text = s.letter + "(" + s.value + ")";
                            }
                            else
                            {
                                ((Label)tblBoard.GetControlFromPosition(i, j)).Text = "";
                            }
                        }
                    }
                    tblBoard.ResumeLayout();
                }
                board = b;
            }
        }
Exemple #39
0
 /// <summary>
 /// Create plecement move.
 /// </summary>
 /// <param name="player">Player placing the stone.</param>
 /// <param name="stone">Stone to be placed.</param>
 /// <param name="pos">Position to place on.</param>
 public PlaceStone(Player player, Stone stone, Vector2Int pos) : base(player)
 {
     Stone    = stone;
     Position = pos;
 }
        /**
         * Check, if specified stone is touchable and return true if so
         * @param stone stone to check
         * @return true, if touchable
         */
        private bool StoneIsTouchable(Stone stone)
        {
            var leanSelectable = stone.gameObject.GetComponent <LeanSelectable>();

            return(leanSelectable.enabled);
        }
Exemple #41
0
 /**
  * stone not longer owend by Player
  *
  * @param stone to remove
  */
 public void RemoveStone(Stone stone)
 {
     _stones.Remove(stone);
 }
Exemple #42
0
 /**
  * add Stone to team, Stone can still be added to CanHoldHookableObject
  *
  * @param stone to add
  */
 public void AddStone(Stone stone)
 {
     _stones.Add(stone);
 }
Exemple #43
0
 private void PickUpStone(Stone stone)
 {
     pickedUpStone = stone;
     SoundManager.PlayPickUpStoneSound(transform.position);
     networkView.RPC ("SetAnimationControllerTrigger",RPCMode.AllBuffered,"grab");
     stone.networkView.RPC ("OnPickUp",RPCMode.AllBuffered,Network.AllocateViewID(),networkView.viewID);
     SetGodMode(false);
 }
Exemple #44
0
        private bool CheckBlockCollide(PlayerLocation location)
        {
            var bbox = GetBoundingBox();
            var pos  = location.ToVector3();

            var coords = new BlockCoordinates(
                (int)Math.Floor(KnownPosition.X),
                (int)Math.Floor((bbox.Max.Y + bbox.Min.Y) / 2.0),
                (int)Math.Floor(KnownPosition.Z));

            Dictionary <double, Block> blocks = new Dictionary <double, Block>();

            for (int x = -1; x < 2; x++)
            {
                for (int z = -1; z < 2; z++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        Block block = Level.GetBlock(coords.X + x, coords.Y + y, coords.Z + z);
                        if (block is Air)
                        {
                            continue;
                        }

                        BoundingBox blockbox = block.GetBoundingBox() + 0.3f;
                        if (blockbox.Intersects(GetBoundingBox()))
                        {
                            //if (!blockbox.Contains(KnownPosition.ToVector3())) continue;

                            if (block is FlowingLava || block is StationaryLava)
                            {
                                HealthManager.Ignite(1200);
                                continue;
                            }

                            if (!block.IsSolid)
                            {
                                continue;
                            }

                            blockbox = block.GetBoundingBox();

                            var midPoint = blockbox.Min + new Vector3(0.5f);
                            blocks.Add(Vector3.Distance((pos - Velocity), midPoint), block);
                        }
                    }
                }
            }

            if (blocks.Count == 0)
            {
                return(false);
            }

            var firstBlock = blocks.OrderBy(pair => pair.Key).First().Value;

            BoundingBox boundingBox = firstBlock.GetBoundingBox();

            if (!SetIntersectLocation(boundingBox, KnownPosition))
            {
                // No real hit
                return(false);
            }

            // Use to debug hits, makes visual impressions (can be used for paintball too)
            var substBlock = new Stone {
                Coordinates = firstBlock.Coordinates
            };

            Level.SetBlock(substBlock);
            // End debug block

            Velocity = Vector3.Zero;
            return(true);
        }
 internal string GetStone()
 {
     return(Stone.GetValue().ToString());
 }
 public void OnEventRaised(Stone s)
 {
     Response.Invoke(s);
 }
 public void remove(Stone tempcard)
 {
     cards.Remove(tempcard);
 }
        public int boardPointForWinner(List <Stone> playerStones, Player player)
        {
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num8 = 0;

            while (true)
            {
                if (num8 >= playerStones.Count)
                {
                    int num5 = 0;
                    int num9 = 0;
                    while (true)
                    {
                        if (num9 >= playerStones.Count)
                        {
                            num /= 2;
                            Console.WriteLine("Player has " + num3.ToString() + " in pair.");
                            Console.WriteLine("Player has " + num.ToString() + " half pair.");
                            Console.WriteLine("Player has " + num2.ToString() + " one stone.");
                            Console.WriteLine("If everything goes as player wants " + num5.ToString() + " moves advantage occurs!");
                            Console.WriteLine("If Player goes double " + player.getDoubleScore().ToString() + " moves needed!");
                            if (player.getHasJoker())
                            {
                                Console.WriteLine("Player has Joker!");
                                num2--;
                            }
                            int num6 = ((num2 - num) < 0) ? 1 : 2;
                            int num7 = player.getPriority() ? 1 : 0;
                            if (num7 == 1)
                            {
                                Console.WriteLine("Player starts game! Has One move advantage from others");
                            }
                            num4 = (num6 != 1) ? (num2 - (num5 + num7)) : (((num - num2) + num) - (num5 + num7));
                            player.setPairScore(num4);
                            return(num4);
                        }
                        Stone stone2 = playerStones[num9];
                        if (stone2.getIsNothing())
                        {
                            int num10 = 0;
                            while (true)
                            {
                                if (num10 >= playerStones.Count)
                                {
                                    break;
                                }
                                Stone stone3 = playerStones[num10];
                                int   num11  = stone2.getValue() - stone3.getValue();
                                if ((stone2.getValue() != stone3.getValue()) || (stone2.getColor() != stone3.getColor()))
                                {
                                    if (((num11 == 2) && (stone3.getIsNothing() || stone3.getIsRightOfPair())) && (stone2.getColor() == stone3.getColor()))
                                    {
                                        num5++;
                                        break;
                                    }
                                    if (((num11 == 2) && (stone3.getIsNothing() || stone3.getIsMemberOfHalfPair())) && (stone2.getColor() == stone3.getColor()))
                                    {
                                        num5++;
                                        break;
                                    }
                                }
                                num10++;
                            }
                        }
                        num9++;
                    }
                }
                Stone stone = playerStones[num8];
                if (stone.getIsMemberOfPair())
                {
                    num3++;
                }
                else if (stone.getIsMemberOfHalfPair() && stone.getRightNode().getIsMemberOfPair())
                {
                    num3++;
                }
                else if (stone.getIsRightOfPair() && stone.getLeftNode().getIsMemberOfPair())
                {
                    num3++;
                }
                else if (stone.getIsMemberOfHalfPair() && stone.getRightNode().getIsRightOfPair())
                {
                    num++;
                }
                else if (stone.getIsRightOfPair() && stone.getLeftNode().getIsMemberOfHalfPair())
                {
                    num++;
                }
                else if (stone.getIsNothing())
                {
                    num2++;
                }
                num8++;
            }
        }
 /**
  * check if stone is child of CanHoldHookableObject
  *
  * @param stone Stone to check
  */
 public abstract bool IsStoneInCanHoldHookableObject(Stone stone);
        public void Search(Stone me)
        {
            //Console.WriteLine("Thinking in {0} Counts and current deep is {1}", _queue.Count, _queue.Peek().Depth);

            while (_queue.Count != 0 && _queue.Peek().Depth > 0)
            {
                try
                {
                    var node = _queue.Dequeue();
                    Eval(node, me);
                }
                catch(OutOfMemoryException e)
                {
                    break;
                }
            }
        }
Exemple #51
0
 public void remove(Stone tempcard)
 {
     card = null;
 }
Exemple #52
0
        //returns the field the Player wants to visit
        public int[] SetStep(Map m, Token.PlayerColor color, int[] pos, int check, Control contrl, List<int[]> taken)
        {
            int[,] help;
            Random r = new Random();
            int r1;
            List<int[]> priority = new List<int[]>();
            List<int[]> visitable = new List<int[]>();

            if (m.Field[pos[0], pos[1]].Tok == "stone")
            {
                Token.PlayerColor c = m.Field[pos[0], pos[1]].Color;
                help = new Stone(c).nextStep(m, pos);//field of information where you can move, or have to move a stone
            }
            else
            {
                Token.PlayerColor c = m.Field[pos[0], pos[1]].Color;
                help = new Draught(c).nextStep(m, pos);//field of information where you can move, or have to move a draught
            }

            for (int a = 0; a < help.GetLength(1); ++a)
            {
                for (int b = 0; b < help.GetLength(1); ++b)
                {
                    if (help[a, b] == 1) priority.Add(new int[] { a, b }); //builds a list of field with priority
                    if (help[a, b] == 0) visitable.Add(new int[] { a, b });//builds a list of field which are visitable
                }
            }
            int[] temp;
            Token[,] field = m.Field;
            if (priority.Count != 0)
            {//if there are fields with higher priority
                for(int i=0; i<priority.Count; i++)
                {
                    temp = new int[] { priority[i][0], priority[i][1] };
                    contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] };
                    return temp;
                }
            }
            else
            {
                for(int i=0; i<visitable.Count; i++)
                {
                    temp = new int[] { visitable[i][0], visitable[i][1] };
                    if (!removeTokens(field, color, temp, m))
                    {
                        contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] };
                        return temp;
                    }
                }
            }
            if (check < 80)
            {
                taken.Add(pos);
                return SetStep(m, color, ChooseToken(m, color, taken), check + 1, contrl, taken);
            }
            else
            {
                if (priority.Count != 0)
                {//if there are fields with higher priority
                    r1 = r.Next(0, priority.Count);
                    temp = new int[] { priority[r1][0], priority[r1][1] };//choose a random field
                }
                else
                {
                    r1 = r.Next(0, visitable.Count);
                    temp = new int[] { visitable[r1][0], visitable[r1][1] };//choose a random field
                }
                contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] };
                return temp;
            }
        }
 public RoutedMovePlayedEventArgs(RoutedEvent routedEvent, object source, GoBoardPoint pos, Stone stoneColor)
     : base(routedEvent, source)
 {
     Position = pos;
     StoneColor = stoneColor;
 }
 public PartialViewResult ProductSummary(Stone product)
 {
     return(PartialView(product));
 }
        // Methods
        public List <Stone> boardManager(List <Stone> playerBoard, Player player)
        {
            int                  doubleCount = 0;
            List <Stone>         list        = new List <Stone>();
            List <Stone>         colorGroup  = new List <Stone>();
            List <Stone>         list3       = new List <Stone>();
            List <Stone>         list4       = new List <Stone>();
            List <Stone>         list5       = new List <Stone>();
            List <List <Stone> > y           = new List <List <Stone> >();
            List <List <Stone> > list7       = new List <List <Stone> >();
            List <List <Stone> > list8       = new List <List <Stone> >();
            List <List <Stone> > list9       = new List <List <Stone> >();
            List <Stone>         list10      = new List <Stone>();
            List <Stone>         list11      = new List <Stone>();
            List <Stone>         list12      = new List <Stone>();
            List <Stone>         list13      = new List <Stone>();
            List <Stone>         result      = new List <Stone>();

            Stone stone = playerBoard.Find(item => item.getIsJoker());

            if (stone != null)
            {
                list.Add(stone);
                player.setHasJoker();
                playerBoard.Remove(stone);
            }
            Stone stone2 = playerBoard.Find(item => item.getIsJoker());

            if (stone2 != null)
            {
                list.Add(stone2);
                player.setHasJoker();
                playerBoard.Remove(stone2);
            }
            int num4 = 0;

            while (true)
            {
                if (num4 == playerBoard.Count)
                {
                    break;
                }
                else if (playerBoard[num4].getColor() == "Yellow")
                {
                    colorGroup.Add(playerBoard[num4]);
                }
                else if (playerBoard[num4].getColor() == "Blue")
                {
                    list5.Add(playerBoard[num4]);
                }
                else if (playerBoard[num4].getColor() == "Black")
                {
                    list4.Add(playerBoard[num4]);
                }
                else if (playerBoard[num4].getColor() == "Red")
                {
                    list3.Add(playerBoard[num4]);
                }
                num4++;
            }

            if (colorGroup.Count > 0)
            {
                y           = this.checkPairs(colorGroup);
                doubleCount = this.checkDoubles(colorGroup, doubleCount);
                this.finishBoard(y, result, 1);
            }
            if (list3.Count > 0)
            {
                list7       = this.checkPairs(list3);
                doubleCount = this.checkDoubles(list3, doubleCount);
                this.finishBoard(list7, result, 1);
            }
            if (list4.Count > 0)
            {
                list9       = this.checkPairs(list4);
                doubleCount = this.checkDoubles(list4, doubleCount);
                this.finishBoard(list9, result, 1);
            }
            if (list5.Count > 0)
            {
                list8       = this.checkPairs(list5);
                doubleCount = this.checkDoubles(list5, doubleCount);
                this.finishBoard(list8, result, 1);
            }
            if (colorGroup.Count > 0)
            {
                this.finishBoard(y, result, 2);
            }
            if (list3.Count > 0)
            {
                this.finishBoard(list7, result, 2);
            }
            if (list5.Count > 0)
            {
                this.finishBoard(list8, result, 2);
            }
            if (list4.Count > 0)
            {
                this.finishBoard(list9, result, 2);
            }
            int num3 = (player.getMyBoard().Count - (2 * doubleCount)) / 2;

            player.setDoubleScore(num3);
            for (int i = 0; i < list.Count; i++)
            {
                result.Add(list[i]);
            }
            return(result);
        }
Exemple #56
0
 /**
  * check if stone belongs to Team
  *
  * @param stone to check
  */
 public bool ContainsStone(Stone stone)
 {
     //will cause null pointer exception if contains called and some stones are null if deleted?
     return(_stones.Contains(stone));
 }
        public void Eval(Node node, Stone me)
        {
            Board.ReverseParam param = node.Board.PutStoneWithReverse(node.Place[0], node.Place[1], node.Board.HandStone);

            if (!param.CanPlace)
            {
                dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] = int.MinValue / 2;
                return;
            }

            node.Depth -= 1;

            List<int[]> placeable = node.Board.PlaceablePoints;

            int placeableCount = placeable.Count;
            placeableCount *= placeableCount;

            //自身の評価

            if (node.Board.HandStone == me)
                node.Value += placeableCount;
            else
                node.Value -= placeableCount;

            dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] += node.Value;

            //Console.WriteLine("{0},{1} Changed => {2}", node.Parent[0], node.Parent[1], node.Value);

            //次に置ける場所がない
            if (placeable.Count == 0)
            {
                if (node.Board.HandStone == me) //自分の番でパスするのは
                    dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] = int.MinValue / 2; //最悪なのでその先は探索しない
                else
                {
                    //相手の番でパスする
                    Board past = new Board(node.Board);

                    past.Pass();

                    //かつ自分もパス
                    if (past.PlaceablePoints.Count == 0)
                    {
                        past.Pass();
                        int[] Counts = past.CountStones();
                        switch (me)
                        {
                            case Stone.Black:
                                {
                                    if (Counts[0] > Counts[1]) //両方共パスして勝っているなら
                                        dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] = int.MaxValue / 2; //最高
                                    break;
                                }
                            case Stone.White:
                                {
                                    if(Counts[0] < Counts[1])
                                        dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] = int.MaxValue / 2;
                                    break;
                                }
                        }
                    }
                    else
                    {
                        //自分はパスしない(相手にだけパスさせる)なら
                        dict[string.Format("{0},{1}", node.Parent[0], node.Parent[1])] += 100; //評価を上げる
                    }
                }
            }

            //Console.WriteLine("{0},{1} Changed => {2}", node.Parent[0], node.Parent[1], node.Value);

            //次の世代を生成

            foreach (var n in placeable)
            {
                Node next = new Node() { Parent = node.Parent, Place = n, Board = new Board(node.Board), Depth = node.Depth, Value = node.Value };
                _queue.Enqueue(next);
            }
        }
        public List <List <Stone> > checkPairs(List <Stone> colorGroup)
        {
            bool                 flag  = true;
            List <Stone>         item  = new List <Stone>();
            List <Stone>         list2 = new List <Stone>();
            List <List <Stone> > list3 = new List <List <Stone> >();
            int num4 = 0;

            while (true)
            {
                if (num4 >= colorGroup.Count)
                {
                    int num6 = 0;
                    while (true)
                    {
                        if (num6 >= colorGroup.Count)
                        {
                            list3.Add(item);
                            list3.Add(list2);
                            return(list3);
                        }
                        Stone stone2 = colorGroup[num6];
                        if (stone2.getIsMemberOfHalfPair())
                        {
                            item.Add(stone2);
                            while (true)
                            {
                                if (flag)
                                {
                                    Stone stone3 = stone2.getRightNode();
                                    item.Add(stone3);
                                    if (stone3.getHasRight())
                                    {
                                        flag   = true;
                                        stone2 = stone3;
                                        continue;
                                    }
                                    flag = false;
                                }
                                flag = true;
                                break;
                            }
                        }
                        if (!stone2.getHasRight() && !stone2.getHasLeft())
                        {
                            list2.Add(stone2);
                        }
                        num6++;
                    }
                }
                Stone left = colorGroup[num4];
                int   num  = left.getValue();
                int   num5 = 0;
                while (true)
                {
                    if (num5 >= colorGroup.Count)
                    {
                        num4++;
                        break;
                    }
                    int num2 = colorGroup[num5].getValue();
                    int num3 = num + 1;
                    if (((num2 == num3) && !left.getHasRight()) && !colorGroup[num5].getHasLeft())
                    {
                        left.rightNode(colorGroup[num5]);
                        colorGroup[num5].leftNode(left);
                    }
                    num5++;
                }
            }
        }
Exemple #59
0
    private void Update()
    {
        if (!isGameover)
        {
            if (Judgment())
            {
                if (winStoneType)
                {
                    Debug.Log("Player win!");
                }
                else
                {
                    Debug.Log("AI win!");
                }
                foreach (var data in GameData.NetWorks)
                {
                    GameData.AllNetWorks.Add(data);
                }
                QValueUpdate(winStoneType);
                for (int i = 0; i < GameData.AllNetWorks.Count; i++)
                {
                    for (int z = 3; z >= 0; z--)
                    {
                        string datastr = "";
                        for (int x = 0; x < 4; x++)
                        {
                            datastr += GameData.AllNetWorks[i].qValue[x, z] + ", ";
                        }
                        Debug.Log(datastr);
                    }
                    Debug.Log("=====================================================================");
                }
                isGameover = true;
                string str = "{\n";
                foreach (var data in GameData.AllNetWorks)
                {
                    //for(data.is_stone)
                }
                StreamWriter sw = new StreamWriter(@"data.json");
                sw.Write(str);
                sw.Close();
                SceneManager.LoadScene("GameScene");
            }
        }


        if (Input.GetMouseButtonDown(0))
        {
            // マウスクリック開始(マウスダウン)時にカメラの角度を保持(Z軸には回転させないため).
            newAngle          = MainCamera.transform.localEulerAngles;
            lastMousePosition = Input.mousePosition;
        }
        else if (Input.GetMouseButton(0))
        {
            // マウスの移動量分カメラを回転させる.
            newAngle.y += (Input.mousePosition.x - lastMousePosition.x) * 0.5f;
            newAngle.x -= (Input.mousePosition.y - lastMousePosition.y) * 0.5f;

            if (newAngle.x > 70)
            {
                newAngle.x = 70;
            }
            else if (newAngle.x < 0)
            {
                newAngle.x = 0;
            }

            MainCamera.gameObject.transform.localEulerAngles = newAngle;

            lastMousePosition = Input.mousePosition;
        }

        if (TurnTimer > 0)
        {
            TurnTimer -= Time.deltaTime;
            if (TurnTimer <= 0)
            {
                TurnTimer = 0;
                GameTurnCount++;
                putPlayerStone = false;
                putEnemyStone  = false;
            }
        }

        if (GameTurnCount % 2 == 0 && !putPlayerStone)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = new Ray();
                RaycastHit hit = new RaycastHit();
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                //マウスクリックした場所からRayを飛ばし、オブジェクトがあればtrue
                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
                {
                    if (hit.collider.gameObject.layer == 8)
                    {
                        firstPos = hit.collider.transform.position;
                    }
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                Ray        ray = new Ray();
                RaycastHit hit = new RaycastHit();
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                //マウスクリックした場所からRayを飛ばし、オブジェクトがあればtrue
                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
                {
                    if (hit.collider.gameObject.layer == 8)
                    {
                        Vector3 pos = hit.collider.transform.position;

                        if (pos == firstPos && puttingStone[(int)pos.x, (int)pos.z] < 4)
                        {
                            pos.y = 3.75f;
                            puttingStone[(int)pos.x, (int)pos.z]++;
                            Stone stone = Instantiate(PlayerStonePrefab, pos, Quaternion.identity);
                            stone.stoneType = StoneType.PLAYER;
                            stone.CountData = GameTurnCount;
                            TurnTimer       = 1f;
                            putPlayerStone  = true;
                        }

                        firstPos = Vector3.zero;
                    }
                }
            }
        }

        if (GameTurnCount % 2 == 1 && !putEnemyStone)
        {
            int posX = 0;
            int posZ = 0;
            int rand = Random.Range(0, 10);
            while (true)
            {
                float maxQ = 0;
                if (rand >= 3)
                {
                    foreach (var data in GameData.AllNetWorks)
                    {
                        if (data.is_stone == GameData.boardData.is_stone &&
                            data.stone_type == GameData.boardData.stone_type &&
                            data.enemyPos == GameData.boardData.enemyPos)
                        {
                            for (int x = 0; x < 4; x++)
                            {
                                for (int z = 0; z < 4; z++)
                                {
                                    if (maxQ < data.qValue[x, z])
                                    {
                                        if (puttingStone[posX, posZ] >= 4)
                                        {
                                            continue;
                                        }
                                        maxQ = data.qValue[x, z];
                                        posX = x;
                                        posZ = z;
                                    }
                                }
                            }
                        }
                    }
                    if (maxQ == 0)
                    {
                        rand = 0;
                        continue;
                    }
                }
                else
                {
                    posX = Random.Range(0, 4);
                    posZ = Random.Range(0, 4);
                    if (puttingStone[posX, posZ] >= 4)
                    {
                        continue;
                    }
                }

                Stone stone = Instantiate(EnemyStonePrefab, new Vector3(posX, 3.75f, posZ), Quaternion.identity);
                stone.stoneType = StoneType.ENEMY;
                stone.CountData = GameTurnCount;
                TurnTimer       = 1f;
                putEnemyStone   = true;
                puttingStone[posX, posZ]++;
                break;
            }
        }
    }
Exemple #60
0
        private void PlaceStone(Stone stone)
        {
            GoNode node = null;

            foreach (var child in Game.CurrentNode.ChildNodes)
            {
                if (child is GoMoveNode)
                {
                    if ((child as GoMoveNode).Stone.X == stone.X &&
                        (child as GoMoveNode).Stone.Y == stone.Y)
                    {
                        node    = child;
                        message = string.Empty;
                        break;
                    }
                }
            }
            if (node != null)
            {
                Game.ToMove(node);
                if (Game.CurrentNode is GoMoveNode)
                {
                    SoundUtils.Play("Stone");
                }
                var count = node.ChildNodes.Count;
                if (count > 0)
                {
                    var variant = random.Next(0, count - 1);
                    Game.ToMove(node.ChildNodes[variant]);
                    if (Game.CurrentNode is GoMoveNode)
                    {
                        SoundUtils.Play("Stone");
                    }
                    playerTurn = true;
                }
                else
                {
                    playerTurn = false;
                }

                if (!Game.CurrentNode.HasChildren)
                {
                    if (format.IsRightVariant(Game.CurrentNode))
                    {
                        message = "Solved";
                    }
                    else
                    {
                        message = "Wrong";
                    }
                }

                Invalidate();
                SetComment();
            }
            else
            {
                message = "No path";
                Invalidate();
            }
        }