Пример #1
0
        protected bool UpdateEnemyChaseState(Hero hero, float distToHero)
        {
            bool caught = false;

            caught = Collided(hero);

            if (caught)
            {
                hero.Caught();
                hero.Center = hero.HeroInitialPos;
            }

            TargetPosition = hero.Center;
            if (caught)
            {
                Center       = EnemyInitialPos;
                CurrentState = EnemyState.Patrol;
                return(true);
            }
            else
            {
                Center += .05f * (hero.Center - Center) * difficulty;
            }

            return(false);
        }
Пример #2
0
        private void UpdateEnemyChaseState(Hero hero, float distToHero)
        {
            bool caught = false;

            caught = Collided(hero);

            if (caught)
            {
                hero.Caught();
                hero.Center = hero.HeroInitialPos;
            }

            TargetPosition = hero.Center;
            if (caught)
            {
                hero.Color = Color.Red;
            }

            else
            {
                Center += .05f * (hero.Center - Center);
            }
        }
Пример #3
0
        public bool Update(Hero hero, Wand w)
        {
            heroHit = false;
            health.Update(new Vector2(this.Center.X, this.Center.Y + 1), healthRemaining, initialLives);

            if (current == wizardStatus.isAlive)
            {
                if (shieldCoolDown < 0 && !shielded)
                {
                    shielded       = true;
                    shieldCoolDown = 100;
                }
                else
                {
                    shieldCoolDown--;
                }

                if (shieldCoolDown < 0 && shielded)
                {
                    shielded       = false;
                    shieldCoolDown = 100;
                }


                if (shielded)
                {
                    Texture = "wizardShield";
                }
                else
                {
                    Texture = "wizardRight";
                    if (coolDown < 0)
                    {
                        coolDown = 40;
                        shoot(hero.Center);
                    }
                    else
                    {
                        coolDown--;
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    shot temp = list[i];
                    if (list[i].shotLife == 0)
                    {
                        list[i].bullet.RemoveFromAutoDrawSet();
                        list[i].emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                    }
                    else
                    {
                        temp.shotLife--;
                        if (hero.Collided(temp.bullet) && !temp.hit)
                        {
                            hero.Caught();
                            hero.Center = hero.HeroInitialPos;
                            temp.hit    = true;
                            heroHit     = true;
                        }
                        list[i] = temp;
                        list[i].emitter.Center = list[i].bullet.Center;
                    }
                }
                for (int i = 0; i < w.list.Count; i++)
                {
                    if (w.list[i].bullet.Collided(this))
                    {
                        if (!shielded)
                        {
                            healthRemaining--;
                        }
                        else
                        {
                            Random r = new Random();
                            if (r.Next(0, 100) < 10)
                            {
                                healthRemaining--;
                            }
                        }
                    }
                }

                if (healthRemaining <= 0)
                {
                    current = wizardStatus.isDead;
                    Texture = "Newteddybear";
                    XNACS1Base.PlayACue("Bear-Sound");

                    return(true);
                }

                if (this.Center.X - hero.Center.X > 0)
                {
                    Texture = shielded ? "wizardShieldLeft" : "wizardLeft";
                }
                else
                {
                    Texture = shielded ? "wizardShield" : "wizardRight";
                }
            }

            if (current == wizardStatus.isDead)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
            }
            return(false);
        }
        private void UpdateEnemyChaseState(Hero hero, float distToHero)
        {
            bool caught = false;

            caught = Collided(hero);

            if (caught) {
                hero.Caught();
                hero.Center = hero.HeroInitialPos;
            }

            TargetPosition = hero.Center;
            if (caught)
                hero.Color = Color.Red;

            else {
                Center += .05f * (hero.Center - Center);
            }
        }
Пример #5
0
        protected bool UpdateEnemyChaseState(Hero hero, float distToHero)
        {
            bool caught = false;

            caught = Collided(hero);

            if (caught) {
                hero.Caught();
                hero.Center = hero.HeroInitialPos;

            }

            TargetPosition = hero.Center;
            if (caught)
            {
                Center = EnemyInitialPos;
                CurrentState = EnemyState.Patrol;
                return true;
            }
            else
            {
                Center += .05f * (hero.Center - Center) * difficulty;
            }

            return false;
        }
Пример #6
0
        public bool Update(Hero hero, Wand w)
        {
            heroHit = false;
            health.Update(new Vector2(this.Center.X, this.Center.Y+1), healthRemaining, initialLives);

            if (current == wizardStatus.isAlive) {
                if (shieldCoolDown < 0 && !shielded) {
                    shielded = true;
                    shieldCoolDown = 100;
                }
                else
                    shieldCoolDown--;

                if (shieldCoolDown < 0 && shielded) {
                    shielded = false;
                    shieldCoolDown = 100;
                }

                if (shielded) {
                    Texture = "wizardShield";

                }
                else {
                    Texture = "wizardRight";
                    if (coolDown < 0) {
                        coolDown = 40;
                        shoot(hero.Center);
                    }
                    else
                        coolDown--;
                }

                for (int i = 0; i < list.Count; i++) {
                    shot temp = list[i];
                    if (list[i].shotLife == 0) {
                        list[i].bullet.RemoveFromAutoDrawSet();
                        list[i].emitter.RemoveFromAutoDrawSet();
                        list.Remove(list[i]);
                    }
                    else {
                        temp.shotLife--;
                        if (hero.Collided(temp.bullet) && !temp.hit) {
                            hero.Caught();
                            hero.Center = hero.HeroInitialPos;
                            temp.hit = true;
                            heroHit = true;
                        }
                        list[i] = temp;
                        list[i].emitter.Center = list[i].bullet.Center;
                    }
                }
                for (int i = 0; i < w.list.Count; i++)
                    if (w.list[i].bullet.Collided(this)) {
                        if (!shielded)
                            healthRemaining--;
                        else {
                            Random r = new Random();
                            if (r.Next(0, 100) < 10)
                                healthRemaining--;
                        }
                    }

                if (healthRemaining <= 0) {
                    current = wizardStatus.isDead;
                    Texture = "Newteddybear";
                    XNACS1Base.PlayACue("Bear-Sound");

                    return true;
                }

                if (this.Center.X - hero.Center.X > 0)
                    Texture = shielded ? "wizardShieldLeft" : "wizardLeft";
                else
                    Texture = shielded ? "wizardShield" : "wizardRight";
            }

            if (current == wizardStatus.isDead) {
                for (int i = 0; i < list.Count; i++) {
                    list[i].bullet.RemoveFromAutoDrawSet();
                    list[i].emitter.RemoveFromAutoDrawSet();
                    list.Remove(list[i]);
                }
            }
            return false;
        }