public static void RLCreateEffect(this EcsWorld world, Vector2 position, EffectPreset effectPreset)
        {
            var go = VExt.LayoutSpriteObject(ObjData.r_PrefabSprite, position, ObjData.t_GameObjectsOther, SortingLayer.Effect.ToString(), effectPreset.spriteSingle);
            var e  = world.NewEntityWithGameObject(go);

            e.Set <EffectComponent>().Duration = effectPreset.duration;
        }
Esempio n. 2
0
        void LayoutWallObject(ref List <Vector2Int> emptyCells)
        {
            var cell = VExt.NextFromList(emptyCells);

            var go = VExt.LayoutAnimationObject(
                ObjData.r_PrefabPhysicsAnimation,
                cell.x, cell.y,
                "wall",
                ObjData.t_GameObjectsRoot,
                SortingLayer.Object.ToString(),
                VExt.NextFromArray(ObjData.p_WallsPresets.Animation));

            var e = _world.NewEntityWith(out GameObjectComponent goComponent, out WallComponent _);

            goComponent.Transform           = go.transform;
            goComponent.GO                  = go.GetComponent <PrefabComponentsShortcut>();
            goComponent.GO.NPCNameText.text = e.GetInternalId().ToString();

            var dataComponent = e.Set <NPCDataSheetComponent>();

            dataComponent.Stats.MaxHealthPoint = UnityEngine.Random.Range(minWallHP, maxWallHP + 1);
            dataComponent.Stats.HealthPoint    = dataComponent.Stats.MaxHealthPoint;

            emptyCells.Remove(cell);
        }
Esempio n. 3
0
        void LayoutEnemyObject(ref List <Vector2Int> emptyCells, EnemyPreset enemyPreset)
        {
            var cell = VExt.NextFromList(emptyCells);

            _world.RLCreateEnemy(cell, enemyPreset);

            emptyCells.Remove(cell);
        }
Esempio n. 4
0
        void NewFruitHeal(ref List <Vector2Int> emptyCells)
        {
            var pos = VExt.NextFromList(emptyCells);

            _presets.CollectingItems.TryGetValue("FruitHeal", out CollectingItemPreset preset);
            _world.RLNewLevelObject(preset, pos);
            emptyCells.Remove(pos);
        }
        public static EcsEntity RLNewLevelObject(this EcsWorld world, CollectingItemPreset preset, Vector2 pos)
        {
            var go = VExt.NewGameObject(preset.GameObject, pos);
            var e  = world.NewEntityWithGameObject(go, false);
            var c  = e.Set <CollectItemComponent>();

            c.Spell = preset.Spell;
            return(e);
        }
Esempio n. 6
0
        void IEcsRunSystem.Run()
        {
            foreach (var i in _attackingEntities)
            {
                ref var e  = ref _attackingEntities.Entities[i];
                var     c1 = _attackingEntities.Get1[i];
                var     c2 = _attackingEntities.Get2[i];
                var     c3 = _attackingEntities.Get3[i];

                if (!c1.Run)
                {
                    c1.Run = true;
                    var c = e.Set <ActionAnimationComponent>();
                    c.Animation = AnimatorField.AnimationAttack;
                }

                if (c1.Run && !c1.OnAttack && c2.GO.AnimatorActionTime > attackTime)
                {
                    c1.OnAttack = true;
                    if (c1.PrimaryOrSecondaryWeapon)
                    {
                        _world.RLCreateEffect(c1.TargetPosition, c3.PrimaryWeapon.HitEffect);
                        _world.RLApplyDamage(c1.Target, e, c3.PrimaryWeapon.Damage);
                        if (c3.PrimaryWeapon.SpellPreset != null)
                        {
                            _world.RLApplySpell(c1.Target, e, c3.PrimaryWeapon.SpellPreset);
                        }
                    }
                    else
                    {
                        var go = VExt.LayoutSpriteObject(
                            ObjData.r_PrefabPhysicsSprite,
                            c2.GO.Rigidbody.position,
                            ObjData.t_GameObjectsOther,
                            SortingLayer.Effect.ToString(),
                            c3.SecondaryWeapon.ProjectileSprite);

                        _world.NewEntityWith(out GameObjectComponent goComponent, out ProjectileComponent projectileComponent);
                        goComponent.Transform = go.transform;
                        goComponent.GO        = go.GetComponent <PrefabComponentsShortcut>();

                        projectileComponent.StartPosition = c2.GO.Rigidbody.position;
                        projectileComponent.GoalPosition  = c1.TargetPosition;
                        projectileComponent.Caster        = e;
                        projectileComponent.Target        = c1.Target;
                        projectileComponent.Weapon        = c3.SecondaryWeapon;
                    }
                }

                if (c1.Run && c1.OnAttack && !c2.GO.AnimatorActionRun)
                {
                    e.Unset <ActionAttackComponent>();
                }
            }
        public static void RLCreateEnemy(this EcsWorld world, Vector2 position, EnemyPreset enemyPreset)
        {
            var go = VExt.LayoutAnimationObject(ObjData.r_PrefabPhysicsAnimation, position, enemyPreset.PresetName, ObjData.t_GameObjectsRoot, SortingLayer.Character.ToString(), enemyPreset.Animation);
            var e  = world.NewEntityWithGameObject(go, true);

            e.Set <EnemyComponent>();
            var data = e.Set <NPCDataSheetComponent>();

            data.Stats           = new NPCStats(enemyPreset);
            data.PrimaryWeapon   = new NPCWeapon(enemyPreset.PrimaryWeaponItem, new WB_DamageOnContact());
            data.SecondaryWeapon = new NPCWeapon(enemyPreset.PrimaryWeaponItem, new WB_DamageOnContact());
            data.StatusEffects   = new List <StatusEffect>();
        }
        public static EcsEntity RLNewLevelObject(this EcsWorld world, LevelTilePreset preset, Vector2 pos)
        {
            var go = VExt.NewGameObject(preset.GameObject, pos);
            var e  = world.NewEntityWithGameObject(go, false);

            if (preset.Obstacle)
            {
                e.Set <ObstacleComponent>();
            }
            if (preset.ExitPoint)
            {
                e.Set <ExitPointComponent>();
            }

            return(e);
        }
        public static EcsEntity RLNewLevelObject(this EcsWorld world, PlayerPreset preset, Vector2 pos)
        {
            var go = VExt.NewGameObject(preset.GameObject, pos);
            var e  = world.NewEntityWithGameObject(go, false);

            e.Set <PlayerComponent>();
            var data = e.Set <NPCDataSheetComponent>();

            data.Stats = Service <NPCDataSheet> .Get().NPCStats;

            data.PrimaryWeapon = Service <NPCDataSheet> .Get().PriamaryWeapon;

            data.SecondaryWeapon = Service <NPCDataSheet> .Get().SecondaryWeapon;

            data.StatusEffects = new List <StatusEffect>();
            return(e);
        }
Esempio n. 10
0
        void CreateTileOverlay(Vector2 target)
        {
            if (!CheckObstacleCollision(target))
            {
                var go = VExt.LayoutSpriteObject(
                    ObjData.r_PrefabSprite,
                    target.x, target.y,
                    "tileOverlay",
                    ObjData.t_GameObjectsOther,
                    SortingLayer.TileOverlay.ToString(),
                    ObjData.p_Overlay.spriteSingle);

                _world.NewEntityWith(out GameObjectComponent goComponent, out TargetTileComponent targetTile);
                goComponent.Transform = go.transform;
                goComponent.GO        = go.GetComponent <PrefabComponentsShortcut>();

                SetupTargetTile(target, ref goComponent, ref targetTile);
            }
        }
Esempio n. 11
0
        public void LevelCreate()
        {
            var rooms = new Rooms();

            var roomsArray = VExt.NextFromArray(rooms.RoomsArray);

            Array.Reverse(roomsArray);

            int width  = roomsArray[0].Length;
            int height = roomsArray.Length;;

            List <Vector2Int> emptyCells = new List <Vector2Int>();

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (roomsArray[i][j] != ' ')
                    {
                        NewLevelTile(rooms.GetNameID('.'), new Vector2(j, i));
                    }
                    switch (roomsArray[i][j])
                    {
                    case '.':
                        emptyCells.Add(new Vector2Int(j, i));
                        break;

                    case '#':
                        NewLevelTile(rooms.GetNameID('#'), new Vector2(j, i));
                        break;

                    case 'X':
                        NewLevelTile(rooms.GetNameID('X'), new Vector2(j, i));
                        break;

                    case '@':
                        NewPlayer(j, i);
                        break;

                    case 'A':
                        NewLevelTile(rooms.GetNameID('A'), new Vector2(j, i));
                        break;

                    default:
                        break;
                    }
                }
            }

            for (int i = 0; i < boostHPCount; i++)
            {
                //LayoutBoostHPObject(ref emptyCells);
            }

            for (int i = 0; i < healCount; i++)
            {
                NewFruitHeal(ref emptyCells);
            }

            for (int i = 0; i < wallCount; i++)
            {
                LayoutWallObject(ref emptyCells);
            }

            for (int i = 0; i < enemy01Count; i++)
            {
                LayoutEnemyObject(ref emptyCells, ObjData.p_Enemy01Preset);
            }

            for (int i = 0; i < enemy02Count; i++)
            {
                LayoutEnemyObject(ref emptyCells, ObjData.p_Enemy02Preset);
            }
        }