Exemple #1
0
        void PlayerTurn()
        {
            foreach (var i in _playerEntities)
            {
                var pe  = _playerEntities.Entities[i];
                var pc1 = _playerEntities.Get1[i];
                var pc3 = _playerEntities.Get3[i];

                if (!pc1.Run)
                {
                    pc1.Run      = true;
                    pc1.PhaseEnd = true;

                    foreach (var j in _collectItemEntities)
                    {
                        var ce  = _collectItemEntities.Entities[j];
                        var cc1 = _collectItemEntities.Get1[j];
                        var cc2 = _collectItemEntities.Get2[j];

                        if (pc3.GO.Collider.OverlapPoint(cc1.Transform.position))
                        {
                            if (cc2.Spell != null)
                            {
                                _world.RLApplySpell(pe, ce, cc2.Spell);
                            }
                            ce.RLDestoryGO();
                        }
                    }
                }
            }
        }
Exemple #2
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>();
                }
            }