public void AddGoalieGameToMySQL(GoalieGame playerGame)
 {
     var helper = new GameHelper();
     var hisGame = helper.GetGameFromMySQLByDate(playerGame.Game.Date);
     var sqlToExecute = String.Format(
         "insert into avDBGoalieRS (PlayerId, GameId, G, A, PIM, W, L, OT, T, SOUT, GA, SA, SV, SO, SOG, TOI)" +
         "values ({0},{1}, {2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15})",
             playerGame.Player.Id,
             hisGame,
             playerGame.Goals,
             playerGame.Assists,
             playerGame.PIM,
             playerGame.Win,
             playerGame.Loss,
             playerGame.OT,
             playerGame.Tie,
             playerGame.ShootOut,
             playerGame.GoalsAgainst,
             playerGame.ShotAgaisnt,
             playerGame.Saves,
             playerGame.Shutout,
             playerGame.SOG,
             playerGame.TimeOnIce
         );
     Scripts.ExecuteMySQLNonQuery(sqlToExecute);
 }
Пример #2
0
 public static void Init()
 {
     _helperWindow = GetWindow<GameHelper>();
     _helperWindow.name = "Sprite setter";
     _helperWindow._sprites = new ReorderableList(new List<Sprite>(), typeof(Sprite));
     _helperWindow._sprites.drawElementCallback = _helperWindow.DrawElement;
     _helperWindow.Show();
 }
Пример #3
0
    public Vector2 SetControll(bool byHero, GameHelper.CharacterDirection direc)
    {
        if (CanBeControlledByPlayer)
            isControlledByPlayer = byHero;

        if (direction != direc)
            Flip();

        IsFriend = isControlledByPlayer;
        transform.Find("Saddle").gameObject.SetActive(byHero);// .GetComponent<SpriteRenderer>().enabled = true;
        anim.SetBool("IsControlledByPlayer", isControlledByPlayer);

        return playerCheck.position;
    }
Пример #4
0
    private void SyncGameData()
    {
        var helper = new GameHelper();
        var myGames = helper.GetGameListFromMSSQL();
        var hisGames = helper.GetGameListFromMySQL();
        foreach (var game in myGames)
        {
            var hisGame = hisGames.Where(c => c.Date == game.Date).FirstOrDefault();
            if (hisGame == null)
            {
                AddGame(helper, game);
            }

            else if (game.ShotsFor != hisGame.ShotsFor)
            {
                UpdateGame(helper, game, hisGame);
            }
        }
    }
 public void AddPlayerGameToMySQL(PlayerGame playerGame)
 {
     var helper = new GameHelper();
     var hisGame = helper.GetGameFromMySQLByDate(playerGame.Game.Date);
     var sqlToExecute = String.Format(
         "insert into avDBSkaterRS (PlayerId, GameId, G, A, PIM,S,PP,SH,GW, TOI, PlusMinus, EVTOI,PPTOI,SHTOI, Hits,BlockedShots, AttemptsBlocked, ShotsMissed,GiveAways,TakeAways,FaceoffsWon,FaceoffsLost,PenaltiesTaken,PPAssists,ShAssists,GWAssists,EN,ENAssists)" +
         "values ({0},{1}, {2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27})",
             playerGame.Player.Id,
             hisGame,
             playerGame.Stats.Goals,
             playerGame.Stats.Assists,
             playerGame.Stats.PIM,
             playerGame.Stats.Shots,
             playerGame.Stats.PP,
             playerGame.Stats.SH,
             playerGame.Stats.GW,
             playerGame.Stats.TimeOnIce,
             playerGame.Stats.PlusMinus,
             playerGame.Stats.ENTimeOnIce,
             playerGame.Stats.PPTimeOnIce,
             playerGame.Stats.SHTimeOnIce,
             playerGame.Stats.Hits,
             playerGame.Stats.BlockedShots,
             playerGame.Stats.AttemptsBlocked,
             playerGame.Stats.ShotsMissed,
             playerGame.Stats.GiveAways,
             playerGame.Stats.TakeAways,
             playerGame.Stats.FaceOffsWon,
             playerGame.Stats.FaceOffsLost,
             playerGame.Stats.PenaltiesTaken,
             playerGame.Stats.PPAssists,
             playerGame.Stats.SHAssists,
             playerGame.Stats.GWAssists,
             playerGame.Stats.EmptyNet,
             playerGame.Stats.EmptyNetAssits
         );
     Scripts.ExecuteMySQLNonQuery(sqlToExecute);
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="value">The underlying in-game entity.</param>
 /// <param name="tilePosition">The object's tile position in the current location (if applicable).</param>
 public FarmAnimalTarget(GameHelper gameHelper, FarmAnimal value, Vector2?tilePosition = null)
     : base(gameHelper, TargetType.FarmAnimal, value, tilePosition)
 {
 }
Пример #7
0
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="name">The display name.</param>
 /// <param name="description">The object description (if applicable).</param>
 /// <param name="type">The object type.</param>
 protected BaseSubject(GameHelper gameHelper, string name, string description, string type)
     : this(gameHelper)
 {
     this.Initialize(name, description, type);
 }
        /// <summary>Draw debug metadata to the screen.</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            if (!this.Enabled)
            {
                return;
            }

            this.Monitor.InterceptErrors("drawing debug info", () =>
            {
                // get location info
                GameLocation currentLocation = Game1.currentLocation;
                Vector2 cursorTile           = Game1.currentCursorTile;
                Vector2 cursorPosition       = GameHelper.GetScreenCoordinatesFromCursor();

                // show 'debug enabled' warning + cursor position
                {
                    string metadata = $"{this.WarningText} Cursor tile ({cursorTile.X}, {cursorTile.Y}), position ({cursorPosition.X}, {cursorPosition.Y}).";
                    GameHelper.DrawHoverBox(spriteBatch, metadata, Vector2.Zero, Game1.viewport.Width);
                }

                // show cursor pixel
                spriteBatch.DrawLine(cursorPosition.X - 1, cursorPosition.Y - 1, new Vector2(Game1.pixelZoom, Game1.pixelZoom), Color.DarkRed);

                // show targets within detection radius
                Rectangle tileArea            = GameHelper.GetScreenCoordinatesFromTile(Game1.currentCursorTile);
                IEnumerable <ITarget> targets = this.TargetFactory
                                                .GetNearbyTargets(currentLocation, cursorTile, includeMapTile: false)
                                                .OrderBy(p => p.Type == TargetType.Unknown ? 0 : 1);
                // if targets overlap, prioritise info on known targets
                foreach (ITarget target in targets)
                {
                    // get metadata
                    bool spriteAreaIntersects = target.GetSpriteArea().Intersects(tileArea);
                    ISubject subject          = this.TargetFactory.GetSubjectFrom(target);

                    // draw tile
                    {
                        Rectangle tile = GameHelper.GetScreenCoordinatesFromTile(target.GetTile());
                        Color color    = (subject != null ? Color.Green : Color.Red) * .5f;
                        spriteBatch.DrawLine(tile.X, tile.Y, new Vector2(tile.Width, tile.Height), color);
                    }

                    // draw sprite box
                    if (subject != null)
                    {
                        int borderSize    = 3;
                        Color borderColor = Color.Green;
                        if (!spriteAreaIntersects)
                        {
                            borderSize   = 1;
                            borderColor *= 0.5f;
                        }

                        Rectangle spriteBox = target.GetSpriteArea();
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y, new Vector2(spriteBox.Width, borderSize), borderColor);                    // top
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y, new Vector2(borderSize, spriteBox.Height), borderColor);                   // left
                        spriteBatch.DrawLine(spriteBox.X + spriteBox.Width, spriteBox.Y, new Vector2(borderSize, spriteBox.Height), borderColor); // right
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y + spriteBox.Height, new Vector2(spriteBox.Width, borderSize), borderColor); // bottom
                    }
                }

                // show current target name (if any)
                {
                    ISubject subject = this.TargetFactory.GetSubjectFrom(Game1.player, currentLocation, LookupMode.Cursor, includeMapTile: false);
                    if (subject != null)
                    {
                        GameHelper.DrawHoverBox(spriteBatch, subject.Name, new Vector2(Game1.getMouseX(), Game1.getMouseY()) + new Vector2(Game1.tileSize / 2f), Game1.viewport.Width / 4f);
                    }
                }
            }, this.OnDrawError);
        }
Пример #9
0
 private void Start()
 {
     Application.targetFrameRate = 30;
     baseFilePath = GameHelper.GetSaveDirectory();
 }
Пример #10
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            FarmAnimal animal = this.Target;

            // calculate maturity
            bool  isFullyGrown   = animal.age.Value >= animal.ageWhenMature.Value;
            int   daysUntilGrown = 0;
            SDate dayOfMaturity  = null;

            if (!isFullyGrown)
            {
                daysUntilGrown = animal.ageWhenMature - animal.age;
                dayOfMaturity  = SDate.Now().AddDays(daysUntilGrown);
            }

            // yield fields
            yield return(new CharacterFriendshipField(this.Translate(L10n.Animal.Love), DataParser.GetFriendshipForAnimal(Game1.player, animal, metadata), this.Text));

            yield return(new PercentageBarField(this.Translate(L10n.Animal.Happiness), animal.happiness, byte.MaxValue, Color.Green, Color.Gray, this.Translate(L10n.Generic.Percent, new { percent = Math.Round(animal.happiness / (metadata.Constants.AnimalMaxHappiness * 1f) * 100) })));

            yield return(new GenericField(this.Translate(L10n.Animal.Mood), animal.getMoodMessage()));

            yield return(new GenericField(this.Translate(L10n.Animal.Complaints), this.GetMoodReason(animal)));

            yield return(new ItemIconField(this.Translate(L10n.Animal.ProduceReady), animal.currentProduce.Value > 0 ? GameHelper.GetObjectBySpriteIndex(animal.currentProduce.Value) : null));

            if (!isFullyGrown)
            {
                yield return(new GenericField(this.Translate(L10n.Animal.Growth), $"{this.Translate(L10n.Generic.Days, new { count = daysUntilGrown })} ({this.Stringify(dayOfMaturity)})"));
            }
            yield return(new GenericField(this.Translate(L10n.Animal.SellsFor), GenericField.GetSaleValueString(animal.getSellPrice(), 1, this.Text)));
        }
Пример #11
0
 /*********
 ** Public methods
 *********/
 /****
 ** Constructors
 ****/
 /// <summary>Construct an instance.</summary>
 /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="reflection">Simplifies access to private game code.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 public TargetFactory(Metadata metadata, ITranslationHelper translations, IReflectionHelper reflection, GameHelper gameHelper)
 {
     this.Metadata     = metadata;
     this.Translations = translations;
     this.Reflection   = reflection;
     this.GameHelper   = gameHelper;
 }
Пример #12
0
 private void UpdateGame(GameHelper helper, Game game, Game hisGame)
 {
     hisGame.Win = game.Win;
     hisGame.Loss = game.Loss;
     hisGame.Tie = game.Tie;
     hisGame.OverTimeLoss = game.OverTimeLoss;
     hisGame.OverTimeWin = game.OverTimeWin;
     hisGame.ShootOutLoss = game.ShootOutLoss;
     hisGame.ShootOutWin = game.ShootOutWin;
     hisGame.GoalsAgainst = game.GoalsAgainst;
     hisGame.GoalsFor = game.GoalsFor;
     hisGame.ShotsFor = game.ShotsFor;
     hisGame.ShotsAgainst = game.ShotsAgainst;
     hisGame.PPG = game.PPG;
     hisGame.PPOppertunities = game.PPOppertunities;
     hisGame.PPGA = game.PPGA;
     hisGame.TimesShortHanded = game.TimesShortHanded;
     hisGame.ShortHandedGoalsAgainst = game.ShortHandedGoalsAgainst;
     hisGame.ShortHandedGoalsFor = game.ShortHandedGoalsFor;
     hisGame.Attendence = game.Attendence;
     helper.UpdateMySQLGame(hisGame);
     InfoLabel.Text += String.Format("Updating game {0}. {1}", game.Date, "<br />");
 }
Пример #13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text = base.Request["OrderIds"].Trim(new char[]
            {
                ','
            });
            string text2 = base.Request["PIds"].Trim(new char[]
            {
                ','
            });

            if (string.IsNullOrEmpty(text) && string.IsNullOrEmpty(text2))
            {
                return;
            }
            System.Data.DataSet   printData = this.GetPrintData(text, text2);
            System.Data.DataTable dataTable = printData.Tables[0];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                System.Data.DataRow dataRow = dataTable.Rows[i];
                System.Web.UI.HtmlControls.HtmlGenericControl htmlGenericControl = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                htmlGenericControl.Attributes["class"] = "order print";
                htmlGenericControl.Attributes["style"] = "padding-bottom:60px;padding-top:40px;";
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("");
                stringBuilder.AppendFormat("<div class=\"info clear\"><ul class=\"sub-info\"><li><span>中奖编号: </span>{0}</li><li><span>开奖时间: </span>{1}</li></ul></div>", (int.Parse(dataRow["Ptype"].ToString()) == 1) ? dataRow["PrizeNums"].ToString().Remove(dataRow["PrizeNums"].ToString().Length - 1) : (System.Convert.ToDateTime(dataRow["WinTime"]).ToString("yyyy-MM-dd-") + dataRow["LogId"].ToString()), System.Convert.ToDateTime(dataRow["WinTime"]).ToString("yyyy-MM-dd HH:mm:ss"));
                stringBuilder.Append("<table><col class=\"col-1\" /><col class=\"col-3\" /><col class=\"col-3\" /><col class=\"col-3\" /><thead><tr><th>奖品信息</th><th>活动名称</th><th>收货人</th><th>奖品等级</th></tr></thead><tbody>");
                stringBuilder.AppendFormat("<tr><td>{0}<br><span style=\"color: #888\">{1}</span></td>", dataRow["ProductName"].ToString(), dataRow["SkuIdStr"].ToString());
                stringBuilder.AppendFormat("<td>{0}<br /><span class=\"jpname\">[{1}]</span></td>", dataRow["Title"].ToString(), GameHelper.GetGameTypeName(dataRow["GameType"].ToString()));
                stringBuilder.AppendFormat("<td>{0}<br />{1}</td>", dataRow["Receiver"].ToString(), dataRow["Tel"].ToString());
                stringBuilder.AppendFormat("<td style='padding-left:15px;'>{0}</td>", GameHelper.GetPrizeGradeName(dataRow["PrizeGrade"].ToString()));
                stringBuilder.Append("</tr>");
                stringBuilder.Append("</tbody></table>");
                htmlGenericControl.InnerHtml = stringBuilder.ToString();
                this.divContent.Controls.AddAt(0, htmlGenericControl);
            }
        }
Пример #14
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public TreeSubject(GameHelper gameHelper, Tree tree, Vector2 tile, ITranslationHelper translations)
     : base(gameHelper, TreeSubject.GetName(tree), null, L10n.Types.Tree(), translations)
 {
     this.Target = tree;
     this.Tile   = tile;
 }
Пример #15
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="type">The target type.</param>
 /// <param name="value">The underlying in-game entity.</param>
 /// <param name="tilePosition">The object's tile position in the current location (if applicable).</param>
 /// <param name="reflectionHelper">Simplifies access to private game code.</param>
 public CharacterTarget(GameHelper gameHelper, SubjectType type, NPC value, Vector2?tilePosition, IReflectionHelper reflectionHelper)
     : base(gameHelper, type, value, tilePosition)
 {
     this.Reflection = reflectionHelper;
 }
Пример #16
0
        static void Main(string[] args)
        {
            string input = string.Empty;

            //ServerHelper.Initialize("http://106.75.33.221:7000/");
            ServerHelper.Initialize("http://dev.magcore.clawit.com/");

Player:
            Console.WriteLine("Enter nickname:");
            input = Console.ReadLine();
            string name = input.Trim();

            Console.WriteLine("Enter color(0~9):");
            input = Console.ReadLine();
            int color = Int32.Parse(input);

            self = PlayerHelper.CreatePlayer(name, color);
            if (self == null)
            {
                Console.WriteLine("Player has already existed with same name. Try to get a new name.");
                goto Player;
            }

            string gameId  = string.Empty;
            string mapName = string.Empty;

            Console.WriteLine("1: Create a new game");
            Console.WriteLine("2: Join a game");
            input = Console.ReadLine();
            if (input == "1")
            {
                map    = MapHelper.GetMap("RectSmall");
                game   = new Game(map.Rows.Count, map.Rows[0].Count);
                gameId = GameHelper.CreateGame("RectSmall");
            }
            else
            {
                Console.WriteLine("Game list:");
List:
                var list = GameHelper.GameList();
                if (list == null || list.Length == 0)
                {
                    Thread.Sleep(1000);
                    goto List;
                }
                else
                {
                    for (int i = 0; i < list.Length; i++)
                    {
                        if (list[i].state == 0)
                        {
                            Console.WriteLine("{0} : {1} 地图:{2}", i, list[i].id.ToString(), list[i].map.ToString());
                        }
                    }
                }
                Console.WriteLine("Select a game to join:");
                input = Console.ReadLine();
                if (Int32.TryParse(input.Trim(), out int sel) &&
                    sel >= 0 && sel < list.Length)
                {
                    gameId  = list[sel].id.ToString();
                    mapName = list[sel].map.ToString();

                    map  = MapHelper.GetMap(mapName);
                    game = new Game(map.Rows.Count, map.Rows[0].Count);
                }
                else
                {
                    Console.WriteLine("Select error.");
                    goto List;
                }
            }


            game.Id = gameId;

            if (!GameHelper.JoinGame(gameId, self.Id))
            {
                Console.WriteLine("Join game fail.");
            }
            else
            {
                Console.WriteLine("Join game Ok.");
            }

            PlayerHelper.GetPlayer(ref self);
            Console.WriteLine("Self info updated.");

            //找到地图上所有的基地, 为杀手准备
            GameHelper.GetGame(game.Id, ref game);
            _enemies.Clear();
            foreach (var row in game.Rows)
            {
                foreach (var cell in row.Cells)
                {
                    if (cell.Type == 2 && cell.OwnerIndex != self.Index)
                    {
                        _enemies.Add(cell.Position.ToString(), cell.Position);
                    }
                }
            }

            //新开一个线程用于更新最新战斗数据
            Task.Factory.StartNew(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                while (true)
                {
                    GameHelper.GetGame(game.Id, ref game);

                    if (game.State > 1)
                    {
                        Console.WriteLine("Game over");
                        break;
                    }

                    Thread.Sleep(500);
                }
            });

            Attack();
        }
Пример #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Did = base.Request.QueryString["LogId"];
            string str = Globals.RequestQueryStr("pid");

            if (!string.IsNullOrEmpty(this.Did))
            {
                PrizesDeliveQuery query = new PrizesDeliveQuery {
                    Status    = -1,
                    PageIndex = 1,
                    PageSize  = 2,
                    PrizeType = -1
                };
                DbQueryResult result = null;
                if (!string.IsNullOrEmpty(str) && (str != "0"))
                {
                    query.Pid = str;
                    result    = GameHelper.GetAllPrizesDeliveryList(query, "", "*");
                }
                else
                {
                    query.LogId  = this.Did;
                    query.SortBy = "LogId";
                    result       = GameHelper.GetPrizesDeliveryList(query, "", "*");
                }
                DataTable data = (DataTable)result.Data;
                if ((data != null) && (data.Rows.Count > 0))
                {
                    DataRow row = data.Rows[0];
                    this.txtStatus.Text        = GameHelper.GetPrizesDeliveStatus(this.Dbnull2str(row["status"]), this.Dbnull2str(row["IsLogistics"]), this.Dbnull2str(row["PrizeType"]), row["gametype"].ToString());
                    this.txtCourierNumber.Text = this.Dbnull2str(row["CourierNumber"]);
                    this.txtExpressName.Text   = this.Dbnull2str(row["ExpressName"]);
                    this.txtTel.Text           = this.Dbnull2str(row["Tel"]);
                    this.txtDTel.Text          = this.Dbnull2str(row["Tel"]);
                    this.txtReceiver.Text      = this.Dbnull2str(row["Receiver"]);
                    this.txtDeliever.Text      = this.Dbnull2str(row["Receiver"]);
                    this.txtAddress.Text       = this.Dbnull2str(row["Address"]);
                    this.txtRegionName.Text    = this.Dbnull2str(row["ReggionPath"]);
                    this.txtImage.ImageUrl     = (row["ThumbnailUrl100"] == DBNull.Value) ? "/utility/pics/none.gif" : row["ThumbnailUrl100"].ToString();
                    if (this.txtRegionName.Text.Trim() != "")
                    {
                        string[] strArray = this.txtRegionName.Text.Trim().Split(new char[] { ',' });
                        this.txtRegionName.Text = RegionHelper.GetFullRegion(int.Parse(strArray[strArray.Length - 1]), ",");
                    }
                    if (!string.IsNullOrEmpty(str) && (str != "0"))
                    {
                        if (this.txtTel.Text == "")
                        {
                            this.txtTel.Text  = this.Dbnull2str(row["Tel"]);
                            this.txtDTel.Text = this.Dbnull2str(row["Tel"]);
                        }
                        this.txtPlayTime.Text  = ((DateTime)row["WinTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                        this.txtGameTitle.Text = row["Title"].ToString();
                    }
                    else
                    {
                        if (((this.txtImage.ImageUrl == "/utility/pics/none.gif") && (row["PrizeId"] != DBNull.Value)) && (Globals.ToNum(row["PrizeId"]) > 0))
                        {
                            int prizeId = Globals.ToNum(row["PrizeId"]);
                            if (prizeId > 0)
                            {
                                GamePrizeInfo gamePrizeInfoById = GameHelper.GetGamePrizeInfoById(prizeId);
                                if (gamePrizeInfoById != null)
                                {
                                    this.txtImage.ImageUrl = gamePrizeInfoById.PrizeImage;
                                }
                            }
                        }
                        if (this.txtDeliever.Text == "")
                        {
                            this.txtReceiver.Text = this.Dbnull2str(row["RealName"]);
                            this.txtDeliever.Text = this.Dbnull2str(row["RealName"]);
                        }
                        if (this.txtTel.Text == "")
                        {
                            this.txtTel.Text  = this.Dbnull2str(row["CellPhone"]);
                            this.txtDTel.Text = this.Dbnull2str(row["CellPhone"]);
                        }
                        this.txtGameTitle.Text = row["GameTitle"].ToString();
                        this.txtPlayTime.Text  = ((DateTime)row["PlayTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    this.txtPrizeGrade.Text  = GameHelper.GetPrizeGradeName(this.Dbnull2str(row["PrizeGrade"]));
                    this.txtGameType.Text    = GameHelper.GetGameTypeName(row["GameType"].ToString());
                    this.txtProductName.Text = row["ProductName"].ToString();
                }
            }
        }
Пример #18
0
 private void AddGame(GameHelper helper, Game game)
 {
     helper.AddGameToMySQL(game);
     InfoLabel.Text += String.Format("Adding game {0}. {1}", game.Date, "<br />");
 }
Пример #19
0
        //保存按钮点击后
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            switch (App.Config.MainConfig.Environment.GamePathType)
            {
            case GameDirEnum.ROOT:
                App.Handler.GameRootPath = Path.GetFullPath(".minecraft");
                break;

            case GameDirEnum.APPDATA:
                App.Handler.GameRootPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\.minecraft";
                break;

            case GameDirEnum.PROGRAMFILES:
                App.Handler.GameRootPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\.minecraft";
                break;

            case GameDirEnum.CUSTOM:
                App.Handler.GameRootPath = App.Config.MainConfig.Environment.GamePath + "\\.minecraft";
                break;

            default:
                throw new ArgumentException(App.GetResourceString("String.Settingwindow.Message.GamePathType.Error"));
            }
            App.Handler.VersionIsolation = App.Config.MainConfig.Environment.VersionIsolation;
            App.Downloader.CheckFileHash = App.Config.MainConfig.Download.CheckDownloadFileHash;

            if (_isGameSettingChanged)
            {
                if (App.Config.MainConfig.Environment.VersionIsolation)
                {
                    await GameHelper.SaveOptionsAsync(VersionOption.Type.options,
                                                      versionOptionsGrid.ItemsSource as List <VersionOption>,
                                                      App.Handler,
                                                      VersionsComboBox.SelectedItem as MCVersion);

                    await GameHelper.SaveOptionsAsync(VersionOption.Type.optionsof,
                                                      versionOptionsofGrid.ItemsSource as List <VersionOption>,
                                                      App.Handler,
                                                      VersionsComboBox.SelectedItem as MCVersion);
                }
                else
                {
                    await GameHelper.SaveOptionsAsync(VersionOption.Type.options,
                                                      versionOptionsGrid.ItemsSource as List <VersionOption>,
                                                      App.Handler,
                                                      new() { ID = "null" });

                    await GameHelper.SaveOptionsAsync(VersionOption.Type.optionsof,
                                                      versionOptionsofGrid.ItemsSource as List <VersionOption>,
                                                      App.Handler,
                                                      new() { ID = "null" });
                }
            }

            App.Config.Save();
            App.ProxyRe();

            saveButton.Content = App.GetResourceString("String.Settingwindow.Saving");
            EnvironmentObj env  = App.Config.MainConfig.Environment;
            Java           java = null;

            if (env.AutoJava)
            {
                java = Java.GetSuitableJava(App.JavaList);
            }
            else
            {
                java = App.JavaList.Find(x => x.Path == env.JavaPath);
                if (java == null)
                {
                    java = Java.GetJavaInfo(env.JavaPath);
                }
            }
            if (java != null)
            {
                App.Handler.Java = java;
                Close();
            }
            else
            {
                await this.ShowMessageAsync(App.GetResourceString("String.Settingwindow.SaveError"),
                                            App.GetResourceString("String.Settingwindow.JavaError"));
            }
        }
Пример #20
0
 /*********
 ** Protected methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 protected BaseSubject(SubjectFactory codex, GameHelper gameHelper, ITranslationHelper translations)
 {
     this.Codex      = codex;
     this.GameHelper = gameHelper;
     this.Text       = translations;
 }
Пример #21
0
 private System.Data.DataSet GetPrintData(string orderIds, string pIds)
 {
     orderIds = "'" + orderIds.Replace(",", "','") + "'";
     pIds     = "'" + pIds.Replace(",", "','") + "'";
     return(GameHelper.GetOrdersAndLines(orderIds, pIds));
 }
Пример #22
0
        private void BindDate()
        {
            GameInfo modelByGameId = GameHelper.GetModelByGameId(this._gameId);

            if (modelByGameId != null)
            {
                this.UCGameInfo.GameInfo = modelByGameId;
                System.Collections.Generic.IList <GamePrizeInfo> gamePrizeListsByGameId = GameHelper.GetGamePrizeListsByGameId(this._gameId);
                this.UCGamePrizeInfo.PrizeLists         = gamePrizeListsByGameId;
                this.UCGamePrizeInfo.NotPrzeDescription = modelByGameId.NotPrzeDescription;
                try
                {
                    this.lbPrizeGade0.Text      = "一等奖:" + gamePrizeListsByGameId.FirstOrDefault((GamePrizeInfo p) => p.PrizeGrade == PrizeGrade.一等奖).PrizeType.ToString();
                    this.lbPrizeGade1.Text      = "二等奖:" + gamePrizeListsByGameId.FirstOrDefault((GamePrizeInfo p) => p.PrizeGrade == PrizeGrade.二等奖).PrizeType.ToString();
                    this.lbPrizeGade2.Text      = "三等奖:" + gamePrizeListsByGameId.FirstOrDefault((GamePrizeInfo p) => p.PrizeGrade == PrizeGrade.等奖).PrizeType.ToString();
                    this.lbPrizeGade3.Text      = "四等奖:" + gamePrizeListsByGameId.FirstOrDefault((GamePrizeInfo p) => p.PrizeGrade == PrizeGrade.四等奖).PrizeType.ToString();
                    this.lbBeginTime.Text       = modelByGameId.BeginTime.ToString("yyyy-MM-dd HH:mm:ss");
                    this.lbEedTime.Text         = modelByGameId.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
                    this.lbGameDescription.Text = Globals.HtmlDecode(modelByGameId.Description);
                }
                catch (System.Exception)
                {
                }
            }
        }
Пример #23
0
 /// <summary>Construct an instance.</summary>
 /// <param name="codex">Provides subject entries for target values.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="name">The display name.</param>
 /// <param name="description">The object description (if applicable).</param>
 /// <param name="type">The object type.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 protected BaseSubject(SubjectFactory codex, GameHelper gameHelper, string name, string description, string type, ITranslationHelper translations)
     : this(codex, gameHelper, translations)
 {
     this.Initialize(name, description, type);
 }
Пример #24
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="label">A short field label.</param>
 /// <param name="experience">The current progress value.</param>
 /// <param name="maxSkillPoints">The maximum experience points for a skill.</param>
 /// <param name="skillPointsPerLevel">The experience points needed for each skill level.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public SkillBarField(GameHelper gameHelper, string label, int experience, int maxSkillPoints, int[] skillPointsPerLevel, ITranslationHelper translations)
     : base(gameHelper, label, experience, maxSkillPoints, Color.Green, Color.Gray, null)
 {
     this.SkillPointsPerLevel = skillPointsPerLevel;
     this.Translations        = translations;
 }
Пример #25
0
        private void SaveDate()
        {
            int num = -1;

            try
            {
                GameInfo gameInfo = this.UCGameInfo.GameInfo;
                gameInfo.PrizeRate          = this.UCGamePrizeInfo.PrizeRate;
                gameInfo.NotPrzeDescription = this.UCGamePrizeInfo.NotPrzeDescription;
                System.Collections.Generic.IList <GamePrizeInfo> prizeLists = this.UCGamePrizeInfo.PrizeLists;
                string[] array = new string[]
                {
                    "一等奖",
                    "二等奖",
                    "三等奖",
                    "四等奖"
                };
                int  num2 = 0;
                bool flag = GameHelper.Create(gameInfo, out num);
                if (!flag)
                {
                    throw new System.Exception("添加失败!");
                }
                for (int i = 0; i < prizeLists.Count <GamePrizeInfo>(); i++)
                {
                    GamePrizeInfo gamePrizeInfo = prizeLists[i];
                    gamePrizeInfo.GameId = num;
                    if (string.IsNullOrEmpty(gamePrizeInfo.PrizeName))
                    {
                        gamePrizeInfo.PrizeName = array[i];
                    }
                    if (gamePrizeInfo.PrizeType == PrizeType.赠送积分)
                    {
                        gamePrizeInfo.PrizeImage = "/utility/pics/jifen60.png";
                    }
                    if (gamePrizeInfo.PrizeType == PrizeType.赠送优惠券)
                    {
                        gamePrizeInfo.PrizeImage = "/utility/pics/yhq60.png";
                    }
                    if (!GameHelper.CreatePrize(gamePrizeInfo))
                    {
                        throw new System.Exception("添加奖品信息时失败!");
                    }
                    num2 += gamePrizeInfo.PrizeCount;
                }
                if (num2 > 0)
                {
                    GameHelper.CreateWinningPools(gameInfo.PrizeRate, num2, num);
                }
                this.Page.ClientScript.RegisterClientScriptBlock(typeof(System.Web.UI.Page), "ShowSuccess", "<script>$(function () { ShowStep2(); })</script>");
            }
            catch (System.Exception ex)
            {
                if (num > 0)
                {
                    GameHelper.Delete(new int[]
                    {
                        num
                    });
                }
                this.ShowMsg(ex.Message, false);
            }
        }
Пример #26
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="value">The underlying in-game entity.</param>
 /// <param name="tilePosition">The object's tile position in the current location (if applicable).</param>
 /// <param name="reflectionHelper">Simplifies access to private game code.</param>
 /// <param name="getSubject">Get the subject info about the target.</param>
 public TreeTarget(GameHelper gameHelper, Tree value, Vector2 tilePosition, IReflectionHelper reflectionHelper, Func <ISubject> getSubject)
     : base(gameHelper, SubjectType.WildTree, value, tilePosition, getSubject)
 {
     this.Reflection = reflectionHelper;
 }
Пример #27
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="location">The game location.</param>
 /// <param name="position">The tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public TileSubject(GameHelper gameHelper, GameLocation location, Vector2 position, ITranslationHelper translations)
     : base(gameHelper, $"({position.X}, {position.Y})", translations.Get(L10n.Tile.Description), translations.Get(L10n.Types.Tile), translations)
 {
     this.Location = location;
     this.Position = position;
 }
Пример #28
0
 /// <summary>Get how much each NPC likes receiving an item as a gift.</summary>
 /// <param name="item">The potential gift item.</param>
 /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
 private IDictionary <GiftTaste, string[]> GetGiftTastes(Item item, Metadata metadata)
 {
     return(GameHelper.GetGiftTastes(item, metadata)
            .GroupBy(p => p.Value, p => p.Key)
            .ToDictionary(p => p.Key, p => p.ToArray()));
 }
Пример #29
0
    private void SaveLevel()
    {
        string sceneName = GameHelper.GetAllScenes().Find(s => s.Contains("SceneLevel"));

        CurScene = SceneManager.GetSceneByName(sceneName);
        // Save level scene
        EditorSceneManager.SaveScene(CurScene);
        Transform ground =
            CurScene.GetRootGameObjects().ToList().Find(s => s.name.Contains("Background")).transform;
        var prefab = PrefabUtility.GetPrefabParent(ground.gameObject) as GameObject;

        PrefabUtility.ReplacePrefab(ground.gameObject, prefab);
        PrefabUtility.ConnectGameObjectToPrefab(ground.gameObject, prefab);

        MapData = AssetDatabase.LoadAssetAtPath <MapData>(LevelObjectPath + "/" + "MapData" + (CurLevelSelected + 1) + ".asset");
        MapData.ResetData();

        Transform objects = CurScene.GetRootGameObjects().ToList().Find(s => s.name.Contains("Objects")).transform;
        Pipe      p;

        foreach (Transform t in objects)
        {
            prefab = PrefabUtility.GetPrefabParent(t.gameObject) as GameObject;
            if (prefab == null)
            {
                continue;
            }

            p = t.GetComponent <Pipe>();
            if (p == null)
            {
                MapData.NormalObjs.Add(new MapObjBase()
                {
                    Position = t.position,
                    Prefab   = prefab,
                });
            }
            else
            {
                MapData.PipeObjs.Add(new PipeObj()
                {
                    Position      = t.position,
                    Rotation      = t.rotation,
                    Prefab        = prefab,
                    IndexPipe     = p.Index,
                    IsPipeIn      = p.IsPipeIn,
                    DirectionPipe = p.Direction,
                });
            }
        }

        // Save background
        Transform      background = CurScene.GetRootGameObjects().ToList().Find(s => s.name.Contains("GameBackground")).transform;
        SpriteRenderer render;

        foreach (Transform child in background)
        {
            render = child.GetComponent <SpriteRenderer>();
            MapData.Bgs.Add(new BackgroundInfor()
            {
                Position  = child.position,
                Scale     = child.localScale,
                Sprite    = render.sprite,
                Size      = render.size,
                LayerName = render.sortingLayerName,
                DrawMode  = render.drawMode,
                Order     = render.sortingOrder,
            });
        }

        // Save platforms
        Transform platforms = CurScene.GetRootGameObjects().ToList().Find(s => s.name.Contains("Platforms")).transform;
        Platform  path;

        foreach (Transform child in platforms)
        {
            prefab = PrefabUtility.GetPrefabParent(child.gameObject) as GameObject;
            if (child.name.Contains("Platform"))
            {
                path = child.GetComponent <Platform>();
                MapData.Platforms.Add(new PlatformObj
                {
                    Prefab   = prefab,
                    Position = child.position,
                    Path     = path.ListPath(),
                    Speed    = path.GetSpeed(),
                    LoopType = path.GetLoopType(),
                    EaseType = path.GetEaseType(),
                });
            }
        }
    }
Пример #30
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public override IEnumerable <ICustomField> GetData(Metadata metadata)
        {
            // get data
            Item   item       = this.Target;
            Object obj        = item as Object;
            bool   isObject   = obj != null;
            bool   isCrop     = this.FromCrop != null;
            bool   isSeed     = this.SeedForCrop != null;
            bool   isDeadCrop = this.FromCrop?.dead == true;
            bool   canSell    = obj?.canBeShipped() == true || metadata.Shops.Any(shop => shop.BuysCategories.Contains(item.category));

            // get overrides
            bool showInventoryFields = true;

            {
                ObjectData objData = metadata.GetObject(item, this.Context);
                if (objData != null)
                {
                    this.Name           = objData.Name ?? this.Name;
                    this.Description    = objData.Description ?? this.Description;
                    this.Type           = objData.Type ?? this.Type;
                    showInventoryFields = objData.ShowInventoryFields ?? true;
                }
            }

            // don't show data for dead crop
            if (isDeadCrop)
            {
                yield return(new GenericField("Crop", "This crop is dead."));

                yield break;
            }

            // crop fields
            if (isCrop || isSeed)
            {
                // get crop
                Crop crop = this.FromCrop ?? this.SeedForCrop;

                // get harvest schedule
                int  harvestablePhase   = crop.phaseDays.Count - 1;
                bool canHarvestNow      = (crop.currentPhase >= harvestablePhase) && (!crop.fullyGrown || crop.dayOfCurrentPhase <= 0);
                int  daysToFirstHarvest = crop.phaseDays.Take(crop.phaseDays.Count - 1).Sum(); // ignore harvestable phase

                // add next-harvest field
                if (isCrop)
                {
                    // calculate next harvest
                    int      daysToNextHarvest = 0;
                    GameDate dayOfNextHarvest  = null;
                    if (!canHarvestNow)
                    {
                        // calculate days until next harvest
                        int daysUntilLastPhase = daysToFirstHarvest - crop.dayOfCurrentPhase - crop.phaseDays.Take(crop.currentPhase).Sum();
                        {
                            // growing: days until next harvest
                            if (!crop.fullyGrown)
                            {
                                daysToNextHarvest = daysUntilLastPhase;
                            }

                            // regrowable crop harvested today
                            else if (crop.dayOfCurrentPhase >= crop.regrowAfterHarvest)
                            {
                                daysToNextHarvest = crop.regrowAfterHarvest;
                            }

                            // regrowable crop
                            else
                            {
                                daysToNextHarvest = crop.dayOfCurrentPhase; // dayOfCurrentPhase decreases to 0 when fully grown, where <=0 is harvestable
                            }
                        }
                        dayOfNextHarvest = GameHelper.GetDate(metadata.Constants.DaysInSeason).GetDayOffset(daysToNextHarvest);
                    }

                    // generate field
                    string summary;
                    if (canHarvestNow)
                    {
                        summary = "now";
                    }
                    else if (Game1.currentLocation.Name != Constant.LocationNames.Greenhouse && !crop.seasonsToGrowIn.Contains(dayOfNextHarvest.Season))
                    {
                        summary = $"too late in the season for the next harvest (would be on {dayOfNextHarvest})";
                    }
                    else
                    {
                        summary = $"{dayOfNextHarvest} ({TextHelper.Pluralise(daysToNextHarvest, "tomorrow", $"in {daysToNextHarvest} days")})";
                    }

                    yield return(new GenericField("Harvest", summary));
                }

                // crop summary
                {
                    List <string> summary = new List <string>();

                    // harvest
                    summary.Add($"-harvest after {daysToFirstHarvest} {TextHelper.Pluralise(daysToFirstHarvest, "day")}" + (crop.regrowAfterHarvest != -1 ? $", then every {TextHelper.Pluralise(crop.regrowAfterHarvest, "day", $"{crop.regrowAfterHarvest} days")}" : ""));

                    // seasons
                    summary.Add($"-grows in {string.Join(", ", crop.seasonsToGrowIn)}");

                    // drops
                    if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops > 0)
                    {
                        summary.Add($"-drops {crop.minHarvest} to {crop.maxHarvest} ({Math.Round(crop.chanceForExtraCrops * 100, 2)}% chance of extra crops)");
                    }
                    else if (crop.minHarvest > 1)
                    {
                        summary.Add($"-drops {crop.minHarvest}");
                    }

                    // crop sale price
                    Item drop = GameHelper.GetObjectBySpriteIndex(crop.indexOfHarvest);
                    summary.Add($"-sells for {GenericField.GetSaleValueString(this.GetSaleValue(drop, false, metadata), 1)}");

                    // generate field
                    yield return(new GenericField("Crop", string.Join(Environment.NewLine, summary)));
                }
            }

            // crafting
            if (obj?.heldObject != null)
            {
                if (obj is Cask)
                {
                    // get cask data
                    Cask        cask           = (Cask)obj;
                    Object      agingObj       = cask.heldObject;
                    ItemQuality currentQuality = (ItemQuality)agingObj.quality;

                    // calculate aging schedule
                    float effectiveAge = metadata.Constants.CaskAgeSchedule.Values.Max() - cask.daysToMature;
                    var   schedule     =
                        (
                            from entry in metadata.Constants.CaskAgeSchedule
                            let quality = entry.Key
                                          let baseDays = entry.Value
                                                         where baseDays > effectiveAge
                                                         orderby baseDays ascending
                                                         let daysLeft = (int)Math.Ceiling((baseDays - effectiveAge) / cask.agingRate)
                                                                        select new
                    {
                        Quality = quality,
                        DaysLeft = daysLeft,
                        HarvestDate = GameHelper.GetDate(metadata.Constants.DaysInSeason).GetDayOffset(daysLeft)
                    }
                        )
                        .ToArray();

                    // display fields
                    yield return(new ItemIconField("Contents", obj.heldObject));

                    if (cask.minutesUntilReady <= 0 || !schedule.Any())
                    {
                        yield return(new GenericField("Aging", $"{currentQuality.GetName()} quality ready"));
                    }
                    else
                    {
                        string scheduleStr = string.Join(Environment.NewLine, (from entry in schedule select $"-{entry.Quality.GetName()} {TextHelper.Pluralise(entry.DaysLeft, "tomorrow", $"in {entry.DaysLeft} days")} ({entry.HarvestDate})"));
                        yield return(new GenericField("Aging", $"-{currentQuality.GetName()} now (use pickaxe to stop aging){Environment.NewLine}" + scheduleStr));
                    }
                }
                else
                {
                    yield return(new ItemIconField("Contents", obj.heldObject, $"{obj.heldObject.Name} " + (obj.minutesUntilReady > 0 ? "in " + TextHelper.Stringify(TimeSpan.FromMinutes(obj.minutesUntilReady)) : "ready")));
                }
            }

            // item
            if (showInventoryFields)
            {
                // needed for
                {
                    List <string> neededFor = new List <string>();

                    // bundles
                    if (isObject)
                    {
                        string[] bundles = (from bundle in this.GetUnfinishedBundles(obj) orderby bundle.Area, bundle.Name select $"{bundle.Area}: {bundle.Name}").ToArray();
                        if (bundles.Any())
                        {
                            neededFor.Add($"community center ({string.Join(", ", bundles)})");
                        }
                    }

                    // polyculture achievement
                    if (isObject && metadata.Constants.PolycultureCrops.Contains(obj.ParentSheetIndex))
                    {
                        int needed = metadata.Constants.PolycultureCount - GameHelper.GetShipped(obj.ParentSheetIndex);
                        if (needed > 0)
                        {
                            neededFor.Add($"polyculture achievement (ship {needed} more)");
                        }
                    }

                    // full shipment achievement
                    if (isObject && GameHelper.GetFullShipmentAchievementItems().Any(p => p.Key == obj.ParentSheetIndex && !p.Value))
                    {
                        neededFor.Add("full shipment achievement (ship one)");
                    }

                    // a full collection achievement
                    LibraryMuseum museum = Game1.locations.OfType <LibraryMuseum>().FirstOrDefault();
                    if (museum != null && museum.isItemSuitableForDonation(obj))
                    {
                        neededFor.Add("full collection achievement (donate one to museum)");
                    }

                    // yield
                    if (neededFor.Any())
                    {
                        yield return(new GenericField("Needed for", string.Join(", ", neededFor)));
                    }
                }

                // sale data
                if (canSell && !isCrop)
                {
                    // sale price
                    string saleValueSummary = GenericField.GetSaleValueString(this.GetSaleValue(item, this.KnownQuality, metadata), item.Stack);
                    yield return(new GenericField("Sells for", saleValueSummary));

                    // sell to
                    List <string> buyers = new List <string>();
                    if (obj?.canBeShipped() == true)
                    {
                        buyers.Add("shipping box");
                    }
                    buyers.AddRange(from shop in metadata.Shops where shop.BuysCategories.Contains(item.category) orderby shop.DisplayName select shop.DisplayName);
                    yield return(new GenericField("Sells to", TextHelper.OrList(buyers.ToArray())));
                }

                // gift tastes
                var giftTastes = this.GetGiftTastes(item, metadata);
                yield return(new ItemGiftTastesField("Loves this", giftTastes, GiftTaste.Love));

                yield return(new ItemGiftTastesField("Likes this", giftTastes, GiftTaste.Like));
            }

            // fence
            if (item is Fence)
            {
                Fence fence = (Fence)item;

                // health
                if (Game1.getFarm().isBuildingConstructed(Constant.BuildingNames.GoldClock))
                {
                    yield return(new GenericField("Health", "no decay with Gold Clock"));
                }
                else
                {
                    float maxHealth = fence.isGate ? fence.maxHealth * 2 : fence.maxHealth;
                    float health    = fence.health / maxHealth;
                    float daysLeft  = fence.health * metadata.Constants.FenceDecayRate / 60 / 24;
                    yield return(new PercentageBarField("Health", (int)fence.health, (int)maxHealth, Color.Green, Color.Red, $"{Math.Round(health * 100)}% (roughly {Math.Round(daysLeft)} days left)"));
                }
            }

            // recipes
            if (item.GetSpriteType() == ItemSpriteType.Object)
            {
                RecipeModel[] recipes = GameHelper.GetRecipesForIngredient(this.DisplayItem).ToArray();
                if (recipes.Any())
                {
                    yield return(new RecipesForIngredientField("Recipes", item, recipes));
                }
            }

            // owned
            if (showInventoryFields && !isCrop && !(item is Tool))
            {
                yield return(new GenericField("Owned", $"you own {GameHelper.CountOwnedItems(item)} of these"));
            }
        }
Пример #31
0
 /*********
 ** Protected methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 protected BaseSubject(GameHelper gameHelper)
 {
     this.GameHelper = gameHelper;
 }
Пример #32
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="value">The underlying in-game entity.</param>
 /// <param name="tilePosition">The object's tile position in the current location (if applicable).</param>
 public UnknownTarget(GameHelper gameHelper, object value, Vector2?tilePosition = null)
     : base(gameHelper, TargetType.Unknown, value, tilePosition)
 {
 }
Пример #33
0
 /// <summary>Get a rectangle which roughly bounds the visible sprite relative the viewport.</summary>
 public virtual Rectangle GetSpriteArea()
 {
     return(GameHelper.GetScreenCoordinatesFromTile(this.GetTile()));
 }
Пример #34
0
 public Robot()
 {
     _health = GameHelper.GetBotsHealth();
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="label">A short field label.</param>
 /// <param name="ingredient">The ingredient item.</param>
 /// <param name="recipes">The recipe to list.</param>
 public RecipesForIngredientField(GameHelper gameHelper, string label, Item ingredient, RecipeModel[] recipes)
     : base(label, hasValue: true)
 {
     this.Recipes = this.GetRecipeEntries(gameHelper, ingredient, recipes).OrderBy(p => p.Type).ThenBy(p => p.Name).ToArray();
 }
Пример #36
0
 /*********
 ** Private methods
 *********/
 /// <summary>Get a fish pond's possible drops by population.</summary>
 /// <param name="currentPopulation">The current population for showing unlocked drops.</param>
 /// <param name="data">The fish pond data.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <remarks>Derived from <see cref="FishPond.dayUpdate"/> and <see cref="FishPond.GetFishProduce"/>.</remarks>
 private IEnumerable <FishPondDrop> GetEntries(int currentPopulation, FishPondData data, GameHelper gameHelper)
 {
     foreach (var drop in gameHelper.GetFishPondDrops(data))
     {
         bool       isUnlocked = currentPopulation >= drop.MinPopulation;
         SObject    item       = this.GameHelper.GetObjectBySpriteIndex(drop.ItemID);
         SpriteInfo sprite     = gameHelper.GetSprite(item);
         yield return(new FishPondDrop(drop, item, sprite, isUnlocked));
     }
 }
Пример #37
0
 /// <summary>
 /// Private Methods.
 /// </summary>
 private void Awake()
 {
     rigidbody  = GetComponent <Rigidbody2D>();
     gameHelper = Camera.main.GetComponent <GameHelper>();
 }
Пример #38
0
    // Use this for initialization
    void Start()
    {
        gameplay = this;

        _MainCamera = (Camera)gameObject.GetComponent("Camera");

        _SelectionListWindow = new SelectionListWindow(Screen.width / 2, Screen.height / 2 + 100);

        _AbilityManagerList = new SelectionListGenericWindow(Screen.width / 2, Screen.height / 2 + 100);

        _SelectionCardNameWindow = new SelectionCardNameWindow(Screen.width / 2 - 50, Screen.height / 2);
        _SelectionCardNameWindow.CreateCardList();
        _SelectionCardNameWindow.SetGame(this);

        _DecisionWindow = new DecisionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _DecisionWindow.SetGame(this);

        _NotificationWindow = new NotificacionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _NotificationWindow.SetGame(this);

        FromHandToBindList = new List<Card>();

        AttackedList = new List<Card>();

        UnitsCalled = new List<Card>();

        EnemySoulBlastQueue = new List<Card>();

        _PopupNumber = new PopupNumber();

        _MouseHelper = new MouseHelper(this);
        GameChat = new Chat();

        opponent = PlayerVariables.opponent;

        playerHand = new PlayerHand();
        enemyHand = new EnemyHand();

        field = new Field(this);
        enemyField = new EnemyField(this);
        guardZone = new GuardZone();
        guardZone.SetField(field);
        guardZone.SetEnemyField(enemyField);
        guardZone.SetGame(this);

        fieldInfo = new FieldInformation();
        EnemyFieldInfo = new EnemyFieldInformation();

        Data = new CardDataBase();
        List<CardInformation> tmpList = Data.GetAllCards();
        for(int i = 0; i < tmpList.Count; i++)
        {
            _SelectionCardNameWindow.AddNewNameToTheList(tmpList[i]);
        }

        //camera = (CameraPosition)GameObject.FindGameObjectWithTag("MainCamera").GetComponent("CameraPosition");
        //camera.SetLocation(CameraLocation.Hand);

        LoadPlayerDeck();
        LoadEnemyDeck();

        gamePhase = GamePhase.CHOOSE_VANGUARD;

        bDrawing = true;
        bIsCardSelectedFromHand = false;
        bPlayerTurn = false;

        bDriveAnimation = false;
        bChooseTriggerEffects = false;
        DriveCard = null;

        //Texture showed above a card when this is selected for an action (An attack, for instance)
        CardSelector = GameObject.FindGameObjectWithTag("CardSelector");
        _CardMenuHelper = (CardHelpMenu)GameObject.FindGameObjectWithTag("CardMenuHelper").GetComponent("CardHelpMenu");
        _GameHelper = (GameHelper)GameObject.FindGameObjectWithTag("GameHelper").GetComponent("GameHelper");

        bPlayerTurn = PlayerVariables.bFirstTurn;

        //ActivePopUpQuestion(playerDeck.DrawCard());
        _CardMenu = new CardMenu(this);

        _AbilityManager = new AbilityManager(this);
        _AbilityManagerExt = new AbilityManagerExt();

        _GameHelper.SetChat(GameChat);
        _GameHelper.SetGame(this);

        EnemyTurnStackedCards = new List<Card>();

        dummyUnitObject = new UnitObject();
        dummyUnitObject.SetGame(this);

        stateDynamicText = new DynamicText();
    }