Esempio n. 1
0
        public static Action[] GenEventProcessor(this GameUI gameUI, JsonData actionInfo)
        {
            var events = new List <ActionEvent>();

            if (actionInfo.ContainsKey("hit"))
            {
                var hitList = actionInfo["hit"];
                for (var i = 0; i < hitList.Count; i++)
                {
                    events.Add(new ActionEvent
                    {
                        Enemy = SharedRefs.Mode == Constants.GameMode.Offline
                            ? (int)hitList[i]["player"] == 1
                            : (bool)hitList[i]["isEnemy"],
                        Pos      = (int)hitList[i]["target"],
                        Value    = (int)hitList[i]["value"],
                        Time     = (int)hitList[i]["time"],
                        Positive = false
                    });
                }
            }

            if (actionInfo.ContainsKey("passive"))
            {
                var passiveList = actionInfo["passive"];
                for (var i = 0; i < passiveList.Count; i++)
                {
                    if ((string)passiveList[i]["type"] == "heal")
                    {
                        events.Add(new ActionEvent
                        {
                            Enemy = SharedRefs.Mode == Constants.GameMode.Offline
                                ? (int)passiveList[i]["player"] == 1
                                : (bool)passiveList[i]["isEnemy"],
                            Pos      = (int)passiveList[i]["source"],
                            Value    = (int)(double)passiveList[i]["value"],
                            Time     = (int)passiveList[i]["time"],
                            Positive = true
                        });
                    }
                }
            }

            events.Sort((x, y) => x.Time - y.Time);

            return(new Action[]
            {
                () => { gameUI.DiffAnim(events); },
                () => { gameUI.AddEventsToLog(events); }
            });
        }