コード例 #1
0
 protected EntityAttribute(Entity entity, TValueType baseValue, TValueType maxValue, EntityAttributes attributeType)
 {
     Entity        = entity;
     BaseValue     = baseValue;
     MaxValue      = maxValue;
     AttributeType = attributeType;
 }
コード例 #2
0
ファイル: EntityAttributes.cs プロジェクト: gewl/fortda
    public static Type GetType(EntityAttributes attribute)
    {
        switch (attribute)
        {
        case EntityAttributes.CurrentHealth:
            return(typeof(float));

        case EntityAttributes.BaseMoveSpeed:
            return(typeof(float));

        case EntityAttributes.CurrentMoveSpeed:
            return(typeof(float));

        case EntityAttributes.IsAggroed:
            return(typeof(bool));

        case EntityAttributes.NextWaypoint:
            return(typeof(Vector3));

        case EntityAttributes.CurrentTarget:
            return(typeof(Transform));

        case EntityAttributes.CurrentTargetPosition:
            return(typeof(Vector3));

        case EntityAttributes.CurrentRotationSpeed:
            return(typeof(float));

        case EntityAttributes.CurrentDirection:
            return(typeof(Vector3));

        default:
            return(typeof(float));
        }
    }
コード例 #3
0
        public void AddMapping(AttributeDefinition mapping)
        {
            if (mapping is EntityAttribute)
            {
                var m = mapping as EntityAttribute;

                //if (!EntityAttributes.Contains(m))
                //{
                //    EntityAttributes.Add(m);
                //}

                foreach (var a in EntityAttributes)
                {
                    if (a.Name.Equals(m.Name) && a.IfcEntityAttribute.Equals(m.IfcEntityAttribute))
                    {
                        return;
                    }
                }
                EntityAttributes.Add(m);
            }
            else if (mapping is BbTypeAttribute)
            {
                var n = mapping as BbTypeAttribute;
                foreach (var s in BbTypeAttributes)
                {
                    if (s.Name.Equals(n.Name))
                    {
                        return;
                    }
                }

                BbTypeAttributes.Add(n);
            }
        }
コード例 #4
0
ファイル: EnemyManager.cs プロジェクト: ehuaa/NetEase
    public GameObject Spawn(int ID, int EntityID, Vector3 pos, Quaternion quat)
    {
        GameObject obj = null;

        if (ID == 1)
        {
            obj = Instantiate(EnemyBear, pos, quat);
        }
        else
        {
            obj = Instantiate(EnemyBunny, pos, quat);
        }

        EntityAttributes ea = obj.GetComponent <EntityAttributes>();

        ea.ID       = ID;
        ea.EntityID = EntityID;

        if (enemyArray.ContainsKey(ea.EntityID) == true)
        {
            enemyArray[ea.EntityID].SetActive(false);
            Destroy(enemyArray[ea.EntityID]);
            enemyArray.Remove(ea.EntityID);
        }

        this.enemyArray.Add(EntityID, obj);

        return(obj);
    }
コード例 #5
0
        public Student(string firstName, string lastName, IEnumerable <int> scores)
        {
            _scores.AddRange(scores);

            Attributes = new EntityAttributes();
            FirstName  = firstName;
            LastName   = lastName;
        }
コード例 #6
0
 /// <summary>
 /// If team is -1 then the team will be autoassigned and the spawnBounds will be the spawn bounds of the
 /// assigned team.
 /// </summary>
 /// <param name="name">Name of the new entity</param>
 /// <param name="team">Team of the new entity or -1</param>
 /// <param name="attributes">Attributes of the entity</param>
 /// <param name="spawnBounds">Spawn bounds - ignored if team is -1</param>
 /// <param name="callback">Optional callback for after the first world created with entity in it</param>
 public EntityAddedMutation(string name, int team, EntityAttributes attributes, Rect2 spawnBounds, Action <Entity> callback)
 {
     Name        = name;
     Team        = team;
     Attributes  = attributes;
     SpawnBounds = spawnBounds;
     Callback    = callback;
 }
コード例 #7
0
 internal void ModifyAttribute(TValueType baseValue, TValueType currentValue, TValueType minValue, TValueType maxValue, EntityAttributes attributeType)
 {
     AttributeType = attributeType;
     BaseValue     = baseValue;
     MaxValue      = maxValue;
     MinValue      = minValue;
     CurrentValue  = currentValue;
 }
コード例 #8
0
ファイル: Sensor.cs プロジェクト: crazyants/NetFusion
        public Sensor(Guid sensorId, string displayName, decimal currentValue)
        {
            Attributes = new EntityAttributes();

            SensorId     = sensorId;
            DisplayName  = displayName;
            CurrentValue = currentValue;
        }
コード例 #9
0
ファイル: Entity.cs プロジェクト: oas/MiNET
        public virtual EntityAttributes GetEntityAttributes()
        {
            var attributes = new EntityAttributes();

            attributes["minecraft:attack_damage"] = new EntityAttribute
            {
                Name     = "minecraft:attack_damage",
                MinValue = 0,
                MaxValue = 16,
                Value    = AttackDamage
            };
            attributes["minecraft:absorption"] = new EntityAttribute
            {
                Name     = "minecraft:absorption",
                MinValue = 0,
                MaxValue = float.MaxValue,
                Value    = HealthManager.Absorption
            };
            attributes["minecraft:health"] = new EntityAttribute
            {
                Name     = "minecraft:health",
                MinValue = 0,
                MaxValue = 20,
                Value    = HealthManager.Hearts
            };
            attributes["minecraft:knockback_resistance"] = new EntityAttribute
            {
                Name     = "minecraft:knockback_resistance",
                MinValue = 0,
                MaxValue = 1,
                Value    = 0
            };
            attributes["minecraft:luck"] = new EntityAttribute
            {
                Name     = "minecraft:luck",
                MinValue = -1025,
                MaxValue = 1024,
                Value    = 0
            };
            attributes["minecraft:fall_damage"] = new EntityAttribute
            {
                Name     = "minecraft:fall_damage",
                MinValue = 0,
                MaxValue = float.MaxValue,
                Value    = 0
            };
            attributes["minecraft:follow_range"] = new EntityAttribute
            {
                Name     = "minecraft:follow_range",
                MinValue = 0,
                MaxValue = 2048,
                Value    = 16
            };

            return(attributes);
        }
コード例 #10
0
 private void OnAttributeChanged(EntityAttributes attributeType)
 {
     if (attributeType == EntityAttributes.Health || attributeType == EntityAttributes.MaxHealth)
     {
         health.Ratio = unit.HealthRatio;
     }
     else if (attributeType == EntityAttributes.Power || attributeType == EntityAttributes.MaxPower)
     {
         mainResource.Ratio = Mathf.Clamp01((float)unit.Mana / unit.MaxMana);
     }
 }
コード例 #11
0
        public void DeleteAttribute(string n)
        {
            var a = EntityAttributes.FirstOrDefault(b => b.Name.ToLower() == n.ToLower());

            if (a != null)
            {
                EntityAttributes.Remove(a);
            }
            //_attributeMappingList.RemoveAt(n);
            //return _attributeMappingList;
        }
コード例 #12
0
ファイル: PlayerManager.cs プロジェクト: ehuaa/NetEase
    public void SetBackpack(MsgSCBackpack msg)
    {
        GameSceneManager gs = GetComponent <GameSceneManager>();

        GameObject obj = GetPlayerOjb(gs.userID);

        if (obj != null)
        {
            EntityAttributes ea = obj.GetComponent <EntityAttributes>();
            ea.SetBackpack(msg);
        }
    }
コード例 #13
0
 // Simple getters.
 public object GetAttribute(EntityAttributes attribute)
 {
     try
     {
         return(Attributes[attribute]);
     }
     catch (Exception)
     {
         Debug.Log("Soft attribute not found:");
         Debug.Log(attribute);
         return(null);
     }
 }
コード例 #14
0
        protected void InitializeControllers()
        {
            BattleController    = GetComponent <BattleController>();
            AnimationController = GetComponent <AnimationController>();
            MovementController  = GetComponent <MovementController>();
            EntityAttributes    = GetComponent <EntityAttributes>();

            ProgressBarControllers =
                GetComponents <ProgressBarController>().ToDictionary(b => b.progressBarName, b => b);

            if (ProgressBarControllers != null && ProgressBarControllers.ContainsKey("HealthBar"))
            {
                HealthBarController = ProgressBarControllers["HealthBar"];
            }
        }
コード例 #15
0
        private void LoadAttributes(PropertyInfo property)
        {
            AttributeExtractor extractor = new AttributeExtractor(property);

            if (extractor.UnmappedAttribute != null)
            {
                return;
            }

            if (extractor.EntityAttribute != null)
            {
                EntityAttributes.Add(extractor.EntityAttribute);
            }

            if (extractor.FormulaAttribute != null)
            {
                FormulaAttributes.Add(extractor.FormulaAttribute);
            }

            if (extractor.ColumnAttribute != null)
            {
                if (!ColumnAttributes.Contains(extractor.ColumnAttribute))
                {
                    ColumnAttributes.Add(extractor.ColumnAttribute);
                }

                if (extractor.ForeignKeyAttribute != null)
                {
                    ColumnForeignKeys[extractor.ColumnAttribute] = extractor.ForeignKeyAttribute;
                }

                if (extractor.PrimaryKeyAttribute != null)
                {
                    ColumnPrimaryKeys[extractor.ColumnAttribute] = extractor.PrimaryKeyAttribute;
                }
            }

            if (!extractor.PropertyIsMapped())
            {
                /*
                 * We should warn the user if they have a property in this class that is not mapped, as
                 * this may have been unintentional. They should used an UnmappedAttribute if they wish to
                 * express that the property was left unmapped on purpose.
                 */

                Logger.Warn(MethodBase.GetCurrentMethod(), $"Property {property.Name} of class {entityType.Name} is not mapped explicitly, use an UnmappedAttribute if this was intentional.");
            }
        }
コード例 #16
0
    // Setter for soft attribute that checks input value against expected type for that attribute.
    public void SetAttribute(EntityAttributes attribute, object newValue)
    {
        if (!object.ReferenceEquals(newValue.GetType(), EntityAttributeTypes.GetType(attribute)))
        {
            Debug.Log("Tried to update SoftAttribute with invalid type.");
            Debug.Log("Attribute:");
            Debug.Log(attribute);
            Debug.Log("Value:");
            Debug.Log(newValue);
            Debug.Log("Expected type:");
            Debug.Log(EntityAttributeTypes.GetType(attribute));
            return;
        }

        Attributes[attribute] = newValue;
    }
コード例 #17
0
ファイル: EnemyManager.cs プロジェクト: ehuaa/NetEase
    public bool IsEnemyGameObject(GameObject obj)
    {
        EntityAttributes ea = obj.GetComponent <EntityAttributes>();

        if (ea == null)
        {
            return(false);
        }

        if (enemyArray.ContainsKey(ea.EntityID) == false)
        {
            return(false);
        }

        return(true);
    }
コード例 #18
0
ファイル: PlayerManager.cs プロジェクト: ehuaa/NetEase
    public GameObject CreatePlayer(int userID, int entityID, Vector3 pos, Quaternion quat, bool actor)
    {
        GameObject       obj = null;
        EntityAttributes ea  = null;

        //Other players
        if (actor != true)
        {
            obj = Instantiate(otherplayer, pos, quat);

            ea = obj.GetComponent <EntityAttributes>();

            ea.ID = userID;
            ea.ID = entityID;

            if (playerArray.ContainsKey(ea.ID) == true)
            {
                Destroy(playerArray[ea.ID]);
                playerArray.Remove(ea.ID);
            }


            playerArray.Add(ea.ID, obj);

            return(obj);
        }

        // Current player
        obj = Instantiate(player, pos, quat);

        ea          = obj.GetComponent <EntityAttributes>();
        ea.ID       = userID;
        ea.EntityID = entityID;

        CameraFollower cam = Camera.main.GetComponent <CameraFollower>();

        if (cam != null)
        {
            cam.SetCameraPosition(obj.transform.position);
            cam.target = obj.transform;
            cam.SetOffset();
        }

        playerArray.Add(ea.ID, obj);
        return(obj);
    }
コード例 #19
0
ファイル: Package.cs プロジェクト: DarkSeraphim/MiNET
        public void Write(EntityAttributes attributes)
        {
            if (attributes == null)
            {
                WriteVarInt(0);
                return;
            }

            WriteVarInt(attributes.Count);
            foreach (EntityAttribute attribute in attributes.Values)
            {
                Write(attribute.Name);
                Write(attribute.MinValue);
                Write(attribute.Value);
                Write(attribute.MaxValue);
            }
        }
コード例 #20
0
ファイル: Package.cs プロジェクト: DarkSeraphim/MiNET
        public EntityAttributes ReadEntityAttributes()
        {
            var attributes = new EntityAttributes();
            int count      = ReadVarInt();

            for (int i = 0; i < count; i++)
            {
                EntityAttribute attribute = new EntityAttribute
                {
                    Name     = ReadString(),
                    MinValue = ReadFloat(),
                    Value    = ReadFloat(),
                    MaxValue = ReadFloat(),
                };

                attributes[attribute.Name] = attribute;
            }

            return(attributes);
        }
コード例 #21
0
    public GameObject CreateTrap(int ID, int EntityID, Vector3 pos, Quaternion quat)
    {
        GameObject obj = null;

        if (ID == 1)
        {
            obj = Instantiate(trapPin, pos, quat);
        }
        else
        {
            obj = Instantiate(trapSpeed, pos, quat);
        }

        EntityAttributes ea = obj.GetComponent <EntityAttributes>();

        ea.ID       = ID;
        ea.EntityID = EntityID;

        addTrapArray(ea.EntityID, obj);

        return(obj);
    }
コード例 #22
0
    public override void Initialize(int ownerUniqueID)
    {
        this.ownerUniqueID = ownerUniqueID;
        identifier         = PStrings.entityController;

        input = new EntityInput();
        input.InitializeDefaults();
        attributes = new EntityAttributes();
        attributes.InitializeDefaults();
        state = new EntityState();
        state.InitializeDefaults();

        entityData       = (EntityData)GridData.GetExtensible(ownerUniqueID);
        rigidbody        = entityData.gameObject.GetComponent <Rigidbody>();
        weaponController = entityData.gameObject.GetComponent <WeaponController>();
        if (weaponController != null)
        {
            weaponController.Initialize(entityData);
        }
        waypointManager = (WaypointManagerData)entityData.GetExtension(PStrings.waypointManager);
        pathfindManager = (PathfindManagerData)entityData.GetExtension(PStrings.pathfindManager);

        state.rotationCurrent = Metrics.OrientationFromDirection[(int)entityData.orientation];
    }
コード例 #23
0
 public EntityAttributeInt(Entity entity, int baseValue, int maxValue, EntityAttributes attributeType) : base(entity, baseValue, maxValue, attributeType)
 {
     CurrentValue = BaseValue;
 }
コード例 #24
0
ファイル: Command.cs プロジェクト: crazyants/NetFusion
 protected Command()
 {
     Attributes = new EntityAttributes();
 }
コード例 #25
0
 public DynamicEntityAttribute DynamicEntityAttribute()
 {
     return((DynamicEntityAttribute)EntityAttributes.Single(x => x is DynamicEntityAttribute));
 }
コード例 #26
0
 public SensorReading()
 {
     Attributes = new EntityAttributes();
 }
コード例 #27
0
 public EntityAttributeFloat(Entity entity, float baseValue, float maxValue, EntityAttributes attributeType) : base(entity, baseValue, maxValue, attributeType)
 {
     CurrentValue = BaseValue;
 }
コード例 #28
0
ファイル: DomainEvent.cs プロジェクト: crazyants/NetFusion
 protected DomainEvent()
 {
     Attributes = new EntityAttributes();
 }
コード例 #29
0
ファイル: Sensor.cs プロジェクト: crazyants/NetFusion
 public Sensor()
 {
     Attributes = new EntityAttributes();
 }