コード例 #1
0
        private void UpdatePlayer()
        {
            D3Actor d3Player = memReader.GetPlayer();

            if (d3Player != null)
            {
                this.Me = Player.CreateInstance(this.injector, d3Player.Pointer, d3Player.Acd.Pointer,
                                                d3Player.SnoID, (int)d3Player.ActorID, (int)d3Player.AcdID,
                                                new AABB(d3Player.Pos1, d3Player.Pos2), d3Player.Direction, d3Player.WorldID,
                                                d3Player.Acd.SceneID);

                this.Me.SkillSlots.UpdateSkills(memReader.GetActiveSkills());

                this.Me.Backpack = new Backpack(d3Player.Acd.Attributes[D3Attribute.Backpack_Slots].Value);
                this.Me.Stash    = new Stash(d3Player.Acd.Attributes[D3Attribute.Shared_Stash_Slots].Value);

                this.Me.Health = new Resource(
                    d3Player.Acd.Attributes[D3Attribute.Hitpoints_Cur].Value,
                    d3Player.Acd.Attributes[D3Attribute.Hitpoints_Max].Value);

                D3AttributeValue primaryResource = d3Player.Acd.Attributes[D3Attribute.Resource_Type_Primary];
                this.Me.PrimaryResourceType = (ResourceType)primaryResource.Value;
                this.Me.PrimaryResource     = new Resource(
                    (int)d3Player.Acd.Attributes[D3Attribute.Resource_Cur, primaryResource.Value].ValueF,
                    (int)d3Player.Acd.Attributes[D3Attribute.Resource_Max, primaryResource.Value].ValueF);

                D3AttributeValue secondaryResource;
                if (d3Player.Acd.Attributes.TryGetValue(D3Attribute.Resource_Type_Secondary, out secondaryResource))
                {
                    this.Me.SecondaryResourceType = (ResourceType)secondaryResource.Value;
                }
                else
                {
                    this.Me.SecondaryResourceType = ResourceType.None;
                }
                if (this.Me.SecondaryResourceType != ResourceType.None)
                {
                    this.Me.SecondaryResource = new Resource(
                        (int)d3Player.Acd.Attributes[D3Attribute.Resource_Cur, secondaryResource.Value].ValueF,
                        (int)d3Player.Acd.Attributes[D3Attribute.Resource_Max, secondaryResource.Value].ValueF);
                }

                this.Me.Level       = d3Player.Acd.Attributes[D3Attribute.Level].Value;
                this.Me.XPNextLevel = Experience.Levels[this.Me.Level];
                this.Me.XP          = this.Me.XPNextLevel - d3Player.Acd.Attributes[D3Attribute.Experience_Next].Value;

                this.Me.GlobalCooldown = d3Player.Acd.Attributes[D3Attribute.General_Cooldown].Value;
            }
            else
            {
                this.Me = null;
            }
        }