Exemple #1
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="part"></param>
        public void DeleteSlotWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return;
            }

            WeaponPartsStruct lastParts = entity.weaponBasicData.GetParts();
            var parts = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(), part,
                UniversalConsts.InvalidIntId);

            entity.weaponBasicData.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(entity.weaponBasicData.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
Exemple #2
0
 public void Update(PlayerEntity playerEntity, WeaponEntity weaponEntity, IUserCmd cmd)
 {
     _leftcmd.SetCurrentCmd(cmd);
     _rightCmd.SetCurrentCmd(cmd);
     _leftFireLogic.OnFrame(playerEntity, weaponEntity, _leftcmd);
     _rightFireLogic.OnFrame(playerEntity, weaponEntity, _rightCmd);
 }
Exemple #3
0
 internal static void SetFlagWaitDestroy(this WeaponEntity weaponEntity)
 {
     if (!weaponEntity.isFlagSyncSelf)
     {
         weaponEntity.isFlagDestroy = true;
     }
 }
        public void TryHoldGrenade(bool autoStuff = true, bool tryArm = true)
        {
            var weaponAgent = this[EWeaponSlotType.ThrowingWeapon];

            if (autoStuff && weaponAgent.IsValid())
            {
                return;
            }
            int nextId = _grenadeHandler.FindUsable(autoStuff);

            if (nextId < 0 || weaponAgent.ConfigId == nextId)
            {
                return;
            }
            WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct();
            WeaponEntity             newEntity     =
                weaponAgent.ReplaceWeapon(Owner, WeaponUtil.CreateScan(nextId), ref refreshParams);

            SyncBagWeapon(EWeaponSlotType.ThrowingWeapon, newEntity.entityKey.Value);
            RefreshWeaponModelAndParts(refreshParams);
            if (tryArm)
            {
                TryArmWeaponImmediately(EWeaponSlotType.ThrowingWeapon);
            }
        }
    /// <summary> Take loot logic,
    /// If there is an empty slot, then the weapon is added to it
    /// If there is such a weapon, then the number of cartridges is added
    /// </summary>
    /// <param name="loot"> Loot in world entity </param>
    private void TakeLoot(Loot loot)
    {
        var characterWeapon = Weapons.Find(w => w.Weapon == loot.Weapon);

        if (characterWeapon != null)
        {
            if (characterWeapon.CartridgesTotal < characterWeapon.Weapon.MaxCartridges)
            {
                characterWeapon.CartridgesTotal += loot.CartridgesTotal + loot.CartridgesInMagazine;
                UpdateGamePanel();
                loot.PlayLootSound();
                Destroy(loot.gameObject);
            }
            LootInInteractionZone = null;
        }
        else if (Weapons.Count < Description.WeaponsCount)
        {
            var newWeapon = new WeaponEntity(this, loot.Weapon);
            newWeapon.CartridgesInMagazine = loot.CartridgesInMagazine;
            newWeapon.CartridgesTotal      = loot.CartridgesTotal;
            Weapons.Add(newWeapon);
            loot.PlayLootSound();
            Destroy(loot.gameObject);
            LootInInteractionZone = null;
        }
    }
Exemple #6
0
 public void Update(PlayerEntity playerEntity, WeaponEntity weaponEntity, IUserCmd cmd)
 {
     _cmd.SetCurrentCmd(cmd);
     if (null != _fireLogic)
     {
         _fireLogic.OnFrame(playerEntity, weaponEntity, _cmd);
     }
 }
Exemple #7
0
 internal static WeaponScanStruct ToWeaponScan(this WeaponEntity weaponEntity)
 {
     if (!weaponEntity.hasWeaponScan)
     {
         weaponEntity.AddWeaponScan();
     }
     weaponEntity.weaponScan.CopyFrom(weaponEntity.weaponBasicData);
     return(weaponEntity.weaponScan.Value);
 }
Exemple #8
0
 public static bool TryGetWeapon(this PlayerEntity playerEntity,
                                 Contexts contexts, EWeaponSlotType slot, out WeaponEntity weaponEntity)
 {
     return(TryGetWeapon(playerEntity,
                         contexts,
                         (EWeaponBagIndex)playerEntity.bagState.CurBag,
                         slot,
                         out weaponEntity));
 }
        private void Weapon_ImageLoaded(Entity entity)
        {
            WeaponEntity weapon = (WeaponEntity)entity;

            if (weapon.Preferred)
            {
                heroEntity.SwitchTo(weapon);
            }
        }
Exemple #10
0
 public static void SetDestroy(this WeaponEntity weaponEntity)
 {
     if (weaponEntity.hasOwnerId)
     {
         weaponEntity.RemoveOwnerId();
     }
     weaponEntity.isFlagSyncSelf    = false;
     weaponEntity.isFlagSyncNonSelf = false;
     weaponEntity.isFlagDestroy     = true;
 }
    /// <summary> Initialisation character after start </summary>
    /// <param name="description"> Character description</param>
    private void InitCharacter(CharacterDescription description)
    {
        Description = description;
        Health      = Description.MaxHealth;
        RB          = GetComponent <Rigidbody2D>();
        Animator    = GetComponent <Animator>();

        SelectedWeapon = new WeaponEntity(this, Description.StartedWeapon);
        SelectedWeapon.CartridgesTotal = SelectedWeapon.Weapon.MaxCartridges;
        Weapons.Add(SelectedWeapon);

        if (RB == null)
        {
            Debug.LogError("RigidBody2D not found", this);
        }
        if (Animator == null)
        {
            Debug.LogError("Animator not found", this);
        }

        Animator.runtimeAnimatorController = Description.Animator;

        //Set hands
        if (FirstShoulder)
        {
            FirstShoulder.sprite = Description.FirstShoulder;
        }
        if (FirstForearm)
        {
            FirstForearm.sprite = Description.FirstForearm;
        }
        if (FirstForearmOutline)
        {
            FirstForearmOutline.sprite = Description.FirstForearmOutline;
        }
        if (SecondShoulder)
        {
            SecondShoulder.sprite = Description.SecondShoulder;
        }
        if (SecondForearm)
        {
            SecondForearm.sprite = Description.SecondForearm;
        }
        if (SecondForearmOutline)
        {
            SecondForearmOutline.sprite = Description.SecondForearmOutline;
        }

        //Set head
        if (HeadTransform)
        {
            HeadTransform.sprite = Description.HeadSprite;
        }
    }
Exemple #12
0
 public static void AddOwner(this WeaponEntity weaponEntity, EntityKey entityKey)
 {
     if (!weaponEntity.hasOwnerId)
     {
         weaponEntity.AddOwnerId(entityKey);
     }
     else
     {
         weaponEntity.ownerId.Value = entityKey;
     }
     weaponEntity.isFlagSyncSelf = true;
 }
Exemple #13
0
 internal static void SetFlagHasOwnwer(this WeaponEntity weaponEntity, EntityKey entityKey)
 {
     if (!weaponEntity.hasOwnerId)
     {
         weaponEntity.AddOwnerId(entityKey);
     }
     else
     {
         weaponEntity.ownerId.Value = entityKey;
     }
     weaponEntity.isFlagSyncSelf = true;
     weaponEntity.isFlagDestroy  = false;
 }
Exemple #14
0
        public override Player Map(PlayerEntity entity)
        {
            Type type = charactarTypesDict[entity.Character];

            SkinEntity   skinEntity   = _uof.Repository <ISkinsRepository>().Get(entity.SkinId);
            Skin         skin         = _skinMapper.Map(skinEntity);
            WeaponEntity weaponEntity = _uof.Repository <IWeaponsRepository>().Get(entity.WeaponId);
            Weapon       weapon       = _weaponMapper.Map(weaponEntity);

            Character character = (Character)Activator.CreateInstance(type, entity.Id, skin, weapon);
            Player    player    = (Player)Activator.CreateInstance(typeof(Player), entity.Id, entity.Money, character);

            return(player);
        }
Exemple #15
0
        public static EntityKey CreateCustomizeWeapon(EntityKey lastKey, EntityKey owner, int configId)
        {
            if (lastKey.IsValid())
            {
                WeaponEntity currWeapon = WeaponEntityFactory.GetWeaponEntity(lastKey);
                if (currWeapon != null)
                {
                    WeaponEntityFactory.RemoveWeaponEntity(currWeapon);
                }
            }
            WeaponEntity newWeapon = WeaponEntityFactory.CreateEntity(WeaponUtil.CreateScan(configId));

            newWeapon.SetRetain(owner);
            return(newWeapon.entityKey.Value);
        }
Exemple #16
0
 internal static void ResetFireModel(this WeaponEntity weapoon)
 {
     if (weapoon.weaponBasicData.FireMode == 0)
     {
         bool hasAutoFireModel = SingletonManager.Get <WeaponDataConfigManager>().HasAutoFireMode(weapoon.weaponBasicData.ConfigId);
         if (hasAutoFireModel)
         {
             SetFireMode(weapoon, EFireMode.Auto);
         }
         else
         {
             SetFireMode(weapoon, SingletonManager.Get <WeaponDataConfigManager>().GetFirstAvaliableFireMode(weapoon.weaponBasicData.ConfigId));
         }
     }
 }
Exemple #17
0
        public static void SyncSelf(this WeaponScanStruct weaponScan, WeaponEntity weaponEntity)
        {
            var weaponBasicData = weaponEntity.weaponBasicData;

            weaponScan.Assign(weaponEntity.entityKey.Value, weaponBasicData.ConfigId);
            weaponScan.AvatarId       = weaponBasicData.WeaponAvatarId;
            weaponScan.UpperRail      = weaponBasicData.UpperRail;
            weaponScan.LowerRail      = weaponBasicData.LowerRail;
            weaponScan.Magazine       = weaponBasicData.Magazine;
            weaponScan.Muzzle         = weaponBasicData.Muzzle;
            weaponScan.Bullet         = weaponBasicData.Bullet;
            weaponScan.Stock          = weaponBasicData.Stock;
            weaponScan.ReservedBullet = weaponBasicData.ReservedBullet;
            weaponScan.FireMode       = (EFireMode)weaponBasicData.FireMode;
            weaponScan.PullBolt       = weaponBasicData.PullBolt;
        }
Exemple #18
0
 public static void SetRetain(this WeaponEntity weaponEntity, EntityKey owner)
 {
     if (!owner.IsValid())
     {
         return;
     }
     weaponEntity.isFlagSyncSelf    = true;
     weaponEntity.isFlagSyncNonSelf = false;
     if (weaponEntity.hasOwnerId)
     {
         weaponEntity.ownerId.Value = owner;
     }
     else
     {
         weaponEntity.AddOwnerId(owner);
     }
 }
 /// <summary> Interaction logic </summary>
 private void Interaction()
 {
     //If character is near loot
     if (LootInInteractionZone)
     {
         var tempWeapon = SelectedWeapon;
         var newWeapon  = new WeaponEntity(this, LootInInteractionZone.Weapon);
         newWeapon.CartridgesInMagazine = LootInInteractionZone.CartridgesInMagazine;
         newWeapon.CartridgesTotal      = LootInInteractionZone.CartridgesTotal;
         SelectedWeapon = newWeapon;
         Weapons[CurrentWeaponIndex] = SelectedWeapon;
         LootInInteractionZone.InitLoot(tempWeapon.Weapon, tempWeapon.CartridgesTotal, tempWeapon.CartridgesInMagazine);
         if (LootInInteractionZone != null)
         {
             LootInInteractionZone.PlayLootSound();
         }
     }
 }
        private bool ReplaceCommonWeapon(EWeaponSlotType slotType, WeaponScanStruct orient, int bagIndex)
        {
            //  if (vertify)
            if (!processHelper.FilterVailed(orient, slotType))
            {
                return(false);
            }
            logger.InfoFormat("replace weapon:{0}: ", orient);
            //特殊全局性武器只取武器背包第0个索引值
            var weaponAgent = GetWeaponAgent(slotType);
            WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct();
            WeaponEntity             newEntity     = weaponAgent.ReplaceWeapon(Owner, orient, ref refreshParams);

            if (newEntity == null)
            {
                return(false);
            }
            SyncBagWeapon(slotType, newEntity.entityKey.Value);
            RefreshWeaponModelAndParts(refreshParams);
            return(true);
        }
Exemple #21
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetSlotWeaponPart(EWeaponSlotType slot, int id)
        {
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return(false);
            }
            NewWeaponConfigItem wpConfig  = SingletonManager.Get <WeaponConfigManager>().GetConfigById(entity.weaponBasicData.ConfigId);
            WeaponPartsStruct   lastParts = entity.weaponBasicData.GetParts();
            int  realAttachId             = BagUtility.GetRealAttachmentId(id, wpConfig.Id);
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, wpConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(),
                SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                realAttachId);

            entity.weaponBasicData.ApplyParts(attachments);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = entity.weaponBasicData.GetParts();
            RefreshModelWeaponParts(refreshData);
            return(true);
        }
Exemple #22
0
        /// <summary>
        /// 更新到槽位但不是拿在手上
        /// 老的武器entity会被重置或销毁掉
        /// </summary>
        /// <param name="slotType"></param>
        /// <param name="orient"></param>
        /// <param name="bagIndex"></param>
        /// <param name="useBagGlobal"></param>
        /// <returns></returns>
        private bool ReplaceCommonWeapon(EWeaponSlotType slotType, WeaponScanStruct orient, int bagIndex)
        {
            //  if (vertify)
            if (!weaponProcessor.FilterVailed(orient, slotType))
            {
                return(false);
            }
            bool refreshAppearance = (bagIndex == HeldBagPointer || bagIndex < 0);
            //特殊全局性武器只取武器背包第0个索引值
            var weaponAgent = GetWeaponAgent(slotType, bagIndex);
            WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct();
            WeaponEntity             newEntity     = weaponAgent.ReplaceWeapon(Owner, orient, ref refreshParams);

            if (newEntity == null)
            {
                return(false);
            }
            playerWeaponAgent.AddBagWeapon(slotType, newEntity.entityKey.Value, bagIndex);
            if (refreshAppearance)
            {
                RefreshModelWeaponParts(refreshParams);
            }
            return(true);
        }
Exemple #23
0
        /// <summary>
        /// 自动装填手雷到腰间,手雷已装备情况下忽略
        /// </summary>
        public void TryHoldGrenade(bool autoStuff = true, bool tryArm = true)
        {
            var weaponAgent = GetWeaponAgent(EWeaponSlotType.ThrowingWeapon, 0);

            if (autoStuff && weaponAgent.IsValid())
            {
                return;
            }
            int nextId = grenadeHelper.FindUsable(autoStuff);

            if (nextId < 0 || weaponAgent.ConfigId == nextId)
            {
                return;
            }
            WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct();
            WeaponEntity             newEntity     = weaponAgent.ReplaceWeapon(Owner, WeaponUtil.CreateScan(nextId), ref refreshParams);

            playerWeaponAgent.AddBagWeapon(EWeaponSlotType.ThrowingWeapon, newEntity.entityKey.Value, 0);
            RefreshModelWeaponParts(refreshParams);
            if (tryArm)
            {
                TryArmWeapon(EWeaponSlotType.ThrowingWeapon);
            }
        }
Exemple #24
0
        public static bool TryGetWeapon(this PlayerEntity playerEntity,
                                        Contexts contexts,
                                        EWeaponBagIndex bagIndex,
                                        EWeaponSlotType slot,
                                        out WeaponEntity weaponEntity)
        {
            if (slot <= EWeaponSlotType.None ||
                bagIndex <= EWeaponBagIndex.None ||
                bagIndex >= EWeaponBagIndex.Length ||
                slot >= EWeaponSlotType.Length)
            {
                weaponEntity = new WeaponEntity();
                return(false);
            }
            var entityId = GetWeaponInSlot(playerEntity, slot);

            if (!entityId.HasValue)
            {
                weaponEntity = new WeaponEntity();
                return(false);
            }
            weaponEntity = contexts.weapon.GetEntityWithEntityKey(new EntityKey(entityId.Value, (short)EEntityType.Weapon));
            return(null != weaponEntity);
        }
Exemple #25
0
        private int Shoot(int entityId, WeaponEntity weaponEntity)
        {
            var transformComponent = this.EntityManager.GetComponent<TransformComponent>(entityId);

            // Compute initial position.
            var position = transformComponent.Position;
            if (weaponEntity.Anchor != null)
            {
                position += weaponEntity.Anchor.Offset;
            }

            // Compute initial velocity.
            var velocity = Vector2F.UnitX * weaponEntity.Weapon.Speed;

            // Gather initial attributes of projectile.
            var configuration = new AttributeTable
            {
                { TransformComponent.AttributePosition, position },
                { MovementComponent.AttributeVelocity, velocity }
            };

            // Create projectile.
            var projectileBlueprint = this.BlueprintManager.GetBlueprint(weaponEntity.Weapon.ProjectileBlueprintId);
            var projectileEntityId = this.EntityManager.CreateEntity(projectileBlueprint, configuration);

            return projectileEntityId;
        }
Exemple #26
0
 internal static void Activate(this WeaponEntity weaponEntity, bool activate)
 {
     weaponEntity.isActive = activate;
 }
        private void Initialize(bool loaded = false)
        {
            _firingHit = _monsterHit = false;

            HeroCoins = 100;

            heroEntity              = new HeroEntity(11 * 32, 29 * 32);
            heroEntity.FloorY       = 1500;
            heroEntity.HealthPoints = 30f;
            heroEntity.Invicibility = 3000f;
            heroEntity.ClimbSpeed   = heroEntity.Jump / 5;
            heroEntity.RealWidth    = 25;
            heroEntity.RealHeight   = 57;
            heroEntity.RealX        = 18;
            heroEntity.RealY        = 18;
            heroEntity.AxeDamage    = 1f;

            HeroWeapons = new List <WeaponEntity>();

            WeaponEntity weapon = new WeaponEntity();

            weapon.BulletDamage       = 1;
            weapon.FireRate           = 1;
            weapon.RechargeTime       = 3000;
            weapon.TimeBetweenBullets = 430;
            weapon.ImageLoaded       += Weapon_ImageLoaded;
            weapon.Preferred          = true;
            weapon.NeedsRecharge      = true;
            weapon.BulletLifespan     = 450;
            weapon.RealHeight         = weapon.RealWidth = 1;
            weapon.BulletSpeed        = new Vector2(3 * Constants.EntitySpeed, 0);

            HeroWeapons.Add(weapon);
            //   Floor = new ObstacleEntity(ObstacleType.Floor, 0, 206);

            Laders = new List <Entity>();

            obstacleEntities = new List <ObstacleEntity>();
            // obstacleEntities.Add(Floor);

            //           CreateHaystack(250, 0);
            //   CreateLader(400, 0);
            //   CreateLader(550, 0);
            //   CreateLader(200, 0);

            MonsterEntities       = new List <MonsterEntity>();
            FarmerEntities        = new List <FarmerEntity>();
            FiringMonsterEntities = new List <FiringMonsterEntity>();
            CreateFarmer(20 * 32, 43 * 32);
            CreateGuard(91 * 32, 37 * 32);
            CreateFarmer(101 * 32, 38 * 32);
            CreateGuard(110 * 32, 38 * 32);

            TriangularLaders = new List <TriangularLader>();
//            CreateTriangularLader(600, 0);

            Marshes = new List <MarshEntity>();
//            CreateMarsh(heroEntity.X - 150, 200, 8 * 16, 6 * 16);

            Background = new StaticBackground();
            // Background.Height = 120;

            this.RNG = new Random(228);

            heroEntity.SwitchTo(weapon);
            heroEntity.AttachBackground(Background);
        }
Exemple #28
0
 /// <summary>
 /// sync from event of playerEntiy.BagSet.WeaponSlot Component
 /// </summary>
 /// <param name="entityKey"></param>
 internal void Sync(EntityKey entityKey)
 {
     entity = WeaponEntityFactory.GetWeaponEntity(WeaponContext, entityKey);
 }
Exemple #29
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var weapon1 = new WeaponEntity
            {
                Id        = 1,
                Price     = 0,
                Damage    = 90,
                Distance  = 200,
                ModelPath = "models/weapons/skin1.3ds",
                Name      = "Стандартний молот",
                Character = Entities.Enums.CharacterType.GNOME
            };

            var weapon2 = new WeaponEntity
            {
                Id        = 2,
                Price     = 0,
                Damage    = 70,
                Distance  = 300,
                ModelPath = "models/weapons/skin2.3ds",
                Name      = "Стандартний лук",
                Character = Entities.Enums.CharacterType.ELF
            };

            var weapon3 = new WeaponEntity
            {
                Id        = 3,
                Price     = 0,
                Damage    = 120,
                Distance  = 100,
                ModelPath = "models/weapons/skin3.3ds",
                Name      = "Стандартний меч",
                Character = Entities.Enums.CharacterType.WARRIOR
            };

            var weapon4 = new WeaponEntity
            {
                Id        = 4,
                Price     = 0,
                Damage    = 180,
                Distance  = 50,
                ModelPath = "models/weapons/skin4.3ds",
                Name      = "Стандартний посох",
                Character = Entities.Enums.CharacterType.MAGICIAN
            };

            var weapon5 = new WeaponEntity
            {
                Id        = 5,
                Price     = 300,
                Damage    = 220,
                Distance  = 50,
                ModelPath = "models/weapons/skin5.3ds",
                Name      = "Золотий посох",
                Character = Entities.Enums.CharacterType.MAGICIAN
            };

            var skin1 = new SkinEntity
            {
                Id        = 1,
                Price     = 0,
                ModelPath = "models/skins/skin1.3ds",
                Name      = "Стандартний вигляд",
                Character = Entities.Enums.CharacterType.GNOME
            };

            var skin2 = new SkinEntity
            {
                Id        = 2,
                Price     = 0,
                ModelPath = "models/skins/skin2.3ds",
                Name      = "Стандартний вигляд",
                Character = Entities.Enums.CharacterType.ELF
            };

            var skin3 = new SkinEntity
            {
                Id        = 3,
                Price     = 0,
                ModelPath = "models/skins/skin3.3ds",
                Name      = "Стандартний вигляд",
                Character = Entities.Enums.CharacterType.WARRIOR
            };

            var skin4 = new SkinEntity
            {
                Id        = 4,
                Price     = 0,
                ModelPath = "models/skins/skin4.3ds",
                Name      = "Стандартний вигляд",
                Character = Entities.Enums.CharacterType.MAGICIAN
            };

            var skin5 = new SkinEntity
            {
                Id        = 5,
                Price     = 100,
                ModelPath = "models/skins/skin5.3ds",
                Name      = "Маг з плащем",
                Character = Entities.Enums.CharacterType.MAGICIAN
            };

            var skin6 = new SkinEntity
            {
                Id        = 6,
                Price     = 300,
                ModelPath = "models/skins/skin6.3ds",
                Name      = "Маг в костюмі",
                Character = Entities.Enums.CharacterType.MAGICIAN
            };

            var player = new PlayerEntity
            {
                Id        = 1,
                Character = Entities.Enums.CharacterType.ELF,
                Money     = 500,
                SkinId    = 2,
                WeaponId  = 2
            };

            modelBuilder.Entity <PlayerEntity>(entity =>
            {
                entity.HasKey(e => e.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
                entity.Property(e => e.Money).IsRequired();
                entity.HasOne <WeaponEntity>().WithMany().HasForeignKey(w => w.WeaponId);
                entity.HasOne <SkinEntity>().WithMany().HasForeignKey(s => s.SkinId);
            });

            modelBuilder.Entity <SkinEntity>(entity =>
            {
                entity.HasKey(e => e.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
                entity.Property(e => e.Name).IsRequired();
                entity.Property(e => e.Price).IsRequired();
                entity.Property(e => e.ModelPath).IsRequired();
                entity.Property(e => e.Character).IsRequired();
            });

            modelBuilder.Entity <WeaponEntity>(entity =>
            {
                entity.HasKey(e => e.Id);
                entity.Property(e => e.Id).ValueGeneratedOnAdd();
                entity.Property(e => e.Name).IsRequired();
                entity.Property(e => e.Damage).IsRequired();
                entity.Property(e => e.Price).IsRequired();
                entity.Property(e => e.ModelPath).IsRequired();
                entity.Property(e => e.Character).IsRequired();
            });

            modelBuilder.Entity <PlayerEntity>().HasData(player);
            modelBuilder.Entity <WeaponEntity>().HasData(weapon1, weapon2, weapon3, weapon4, weapon5);
            modelBuilder.Entity <SkinEntity>().HasData(skin1, skin2, skin3, skin4, skin5, skin6);
        }
Exemple #30
0
 public static void RemoveOwner(this WeaponEntity weaponEntity)
 {
     weaponEntity.isFlagSyncSelf = false;
 }
 public static void RemoveWeaponEntity(WeaponEntity entity)
 {
     AssertUtility.Assert(SharedConfig.IsServer, "only Server remove weapon directly");
     DebugUtil.MyLog("Server Remove Weapon directly:" + entity.entityKey.Value, DebugUtil.DebugColor.Blue);
     WeaponEntityExt.SetDestroy(entity);
 }