예제 #1
0
        private void ChangeTotalLabel(int num, PLAYERS player)
        {
            if (num < 0)
            {
                throw new ArgumentOutOfRangeException("The number to write to the label cannot be negative.", nameof(num));
            }

            switch (player)
            {
            case PLAYERS.Dealer:
                if (num == 0)
                {
                    this.DealerBoxHeader = DEALER_HIDDEN_HEADER_TEXT;
                }
                else
                {
                    this.DealerBoxHeader = String.Format(DEALER_HEADER_TEXT, num);
                }
                RaisePropertyChanged(nameof(DealerBoxHeader));
                break;

            case PLAYERS.Human:
                if (num == 0)
                {
                    this.PlayerBoxHeader = PLAYER_HIDDEN_HEADER_TEXT;
                }
                else
                {
                    this.PlayerBoxHeader = String.Format(PLAYER_HEADER_TEXT, num);
                }
                RaisePropertyChanged(nameof(PlayerBoxHeader));
                break;
            }
        }
예제 #2
0
        private void PlayerConfirm(int id, String token, String nickname, String age, String sex, String description)
        {
            TOKENS t = (from data in c.TOKENS
                        where data.VALUE_TOKEN.Contains(token)
                        select data).FirstOrDefault();

            c.TOKENS.Remove(t);
            c.SaveChanges();

            USERS u = (from data in c.USERS
                       where data.ID_USER == id
                       select data).FirstOrDefault();

            u.STATUS_USER = 2;
            c.SaveChanges();

            PLAYERS p = new PLAYERS()
            {
                ID_USER            = id,
                NICK_PLAYER        = nickname,
                AGE_PLAYER         = int.Parse(age),
                SEX_PLAYER         = sex,
                DESCRIPTION_PLAYER = description,
                PP_PLAYER          = 0,
                NP_PLAYER          = 0,
                SEALS_PLAYER       = 0,
                LEVEL_PLAYER       = 1
            };

            c.PLAYERS.Add(p);
            c.SaveChanges();
        }
예제 #3
0
        public double GetArmy(int team)
        {
            double army = 0;

            foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team))
            {
                army += pl.ARMY;
            }
            return(army / 1000);
        }
예제 #4
0
        public double GetIncome(int team)
        {
            double income = 0;

            foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team))
            {
                income += pl.INCOME;
            }
            return(income / 1000);
        }
예제 #5
0
        public double GetKilled(int team)
        {
            double kills = 0;

            foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team))
            {
                kills += pl.KILLSUM;
            }
            return(kills / 1000);
        }
예제 #6
0
        public List <string> _RACES()
        {
            List <string> races = new List <string>();

            foreach (dsplayer pl in PLAYERS.OrderBy(o => o.REALPOS))
            {
                races.Add(pl.RACE);
            }
            return(races);
        }
예제 #7
0
        public void CreatePlayer(string nick, string pass)
        {
            PLAYERS pl = new PLAYERS();

            pl.NickName = nick;
            pl.Password = pass;
            pl.Coins    = 1000;


            bJContext.PLAYERS.Add(pl);
            bJContext.SaveChanges();
        }
예제 #8
0
		public Game() {
			gameInProgress = false;
			winner = PLAYERS.NEITHER;
			computer = PLAYERS.P1;
			human = PLAYERS.P2;
			computerColor = ConsoleColor.DarkGreen;
			humanColor = ConsoleColor.White;
			board = new PIECES[8, 6];
			zBoard = new long[48, 10];
			currentHash = 0;
			removals = new Stack<Removal>();
		}//end of constructor
예제 #9
0
        public void Init()
        {
            MINKILLSUM  = _MINKILLSUM();
            MAXKILLSUM  = _MAXKILLSUM();
            MINARMY     = _MINARMY();
            MININCOME   = _MININCOME();
            MAXLEAVER   = _MAXLEAVER();
            PLAYERCOUNT = PLAYERS.Count;

            FixPos();
            PLAYERS = PLAYERS.OrderBy(x => x.REALPOS).ToList();
            RACES   = _RACES();
        }
예제 #10
0
 private void RememberJustPlayed(PLAYERS played)
 {
     if (played == PLAYERS.PLAYER_X)
     {
         m_justPlayed    = PLAYERS.PLAYER_X;
         m_justNotPlayed = PLAYERS.PLAYER_O;
     }
     else
     {
         m_justPlayed    = PLAYERS.PLAYER_O;
         m_justNotPlayed = PLAYERS.PLAYER_X;
     }
 }
예제 #11
0
		}//end of IsGameOver method

		public List<Move> MoveGenerator(PLAYERS player) {
			List<Move> returnValue;
			if(player == PLAYERS.P1) {
				returnValue = MoveGenP1();
			}
			else if(player == PLAYERS.P2) {
				returnValue = MoveGenP2();
			}
			else {
				returnValue = new List<Move>();
			}
			return returnValue;
		}//end of MoveGenerator method
예제 #12
0
		}//end of StartGame method

		public bool IsMoveLegal(int[] move, PLAYERS player) {
			bool returnValue = false;
			Move checkMove = new Move(move);
			List<Move> legalMoves = MoveGenerator(player);
//			Console.WriteLine("Moves Generated:");
			foreach(Move m in legalMoves) {
				//DEBUG
//				Console.WriteLine($"\t{m.ToString()}");
				//END DEBUG				
				if(checkMove == m) {
					returnValue = true;
				}
			}
			return returnValue;
		}//end of IsMoveLegal method
예제 #13
0
        public void UpdatePlayer(int playerID, int WinnerID)
        {
            PLAYERS pl = GetPLAYERS(playerID);

            pl.GamesCount++;

            if (playerID == WinnerID)
            {
                pl.WinCount++;
            }


            bJContext.PLAYERS.Attach(pl);
            bJContext.Entry(pl).State = System.Data.Entity.EntityState.Modified;
            bJContext.SaveChanges();
        }
예제 #14
0
        public string GenHash()
        {
            string md5        = "";
            string hashstring = "";

            foreach (dsplayer pl in PLAYERS.OrderBy(o => o.POS))
            {
                hashstring += pl.POS + pl.RACE;
            }
            hashstring += MINARMY + MINKILLSUM + MININCOME + MAXKILLSUM;
            using (MD5 md5Hash = MD5.Create())
            {
                md5 = GetMd5Hash(md5Hash, hashstring);
            }
            HASH = md5;
            return(md5);
        }
예제 #15
0
        private PLAYERS GetPLAYERS(int playerID)
        {
            PLAYERS pl = new PLAYERS();

            using (var db = new BJContext())
            {
                var query = from s in db.PLAYERS
                            where s.PlayerID == playerID
                            select s;

                foreach (var student in query)
                {
                    if (student.PlayerID != 0)
                    {
                        pl = student;
                    }
                }
            }
            return(pl);
        }
예제 #16
0
		}//end of UndoMove method

		public bool IsGameOver() {
			bool returnValue = false;
			bool p1KingFound = false;
			for(int i = 0; i < 8; i++) {
				for(int j = 0; j < 6; j++) {
					if(board[i, j] == PIECES.P1_KING) {
						p1KingFound = true;
						break;
					}
				}
				if(p1KingFound) {
					break;
				}
			}
			if(!p1KingFound || MoveGenerator(PLAYERS.P1).Count == 0) {
				winner = PLAYERS.P2;
				returnValue = true;
			}
			bool p2KingFound = false;
			for(int i = 0; i < 8; i++) {
				for(int j = 0; j < 6; j++) {
					if(board[i, j] == PIECES.P2_KING) {
						p2KingFound = true;
						break;
					}
				}
				if(p2KingFound) {
					break;
				}
			}
			if(!p1KingFound || MoveGenerator(PLAYERS.P1).Count == 0) {
				winner = PLAYERS.P2;
				returnValue = true;
			}
			if(!p2KingFound || MoveGenerator(PLAYERS.P2).Count == 0) {
				winner = PLAYERS.P1;
				returnValue = true;
			}
			return returnValue;
		}//end of IsGameOver method
예제 #17
0
    public bool tryMove(PLAYERS player, int gridX, int gridY, int previousGridX, int previousGridY)
    {
        Player movingPlayer = player == PLAYERS.player1 ? player1 : player2;
        Player otherPlayer  = player == PLAYERS.player1 ? player2 : player1;

        bool checkLimits      = gridX < 0 || gridX >= gridWidth || gridY >= gridHeight || gridY < 0;
        bool checkOtherPlayer = otherPlayer.gridX == gridX && otherPlayer.gridY == gridY;

        if (!checkLimits && !checkOtherPlayer && tiles[gridX, gridY].checkIfCanMove(movingPlayer))
        {
            if (tileContent[gridX, gridY] != null)
            {
                if (tileContent[gridX, gridY].contentType == TILE_CONTENTS.obstacle)
                {
                    return(false);
                }
                if (tileContent[gridX, gridY].contentType == TILE_CONTENTS.powerUp)
                {
                    Destroy(tileContent[gridX, gridY].gameObject);
                    movingPlayer.getPowerup();
                    tileContent[gridX, gridY] = null;
                }
            }

            tiles[previousGridX, previousGridY].setOwner(movingPlayer);
            //empty the current tile
            //tiles[gridX, gridY].setOwner(null);

            if (Random.Range(0f, 1f) < gameSettings.powerUpsSpawnRate)
            {
                spawnPowerUp();
            }

            return(true);
        }

        return(false);
    }
예제 #18
0
    public void OnTriggerStay(Collider co)
    {
        // if (c < 0.1f) return;
        //GunBehavior gb = co.transform.root.GetComponent<GunBehavior>();
        //if (gb == null) gb = co.transform.GetComponent<GunBehavior>();

        PLAYERS pl = co.transform.root.GetComponent <PLAYERS>();

        if (pl == null)
        {
            pl = co.transform.GetComponent <PLAYERS>();
        }

        BulletBehaviour bb = co.transform.root.GetComponent <BulletBehaviour>();

        if (bb == null)
        {
            bb = co.transform.GetComponent <BulletBehaviour>();
        }

        if (bb != null)
        {
            Debug.Log("弾丸同士の接触");
            Destroy(gameObject);
            return;
        }

        if (pl == null /* && gb == null*/)
        {
            HittingObject(co, false);
        }
        else if (pl != null /*&& gb != null*/ && pl.userID != n /*&& gb.userID != n*/)
        {
            HittingObject(co, true);
        }
    }
예제 #19
0
		}//end of SetComputerPlayer method

		public void SetHumanPlayer(PLAYERS player) {
			human = player;
		}//end of SetHumanPlayer method
예제 #20
0
		}//end of GetWinner method

		public void SetComputerPlayer(PLAYERS player) {
			computer = player;
		}//end of SetComputerPlayer method
예제 #21
0
 public void setCurrentPlayer(int p)
 {
     currentPlayer = (PLAYERS)p;
     playerNumber  = p;
 }
예제 #22
0
 //勝者を設定
 public void SetWinner(PLAYERS winner)
 {
     DataManager.Instance.SetWinPlayer(winner);
 }
 // Start is called before the first frame update
 void Start()
 {
     players = GetComponent <PLAYERS>();
     wSel    = GetComponent <WeaponSelector>();
 }
예제 #24
0
 //勝者を設定
 public void SetWinPlayer(PLAYERS winner)
 {
     _Winner = winner;
 }