Esempio n. 1
0
        public void EnemyUseSkill(SkillType skillType, uint callerID, uint targetID)
        {
            foreach (CoolDown cd in _game.CoolDownComponent.All)
            {
                if (cd.Type == skillType && cd.UserID == callerID)
                {
                    return;
                }
            }

            uint eid = Entity.NextEntity();
            uint eid_2 = Entity.NextEntity();
            uint eid_3 = Entity.NextEntity();
            InstantEffect instantEffect;
            DirectDamage directDamage;
            CoolDown coolDown;
            Sprite sprite;
            TimedEffect timedEffect;

            switch (skillType) //add in any skills you need an enemy to use
            {
                case SkillType.DamagingPull:

                    instantEffect = new InstantEffect()
                    {
                        EntityID = eid,
                    };
                    _game.InstantEffectComponent.Add(eid, instantEffect);

                    TargetedKnockBack targetedKnockBack = new TargetedKnockBack()
                    {
                        TargetID = targetID,
                        Origin = _game.PositionComponent[callerID].Center,
                        Distance = -15,
                    };
                    _game.TargetedKnockBackComponent.Add(eid, targetedKnockBack);

                    directDamage = new DirectDamage()
                    {
                        TargetID = targetID,
                        Damage = 1,
                        EntityID = eid,
                    };
                    _game.DirectDamageComponent.Add(eid, directDamage);

                    coolDown = new CoolDown()
                    {
                        EntityID = eid_2,
                        MaxTime = 8f,
                        TimeLeft = 8f,
                        Type = SkillType.DamagingPull,
                        UserID = callerID,
                    };
                    _game.CoolDownComponent.Add(eid_2, coolDown);

                    timedEffect = new TimedEffect()
                    {
                        EntityID = eid_3,
                        TimeLeft = 2f,
                        TotalDuration = 2f,
                    };
                    _game.TimedEffectComponent.Add(eid_3, timedEffect);

                    sprite = new Sprite()
                    {
                        EntityID = eid_3,
                        SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/Skills/Effects/SpiderWeb"),
                        SpriteBounds = new Rectangle(0, 0, 50, 50),
                    };
                    _game.SpriteComponent.Add(eid_3, sprite);

                    Position webPosition = _game.PositionComponent[targetID];
                    webPosition.EntityID = eid_3;
                    _game.PositionComponent.Add(eid_3, webPosition);

                    Buff buffEffect = new Buff()
                    {
                        EntityID = eid_3,
                        TargetID = targetID,
                        MovementSpeed = -50,
                    };
                    _game.BuffComponent.Add(eid_3, buffEffect);

                    break;

                case SkillType.SniperShot:
                    Position callerPos = _game.PositionComponent[callerID];
                    Position targetPos = _game.PositionComponent[targetID];

                    Vector2 direction = targetPos.Center - callerPos.Center;

                    //if (_game.SpriteAnimationComponent.Contains(callerID))
                    //{
                    //    SpriteAnimation spriteAnimation = _game.SpriteAnimationComponent[callerID];
                    //    spriteAnimation.CurrentAnimationRow = (int)_game.MovementComponent.GetFacingFromDirection(direction);
                    //    _game.SpriteAnimationComponent[callerID] = spriteAnimation;
                    //}

                    eid = _game.SkillEntityFactory.CreateSkillProjectile(SkillType.SniperShot, direction, callerPos, 1, 300,callerID, true, false);

                    coolDown = new CoolDown()
                    {
                        EntityID = eid,
                        MaxTime = 1f,
                        TimeLeft = 1f,
                        Type = SkillType.SniperShot,
                        UserID = callerID,
                    };
                    _game.CoolDownComponent.Add(eid, coolDown);

                    break;

                case SkillType.Cloak:
                    timedEffect = new TimedEffect()
                    {
                        EntityID = eid,
                        TimeLeft = 12f,
                        TotalDuration = 12f,
                    };
                    _game.TimedEffectComponent.Add(eid, timedEffect);

                    Cloak cloak = new Cloak(eid, targetID, 10);
                    _game.CloakComponent.Add(eid, cloak);

                    coolDown = new CoolDown()
                    {
                        EntityID = eid,
                        MaxTime = 12f,
                        TimeLeft = 12f,
                        Type = SkillType.Cloak,
                        UserID = callerID,
                    };
                    _game.CoolDownComponent.Add(eid, coolDown);

                    break;

                default:
                    throw new NotImplementedException();
            }
        }
        public void EnemyUseSkill(SkillType skillType, uint callerID, uint targetID)
        {
            foreach (CoolDown cd in _game.CoolDownComponent.All)
            {
                if (cd.Type == skillType && cd.UserID == callerID)
                {
                    return;
                }
            }

            uint eid = Entity.NextEntity();
            uint eid_2 = Entity.NextEntity();
            uint eid_3 = Entity.NextEntity();

            switch (skillType) //add in any skills you need an enemy to use
            {
                case SkillType.DamagingPull:

                    InstantEffect instantEffect = new InstantEffect()
                    {
                        EntityID = eid,
                    };
                    _game.InstantEffectComponent.Add(eid, instantEffect);

                    TargetedKnockBack targetedKnockBack = new TargetedKnockBack()
                    {
                        TargetID = targetID,
                        Origin = _game.PositionComponent[callerID].Center,
                        Distance = -15,
                    };
                    _game.TargetedKnockBackComponent.Add(eid, targetedKnockBack);

                    CoolDown coolDown = new CoolDown()
                    {
                        EntityID = eid_2,
                        MaxTime = 8f,
                        TimeLeft = 8f,
                        Type = SkillType.DamagingPull,
                        UserID = callerID,
                    };
                    _game.CoolDownComponent.Add(eid_2, coolDown);

                    TimedEffect timedEffect = new TimedEffect()
                    {
                        EntityID = eid_3,
                        TimeLeft = 2f,
                        TotalDuration = 2f,
                    };
                    _game.TimedEffectComponent.Add(eid_3, timedEffect);

                    Buff buffEffect = new Buff()
                    {
                        EntityID = eid_3,
                        TargetID = targetID,
                        MovementSpeed = -50,
                    };
                    _game.BuffComponent.Add(eid_3, buffEffect);

                    break;
            }
        }