Ejemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         GAME.CheckpointSave();
     }
 }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         GAME.LoadScene(sceneName);
     }
 }
Ejemplo n.º 3
0
        public TeamModel GetGameByID(string id)
        {
            int        _id         = Convert.ToInt32(id);
            FileUpload fileservice = new FileUpload();

            using (SPORT_LINK_DBDataContext db = new SPORT_LINK_DBDataContext())
            {
                var query = from gm in db.GAMEs where gm.Game_Id.Equals(_id) select gm;
                if (query.Count() != 0)
                {
                    TeamModel data = new TeamModel();
                    GAME      gm   = query.First();
                    data.G_ID      = gm.Game_Id;
                    data.TeamOne   = gm.Team1;
                    data.TeamTwo   = gm.Team2;
                    data.Date      = Convert.ToString(gm.sDate);
                    data.Venue     = gm.Venue;
                    data.LeaguName = gm.LEAGUE.Name;
                    data.LeagueID  = Convert.ToInt32(gm.League_Id);
                    data.ImagePath = fileservice.getGameImagePathById(Convert.ToString(gm.Game_Id));
                    return(data);
                }
                else
                {
                    return(null);
                }
            };
        }
Ejemplo n.º 4
0
        public int AddMatch(Game game)
        {
            using (SPORT_LINK_DBDataContext db = new SPORT_LINK_DBDataContext())
            {
                var query = (from res in db.GAMEs where res.Game_Id.Equals(game.ID) && res.League_Id.Equals(game.LeagueID) select res);
                if (query.Count() == 0)     //AddGame
                {
                    GAME toinsert = new GAME();
                    //      toinsert.Game_Id = game.ID;
                    toinsert.Team1     = game.TeamOne;
                    toinsert.Team2     = game.TeamTwo;
                    toinsert.sDate     = game.sDate;
                    toinsert.Venue     = game.Venue;
                    toinsert.GameType  = game.Type;
                    toinsert.League_Id = game.LeagueID;
                    db.GAMEs.InsertOnSubmit(toinsert);
                    db.SubmitChanges();
                }
            };

            using (SPORT_LINK_DBDataContext db = new SPORT_LINK_DBDataContext())
            {
                var queryID = (from tm in db.GAMEs
                               select tm).ToList();
                GAME res = queryID.Last();
                int  ID  = res.Game_Id;
                return(ID);
            };
        }
Ejemplo n.º 5
0
    //Setujemo scene
    public void SetGameState(GAME state)
    {
        switch (state)
        {
        case GAME.MENU:
            menuPanel.SetActive(true);
            gameOverPanel.SetActive(false);
            playPanel.SetActive(false);
            break;

        case GAME.READY:
            menuPanel.SetActive(false);
            gameOverPanel.SetActive(false);
            playPanel.SetActive(true);
            break;

        case GAME.GAME_OVER:
            menuPanel.SetActive(false);
            gameOverPanel.SetActive(true);
            playPanel.SetActive(true);
            sudoku.fillValues();
            break;

        case GAME.PLAYING:
            break;
        }
    }
Ejemplo n.º 6
0
    void CreateGrid()
    {
        float W = GAME.Instance().mapSize.x / 2 + 5;
        float H = GAME.Instance().mapSize.y / 2 + 5;


        int noGrids = 20;

        float w = 2 * W / noGrids;
        float h = 2 * H / noGrids;

        var grid = new GameObject("Grid");

        for (int i = 0; i < noGrids; i++)
        {
            GameObject   lrGO = Instantiate(LinePrefab, parent: grid.transform);
            LineRenderer lr   = lrGO.GetComponent <LineRenderer>();
            lr.SetPositions(new Vector3[] { new Vector3(-W, -H + i * h, 0), new Vector3(W, -H + i * h, 0) });
        }

        for (int i = 0; i < noGrids; i++)
        {
            GameObject   lrGO = Instantiate(LinePrefab, parent: grid.transform);
            LineRenderer lr   = lrGO.GetComponent <LineRenderer>();
            lr.SetPositions(new Vector3[] { new Vector3(-W + i * w, -H, 0), new Vector3(-W + i * w, H, 0) });
        }
    }
Ejemplo n.º 7
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         GAME.StartFromLastSave();
     }
 }
Ejemplo n.º 8
0
		/// <summary>Expected to get called every frame, increacements timer</summary>
		public void update()
		{
			if(timer > 0f && canCount)
				timer -= GAME.DeltaTime / (float)GAME.GetFramerate();
			else if(timer <= 0f && !doOnce)
				stop();
		}
Ejemplo n.º 9
0
        public static int RollGold(GAME game, CLASSES Class)
        {
            setGoldDice(game, Class);
            int Dice       = 4;
            int multiplier = 10;
            int Gold       = 0;

            if (game == PATHFINDER)
            {
                Dice = 6;
            }
            if (game == DND5e)
            {
                if (Class == MONK)
                {
                    multiplier = 1;
                }
            }


            for (int i = 1; i <= GoldDice; i++)
            {
                Gold += (multiplier * Rolling.RollD(Dice));
            }
            return(Gold);
        }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        game = GAME.Instance();
        originalScoreScale = scoreText.transform.localScale;

        CreateGrid();
        Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);
    }
 public void AddGame(GAME game)
 {
     using (var gameContext = new GamesDBEntities())
     {
         gameContext.GAMES.Add(game);
         gameContext.SaveChanges();
     }
 }
Ejemplo n.º 12
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.collider.CompareTag("Wall"))
     {
         Rect currentMapSize = GAME.Instance().CurrentMapSize();
         transform.position = new Vector3(currentMapSize.center.x, currentMapSize.center.y, 0);
     }
 }
Ejemplo n.º 13
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         GAME.Instance().IncreaseScore(score);
         Action(player);
         Disappear();
     }
 }
Ejemplo n.º 14
0
 public connection_struct(string name, bool is_in_game, bool is_in_party, GAME current_game, bool online, int conn_id)
 {
     this.name         = name;
     this.is_in_game   = is_in_game;
     this.is_in_party  = is_in_party;
     this.current_game = current_game;
     this.online       = online;
     this.conn_id      = conn_id;
 }
Ejemplo n.º 15
0
        //khởi tạo giỏ hàng theo magame được truyền vào với so lượng mặc định là 1
        public Giohang(int MaGame)
        {
            iMaGame = MaGame;
            GAME game = data.GAMEs.Single(n => n.MaGame == iMaGame);

            sTenGame = game.TenGame;
            sAnhbia  = game.Anhbia;
            dDongia  = double.Parse(game.GiaBan.ToString());
            iSoluong = 1;
        }
Ejemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "CODGAME,CODUSER,CODPLATAFORMA,DESCRICAO,ANO")] GAME gAME)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gAME).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gAME));
 }
Ejemplo n.º 17
0
	void Awake()
	{
		instance = this;

		if (Application.platform == RuntimePlatform.Android) {
			for (int i=0; i<killIfAndroid.Length; i++) {
				Destroy (killIfAndroid [0]);
			}
		}
	}
        public void POST(GAME game, string username, int score)
        {
            string url = "";

            url = GetURLFromGame(game, username);
            web = new WWW(url, GetJSON(score));
            //WWW www = new WWW(url, form);

            user.StartCoroutine(ExecuteREST(web, "POST"));
        }
Ejemplo n.º 19
0
        public void Draw(int mx, int my, MouseState state)
        {
            GAME.SprBatch.Begin(sortMode: SpriteSortMode.FrontToBack, blendState: BlendState.NonPremultiplied, samplerState: SamplerState.PointClamp);
            var width  = GAME.SprBatch.GraphicsDevice.Viewport.Width;
            var height = GAME.SprBatch.GraphicsDevice.Viewport.Height;

            int chunkHCount = (int)Math.Ceiling(width / ZOOM_FACTOR) + 1;
            int chunkVCount = (int)Math.Ceiling(height / ZOOM_FACTOR) + 1;

            var LUCorner       = new Vector2(ViewX - 0.5f * width, ViewY - 0.5f * height);
            var initChunkPoint = new Vector2((float)Math.Floor(LUCorner.X / ZOOM_FACTOR), (float)Math.Floor(LUCorner.Y / ZOOM_FACTOR));
            var initDrawPoint  = new Vector2(-LUCorner.X + (int)initChunkPoint.X * ZOOM_FACTOR, -LUCorner.Y + (int)initChunkPoint.Y * ZOOM_FACTOR);

            //Game.DebugInfo.DebugMessage += $"Position: {new Vector2(ViewX, ViewY)}\n";

            for (int x = 0; x < chunkHCount; x++)
            {
                for (int y = 0; y < chunkVCount; y++)
                {
                    var chunkPos = new Vector2(initChunkPoint.X + x, initChunkPoint.Y + y);
                    var drawPos  = initDrawPoint + new Vector2(x * ZOOM_FACTOR, y * ZOOM_FACTOR);
                    GetChunk(chunkPos).Draw(drawPos);
                }
            }
            Game.DebugInfo.DebugMessage += $"Chunks: {_chunks.Count}\n";

            var xx = (LUCorner.X + mx) / (SCALE * CELL_SIZE);
            var yy = (LUCorner.Y + my) / (SCALE * CELL_SIZE);
            int cx = (int)Math.Floor(xx / CHUNK_SIZE);
            int cy = (int)Math.Floor(yy / CHUNK_SIZE);
            int vx = (int)Math.Floor(xx % CHUNK_SIZE);
            int vy = (int)Math.Floor(yy % CHUNK_SIZE);

            vx = (vx + CHUNK_SIZE) % CHUNK_SIZE;
            vy = (vy + CHUNK_SIZE) % CHUNK_SIZE;
            var chunk = GetChunk(cx, cy);

            chunk.DrawGrid(initDrawPoint + new Vector2((cx - initChunkPoint.X) * ZOOM_FACTOR, (cy - initChunkPoint.Y) * ZOOM_FACTOR), new Vector2(vx, vy));
            Game.DebugInfo.DebugMessage += chunk[vx, vy].ToString();
            if (state.RightButton == ButtonState.Pressed &&
                chunk[vx, vy].Content.Count > 0)
            {
                chunk[vx, vy].Content[0].Delete();
            }
            var gx = cx * CHUNK_SIZE + vx;
            var gy = cy * CHUNK_SIZE + vy;

            if (state.LeftButton == ButtonState.Pressed &&
                !GAME.SpawnExist(gx, gy))
            {
                GAME.AddSpawn(gx, gy);
            }

            GAME.SprBatch.End();
        }
Ejemplo n.º 20
0
        public static string displayRace(RACE R, GAME G)
        {
            string sub = null;

            if (G == DND5e)
            {
                sub = displayRace5e(R);
            }

            return(sub);
        }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        body = GetComponent <Rigidbody2D>();
        bulletSpawnOffset = transform.Find("BulletSpawnOffset");
        _GAME             = GAME.Instance();

        maxSpeed      = playerLevels.playerSpeedLevels[0];
        bulletSpeed   = playerLevels.bulletSpeedLevels[0];
        shootInterval = playerLevels.bulletShootIntervalLevels[0];
        noBullets     = playerLevels.bulletCountLevels[0];
        currentMana   = maxMana;
    }
Ejemplo n.º 22
0
        public static int RollHP(GAME game, CLASSES Class, int lv)
        {
            setHPDice(game, Class);

            int HP = HPDice;

            for (int i = 2; i <= lv; i++)
            {
                HP += Rolling.RollD(HPDice);
            }
            return(HP);
        }
Ejemplo n.º 23
0
        public static void displayBackground(int[] background, GAME G)
        {
            List <string> backgrounds = collectBackgrounds(G);

            frmref.BackgroundOutput.Text = backgrounds[background[0] - 1];
            frmref.TraitOutput.Text      = background[1].ToString();
            frmref.IdealOutput.Text      = background[2].ToString();
            frmref.BondOutput.Text       = background[3].ToString();
            frmref.FlawOutput.Text       = background[4].ToString();

            displayBackgroundSpecial(background[1], background[5]);
        }
Ejemplo n.º 24
0
        public EditGamePageDataContext(GAME game)
        {
            games          = new ObservableCollection <GAME>();
            genres         = new ObservableCollection <GENRES>();
            genreContainer = new ObservableCollection <GenreContainer>();

            day   = new List <string>();
            month = new List <string>();
            year  = new List <string>();

            InitGames();

            this.game = game;
            gameId    = game.ID;

            InitGameGenres();
            InitDescription();

            openFileDialogCommand          = new Command(ExecuteOpenFileDialog);
            openFileDialogCommandGameFile  = new Command(ExecuteOpenFileDialogGameFile);
            openFileDialogCommandBackImage = new Command(ExecuteOpenFileDialogBackImage);

            openFileDialogGameFile = new OpenFileDialog()
            {
                Multiselect = false,
                Filter      = "Executable file *.exe|*.EXE"
            };

            openFileDialog = new OpenFileDialog()
            {
                Multiselect = true,
                Filter      = "Image files (*.BMP, *.JPG, *.GIF, *.TIF, *.PNG, *.ICO, *.EMF, *.WMF)|*.bmp;*.jpg;*.gif; *.tif; *.png; *.ico; *.emf; *.wmf"
            };



            GameName  = game.NAME;
            Cost      = game.COST.ToString();
            Publisher = game.PUBLISHER;

            BackImage = game.BACK_IMAGE;

            Image = game.IMAGE;

            InitDays(ref day);
            OnPropertyChanged("Day");

            InitMonthes(ref month);
            OnPropertyChanged("Month");

            InitYears(ref year);
            OnPropertyChanged("Year");
        }
Ejemplo n.º 25
0
        // GET: Game/Create
        public ActionResult Create()
        {
            var idUser = User.Identity.GetUserId();

            GAME objGame = new GAME();

            objGame.CODUSER = idUser;
            objGame.ANO     = DateTime.Now.Year;

            ViewBag.CODPLATAFORMA = new SelectList(db.PLATAFORMA, "CODPLATAFORMA", "DESCRICAO");
            ViewBag.CODUSER       = new SelectList(db.AspNetUsers, "Id", "UserName", idUser);
            return(View(objGame));
        }
Ejemplo n.º 26
0
        public ActionResult Create([Bind(Include = "CODGAME,CODPLATAFORMA,CODUSER,DESCRICAO,ANO")] GAME gAME)
        {
            if (ModelState.IsValid)
            {
                gAME.TITULOEMPRESTADO = false;
                db.GAME.Add(gAME);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(gAME));
        }
        private string GetURLFromGame(GAME game, string username)
        {
            switch (game)
            {
            case GAME._2040:
                return(games.UrlScore2040(username));

            case GAME._Back2Earth:
                return(games.UrlBack2Earth(username));
            }

            return(null);
        }
        public void PUT(GAME game, string username, int score)
        {
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json");
            headers.Add("X-HTTP-Method-Override", "PUT");

            string url = GetURLFromGame(game, username);

            web = new WWW(url, GetJSON(score), headers);

            user.StartCoroutine(ExecuteREST(web, "PUT"));
        }
Ejemplo n.º 29
0
 protected void Update()
 {
     if (dayTimerIsStarted)
     {
         dayTimer -= Time.deltaTime;
         if (dayTimer <= 0)
         {
             ++_daysSurvived;
             dayTimerIsStarted = false;
             GAME.EndGame();
         }
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            EMPRESTIMO eMPRESTIMO = db.EMPRESTIMO.Find(id);

            db.EMPRESTIMO.Remove(eMPRESTIMO);

            GAME objGame = db.GAME.Find(eMPRESTIMO.CODGAME);

            objGame.TITULOEMPRESTADO = false;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 31
0
 public static void setHPDice(GAME game, CLASSES Class)
 {
     if (game == PATHFINDER)
     {/*
       * //12
       * if (Class == 1)
       * {
       *     HPDice = 12;
       * }
       *
       * //8
       * else if ((Class == 2) || (Class == 3) || (Class == 4) || (Class == 6)|| (Class == 9)|| (Class == 15) || (Class == 16) || (Class == 17) || (Class == 18) || (Class == 21) || (Class == 22) || (Class == 24) || (Class == 25) || (Class == 26))
       * {
       *     HPDice = 8;
       * }
       *
       * //10
       * else if ((Class == 5)|| (Class == 7)|| (Class == 8)|| (Class == 13)|| (Class == 14)||(Class == 19) || (Class == 20) || (Class == 23) || (Class == 28))
       * {
       *     HPDice = 10;
       * }
       * //6
       * else if ((Class == 10)|| (Class == 11)|| (Class == 12)|| (Class == 27))
       * {
       *     HPDice = 6;
       * }*/
     }
     else if (game == DND5e)
     {
         // 12 barbarian
         //8 bard cleric druid monk rogue warlock
         //10 fighter paladin ranger
         //6 sorcerer wizard
         if (Class == BARBARIAN)
         {
             HPDice = 12;
         }
         else if ((Class == BARD) || (Class == CLERIC) || (Class == DRUID) || (Class == MONK) || (Class == ROGUE) || (Class == WARLOCK))
         {
             HPDice = 8;
         }
         else if ((Class == FIGHTER) || (Class == PALADIN) || (Class == RANGER))
         {
             HPDice = 10;
         }
         else if ((Class == SORCERER) || (Class == WIZARD))
         {
             HPDice = 6;
         }
     }
 }
Ejemplo n.º 32
0
 private void AddRemovePlaform(GAME.Modules.Warframe.Common.Missions.Enums.Platforms platform)
 {
     _oData.Platforms ^= platform;
 }
Ejemplo n.º 33
0
        public PlacedOrder ExecuteConsolidate(GameState gs, GAME.MODELS.HOUSE h, ref List<PlacedOrder> placedOrderList, ref List<Region> regionList, out string descText)
        {
            List<PlacedOrder> amibolValaszthatunk = new List<PlacedOrder>();

            foreach (var item in placedOrderList)
            {
                if (item.order == ORDER_TYPE.CONDSOLIDATE || item.order == ORDER_TYPE.CONDSOLIDATE_PLUS)
                {
                    if (item.ownerPlayerName == h)
                    {
                        amibolValaszthatunk.Add(item);
                    }
                }
            }

            // na szoval
            //ezek igazabol terulet foglalo  tokenek, szoval ahol vegrehajtjuk ott az a mienklesz
            if( amibolValaszthatunk.Count > 0 )
            {
                PlacedOrder vegreh = amibolValaszthatunk[0];

                for (int i = 0; i < regionList.Count; i++)
                {
                    if (regionList[i].name == vegreh.regionFrom.name)
                    {
                        regionList[i].house = h;
                    }
                }

                descText = h + " use " + vegreh.order.ToString() + " at: " + vegreh.regionFrom.name;

                return vegreh;
            }

            throw new Exception("szintén");

            //foreach (var item in amibolValaszthatunk)
            //{
            //    Region temp = new Region();
            //    for( int i = 0; i < regionList.Count; i++)
            //    {
            //        if ( item.regionFrom.name == regionList[i].name)
            //        {
            //            temp = regionList[i];
            //            temp.house = h;
            //            regionList.Remove(regionList[i]);
            //            regionList.Insert(i, temp);
            //        }
            //    }
            //}
            //
            ////mostmar h jol elfoglaltuk a helyeket, toroljuk a parancsokat
            //
            //foreach (var v in amibolValaszthatunk)
            //{
            //    for (int i = 0; i < placedOrderList.Count; i++)
            //    {
            //        if (v.regionFrom == placedOrderList[i].regionFrom)
            //        {
            //            placedOrderList.Remove(placedOrderList[i]);
            //        }
            //    }
            //}
        }
Ejemplo n.º 34
0
        public void Recruit( GameState gs, GAME.MODELS.HOUSE h, ref List<GAME.MODELS.Unit> unitList )
        {
            //kinyerjuk a szajbatekert, de lenyeges adatokat az aktualis allasbol

            //ez a max elkoltheto
            int MusteringPoints = gs.PlayerList.Where(p => p.playerHouse == h).First().musteringPoints;
            //megnezzuk h mi lenne a legjobb belole

            int allUnitCount = gs.UnitsList.Where(u => u.player == h).Count();
            int soldierCount = gs.UnitsList.Count(u => u.player == h && u.type == GAME.MODELS.UNIT_TYPE.SOLDIER);
            int knightCount = gs.UnitsList.Count(u => u.player == h && u.type == GAME.MODELS.UNIT_TYPE.KNIGHT);
            int machineCount = gs.UnitsList.Count(u => u.player == h && u.type == GAME.MODELS.UNIT_TYPE.MACHINE);

            bool recSold = false;
            bool recKnight = false;
            bool recMach = false;
            //torekedunk az S-K-M 40-40-20 aranyra
            if ( (soldierCount / allUnitCount) < 0.4f)
            {
                //katonat vonunk be
                recSold = true;
            }

            if ((knightCount / allUnitCount) < 0.4f)
            {
                //katonat vonunk be
                recKnight = true;
            }

            if ((machineCount / allUnitCount) < 0.2f)
            {
                //katonat vonunk be
                recMach = true;
            }

            //mostmar tudjuk h mit kell bevonni
            // kiszamoljuk h menyi DB-t kellene bevonni, majd ezt aranyositjuk az összes bevonhato pont alapjan
            int shouldrecS = 0;
            int shouldrecK = 0;
            int shouldrecM = 0;
            if (recSold) shouldrecS = Convert.ToInt32(allUnitCount * 0.4f);
            if (recKnight) shouldrecK = Convert.ToInt32(allUnitCount * 0.4f);
            if (recMach) shouldrecM = Convert.ToInt32(allUnitCount * 0.2f);

            int shouldRecPointS = shouldrecS * 1;
            int shouldRecPointK = shouldrecS * 2;
            int shouldRecPointM = shouldrecS * 2;

            int totalShouldRecPoint = shouldRecPointS + shouldRecPointK + shouldRecPointM;

            if (MusteringPoints == totalShouldRecPoint)
            {
                //akkor bevonhatjuk mindet
            }

            if (MusteringPoints > totalShouldRecPoint)
            {
                //aranyositani kell, felszorozni az arannyal a bevonas darabszamat h noljon
                float arany = (MusteringPoints / totalShouldRecPoint);
                if (recSold) shouldrecS = Convert.ToInt32(shouldrecS  * arany);
                if (recKnight) shouldrecK = Convert.ToInt32(shouldrecK * arany);
                if (recMach) shouldrecM = Convert.ToInt32(shouldrecM * arany);
            }

            //KESOBB MEGKELLNEZNI
           // if (MusteringPoints < totalShouldRecPoint)
           // {
           //     //aranyositani kell, be kell az arannyal a bevonas darabszamat h csokkenjen
           //     float arany = (MusteringPoints / totalShouldRecPoint) * 100;
           //     if (recSold) shouldrecS = (int)Math.Round(shouldrecS * arany);
           //     if (recKnight) shouldrecK = (int)Math.Round(shouldrecK * arany);
           //     if (recMach) shouldrecM = (int)Math.Round(shouldrecM * arany);
           // }

            //mostmar faszan megvan hanyat vonunk be, most megnzzuk hova vonhatjuk be oket
            List<GAME.MODELS.Region> lehetsegesHelyek = new List<GAME.MODELS.Region>();
            foreach (var item in gs.RegionList)
            {
                if ( item.house == h )
                {
                    lehetsegesHelyek.Add(item);
                }
            }

            //most ki kell szamolni hogy ezek kozul hova erdemes mekkora esellyel
            //legfontosabb: szomszedos erod, szomszedos varos, sajaterod

            List<GAME.MODELS.Region> TEMPlehetsegesHelyek = new List<GAME.MODELS.Region>();

            foreach (var item in lehetsegesHelyek)
            {
                if (item.castle || item.city)
                {
                    TEMPlehetsegesHelyek.Add(item);
                }
                else
                {
                    foreach (var n in item.neighbours)
                    {
                        if (n.city || n.castle)
                        {
                            TEMPlehetsegesHelyek.Add(item);
                        }
                    }
                }
            }

            //leszurtuk a "jelentektelen" helyeket
            lehetsegesHelyek = TEMPlehetsegesHelyek;

            // MAJD HA MEG LESZ IDO MARCIUS VEGEN HAHAHA - AKKOR 
            ////itt sulyozni fogjuk azt h hova kellene bevonni a lehetseges helyek kozul
            //List<Tuple<GAME.MODELS.Region, float>> sulyozottHelyek = new List<Tuple<GAME.MODELS.Region, float>>();
            //
            //foreach (var item in lehetsegesHelyek)
            //{
            //    //sulyozasi szempontok:
            //    //  - milyen egysegunk van ott
            //}
            string[] avaiableNext = new string[] { "S", "S", "K", "K", "M" };
            string next = "S";
            int freeID = gs.UnitsList.Count;
            Random rnd = new Random();
            int random = rnd.Next(0, lehetsegesHelyek.Count);
 
            while ( ( shouldrecK <= 0 && shouldrecS <= 0 && shouldrecM <= 0) || MusteringPoints >= 0)
            {
                switch (next)
                {
                    case "S":
                        if (MusteringPoints-1 < 0)
                        {
                            goto end;
                        }
                        GAME.MODELS.Unit u = new GAME.MODELS.Unit();
                        u.ID = freeID;

                        freeID++;
                        u.player = h;
                        u.position = lehetsegesHelyek[rnd.Next(0, lehetsegesHelyek.Count)];
                        unitList.Add(u);
                        MusteringPoints = MusteringPoints - 1;
                        shouldrecS--;
                        next = avaiableNext[rnd.Next(0, avaiableNext.Count())];
                        break;
                    case "K":
                        if (MusteringPoints - 2 < 0)
                        {
                            goto end;
                        }
                        u = new GAME.MODELS.Unit();
                        u.ID = freeID;
                        freeID++;
                        u.player = h;
                        u.position = lehetsegesHelyek[rnd.Next(0, lehetsegesHelyek.Count)];
                        unitList.Add(u);
                        MusteringPoints = MusteringPoints - 2;
                        shouldrecK--;
                        next = avaiableNext[rnd.Next(0, avaiableNext.Count())];
                        break;
                    case "M":
                        if (MusteringPoints - 2 < 0)
                        {
                            goto end;
                        }
                        u = new GAME.MODELS.Unit();
                        u.ID = freeID;
                        freeID++;
                        u.player = h;
                        u.position = lehetsegesHelyek[rnd.Next(0, lehetsegesHelyek.Count)];
                        unitList.Add(u);
                        MusteringPoints = MusteringPoints - 2;
                        shouldrecM--;
                        next = avaiableNext[rnd.Next(0, avaiableNext.Count())];
                        break;
                    default:
                        break;
                }
            }
            end:
            return;
        }
Ejemplo n.º 35
0
        public PlacedOrder ExecuteAttack(GameState gs, GAME.MODELS.HOUSE h, ref List<PlacedOrder> placedOrderList, ref List<Unit> unitList, out string descText, GameInfo gInfo)
        {
            descText = null;
            List<PlacedOrder> amibolValaszthatunk = new List<PlacedOrder>();

            foreach (var item in placedOrderList)
            {
                if (item.order == ORDER_TYPE.ATTACK_MINUS || item.order == ORDER_TYPE.ATTACK_NORMAL || item.order == ORDER_TYPE.ATTACK_PLUS)
                {
                    if (item.ownerPlayerName == h)
                    {
                        amibolValaszthatunk.Add(item);
                    }
                }
            }
            // na szoval
            ///mindig az elsot hajtjuk vegre
            if (amibolValaszthatunk.Count != 0)
            {
                PlacedOrder vegrehajtando = amibolValaszthatunk[0];

                descText = h.ToString();
                //megnezzuk van-e ellenseg a target teruleten
                //ehhez tudnnonk kellh holvan ellenseg

                List<Region> ezenAmegyenEllensegVan = new List<Region>();
                foreach (var item in unitList)
                {
                    if (item.player != h && item.player != HOUSE.NONE)
                    {
                        if (!ezenAmegyenEllensegVan.Contains(item.position))
                        {
                            ezenAmegyenEllensegVan.Add(item.position);
                        }
                    }
                }


                if (ezenAmegyenEllensegVan.Contains(vegrehajtando.regionTo))
                {
                    //csata
                    // itt asszem bekéne hivni gameinfobol a csatát

                    if (gInfo.Battle(ref unitList, ref gs.RegionList, vegrehajtando.regionFrom, vegrehajtando.regionTo))
                    {
                        //megnyertuk a csattat
                        //atmuvoljuk a seregunket
                        HOUSE vesztes = HOUSE.NONE;

                        foreach (var item in unitList)
                        {
                            //osszegyujtjok h kik vannak itt es koet rajkuk a sajt helyukre
                            if (item.position == vegrehajtando.regionTo)
                            {
                                vesztes = item.player;
                            }
                        }

                        if (vesztes == HOUSE.NONE)
                        {
                            throw new Exception("bajvanbaj,...\nTCS\n");
                        }

                        //most szetdobjuk oket a tobbi mezore

                        List<Region> lehetsegesmegyekazathelyezesre = new List<Region>();

                        foreach (var item in vegrehajtando.regionTo.neighbours)
                        {
                            if ((item.house == vesztes) || ( item.house == HOUSE.NONE))
                            {
                                if (!lehetsegesmegyekazathelyezesre.Contains(item))
                                {
                                    lehetsegesmegyekazathelyezesre.Add(item);
                                }
                            }
                        }

                        descText = h + " execute attack(battle) from " + vegrehajtando.regionFrom.name + " to " + vegrehajtando.regionTo.name + " ( result: WIN )";

                        foreach (var item in unitList)
                        {
                            if (item.position == vegrehajtando.regionTo)
                            {
                                Random rnd = new Random();
                                item.position = lehetsegesmegyekazathelyezesre[rnd.Next(0, lehetsegesmegyekazathelyezesre.Count)];
                                descText += "\n defeated unit: " + item.type + " ( ID: " + item.ID + " ) moved to: " + item.position.name;
                            }
                        }

                        return vegrehajtando;
                    }
                    else
                    {
                        descText = h + " execute attack(battle) from " + vegrehajtando.regionFrom.name + " to " + vegrehajtando.regionTo.name + " ( result: LOST )";
                        return vegrehajtando;
                    }

                    

                }
                else
                {//movin'
                    int sum = 0;
                    foreach (var item in unitList)
                    {
                        //elvileg csak a sajatuk van itt
                        if (item.position == vegrehajtando.regionFrom)
                        {
                            item.position = vegrehajtando.regionTo;
                            sum++;
                        }
                    }
                    descText = h + " execute attack(move) from " + vegrehajtando.regionFrom.name + " to " + vegrehajtando.regionTo.name + " ( moved unit: " + sum + " )";
                }
                //vegultoroljuk
                return vegrehajtando;
            }

            throw new Exception("itt valami elvan baszva");
        }