Exemple #1
0
        public void Update(EnemyManager director)
        {
            if (!canFire)
                {
                    // Incriment cooldown timer
                    intermitent.update();
                    if (intermitent.ring())
                    {
                        canFire = true;
                        intermitent.set(intermitentTime);
                    }
                }

                if (canFire && !lockedOn)
                {

                    // Select Target from director
                    if (!director.isEmpty())
                    {

                        LinkedListNode<Enemy> potential = director.minions.First;
                        LinkedListNode<Enemy> test = director.minions.First;
                        while (test != null)
                        {
                            if (test.Value.position.X > attached.Xpos - 100 && test.Value.position.X < attached.Xpos + 200)
                            {
                                potential = test;
                                lockedOn = true;

                            }
                            test = test.Next;
                        }
                        target = potential;
                        charge.set(chargeTime, true);

                    }
                }

                if (lockedOn)
                {
                    // Charge the laser
                    charge.update();
                    laserTarget = target.Value.position;
                    if (charge.ring())
                    {
                        //FIRE THE LASER!!!
                        if (director.minions.Contains(target.Value))
                        {
                            director.minions.Remove(target);
                        }
                        lockedOn = false;
                        canFire = false;
                    }
                }
        }
        public void Update(EnemyManager director)
        {
            if (!canFire)
            {
                // Incriment cooldown timer
                intermitent.update();
                if (intermitent.ring())
                {
                    canFire = true;
                }
            }

            if (canFire && !lockedOn)
            {

                // Select Target from director
                if (!director.isEmpty())
                {
                    LinkedListNode<Projectile> potential = director.minions.First;
                    LinkedListNode<Projectile> test = director.minions.First;
                    while (test != null)
                    {
                        if (test.Value.posy > potential.Value.posy)
                            potential = test;
                        test = test.Next;
                    }
                    target = potential;
                    charge.set(true);
                    lockedOn = true;
                }
            }

            if (lockedOn)
            {
                // Charge the laser
                charge.update();
                if (charge.ring())
                {
                    //FIRE THE LASER!!!
                    director.minions.Remove(target);
                }
            }
        }