Exemplo n.º 1
0
        public AgentAnimator(string name, Agent agent)
        {
            this.agent = agent;
            //sound processing
            var soundJson = AssemblyHelper.ReadResourceString(name, "sounds-mp3.json");
            var soundData = JsonConvert.DeserializeObject <Dictionary <string, string> >(soundJson);

            Sounds = new List <SoundData>();
            foreach (var data in soundData)
            {
                Sounds.Add(new SoundData(data.Key, data.Value));
            }

            //image processing
            imageSheet = AgentEnvirontment.Current.Delegate.GetImageSheet(name, "map.png");

            Animations = new List <AgentAnimation>();
            foreach (var animationKey in agent.Model.Animations)
            {
                //if (animationKey.Value.TryGetValue("frames", out AgentAnimationModel animation))
                //{
                Animations.Add(new AgentAnimation(this, animationKey.Key, animationKey.Value));
                // };
            }

            aTimer          = new System.Timers.Timer();
            aTimer.Elapsed += ATimer_Elapsed;
        }
Exemplo n.º 2
0
        public Agent(string agent)
        {
            //we initialize context
            queue = new QueueProcessor();

            var agentJson = AssemblyHelper.ReadResourceString(agent, "agent.json");

            Model = JsonConvert.DeserializeObject <AgentModel>(agentJson);


            ImageSize = new Size(Model.FrameSize[0], Model.FrameSize[1]);
            Animator  = new AgentAnimator(agent, this);

            Animator.NeedsRefresh += Animator_NeedsRefresh;
        }