Exemplo n.º 1
0
        public BalloonBomb(AOE p, bool thrown=true)
            : base()
        {
            parent = p;
            if (!thrown)
            {
                setTexture(new AnimatedTexture(AOE.BASETEX + "aoe storedballoon"));
                radius = 0f;
            }
            else
            {
                setTexture(new AnimatedTexture(AOE.BASETEX + "aoe balloonbomb"));
                radius = 0f;
                switch (parent.curDirection)
                {
                    case Character.Direction.Left: position = parent.getLeft(); break;
                    case Character.Direction.Right: position = parent.getRight(); break;
                    case Character.Direction.Forward: position = parent.getBottom(); break;
                    case Character.Direction.Back: position = parent.getTop(); break;
                }
                velocity = AOE.BALLOON_BOMBS_SPEED * parent.fourWayDirection();
                acceleration = AOE.BALLOON_BOMBS_ACCELERATION * parent.fourWayDirection();
            }

            explosion = new AnimatedTexture(AOE.BASETEX + "aoe-balloon-explode", 4, 100);
        }
Exemplo n.º 2
0
 public static void Initialize(Character c)
 {
     if (!texturesLoaded)
     {
         foreach (AnimatedTexture tex in c.characterTextures.Values)
         {
             tex.LoadTextures();
         }
         texturesLoaded = true;
     }
 }
Exemplo n.º 3
0
 public string getSide(Character.Direction direction)
 {
     switch (direction)
     {
         case Character.Direction.Left: return "side";
         case Character.Direction.Right: return "side";
         case Character.Direction.Forward: return "forward";
         case Character.Direction.Back: return "back";
         default: return "side";
     }
 }
Exemplo n.º 4
0
 public override void hitBy(Character e, double damage, Vector2 knockbackOrigin, float knockbackStrength, float knockbackDuration)
 {
     base.hitBy(e, damage, Vector2.Zero, 0, 0);
     setTexture(bleedingTexture);
     bleedingTime = BLEED_TIME;
     bleeding = true;
     originalPosition = position;
     if (health <= 0)
     {
         foreach (SwampFlower f in flowers)
             Game1.levelManager.enemiesToKill.Add(f);
     }
 }
Exemplo n.º 5
0
 public void Initialize(Character c)
 {
     if (!texturesLoaded)
         {
             foreach (AnimatedTexture tex in c.characterTextures.Values)
             {
                 tex.LoadTextures();
             }
             TextureManager.Add(BASETEX + "aoe storedballoon");
             TextureManager.Add(BASETEX + "aoe balloonbomb");
             TextureManager.Add(BASETEX + "aoe balloonline");
             TextureManager.Add(BASETEX + "aoe-balloon-explode 1");
             TextureManager.Add(BASETEX + "aoe-balloon-explode 2");
             TextureManager.Add(BASETEX + "aoe-balloon-explode 3");
             TextureManager.Add(BASETEX + "aoe-balloon-explode 4");
             texturesLoaded = true;
         }
         for (int i = 0; i < STORED_BALLOON_MAX; i++)
             storedBalloons.Add(storedBalloonPool.obtain(null));
 }
Exemplo n.º 6
0
 public override void hitBy(Character e, double damage, Vector2 knockbackOrigin, float knockbackStrength, float knockbackDuration)
 {
     if (stunned)
     {
         health -= damage;
         shakeAnimationStep = 0;
         if (health <= 0f)
         {
             foreach (Dynamite d in dynamite)
                 Game1.levelManager.enemiesToKill.Add(d);
             exploding = true;
         }
     }
 }
Exemplo n.º 7
0
 public override void hitBy(Character e, double damage, Vector2 knockbackOrigin, float knockbackStrength, float knockbackDuration)
 {
     base.hitBy(e, 0, e.position, 20f, 2f);
 }
Exemplo n.º 8
0
 public void Initialize(Character c)
 {
     if (!texturesLoaded)
     {
         foreach (AnimatedTexture tex in c.characterTextures.Values)
         {
             tex.LoadTextures();
         }
         TextureManager.Add(AOE.BASETEX + "aoe storedballoon");
         TextureManager.Add(AOE.BASETEX + "aoe balloonbomb");
         TextureManager.Add(AOE.BASETEX + "aoe balloonline");
         texturesLoaded = true;
     }
 }
Exemplo n.º 9
0
        public Enemy(int type)
        {
            if (type == -1)
                return;
            species = enemyTypes[type];
            hitbox = new Hitbox((int)(enemyHitboxes[type].width * .8f), (int)(enemyHitboxes[type].height * .8f));
            hitbox.active = true;
            setTexture(new AnimatedTexture(Enemy.BASETEX + species,2, 150));
            target = Game1.characterManager.getRandomLiveCharacter();
            currentState = EnemyState.Attacking;

            switch (type)
            {
                case 0:
                    {
                        scale = .75f;
                        maxHealth = 50;
                        currentAI = EnemyAI.Flee; break;
                    }
                case 1:
                    {
                        maxHealth = 100;
                        currentState = EnemyState.AttackingAll;
                        currentAI = EnemyAI.NoMove; break;
                    }
                case 2:
                    {
                        maxHealth = 100;
                        currentAI = EnemyAI.NoFlee; break;
                    }
                case 3:
                    {
                        maxHealth = 200;
                        hitDamage = 15;
                        currentAI = EnemyAI.Neutral;
                        moveSpeed = 30f;
                        break;
                    }
                case 4:
                    {
                        maxHealth = 300;
                        currentAI = EnemyAI.NoFlee; break;
                    }
                case 5:
                    {
                        maxHealth = 50;
                        currentAI = EnemyAI.Flee; break;
                    }
                case 6:
                    {
                        maxHealth = 150;
                        scale = .6f;
                        currentAI = EnemyAI.NoFlee; break;
                    }
                case 7:
                    {
                        maxHealth = 500;
                        currentAI = EnemyAI.SpawnWords;
                        currentState = EnemyState.Walking;
                        attackSpeed = .5f;
                        break;
                    }
                case 8:
                    {
                        currentAI = EnemyAI.Flee; break;
                    }
            }

            hitbox.width = (int)(hitbox.width * scale);
            hitbox.height = (int)(hitbox.height * scale);

            maxHealth *= 1.5f;
            health = maxHealth;

            oldAI = currentAI;
        }
Exemplo n.º 10
0
        public override void Update(GameTime gameTime)
        {
            if (thrown)
            {
                throwAngle += throwDirection * gameTime.ElapsedGameTime.Milliseconds * .01f;
                position = throwCenter + new Vector2((float)Math.Cos(throwAngle) * throwRadius, -(float)Math.Sin(throwAngle) * throwRadius);
                if (throwDirection == 1 && throwAngle > Math.PI)
                {
                    thrown = false;
                }
                if (throwDirection == -1 && throwAngle < 0) thrown = false;
                return;
            }

            float seconds = (float)gameTime.ElapsedGameTime.TotalSeconds;
            for (int i = hitboxesHitBy.Count - 1; i >= 0; i--)
            {
                if (!hitboxesHitBy[i].intersects(hitbox))
                {
                    hitboxesHitBy.RemoveAt(i);
                    continue;
                }
                Game1.levelManager.hitboxesToDeactivate.Add(hitboxesHitBy[i]);
            }
            if (knockbackTime > 0)
            {
                knockbackTime -= seconds;
                //currentAI = EnemyAI.NoMove;
                float nextX = position.X + (velocity.X * seconds);
                float nextY = position.Y + (velocity.Y * seconds);

                if (!canMove(new Vector2(velocity.X * seconds, 0)))
                    nextX = position.X;
                if (!canMove(new Vector2(0, velocity.Y * seconds)))
                    nextY = position.Y;
                position = new Vector2(nextX, nextY);
            }

            if (stunTimer > 0)
            {
                stunTimer -= gameTime.ElapsedGameTime.Milliseconds;
                return;
            }
            Vector2 distance;
            if (currentAI == EnemyAI.SwampBoss || currentAI == EnemyAI.DynamiteBoss)
            {
                base.Update(gameTime);
                return;
            }
            if (currentAI != EnemyAI.NoMove && currentAI != EnemyAI.NoMoveKnockback)
            {
                if (!target.alive)
                    target = Game1.characterManager.getRandomLiveCharacter();
            }
            else
            {
                target = Game1.characterManager.getClosestLiveCharacter(position);
            }

            if (currentAI == EnemyAI.Neutral) currentState = EnemyState.Walking;

            switch(currentState)
            {
                case EnemyState.Walking:
                    {
                         wanderDist += moveSpeed * seconds;
                         if (wanderDist > 200 && wanderStage == 1)
                         {
                             wanderDir = new Vector2((float)Game1.rand.NextDouble(), (float)Game1.rand.NextDouble());
                             wanderDir.Normalize();
                             wanderDist = 0;
                             wanderStage = 0;
                         }
                         if (wanderDist > 200 && wanderStage == 0)
                         {
                             wanderDir = -wanderDir;
                             wanderDist = 0;
                             wanderStage = 1;
                         }
                         position = position + moveSpeed * seconds * wanderDir;

                         if (currentAI == EnemyAI.SpawnWords)
                         {
                             attackCooldown += gameTime.ElapsedGameTime.Milliseconds;
                             if (attackCooldown > 1000 / attackSpeed)
                             {
                                 attackCooldown = 0;
                                 AnimatedTexture oldTexture = texture;
                                 setTexture(new AnimatedTexture(Enemy.BASETEX + species + " attack", 3, 500));
                                 texture.setOnFrameAction(3, delegate()
                                 {
                                     texture = oldTexture;
                                 });
                                 Game1.levelManager.delayAddEnemy(8, position);
                             }
                         }
                         break;
                    }
                case EnemyState.AttackingAll: {
                    attackCooldown += gameTime.ElapsedGameTime.Milliseconds;
                    foreach (Character target in Game1.characterManager.liveCharacters) {
                            distance = target.position - position;
                            if (hitbox.intersects(target.hitbox))
                            {
                                if (attackCooldown > 1000 / attackSpeed)
                                {
                                    target.hitBy(this);
                                    timer = 0;
                                    AnimatedTexture oldTexture = texture;
                                    setTexture(new AnimatedTexture(Enemy.BASETEX + species + " attack", 1, 250));
                                    texture.setOnFrameAction(1, delegate()
                                    {
                                        texture = oldTexture;

                                        if (currentAI == EnemyAI.Flee)
                                        {
                                            currentState = EnemyState.Blocking;
                                            if (species == "word")
                                            {
                                                setTexture(new AnimatedTexture(Enemy.BASETEX + species + " flee", 2, 150));
                                            }
                                        }
                                    });
                                    attackCooldown = 0;
                                }
                            }
                        }
                        break;
                }
                case EnemyState.Attacking:
                    {
                        if (target != null)
                        {
                            distance = target.position - position;
                            attackCooldown += gameTime.ElapsedGameTime.Milliseconds;
                            if (hitbox.intersects(target.hitbox))
                            {
                                if (attackCooldown > 1000 / attackSpeed)
                                {
                                    target.hitBy(this);
                                    timer = 0;
                                    AnimatedTexture oldTexture = texture;
                                    setTexture(new AnimatedTexture(Enemy.BASETEX + species + " attack", 1, 250));
                                    texture.setOnFrameAction(1, delegate()
                                    {
                                        texture = oldTexture;

                                        if (currentAI == EnemyAI.Flee)
                                        {
                                            currentState = EnemyState.Blocking;
                                            if (species == "word")
                                            {
                                                setTexture(new AnimatedTexture(Enemy.BASETEX + species + " flee", 2, 150));
                                            }
                                        }
                                    });
                                    attackCooldown = 0;
                                }
                            }

                            if (hitbox.intersectPercent(target.hitbox) < .25f)
                            {
                                distance.Normalize();
                                if (disableMovementTime > 0f || disableMovementDistance > 0f && currentAI != EnemyAI.NoMove)
                                {
                                    disableMovementTime -= seconds;
                                    velocity -= velocity * 0.80f * seconds;
                                    disableMovementDistance -= velocity.Length() * seconds;
                                    position += velocity * seconds;
                                }
                                else
                                {
                                    if (currentAI != EnemyAI.NoMove) position = position + moveSpeed * seconds * distance; // close in on a target
                                }
                            }
                        }
                        break;
                    }
                case EnemyState.Blocking:
                    {
                        timer += gameTime.ElapsedGameTime.TotalSeconds;
                        distance = position - target.position;
                        distance.Normalize();
                        if (disableMovementTime > 0f || disableMovementDistance > 0f)
                        {
                            disableMovementTime -= seconds;
                            velocity -= velocity * 0.80f * seconds;
                            disableMovementDistance -= velocity.Length() * seconds;
                            position += velocity * seconds;
                        }
                        else
                        {
                            position = position + fleeSpeed * seconds * distance;
                        }
                        alpha -= alpharate * seconds;
                        if (alpha < 0.5f || alpha > 1f)
                            alpharate = -alpharate;
                        if (timer > fleeTime)
                        {
                            hitboxesHitBy.Clear();
                            currentState = EnemyState.Attacking;

                            if (species == "word")
                            {
                                setTexture(new AnimatedTexture(Enemy.BASETEX + species, 2, 150));
                            }
                            alpha = 1f;
                            timer = 0f;
                        }
                        break;
                    }
                default:
                    break;
            }
            base.Update(gameTime);
        }
Exemplo n.º 11
0
 public virtual void hitBy(Character e, double damage)
 {
     hitBy(e, damage, Vector2.Zero, 0, 0);
 }
Exemplo n.º 12
0
 public string get(Character.Direction direction)
 {
     if (animated) return baseTex + " " + getSide(direction) + " " + frame;
     else return baseTex + " " + getSide(direction);
 }
Exemplo n.º 13
0
 public Texture2D getTexture(Character.Direction direction)
 {
     return TextureManager.Get(get(direction));
 }
Exemplo n.º 14
0
 public void killCharacter(Character c)
 {
     c.alive = false;
     charactersToKill.Add(c);
     //c.hitbox = null;
     if (singleControlled == c)
         singleControlled = null;
 }
Exemplo n.º 15
0
        public virtual void hitBy(Character e, double damage, Vector2 knockbackOrigin, float knockbackStrength, float knockbackDuration)
        {
            //if (charactersHitBy.Contains(e))
            //    return;
            //charactersHitBy.Add(e);

            if (Buffer.attBuff) damage *= Buffer.ATTACKBUFFAMOUNT;
            if (e.numVampBats > 0)
            {
                damage *= 1f + (e.numVampBats / 20f);
            }
            health -= damage;
            if (e.numVampBats > 0)
            {
                e.health += damage * (e.numVampBats / 5f);

                Character buffer = Game1.characterManager.playerCharacters[1];
                if (buffer.alive)
                {
                    buffer.health += damage * (e.numVampBats / 5f) * .25f;
                    buffer.health = Math.Min(buffer.health, buffer.maxHealth);
                }

                e.health = Math.Min(e.health, e.maxHealth);
            }
            if (health <= 0)
                Game1.levelManager.killEnemy(this);
            timer = 0;
            if (currentAI == EnemyAI.Flee)
            {
                currentState = EnemyState.Blocking;
                if (species == "word")
                {
                    setTexture(new AnimatedTexture(Enemy.BASETEX + species + " flee", 2, 150));
                }
            }
            if (currentAI == EnemyAI.Neutral)
            {
                currentAI = EnemyAI.NoFlee;
                moveSpeed = 250f;
                currentState = EnemyState.Attacking;
            }
            target = e;

            knockbackStrength *= 2;
            if (currentAI != EnemyAI.NoMove)
            {
                if (knockbackOrigin != Vector2.Zero)
                {
                    Vector2 distance = position - knockbackOrigin;
                    distance.Normalize();
                    velocity = distance * knockbackStrength;
                    knockbackTime = knockbackDuration;
                   // oldAI = currentAI;
                }
            }
        }
Exemplo n.º 16
0
 public void setSingleControlled(Character c)
 {
     singleControlled = c;
 }
Exemplo n.º 17
0
 public override void hitBy(Character e, double damage, Vector2 knockbackOrigin, float knockbackStrength, float knockbackDuration)
 {
     base.hitBy(e, damage, Vector2.Zero, 0, 0);
 }