Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (!Clone && newone == false) {
            timetoborn = Time.time;
            newone = true;
            smoke = true;
        }

        if (smoke == true && newone == true && Time.time - timetoborn > 2f) {
            if (Born)
                Born.Play ();
            smoke = false;
        }

        if (newone == true && Time.time - timetoborn > 4f) {
            if (numberofSpawn < numberofEnnemies) {
                if (maya.Stats.level < 10)
                    Clone = Instantiate (Zombies[Random.Range(0,1)], transform.position, Quaternion.identity) as Enemies;
                else
                    Clone = Instantiate (Zombies[Random.Range(0,2)], transform.position, Quaternion.identity) as Enemies;
                numberofSpawn++;
            } else if (numberofSpawn == numberofEnnemies) {
                Clone = Instantiate (MidBoss, transform.position, Quaternion.identity) as Enemies;
                numberofSpawn++;
            }
            Clone.gameObject.SetActive(true);
            newone = false;
        }

        if (numberofSpawn > numberofEnnemies) {
            gameObject.SetActive(false);
        }
    }
Ejemplo n.º 2
0
    public static void enemyFlee(Enemies.Enemy en)
    {
        for (int j = 0; j< WorldData.gameData.Locations[en.location].getAdjacentNodes().Length; j++)
        {
            if (WorldData.gameData.Locations [WorldData.gameData.Locations [en.location].getAdjacentNodes() [j]].EnemyAtLocation == false)
            {
                LocationData.Location a = WorldData.gameData.Locations [en.location];
                WorldData.gameData.Locations.Remove(WorldData.gameData.Locations [en.location]);
                a.EnemyAtLocation = true;
                WorldData.gameData.Locations.Add(a);

                Enemies.Enemy temp = en;
                WorldData.gameData.Enemy .Remove(en);
                temp.location = WorldData.gameData.Locations [WorldData.gameData.Locations [en .location].getAdjacentNodes() [j]].getNodeNumber();
                WorldData.gameData.Enemy .Add(temp);

                a = WorldData.gameData.Locations [en .location];
                WorldData.gameData.Locations.Remove(WorldData.gameData.Locations [en.location]);
                a.EnemyAtLocation = false;
                WorldData.gameData.Locations.Add(a);

                break;

            }
        }
    }
Ejemplo n.º 3
0
 public void checkHit(Enemies.Enemy tEnemy)
 {
     if (Vector2.Distance(position, tEnemy.position) <= (tEnemy.shipRadius + collisionRadius) * 0.8f)
     {
         tEnemy.takeDamage(0.1f * (1 - collisionRadius));
     }
 }
Ejemplo n.º 4
0
    public static int EnemyAttack(Enemies.Enemy enemy)
    {
        const float combatConstant = .01f;
        const float e = 2.71828f;
        int damage = Mathf.Clamp((int)Mathf.Ceil(Random.Range(0, (int)(enemy.attack * ((Mathf.Pow(e, -1 * combatConstant / ((WorldData.gameData.TotalEndurance / 2) * (WorldData.gameData.TotalStrength/2))   )))))), 0, (int)(enemy.attack * ((Mathf.Pow(e, -1 * combatConstant / ((WorldData.gameData.TotalEndurance / 2) * (WorldData.gameData.TotalStrength/2) + WorldData.gameData.Armor))))));

        return damage;
    }
Ejemplo n.º 5
0
 protected override void Initialize()
 {
     base.Initialize();
     _player.InitializeDrawing(@"Plane\Player", 1f);
     _btns = new ControlButtons(this.Content, this.spriteBatch);
     _playerBullets = new PlayerBullets(this.Content, this.spriteBatch);
     enimies = new Enemies(this.Content, this.spriteBatch);
 }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     a = GetComponent<Animator> ();
     stats = GetComponent<Enemies> ();
     if (isIce)
         StartCoroutine ("ShootIce");
     if (isMole)
         StartCoroutine ("ActivatePower");
 }
Ejemplo n.º 7
0
 public bool collideRadius(Enemies.Enemy enemy)
 {
     float x = (enemy.getPos().X) - (position.X * gWidth);
     float y = (enemy.getPos().Y) - (position.Y * gHeight);
     int hyp = (int)Math.Sqrt((x * x) + (y * y));
     if (hyp <= radius)
         return true;
     return false;
 }
Ejemplo n.º 8
0
 public Enemies(Enemies enemy)
 {
     this.name = enemy.name;
     this.enemyStats = new EnemyStats(enemy.enemyStats);
     this.charAbilitiesIndex = new List<int>(enemy.charAbilitiesIndex);
     //this.statusEffectsIndex = new List<int>(enemy.statusEffectsIndex);
     innateAbilities = new List<Ability>();
     affectedStatusEffects = new List<StatusEffects>();
     onHitStatusEffects = new List<StatusEffects>();
 }
Ejemplo n.º 9
0
 public bool Collide(Enemies.Enemy enemy)
 {
     if (enemy.getRectangle().Intersects(new Rectangle((int)position.X, (int)position.Y, width, height)))
     {
         if((enemy.canFly() && flying) || (!enemy.canFly() && ground))
         {
             if (!piercing)
                 isDead = true;
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 10
0
    void Start()
    {
        worldTicker = GameObject.Find("GameManager").GetComponent<WorldTicker>();
        canvas = GameObject.Find("HealthCanvas").GetComponent<Canvas>();

        EnemyDatabase enemyDB = GameObject.Find("Databases").GetComponent<EnemyDatabase>();
        enemy = enemyDB.getEnemyByID(0); //This, with some work, can be passed to EnemyDatabase so it only runs once
        enemy.Initialize();
        enemy.SetController(this);
        myRig = GetComponent<Rigidbody2D>();

        initHealthBar();
    }
    // Update is called once per frame
    void Update()
    {
        transform.Translate (Vector3.up * speed);
        if ((transform.position.y) >= ScreenHeight) {
            Destroy (gameObject);
        }
        //COLLISIONS
        for(int i=0; i < Main.EnemiesList.Count; i++){
            GameObject target = Main.EnemiesList[i].gameObject;
            if(target!=null){// Checks to avoid missingexception
            enemy = target.GetComponent<Enemies>();// allows access to methods and varibles within targets constructor

            float distance=(transform.position- target.transform.position).magnitude;//creates a float which stores position between 2 variables
            //Debug.Log (target); //check the distance between two vectors
            if(distance <= 0.5f){
                enemy.SubtractLife(target);//access enemy referance and use Subtract method to take HP away from target
                Destroy(gameObject);//Destroy Bullet
            }
            //Score if killed
                if(enemy.Health==0){
                    EnemyCount-=1;// 1 Enemy has been hit, Deduct Health
                    CreateParticles(transform.position, target.renderer.material.color, enemy.speed, 20); // Feed in particles spawn area, color and take in speed for effects
                    Destroy(target.gameObject); //Destroy Enemy
                    EnemiesList.Remove(target.gameObject); //Remove enemy Gameobject from List, also avoids missingexception

                    if(target.renderer.material.color==EnemyType[0]){
                        UI.ChangeScore(10);//Calls ChangeScore from UI Script
                    }
                    if(target.renderer.material.color==EnemyType[1]){
                        UI.ChangeScore(25);
                        int spawn=Random.Range(0,10);
                        if(spawn<8)
                            return;
                        else{
                        //BONUS PICK UP
                        GameObject bonus=GameObject.CreatePrimitive(PrimitiveType.Capsule);
                        bonus.AddComponent<Bonus>();
                        bonus.AddComponent<Strobe>();
                        bonus.transform.localScale = new Vector3(0.2f, 0.2f, 0.1f);
                        bonus.transform.position=target.transform.position;
                        }
                    }
                    if(target.renderer.material.color==EnemyType[2]){
                        UI.ChangeScore(20);
                    }
                }
            }//end target if
        }//end For loop
    }
Ejemplo n.º 12
0
 public Bullet(int dmg, int spd, bool isFlying, bool isGround, bool isHoming, bool isPiercing, int x, int y, Texture2D sprite, int w, int h, Enemies.Enemy t)
 {
     flying = isFlying;
     ground = isGround;
     homing = isHoming;
     piercing = isPiercing;
     power = dmg;
     speed = spd;
     width = w;
     height = h;
     image = sprite;
     position = new Vector2(x,y);
     target = t;
     objectPosition = t.getPos();
     angleChange(objectPosition);
     isDead = false;
 }
Ejemplo n.º 13
0
 public static void enemyAction(Enemies.Enemy e)
 {
     int R = Mathf.Clamp((int)Mathf.Ceil(Random.Range(0, 100)), 0, 101);
        // Debug.Log(R);
     if (R < 10)
     {
         //Debug.Log(1);
         if (e.hp <= e.maxhp * .10)
         {
             enemyFlee(e);
             WorldData.gameData.CombatLog = WorldData.gameData.CombatLog + "The enemy has fled with his tail betwixt his legs.";
         }
         else
             enemyAction(e);
     }
     else if (R > 9 && R < 20)
     {
        // Debug.Log(2);
         if (e.hp <= e.maxhp * .25)
         {
             e.hp = (int)(e.hp + e.maxhp * .2);
             WorldData.gameData.CombatLog = WorldData.gameData.CombatLog + "The enemy has devoured a small, grey kitten and gains 20% health.";
         }
         else
             enemyAction(e);
     }
     else if (R > 19 && R < 30)
     {
         //Debug.Log(3);
         int damage = (int)(1.5 * EnemyAttack(e));
         WorldData.gameData.CombatLog = WorldData.gameData.CombatLog + "The enemy attacks you and smites you betwixt the eyes for " + damage + ".";
         WorldData.gameData.Stats.setHealth(WorldData.gameData.Stats.getHealth() - (damage));
     }
     else
     {
        // Debug.Log(4);
         int damage = EnemyAttack(e);
         WorldData.gameData.CombatLog = WorldData.gameData.CombatLog + "The enemy attacks and deals " + damage + " damage.";
         WorldData.gameData.Stats.setHealth(WorldData.gameData.Stats.getHealth() - (damage));
     }
 }
Ejemplo n.º 14
0
    void SpawnEnemy(Enemies type)
    {
        switch (type) {
            case Enemies.TWITCH:
            {
                // spawn three enemies that stay in position and twitch
                int num_enemies = 3;

                for (int e = 0; e < num_enemies; e++) {
                    start_position = new Vector3 (player.transform.position.x,
                                                  player.transform.position.y,
                                                  player.transform.position.z - radius );
                    target_position = new Vector3 (radius * Mathf.Cos(e * Mathf.PI / (num_enemies-1)),
                                                   radius * Mathf.Sin(e * Mathf.PI / (num_enemies-1)) - (radius / 4),
                                                   radius );
                    GameObject enemy = Instantiate (enemy_type_a, start_position, Quaternion.identity) as GameObject;
                    enemy.GetComponent<EnemyControllerA>().SetTargetPosition(target_position);
                }
                break;
            }
            case Enemies.SQUARE:
            {
                // spawn three enemies that stay in position and twitch
                int num_enemies = 4;

                for (int i = 0; i < num_enemies; i++) {
                    start_position = new Vector3 (player.transform.position.x,
                                                  player.transform.position.y,
                                                  player.transform.position.z - radius );
                    target_position = new Vector3 (radius * Mathf.Cos(i * 2 * Mathf.PI / num_enemies + (Mathf.PI/4)),
                                                   radius * Mathf.Sin(i * 2 * Mathf.PI / num_enemies + (Mathf.PI/4)),
                                                   radius );
                    GameObject enemy = Instantiate (enemy_type_b, start_position, Quaternion.identity) as GameObject;
                    enemy.GetComponent<EnemyControllerB>().Initialize(i, num_enemies);
                }
                break;
            }
        }
    }
Ejemplo n.º 15
0
        public static bool AddEnemy(int enemyId, ApplicationDbContext ctx)
        {
            Creature enemy = new GetCreature(ctx).Get(enemyId);

            if (enemy == null)
            {
                return(false);
            }

            if (Enemies == null)
            {
                Enemies = new List <Creature>();
            }

            var deserializeSettings = new JsonSerializerSettings {
                ObjectCreationHandling = ObjectCreationHandling.Replace
            };

            enemy = JsonConvert.DeserializeObject <Creature>(JsonConvert.SerializeObject(enemy), deserializeSettings);

            Enemies.Add(enemy);

            return(true);
        }
Ejemplo n.º 16
0
        public override void Update(RenderWindow window)
        {
            if (numWaveNow == numWaves && Enemies.Count == 0)
            {
                WinScreen.Display();
            }

            if (numWaveNow != numWaves)
            {
                if ((DateTime.Now - timeNowWave).TotalSeconds > timeToNewWave || Enemies.Count == 0)
                {
                    for (var i = 0; i < numWaveNow; i++)
                    {
                        Enemies.Add(Character.SpawnCharacter(75, new Point(random.Next((int)Program.WidthWindow), -100), CharacterMovesAnimation.StandEnemyTexture, new Pistol()));
                    }

                    timeNowWave = DateTime.Now;
                    numWaveNow++;
                    timeToNewWave = timeBetweenWaves;
                }
            }

            base.Update(window);
        }
Ejemplo n.º 17
0
 public static void AddAnemy(GameEnums.Enemies type, ref GraphicsDeviceManager manager, int count, Random rnd)
 {
     for (var i = 0; i < count; i++)
     {
         var wid        = rnd.Next(50, manager.PreferredBackBufferWidth / 2 - 50);
         var heig       = rnd.Next(50, manager.PreferredBackBufferHeight / 2 - 50);
         var enemy      = SettingsManager.Enemies[type];
         var enemyToAdd = new Enemy
         {
             AnimationCounter = enemy.AnimationCounter,
             AttacksPerSecond = enemy.AttacksPerSecond,
             AbilityPower     = enemy.AbilityPower,
             ArmorValue       = enemy.ArmorValue,
             AttackDamage     = enemy.AttackDamage,
             EnemyType        = enemy.EnemyType,
             HealthPoints     = enemy.HealthPoints,
             MovementSpeed    = enemy.MovementSpeed,
             MagicResistance  = enemy.MagicResistance,
             ManaPoints       = enemy.ManaPoints
         };
         enemyToAdd.Position = new Vector2(wid, heig);
         Enemies.Add(enemyToAdd);
     }
 }
Ejemplo n.º 18
0
        public override void Update(RenderWindow window)
        {
            if ((DateTime.Now - timeNowWave).TotalSeconds > timeToNewWave || Enemies.Count == 0)
            {
                for (var i = 0; i < numWaveNow; i++)
                {
                    enemyGun = Gun.Copy(enemyGun);
                    Enemies.Add(Character.SpawnCharacter(75, new Point(random.Next((int)Program.WidthWindow), -100), CharacterMovesAnimation.StandEnemyTexture, enemyGun));
                }

                timeNowWave = DateTime.Now;
                numMicroWave++;

                if (numMicroWave == 3)
                {
                    numMicroWave = 0;
                    numWaveNow++;
                }

                guns.TryGetValue(numMicroWave, out enemyGun);
            }

            base.Update(window);
        }
Ejemplo n.º 19
0
    public Part[] parts;       // The array of ship Parts


    void Start()
    {
        type = 4;
        setScore(Enemies.getScoresave(type));
        alive  = true; // Its alliiiiivvveeee!
        points = new Vector3[2];
        // There is already an initial position chosen by Main.SpawnEnemy()
        // so add it to points as the initial p0 & p1
        points[0] = pos;
        points[1] = pos;
        InitMovement();
        // Cache GameObject & Material of each Part in parts
        Transform t;

        foreach (Part prt in parts)
        {
            t = transform.Find(prt.name);
            if (t != null)
            {
                prt.go  = t.gameObject;
                prt.mat = ((prt.go).GetComponent <Renderer>()).material;
            }
        }
    }
Ejemplo n.º 20
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.gameObject.layer == 9 || hitInfo.gameObject.layer == 10 || hitInfo.gameObject.layer == 14 || hitInfo.gameObject.layer == 15)
        {
            if (hitInfo.gameObject.layer == 9)
            {
                Enemies enemy = hitInfo.gameObject.GetComponent <Enemies>();
                enemy.TakeDamage(damage);
            }

            if (hitInfo.gameObject.layer == 15)
            {
                EnemyMove escape = hitInfo.gameObject.GetComponent <EnemyMove>();
                escape.TakeDamage(damage);
            }

            if (hitInfo.gameObject.layer == 14)
            {
                Boss boss = hitInfo.gameObject.GetComponent <Boss>();
                boss.TakeDamage(damage);
            }
            Destroy(gameObject);
        }
    }
Ejemplo n.º 21
0
            public void Add(IMsbModel item)
            {
                var m = (Model)item;

                switch (m.Type)
                {
                case ModelType.MapPiece:
                    MapPieces.Add(m);
                    break;

                case ModelType.Object:
                    Objects.Add(m);
                    break;

                case ModelType.Enemy:
                    Enemies.Add(m);
                    break;

                case ModelType.Player:
                    Players.Add(m);
                    break;

                case ModelType.Collision:
                    Collisions.Add(m);
                    break;

                case ModelType.Navmesh:
                    Navmeshes.Add(m);
                    break;

                default:
                    throw new ArgumentException(
                              message: "Item is not recognized",
                              paramName: nameof(item));
                }
            }
Ejemplo n.º 22
0
 private void OnCollisionEnter2D(Collision2D collision)//消灭敌人
 {
     if (collision.gameObject.tag == "Enemies")
     {
         Enemies enemy = collision.gameObject.GetComponent <Enemies>();
         if (anim.GetBool("jumpingdown"))
         {
             enemy.JumpOn();
             rb.velocity = new Vector2(rb.velocity.x, 10);
         }
         else if (transform.position.x < collision.gameObject.transform.position.x)
         {
             hurtAudio.Play();
             rb.velocity = new Vector2(-10, rb.velocity.y);
             isHurt      = true;
         }
         else if (transform.position.x > collision.gameObject.transform.position.x)
         {
             hurtAudio.Play();
             rb.velocity = new Vector2(10, rb.velocity.y);
             isHurt      = true;
         }
     }
 }
Ejemplo n.º 23
0
    void endBattle()
    {
        if (state == BattleState.WON)
        {
            Debug.Log("Won the batle");
            dialogueText.text = "You won the battle";

            StartCoroutine(earnExperience());

            Currency.gold += (int)Random.Range(5.0f, 15.0f);

            foreach (DropController drop in Enemies.enemiesList[Enemies.getSelectedEnemy()].drops)
            {
                Debug.Log("Rolando chance do item " + drop.itemName + ".");
                if (drop.rollDropChance())
                {
                    Debug.Log("Item name on battleSystem " + drop.itemName);
                    Item item = Items.getItemByName(drop.itemName);
                    item.amount = 1;
                    Players.playersList[Players.getSelectedPlayer()].inventory.addItem(item);
                }
            }

            // display exp earned text
            // verify level up to display in text
            // press any key to quit battle
            SceneManager.LoadScene("MainCity");
        }

        if (state == BattleState.LOST)
        {
            dialogueText.text = "You lost the battle";
            // display some lost text
            // press any key to return
        }
    }
        public MainWindow()
        {
            InitializeComponent();
            FoxDraw foxDraw = new FoxDraw(canvas);

            gameSetup      = new GameSetup(canvas, 500);
            enemies        = new Enemies();
            headsUpDisplay = new HeadsUpDisplay(canvas);
            player         = new Player(headsUpDisplay, enemies, canvas);
            graphics       = new Draw(canvas, foxDraw, enemies, headsUpDisplay, player);

            Characters.AddToList(player);

            enemies.Add(new Enemy("Boss", player, canvas, Images.boss, 9, 9, true, 20, 20, 10));
            enemies.Add(new Enemy("SkeletonA", player, canvas, Images.skeleton, 0, 5));
            enemies.Add(new Enemy("SkeletonB", player, canvas, Images.skeleton, 4, 3));
            enemies.Add(new Enemy("SkeletonC", player, canvas, Images.skeleton, 7, 8));

            animator = new Animator(player, graphics);

            graphics.Refresh();
            Sound.PlayMusic(Sounds.mapMusic);
            animator.SpriteAnimation();
        }
Ejemplo n.º 25
0
        // Display the current map
        public override string ToString()
        {
            string s = "";

            for (int y = 0; y < Rows; y++)
            {
                for (int x = 0; x < Cols; x++)
                {
                    Coordinates pos = new Coordinates(x, y);
                    char        c   = '_';
                    if (MyAnts.ContainsKey(pos))
                    {
                        c = 'a';
                    }
                    else if (Walls.Contains(pos))
                    {
                        c = '#';
                    }
                    else if (Enemies.Contains(pos))
                    {
                        c = 'e';
                    }
                    else if (Food.Contains(pos))
                    {
                        c = '.';
                    }
                    else if (Hills.Contains(pos))
                    {
                        c = '*';
                    }
                    s += c;
                }
                s += "\n";
            }
            return(s);
        }
Ejemplo n.º 26
0
        public void Tick(double deltaTime)
        {
            //Player.Tick(deltaTime);

            foreach (var x in AllEntities)
            {
                x.Tick(deltaTime);
            }

            _physics.Tick(deltaTime);

            var buf1 = Enemies.Where(e => e.Health <= 0).ToList();

            foreach (var e in buf1)
            {
                RemoveMonstor(e);
            }
            var buf2 = Particles.Where(e => e.Lifetime <= 0).ToList();

            foreach (var e in buf2)
            {
                RemoveEntity(e);
            }
        }
Ejemplo n.º 27
0
 public void TakeDamage(Enemies e)
 {
     if (YVel < 0.0f)
     {
         e.TakeDamage("stomp");
         YVel         = bounceHeight / riseTime;
         YTime.Amount = YTime.Min;
     }
     else
     {
         if (curPowerUp == Powerups.fire || curPowerUp == Powerups.leaf || curPowerUp == Powerups.frog)
         {
             curPowerUp = Powerups.big;
         }
         else if (curPowerUp == Powerups.big)
         {
             curPowerUp = Powerups.small;
         }
         else
         {
             curPowerUp = Powerups.dead;
         }
     }
 }
Ejemplo n.º 28
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.name == "HeavyBandit")
        {
            Enemies enemy = hitInfo.GetComponent <Enemies>();
            if (enemy != null)
            {
                enemy.Hurt(damage);
            }
        }

        if (hitInfo.name == "WeakSpot")
        {
            ShootingDemon sd = hitInfo.GetComponent <ShootingDemon>();
            if (sd != null)
            {
                sd.Hurt(damage);
            }
        }



        Destroy(gameObject);
    }
Ejemplo n.º 29
0
        public void AddEnemy(Vector3 pos, Enemies e)
        {
            //pos.Y += 300;
            switch (e)
            {
                case Enemies.Slime:
                    {
                        Enemy slimeEnemy = new Enemy("Gooey1", false, 0, 10, 10, new Vector2(1, 1), 100, pos, AI.Forward, 10, 10, 100, 0);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Slime2:
                    {
                        Enemy slimeEnemy = new Enemy("Gooey2", false, 0, 10, 10, new Vector2(1, 3), 100, pos, AI.Sin, 15, 15, 200, 0);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Slime3:
                    {
                        Enemy slimeEnemy = new Enemy("Gooey3", false, 1, 20, 20, new Vector2(1, 2), 100, pos, AI.Forward, 20, 20, 300, 0);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Slime4:
                    {
                        Enemy slimeEnemy = new Enemy("Gooey4", false, 1, 30, 20, new Vector2(1, 2), 100, pos, AI.Sin, 25, 25, 400, 0);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Ghost:
                    {
                        Enemy slimeEnemy = new Enemy("Ghost", true, 2, 40, 60, new Vector2(2, 4), 100, pos, AI.Ghost, 40, 40, 400, 1);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Skeleton:
                    {
                        Enemy slimeEnemy = new Enemy("Skeleton", true, 1, 120, 40, new Vector2(1, 2), 100, pos, AI.Forward, 80, 50, 400, -1);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Zombie:
                    {
                        Enemy slimeEnemy = new Enemy("Zombie", true, 0, 160, 50, new Vector2(0.5f, 1), 100, pos, AI.Forward, 100, 60, 400, -1);
                        enemies.Add(slimeEnemy);

                        break;
                    }
                case Enemies.Boss:
                    {
                        Enemy boss1Enemy = new Enemy(bossBehaviour.BossName, bossBehaviour.Animated, bossBehaviour.ModelID, bossBehaviour.Hp, 10, new Vector2(0.2f, 0.2f), bossBehaviour.Radius, pos, AI.Boss, bossBehaviour.Loot, bossBehaviour.Xp, bossBehaviour.Score, 0);
                        enemies.Add(boss1Enemy);
                        break;
                    }
            }
            castle.EnemiesInCurrentWave--;
        }
Ejemplo n.º 30
0
        public void ReportPoisonImmune(Enemies.ImmuneEnemy immuneEnemy, Trap poisonTrap)
        {
            //there's only one achievement that matters here
            if (achieved[Achievements.WhyWontYouDie])
                return;

            //we only care about fully upgraded traps
            if (poisonTrap.CanUpgrade)
                return;

            if (poisonCounts == null)
                poisonCounts = new Dictionary<Enemy, int>();

            if (poisonCounts.ContainsKey(immuneEnemy))
            {
                poisonCounts[immuneEnemy]++;
                if (poisonCounts[immuneEnemy] >= 5)
                {
                    achieved[Achievements.WhyWontYouDie] = true;
                    saveAchieved();
                    poisonCounts = null;
                }
            }
            else
            {
                poisonCounts[immuneEnemy] = 1;
            }
        }
Ejemplo n.º 31
0
 public static void onClickBattle(int enemyId)
 {
     Enemies.setSelectedEnemy(enemyId);
     SceneManager.LoadScene("Battle");
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // set up the display window
            graphics.PreferredBackBufferWidth = 500;
            graphics.PreferredBackBufferHeight = 500;
            graphics.ApplyChanges();

            // update the ViewportHeight and ViewportWidth constants so the screens know
            // how to draw themselves
            GameConstants.ViewportHeight = graphics.GraphicsDevice.Viewport.Height;
            GameConstants.ViewportWidth = graphics.GraphicsDevice.Viewport.Width;

            // display title in the window
            Window.Title = "Alien Attack";

            // setup the state of the game
            currentGameState = GameConstants.GameState.Title;
            currentKeyboardState = Keyboard.GetState();
            prevKeyBoardState = currentKeyboardState;

            // set up the screens
            titleScreen = new TitleScreen();
            instructionScreen = new InstructionScreen();
            highScoreScreen = new HighScoreScreen();
            creditsScreen = new CreditsScreen();
            introScreen = new IntroScreen();
            readyScreen = new GetReadyScreen();
            gameOverScreen = new GameOverScreen();

            // set up the game objects
            gameCamera = new Camera();
            player = new Player();
            enemies = new Enemies();
            map = new Map();
            miniMap = new MiniMap();
            skybox = new Skybox();

            // set up the ingame displays
            score = new Score();
            highScore = new HighScore();

            // set up the soundtrack
            gameSongs = new GameSongs();

            base.Initialize();
        }
Ejemplo n.º 33
0
        public void CheckBulletsImpact()
        {
            if (Level == 1)
            {
                //Hero to Enemies
                for (int index = 0; index < Hero.bullets.Count; index++)
                {
                    foreach (Enemy enemy in Enemies)
                    {
                        Rectangle b = new Rectangle(Hero.bullets[index].Location.X, Hero.bullets[index].Location.Y, Hero.bullets[index].BulletImg.Width, Hero.bullets[index].BulletImg.Height);
                        Rectangle h = new Rectangle(enemy.Location.X, enemy.Location.Y, 37, 35);
                        if (b.IntersectsWith(h))
                        {
                            Hero.bullets[index].Hit = true;
                            enemy.Health           -= 50;
                        }
                    }
                    for (int i = 0; i < Enemies.Count; i++)
                    {
                        if (Enemies.ElementAt(i).Health <= 0)
                        {
                            Enemies.RemoveAt(i);
                            i--;
                        }
                    }
                }


                //Hero to Meteors
                for (int index = 0; index < Hero.bullets.Count; index++)
                {
                    foreach (Meteor meteor in Meteors)
                    {
                        Rectangle b = new Rectangle(Hero.bullets[index].Location.X, Hero.bullets[index].Location.Y, Hero.bullets[index].BulletImg.Width, Hero.bullets[index].BulletImg.Height);
                        Rectangle m = new Rectangle(meteor.Location.X, meteor.Location.Y, 40, 40);
                        Rectangle h = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);
                        if (b.IntersectsWith(m))
                        {
                            Hero.bullets[index].Hit = true;
                            meteor.Health          -= 40;
                        }
                        if (h.IntersectsWith(m))
                        {
                            Hero.Health = 0;
                        }
                    }

                    for (int i = 0; i < Meteors.Count; i++)
                    {
                        if (Meteors.ElementAt(i).Health <= 0)
                        {
                            Meteors.RemoveAt(i);
                            i--;
                        }
                    }
                }

                //Enemies to Hero
                foreach (Enemy enemy in Enemies)
                {
                    for (int index = 0; index < enemy.Bullets.Count; index++)
                    {
                        Rectangle b = new Rectangle(enemy.Bullets[index].Location.X, enemy.Bullets[index].Location.Y, enemy.Bullets[index].Image.Width, enemy.Bullets[index].Image.Height);
                        Rectangle h = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 70, 80);
                        if (b.IntersectsWith(h))
                        {
                            enemy.Bullets[index].ToBeRemoved = true;
                            Hero.Health -= 1;
                        }
                    }
                }

                //Meteors to Enemies
                foreach (Meteor meteor in Meteors)
                {
                    Rectangle m = new Rectangle(meteor.Location.X, meteor.Location.Y, 50, 50);
                    foreach (Enemy enemy in Enemies)
                    {
                        Rectangle e = new Rectangle(enemy.Location.X, enemy.Location.Y, 37, 35);
                        if (m.IntersectsWith(e))
                        {
                            meteor.Health -= 40;
                            enemy.Health   = 0;
                        }
                    }
                    Rectangle h = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);
                    if (m.IntersectsWith(h))
                    {
                        Hero.Health = 0;
                    }
                }
                for (int i = 0; i < Meteors.Count; i++)
                {
                    if (Meteors.ElementAt(i).Health <= 0)
                    {
                        Meteors.RemoveAt(i);
                        i--;
                    }
                }

                for (int i = 0; i < Enemies.Count; i++)
                {
                    if (Enemies.ElementAt(i).Health <= 0)
                    {
                        Enemies.RemoveAt(i);
                        i--;
                    }
                }
            }
            else if (Level == 2)
            {
                //Hero to Meteors
                for (int index = 0; index < Hero.bullets.Count; index++)
                {
                    foreach (Meteor meteor in Meteors)
                    {
                        Rectangle b = new Rectangle(Hero.bullets[index].Location.X, Hero.bullets[index].Location.Y, Hero.bullets[index].BulletImg.Width, Hero.bullets[index].BulletImg.Height);
                        Rectangle m = new Rectangle(meteor.Location.X, meteor.Location.Y, 40, 40);
                        Rectangle h = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);
                        if (b.IntersectsWith(m))
                        {
                            Hero.bullets[index].Hit = true;
                            meteor.Health          -= 40;
                        }
                        if (h.IntersectsWith(m))
                        {
                            Hero.Health = 0;
                        }
                    }

                    for (int i = 0; i < Meteors.Count; i++)
                    {
                        if (Meteors.ElementAt(i).Health <= 0)
                        {
                            Meteors.RemoveAt(i);
                            i--;
                        }
                    }
                }
                foreach (Meteor meteor in Meteors)
                {
                    Rectangle m = new Rectangle(meteor.Location.X, meteor.Location.Y, 50, 50);
                    foreach (Enemy enemy in Enemies)
                    {
                        Rectangle e = new Rectangle(enemy.Location.X, enemy.Location.Y, 37, 35);
                        if (m.IntersectsWith(e))
                        {
                            meteor.Health -= 40;
                            enemy.Health   = 0;
                        }
                    }
                    Rectangle h = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);
                    if (m.IntersectsWith(h))
                    {
                        Hero.Health = 0;
                    }
                }

                for (int i = 0; i < Meteors.Count; i++)
                {
                    if (Meteors.ElementAt(i).Health <= 0)
                    {
                        Meteors.RemoveAt(i);
                        i--;
                    }
                }

                for (int i = 0; i < Enemies.Count; i++)
                {
                    if (Enemies.ElementAt(i).Health <= 0)
                    {
                        Enemies.RemoveAt(i);
                        i--;
                    }
                }
            }
            else if (Level == 3)
            {
                Rectangle b1 = new Rectangle(Boss.Location.X, Boss.Location.Y + 20, 150, 50);
                Rectangle b2 = new Rectangle(Boss.Location.X + 55, Boss.Location.Y, 50, 150);
                Rectangle h  = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);

                //Hero to Boss
                for (int index = 0; index < Hero.bullets.Count; index++)
                {
                    Rectangle b = new Rectangle(Hero.bullets[index].Location.X, Hero.bullets[index].Location.Y, Hero.bullets[index].BulletImg.Width, Hero.bullets[index].BulletImg.Height);
                    if (b.IntersectsWith(b1) || b.IntersectsWith(b2))
                    {
                        Boss.Health            -= 5;
                        Hero.bullets[index].Hit = true;
                    }
                }

                //Boss to Hero
                for (int index = 0; index < Boss.Bullets.Count; index++)
                {
                    Rectangle b = new Rectangle(Boss.Bullets[index].Location.X, Boss.Bullets[index].Location.Y, Boss.Bullets[index].Image.Width, Boss.Bullets[index].Image.Height);
                    if (b.IntersectsWith(h))
                    {
                        Hero.Health -= 35;
                        Boss.Bullets[index].ToBeRemoved = true;
                    }
                }

                for (int index = 0; index < Hero.bullets.Count; index++)
                {
                    foreach (Meteor meteor in Meteors)
                    {
                        Rectangle b  = new Rectangle(Hero.bullets[index].Location.X, Hero.bullets[index].Location.Y, Hero.bullets[index].BulletImg.Width, Hero.bullets[index].BulletImg.Height);
                        Rectangle m  = new Rectangle(meteor.Location.X, meteor.Location.Y, 40, 40);
                        Rectangle h1 = new Rectangle(Hero.Location.X, Hero.Location.Y + 30, 80, 50);
                        if (b.IntersectsWith(m))
                        {
                            Hero.bullets[index].Hit = true;
                            meteor.Health          -= 40;
                        }
                        if (h.IntersectsWith(m))
                        {
                            Hero.Health = 0;
                        }
                    }
                }

                for (int i = 0; i < Meteors.Count; i++)
                {
                    if (Meteors.ElementAt(i).Health <= 0)
                    {
                        Meteors.RemoveAt(i);
                        i--;
                    }
                }
                if (Boss.Health <= 0)
                {
                    //GAME OVER - WIN
                }
            }

            for (int i = 0; i < Hero.bullets.Count; i++)
            {
                if (Hero.bullets.ElementAt(i).Hit)
                {
                    Hero.bullets.RemoveAt(i);
                    i--;
                }
            }

            for (int i = 0; i < Boss.Bullets.Count; i++)
            {
                if (Boss.Bullets.ElementAt(i).ToBeRemoved)
                {
                    Boss.Bullets.RemoveAt(i);
                    i--;
                }
            }


            foreach (Enemy enemy in Enemies)
            {
                for (int i = 0; i < enemy.Bullets.Count; i++)
                {
                    if (enemy.Bullets.ElementAt(i).ToBeRemoved)
                    {
                        enemy.Bullets.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Ejemplo n.º 34
0
        private void MoveEnemies(GameTime gameTime)
        {
            ICamera camera = (ICamera)Game.Services.GetService(typeof(ICamera));

            int itemsToDelete = 0;

            foreach (Enemy s in enemies)
            {
                if (s.Active)
                {
                    switch (s.AI)
                    {
                        case AI.Forward:
                            {
                                s.PositionZ -= (s.Speed * (gameTime.ElapsedGameTime.Milliseconds)) / 4;
                                s.Update(camera.ViewMatrix, camera.ProjectionMatrix, gameTime);

                                break;
                            }
                        case AI.Sin:
                            {
                                s.PositionZ -= (s.Speed * (gameTime.ElapsedGameTime.Milliseconds)) / 4;
                                s.PositionX += (float)(Math.Sin(s.PositionZ / 1000) * s.Speed);
                                s.Update(camera.ViewMatrix, camera.ProjectionMatrix, gameTime);
                                break;
                            }
                        case AI.Ghost:
                            {
                                s.PositionZ -= (s.Speed * (gameTime.ElapsedGameTime.Milliseconds)) / 4;
                                s.PositionX += (float)(Math.Sin(s.PositionZ / 1000) * s.Speed);

                                // add particles to ghost
                                //for (int i = 0; i < 1; i++)
                                //{
                                //    ghostParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f + 1, s.PositionZ * 0.008f), Vector3.Zero);
                                //}

                                s.Update(camera.ViewMatrix, camera.ProjectionMatrix, gameTime);
                                break;
                            }
                        case AI.Boss:
                            {
                                float speedModifier = 1.0f;

                                if (s.PositionZ >= 4000)
                                {
                                    speedModifier = 4.0f;
                                }

                                moveBoss += (gameTime.ElapsedGameTime.Milliseconds) / 10;

                                s.PositionZ -= (speedModifier) * ((s.Speed * (gameTime.ElapsedGameTime.Milliseconds)) / 4);
                                if (s.PositionZ <= 2000)
                                {
                                    s.PositionZ = 2000;
                                }

                                if (bossBehaviour.MoveStyle.Equals("Sin"))
                                {
                                    s.PositionX = (float)(Math.Sin((moveBoss / 100)) * 4 * 400);
                                }

                                if (bossBehaviour.SpitEnemies)
                                {
                                    if ((s.PositionX > (player.Position.X - 50)) && (s.PositionX < (player.Position.X + 50)))
                                    {
                                        addOneEnemyThisFrame = true;
                                        addEnemyAtPos = s.Position;

                                        if (bossBehaviour.SpitWhatEnemy == "Slime1")
                                        {
                                            enemyToAdd = Enemies.Slime;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Slime2")
                                        {
                                            enemyToAdd = Enemies.Slime2;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Slime3")
                                        {
                                            enemyToAdd = Enemies.Slime3;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Slime4")
                                        {
                                            enemyToAdd = Enemies.Slime4;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Skeleton")
                                        {
                                            enemyToAdd = Enemies.Skeleton;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Zombie")
                                        {
                                            enemyToAdd = Enemies.Zombie;
                                        }
                                        if (bossBehaviour.SpitWhatEnemy == "Ghost")
                                        {
                                            enemyToAdd = Enemies.Ghost;
                                        }
                                    }
                                }

                                s.Update(camera.ViewMatrix, camera.ProjectionMatrix, gameTime);
                                break;
                            }
                    }

                    if (s.Position.Z <= -1000)
                    {

                        castle.Upgrade -= 1;
                        for (int i = 0; i < 50; i++)
                        {
                            killEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Up);
                        }
                        s.Active = false;
                    }
                }
                else
                {
                    itemsToDelete++;
                }
            }

            while (itemsToDelete > 0)
            {
                int index = -1;
                foreach (Enemy s in enemies)
                {
                    index++;
                    if (!s.Active)
                    {
                        if (s.AI == AI.Boss)
                        {
                            for (int i = 0; i < 50; i++)
                            {
                                // Create bigger explosion when killing a boss.
                                killEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), new Vector3(0, 10, 0));
                                bloodParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < 10; i++)
                            {
                                killEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                                bloodParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f + 2, s.PositionZ * 0.008f), Vector3.Zero);
                            }
                        }

                        collideCue = soundBank.GetCue("collide");
                        if (!collideCue.IsPlaying)
                        {
                            collideCue.Play();
                        }

                        break;
                    }
                }
                enemies.RemoveRange(index, 1);
                itemsToDelete--;
            }
        }
Ejemplo n.º 35
0
 public static void enemyKilled(Enemies.Enemy enemy)
 {
     enemiesToProcess.Add(enemy.GetType().Name);
     //Get thread 1 to check the awards
     checkEnemyKilledAwards = true;
 }
Ejemplo n.º 36
0
 public static EnemyDefinition Enemy(Enemies enemy, Assets.ObjectDataSets set = Assets.ObjectDataSets.Default) => objectData.enemySets[(int)set].enemyDefinitions[(int)enemy];
Ejemplo n.º 37
0
 public void AddEnemyShip(GameObject enemy, string tag, bool load = false, bool linkWithGameObjectManager = true)
 {
     AddGameObject(enemy, tag, load, linkWithGameObjectManager);
     Enemies.Add(tag, enemy as EnemyShip);
 }
Ejemplo n.º 38
0
    public override void Activate()
    {
        higher = null;
        foreach (GameObject enemy in enemies)
        {
            if (higher == null)
            {
                higher = enemy;
            }
            else
            {
                aux   = enemy.GetComponent <EnemyHealth>().TypeName;
                auxHP = enemy.GetComponent <EnemyHealth>().Health;
                switch (aux)
                {
                case Enemies.Plate:
                    if (aux == Enemies.Cloth || aux == Enemies.Leather || aux == Enemies.Mail || aux == Enemies.Plate)
                    {
                        if (auxHP > higher.GetComponent <EnemyHealth>().Health)
                        {
                            higher = enemy;
                        }
                    }
                    break;

                case Enemies.Mail:
                    if (aux == Enemies.Cloth || aux == Enemies.Leather || aux == Enemies.Mail)
                    {
                        if (auxHP > higher.GetComponent <EnemyHealth>().Health)
                        {
                            higher = enemy;
                        }
                    }
                    break;

                case Enemies.Leather:
                    if (aux == Enemies.Cloth || aux == Enemies.Leather)
                    {
                        if (auxHP > higher.GetComponent <EnemyHealth>().Health)
                        {
                            higher = enemy;
                        }
                    }
                    break;

                case Enemies.Cloth:
                    if (aux == Enemies.Cloth)
                    {
                        if (auxHP > higher.GetComponent <EnemyHealth>().Health)
                        {
                            higher = enemy;
                        }
                    }
                    break;
                }
                //switch ends here
            }
        }
        //foreach ends here
        this.GetComponentInParent <Stats>().PhysicalRes += higher.GetComponent <EnemyHealth>().PhysicalRes;
        higher.GetComponent <EnemyHealth>().AddThreat(Damage * 2, resource);
        Invoke("ExpireRes", Duration);
    }
Ejemplo n.º 39
0
 // Use this for initialization
 void Start()
 {
     Myenemy = GetComponent<Enemies> ();
     rend = gameObject.GetComponent<Renderer> ();
     Enemy=Instantiate(RocketModel, transform.position, Quaternion.Euler(90,0,0))as GameObject;
     Enemyrend = Enemy.GetComponent<Renderer> ();
     Enemyrend.material.SetColor ("_Color", color);
     Enemy.transform.parent = transform;
     InvokeRepeating ("shoot", Random.Range(1,3), 8);
 }
Ejemplo n.º 40
0
        //Code that runs through the game.
        public static void PlayGame()
        {
            //Objects Declaration

            Random  rand = new Random(DateTime.Now.Millisecond);
            TheCave game = new TheCave();

            //Creates arrays that an RNG randomly chooses from

            Enemies[] enemArr = game.InitEnemies();
            Weapons[] wepArr  = game.InitWeapons();
            Armours[] armArr  = game.InitArmours();

            //Get User Profession and put the stats into variables to be used later

            Professions userProf = game.GetProfession();

            //Get the max amount of turns based on difficulty

            int maxTurns = game.GetTurns(game.GetDifficulty());

            Console.Clear();

            Console.WriteLine("-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-");
            Console.WriteLine("|                       You have {0} turns to escape!                        |", maxTurns);
            Console.WriteLine("|            You start with a Dagger that has {0} atk and {1} def            |", wepArr[0].GetAtk(), wepArr[0].GetDef());
            Console.WriteLine("|                You start with Wool Armour that has {0} def                 |", armArr[0].GetDef());
            Console.WriteLine("|                    Press enter to continue. Good Luck!                     |");
            Console.WriteLine("-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-");
            Console.ReadLine();

            Console.Clear();

            //Variable declarations

            // Can only hold a certain amount of items(Inventory)

            Object[] inventory = new Object[10];

            int randomNum  = rand.Next(1, 30);
            int genMonster = 0;
            //int genItem = 0;
            int fwd   = 0;
            int right = 0;

            bool isValid = false;

            string input = "";

            for (int i = 0; i <= maxTurns; i++)
            {
                int userHP  = userProf.GetHealth();
                int userAtk = wepArr[0].GetAtk();
                int userDef = wepArr[0].GetDef() + armArr[0].GetDef();

                //Asks the user the direction they want to go in

                do
                {
                    Console.Write("Which direction would you like to go in? (f, b, l, r): ");
                    input = Console.ReadLine();

                    input = input.ToLower();

                    //Validates user input

                    if (input[0] == 'f' || input[0] == 'b' || input[0] == 'l' || input[0] == 'r')
                    {
                        isValid = true;
                    }
                    else
                    {
                        Console.WriteLine("Input invalid. Please try again.");
                        Console.WriteLine();
                        isValid = false;
                    }
                } while (isValid == false);

                //Allow the user to make decision as to where they go

                switch (input[0])
                {
                case 'f':

                    Console.WriteLine("You moved forward!");
                    fwd++;
                    break;

                case 'b':

                    if (fwd == 0)
                    {
                        Console.WriteLine("You cant move back");
                    }
                    else
                    {
                        Console.WriteLine("You moved backwards");
                        fwd--;
                    }
                    break;

                case 'l':

                    if (right == 0)
                    {
                        Console.WriteLine("You cant move left");
                    }
                    else
                    {
                        Console.WriteLine("You moved left");
                        right++;
                    }
                    break;

                case 'r':

                    Console.WriteLine("You moved right");
                    right--;
                    break;
                }



                genMonster += randomNum;

                if (genMonster >= 100)
                {
                    int randNum = rand.Next(0, 5);


                    //Generate enemies
                    Enemies enem = enemArr[randNum];

                    //Declares the chosen enemies battle stats

                    int    enemAtk  = enem.GetAtk();
                    int    enemDef  = enem.GetDef();
                    int    enemHP   = enem.GetHP();
                    int    enemMP   = enem.GetMP();
                    string enemName = enem.GetName();

                    Console.WriteLine("You have to battle {0}", enemName);

                    for (int j = 0; j < 999; i++)
                    {
                        string userInput = "";

                        Console.WriteLine("What would you like to do? (Attack, Defend, Use Item, Run Away)");
                        userInput = Console.ReadLine().ToLower();

                        int userStatus = game.UserTurn(enemAtk, enemDef, enemHP, userAtk, userDef, userHP, userInput[0]);
                        int enemStatus = game.EnemTurn(enemAtk, enemDef, enemHP, userAtk, userDef, userHP);

                        userHP = userStatus;
                        enemHP = enemStatus;

                        if (userStatus == -1)
                        {
                            genMonster = 0;
                            break;
                        }

                        if (enemHP <= 0)
                        {
                            Console.WriteLine("You have successfully beaten the {0}", enemArr[0].GetName());
                            genMonster = 0;
                            break;
                        }
                        else if (userHP <= 0)
                        {
                            PrintSummary("dead");
                        }
                    }
                }
            }

            //TODO Assign objects where necessary

            //TODO Generate items around the area

            //Allow the use of objects where necessary
            //Give items certain boosts
            //Can drop item if necessary

            //Generate attack and defense of enemies
            //Compare enemies stats to user
            //Depending on stats, depends on damage
            //DEF ATK HP

            //TODO Have an end goal
            //Collected the right amount of quest items?
            //Make it out of the cave?
            //Kill a certain amount of enemies?

            //FUTURE REF: Perhaps have different quests that the user can choose from for replayability
            //FUTURE REF: Generate items in random places
            //FUTURE REF: Generate different maps each time
        }
Ejemplo n.º 41
0
        public void ReportFastSpike(Enemies.QuickEnemy enemy, SpikeTrap trap)
        {
            //only one achievement here
            if (achieved[Achievements.StayAWhile])
                return;

            //only interested in fully upgraded traps
            if (trap.CanUpgrade)
                return;

            if (fastSpikes == null)
                fastSpikes = new Dictionary<Enemy,HashSet<SpikeTrap>>();

            if (fastSpikes.ContainsKey(enemy))
            {
                fastSpikes[enemy].Add(trap);
                if (fastSpikes[enemy].Count >= 5)
                {
                    fastSpikes = null;
                    achieved[Achievements.StayAWhile] = true;
                    saveAchieved();
                }
            }
            else
            {
                fastSpikes[enemy] = new HashSet<SpikeTrap>();
                fastSpikes[enemy].Add(trap);
            }
        }
Ejemplo n.º 42
0
 public void ResetEnemies(Enemies _tar)
 {
     if (transform.position.y <= -10f && _tar.alive==true) {// Resets position once it reachs -1
         print ("clean");
         xPos = Random.Range (ScreenWidthLeft+xScale, ScreenWidthRight);//Spawns objects in range of -8, 8 as ints
         yPos = ScreenHeight + yScale;// Spawns above range of bullets
         Vector3 pos = new Vector3 (Mathf.Round((xPos - xScale / 2)*10)/10, yPos, 0);// so to prevent spawning of screen the equation is My spawn areaa(pos)-half of the enemies widthx-xscale/2, then add its size again to keep it going 1 left and push it 1 right
         transform.position = pos;
     }
 }
Ejemplo n.º 43
0
 public void Dispose()
 {
     Enemies.Clear();
     Players.Clear();
 }
Ejemplo n.º 44
0
 public void SubtractLife(Enemies _Tar)
 {
     //Method with GameObject, Parameter that decreses Health Variable, used in ShipShoot's update
     _Tar.Health--;
     //Debug.Log (name+" Health: " + Health);
     if (_Tar.Health != 0) {
         return;
     } else
     explosionsound.Play ();
     ChangeScore (_Tar.value);
     _Tar.GetComponent<Enemies> ().enabled = false;
     _Tar.GetComponent<Renderer> ().enabled = false;
     Invoke ("Respawn", Random.Range(3, 10));
     //Debug.Log ("HIT " + Health);
 }
Ejemplo n.º 45
0
        private void BuildLevel(List <string[]> levelData)
        {
            // iterate through lines
            for (int i = 0; i < levelData.Count(); i++)
            {
                switch (levelData[i][0])
                {
                case "00":
                    // mario
                    Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance);
                    Mario.Instance.Position            = new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize);
                    break;

                case "01":
                    // floor tiles
                    StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5]));
                    break;

                case "02":
                    // blocks
                    Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4]));
                    break;

                case "03":
                    // floating coins
                    Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize / 4), StringToInt(i, 2) * levelCellSize), "FloatingCoin"));
                    break;

                case "04":
                    // pipes
                    Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5]));
                    break;

                case "05":
                    // enemies
                    Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3]));
                    break;

                case "06":
                    // hills
                    BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "07":
                    // bushes
                    BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "08":
                    // clouds
                    BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "09":
                    // castle
                    Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize));
                    break;

                case "10":
                    // flag pole
                    Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize));
                    break;

                case "11":
                    // check point
                    Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)));
                    break;

                case "12":
                    // coin room
                    CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize / 8), StringToInt(i, 2) * levelCellSize);
                    break;
                }
            }

            DynamicObjects.Add(Mario.Instance);

            foreach (Block block in Blocks)
            {
                DynamicObjects.Add(block);
                DynamicObjects.Add(block.Item); // Add items in each block too.
            }

            foreach (Item coin in Coins)
            {
                DynamicObjects.Add(coin);
            }

            foreach (Enemy enemy in Enemies)
            {
                // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start.
                if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa")
                {
                    enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset);
                }
                DynamicObjects.Add(enemy);
            }

            foreach (Pipe pipe in Pipes)
            {
                StaticObjects.Add(pipe);
            }

            foreach (Flagpole flagpole in Flagpoles)
            {
                StaticObjects.Add(flagpole);
            }

            if (Flagpoles.Count > 0)
            {
                Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y);
            }
        }
Ejemplo n.º 46
0
 void OnValidate()
 {
     enemies     = _enemies;
     gameobjects = _gameobjects;
 }
    private bool inPlay;        // ie, not still in runup

    void Awake()
    {
        boss = Gp.enemies;
    }
Ejemplo n.º 48
0
        private Texture2D whiteRect; // holds a white rectangle texture

        #endregion Fields

        #region Methods

        /// <summary>
        /// Draw the minimap to the screen
        /// </summary>
        /// <param name="gameTime">Gives information on elapsed time for flashing enemies</param>
        /// <param name="player">The position of player is needed for minimap</param>
        /// <param name="enemies">The position of enemies is needed for minimap</param>
        /// <param name="map">The position of the fuel barrels and building is needed for minimap</param>
        public void Draw(GameTime gameTime, Player player, Enemies enemies, Map map)
        {
            // this rectangle describes the position on screen where an object will be drawn
            Rectangle rect = new Rectangle();
            rect.Width = (int) Math.Round((rectWidth * GameConstants.ViewportWidth));
            rect.Height = (int) Math.Round((rectHeight * GameConstants.ViewportHeight));

            // get items to display
            int[,] floorPlan = map.FloorPlan;
            Fuel[] fuelBarrels = map.FuelBarrels;
            Bonuses bonuses = map.Bonuses;

            spriteBatch.Begin();

            // draw floor plan
            for (int x = 0; x < floorPlan.GetLength(0); x++)
            {
                for (int z = 0; z < floorPlan.GetLength(1); z++)
                {
                    if (floorPlan[x, z] != 0)
                    {
                        // move the rectangle into the correct position of the screen
                        rect.X = (int)(xOffset * GameConstants.ViewportWidth) + rect.Width * z;
                        rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * x;

                        spriteBatch.Draw(whiteRect, rect, Color.Orange);
                    }
                }
            }

            // draw fuel barrels
            for (int i = 0; i < fuelBarrels.Length; i++)
            {
                rect.X = (int) (xOffset * GameConstants.ViewportWidth) - rect.Width * (int)fuelBarrels[i].Position.Z;
                rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)fuelBarrels[i].Position.X;
                spriteBatch.Draw(whiteCircle, rect, Color.White);
            }

            // draw bonuses
            foreach (Bonus b in bonuses)
            {
                rect.X = (int)(xOffset * GameConstants.ViewportWidth) - rect.Width * (int)b.Position.Z;
                rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)b.Position.X;
                spriteBatch.Draw(whiteCircle, rect, Color.Purple);
            }

            // draw player
            rect.X = (int)(xOffset * GameConstants.ViewportWidth) - rect.Width * (int)player.Position.Z;
            rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)player.Position.X;
            spriteBatch.Draw(whiteRect, rect, Color.Green);

            // draw enemies
            foreach (Enemy e in enemies)
            {
                if (e.Chasing == true)
                {
                    // flash twice per second if chasing
                    if (gameTime.TotalGameTime.TotalMilliseconds % 500 < 250)
                    {
                        rect.X = (int)(xOffset * GameConstants.ViewportWidth) - rect.Width * (int)e.Position.Z;
                        rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)e.Position.X;
                        spriteBatch.Draw(whiteRect, rect, Color.Red);
                    }
                }
                else
                {
                    rect.X = (int)(xOffset * GameConstants.ViewportWidth) - rect.Width * (int)e.Position.Z;
                    rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)e.Position.X;
                    spriteBatch.Draw(whiteRect, rect, Color.Red);
                }
            }

            //draw enemies next positions (for debugging)
            //foreach (Enemy e in enemies)
            //{
            //    rect.X = (int)(xOffset * GameConstants.ViewportWidth) - rect.Width * (int)e.nextPosition.Z;
            //    rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)e.nextPosition.X;
            //    spriteBatch.Draw(whiteRect, rect, Color.Purple);
            //}

            //draw the enemies A* path (for debugging)
            //if (Helpers.AStarDebugList != null)
            //{
            //    for (int i = 1; i < Helpers.AStarDebugList.Count - 1; i++)
            //    {
            //        rect.X = (int)(xOffset * GameConstants.ViewportWidth) + rect.Width * (int)Helpers.AStarDebugList[i].Y;
            //        rect.Y = (int)(yOffset * GameConstants.ViewportHeight) + rect.Height * (int)Helpers.AStarDebugList[i].X;
            //        spriteBatch.Draw(whiteRect, rect, Color.Pink);
            //    }
            //}

            spriteBatch.End();
        }
Ejemplo n.º 49
0
 public void AddEnemy(Entity entity)
 {
     Enemies.Add(entity.Key, entity);
 }
Ejemplo n.º 50
0
 internal ShiningPersonality(Enemies.CrystalMan master)
 {
     this.master = master;
     mStates = States().GetEnumerator();
     This.Game.AudioManager.AddBackgroundMusic("Music/CrystalBossBG");
 }
Ejemplo n.º 51
0
 private void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 52
0
 internal UndergroundAttackPersonality(Enemies.Worm master)
 {
     this.master = master;
     mStates = States().GetEnumerator();
     This.Game.AudioManager.AddSoundEffect("Effects/Worm_Spawn");
     This.Game.AudioManager.AddBackgroundMusic("Music/EarthBoss");
 }
Ejemplo n.º 53
0
 public void Clear()
 {
     Enemies.Clear();
     AttackTargetID = -1;
 }
Ejemplo n.º 54
0
 internal DarkLinkPersonality(Enemies.FinalBoss master)
 {
     this.master = master;
     mStates = States().GetEnumerator();
 }
 // Use this for initialization
 void Start()
 {
     enemies = Enemies.Instance;
     PlayerStats.Instance.ManageMoneyPerSec(tower.earningPerSec);
 }
Ejemplo n.º 56
0
 internal LiquidPersonality(Enemies.WaterBlobBoss master)
 {
     this.master = master;
     mStates = States().GetEnumerator();
     This.Game.AudioManager.AddBackgroundMusic("Music/WaterBoss");
 }
Ejemplo n.º 57
0
        //public void FromJsonMap(string file)
        //{
        //    if (File.Exists(file))
        //    {
        //        var wmap = Json2Wmap.Convert(File.ReadAllText(file));

        //        FromWorldMap(new MemoryStream(wmap));
        //    }
        //    else
        //    {
        //        throw new FileNotFoundException("Json file not found!", file);
        //    }
        //}

        //public void FromJsonStream(Stream dat)
        //{
        //    byte[] data = { };
        //    dat.Read(data, 0, (int)dat.Length);
        //    var json = Encoding.ASCII.GetString(data);
        //    var wmap = Json2Wmap.Convert(json);
        //    FromWorldMap(new MemoryStream(wmap));
        //} //not working

        public virtual int EnterWorld(Entity entity)
        {
            var player = entity as Player;

            if (player != null)
            {
                try
                {
                    player.Id = GetNextEntityId();
                    entity.Init(this);
                    Players.TryAdd(player.Id, player);
                    PlayersCollision.Insert(player);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
            else
            {
                var enemy = entity as Enemy;
                if (enemy != null)
                {
                    enemy.Id = GetNextEntityId();
                    entity.Init(this);
                    Enemies.TryAdd(enemy.Id, enemy);
                    EnemiesCollision.Insert(enemy);
                    if (enemy.ObjectDesc.Quest)
                    {
                        Quests.TryAdd(enemy.Id, enemy);
                    }
                }
                else
                {
                    var projectile = entity as Projectile;
                    if (projectile != null)
                    {
                        projectile.Init(this);
                        var prj = projectile;
                        Projectiles[new Tuple <int, byte>(prj.ProjectileOwner.Self.Id, prj.ProjectileId)] = prj;
                    }
                    else
                    {
                        var staticObject = entity as StaticObject;
                        if (staticObject != null)
                        {
                            staticObject.Id = GetNextEntityId();
                            staticObject.Init(this);
                            StaticObjects.TryAdd(staticObject.Id, staticObject);
                            if (entity is Decoy)
                            {
                                PlayersCollision.Insert(staticObject);
                            }
                            else
                            {
                                EnemiesCollision.Insert(staticObject);
                            }
                        }
                        else
                        {
                            var pet = entity as Pet;
                            if (pet == null)
                            {
                                return(entity.Id);
                            }
                            if (pet.IsPet)
                            {
                                pet.Id = GetNextEntityId();
                                pet.Init(this);
                                if (!Pets.TryAdd(pet.Id, pet))
                                {
                                    Log.Error("Failed to add pet!");
                                }

                                PlayersCollision.Insert(pet);
                            }
                            else
                            {
                                Log.WarnFormat("This is not a real pet! {0}", pet.Name);
                            }
                        }
                    }
                }
            }
            return(entity.Id);
        }
Ejemplo n.º 58
0
 internal LumberingPersonality(Enemies.FireMan master)
 {
     this.master = master;
     mStates = States().GetEnumerator();
 }
Ejemplo n.º 59
0
 private static bool AutoQ()
 {
     return(Menu.Item("QImpaired").IsActive() && Q.IsReady() &&
            Enemies.Any(e => e.IsValidTarget(Q.Range) && e.IsMovementImpaired() && Q.Cast(e).IsCasted()));
 }
Ejemplo n.º 60
0
        /// <summary>
        /// �K�v�ȃR���e���c�̓ǂݍ��݂�s���܂�
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Content.RootDirectory = @"Content\gameContent";
            Model model1 = this.Content.Load<Model> ("untitled");
            CharactorPalameter playerPara = new CharactorPalameter();
            playerPara.pos = new Vector3(0);
            playerPara.Dir = new Vector3(0, 0, 1);
            playerPara.MaxSpeed = 1;
            player = new Player(this.Content.Load<Model>("untitled"), playerPara);
            enemies = new Enemies();
            CharactorPalameter planePara = new CharactorPalameter();
            planePara.pos = new Vector3(0,0,10);
            planePara.Dir = new Vector3(1,0,0);
            PlaneEnemy plane = new PlaneEnemy(this.Content.Load<Model>("untitled"), planePara);
            enemies.Add(plane);

            mainCamera = new PlayerCamera(player, MathHelper.ToRadians(45.0f),
                                          (float)this.GraphicsDevice.Viewport.Width /
                                            (float)this.GraphicsDevice.Viewport.Height);

            base.LoadContent();
        }