예제 #1
0
    public void spawnEnemy(String type)
    {
        EnemySprite enemySprite = new EnemySprite(type);

        Level.enemyList.Add(enemySprite);
        Futile.stage.AddChild(enemySprite);
    }
예제 #2
0
        public override void Update()
        {
            EnemySprite.Update();

            Enemy.gravityManagement.Update();
            Enemy.Position += Vector2.UnitX;
        }
예제 #3
0
 public static void ResolveNPCTileCollision(EnemySprite enemy, Tile tile)
 {
     if (tile.TileType != TileTypeEnum.Space)
     {
         if (enemy.currentMovement.XDirection == MovementVector.DirectionX.Left)
         {
             enemy.MoveStandStill();
             enemy.Position.X = tile.Position.X + tile.Width;
         }
         if (enemy.currentMovement.XDirection == MovementVector.DirectionX.Right)
         {
             enemy.MoveStandStill();
             enemy.Position.X = tile.Position.X - tile.Width;
         }
         if (enemy.currentMovement.YDirection == MovementVector.DirectionY.Up)
         {
             enemy.MoveStandStill();
             enemy.Position.Y = tile.Position.Y + tile.Height;
         }
         if (enemy.currentMovement.YDirection == MovementVector.DirectionY.Down)
         {
             enemy.MoveStandStill();
             enemy.Position.Y = tile.Position.Y - tile.Height;
         }
     }
 }
예제 #4
0
 /// <summary>
 /// Adds a single NPC to the list of NPCs in the gameworld
 /// </summary>
 /// <param name="npc">An NPC</param>
 public void AddNPC(EnemySprite npc)
 {
     if (!NPCList.Contains(npc))
     {
         NPCList.Add(npc);
     }
 }
예제 #5
0
        public override void Update()
        {
            EnemySprite.Update();

            Enemy.gravityManagement.Update();
            Enemy.Position += EnemyUtil.Util;
        }
예제 #6
0
 /// <summary>
 /// Performs what need to be done if the player touches another NPC
 /// </summary>
 /// <param name="player">The player</param>
 /// <param name="npc">The NPC</param>
 public static void ResolvePlayerNpcCollision(MovingSprite player, EnemySprite npc)
 {
     if (Intersects(player.bounds, npc.bounds))
     {
         // Player bumped into something, play the bump cue
         SoundFxManager.Instance.PlaySound(SoundFxManager.CueEnums.exit);
     }
 }
예제 #7
0
 protected EnemyModel(ItemEnemySpriteFactory itemEnemySpriteFactory)
 {
     ItemEnemySpriteFactory = itemEnemySpriteFactory;
     Sprite      = new EnemySprite(this);
     Support     = false;
     HorizontalV = 1;
     VerticalV   = 2;
 }
예제 #8
0
 public override void Update()
 {
     EnemySprite.Update();
     if (!Enemy.Island)
     {
         Enemy.gravityManagement.Update();
     }
     Enemy.Position -= Vector2.UnitX;
 }
예제 #9
0
 public override void Draw(SpriteBatch spriteBatch, Vector2 location)
 {
     if (count < EnemyUtil.goombaDisappear)
     {
         EnemySprite.Draw(spriteBatch, location);
     }
     else
     {
         Enemy.Position -= Vector2.UnitX * EnemyUtil.bossOffset;
     }
 }
예제 #10
0
 public override void Draw(SpriteBatch spriteBatch, Vector2 location)
 {
     if (count < EnemyUtil.goombaDisappear)
     {
         EnemySprite.Draw(spriteBatch, location);
     }
     else
     {
         GameObjectManager.Instance.GameObjectList.Remove(Enemy);
     }
 }
예제 #11
0
    void Start()
    {
        enemy          = GameObject.Find("ENEMY");
        enemyFire      = enemy.GetComponent <EnemyFire>();
        enemySprite    = enemy.transform.GetChild(0).GetComponent <EnemySprite>();
        enemyDatabase  = enemy.GetComponent <EnemyDatabase>();
        effectParent   = GameObject.Find("EFFECT").transform;
        destroyzoneAll = GameObject.Find("DESTROYZONE").transform.GetChild(0).gameObject;

        StartCoroutine(GameStart());
    }
예제 #12
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Enemy")
     {
         Health      health = collision.GetComponent <Health>();
         EnemySprite sp     = collision.GetComponentInChildren <EnemySprite>();
         sp.HitNoOfTime++;
         health.TakeDamage(damage);
         Instantiate(hitParticleEffect, collision.transform.position, Quaternion.identity);
         Destroy(gameObject);
     }
 }
예제 #13
0
 public override void Update()
 {
     EnemySprite.Update();
     if (!Enemy.Island)
     {
         Enemy.gravityManagement.Update();
     }
     if (delay == 200)
     {
         GameObjectManager.Instance.GameObjectList.Add(new Goomba(Enemy.Position));
         delay = 0;
     }
     delay++;
 }
예제 #14
0
        /// <summary>
        /// Adds an enemy to the game scene
        /// </summary>
        /// <param name="enemy"></param>
        internal void AddEnemy(Enemy enemy)
        {
            EnemySprite enemySprite = new EnemySprite()
            {
                IsVisible = true,
                Texture   = _content.Load <Texture2D>("Images/Characters/enemies"),
                Width     = 48,
                Height    = 48,
                Size      = new Point(48, 48),
                Location  = new Point(enemy.X, enemy.Y),
                Enemy     = enemy
            };

            _enemySprites.Add(enemySprite);
        }
예제 #15
0
        private void AddEnemy(Vector2 position, char enemyType)
        {
            EnemySprite newEnemy;

            if (enemyType.Equals('B'))
            {
                newEnemy = new EnemySprite(game, EnemySprite.EnemyEnum.Butterfly, position);
            }
            else
            {
                newEnemy = new EnemySprite(game, EnemySprite.EnemyEnum.Firefly, position);
            }

            game.CurrentLevel.NpcContainer.AddNPC(newEnemy);
        }
예제 #16
0
 // Use this for initialization
 void Start()
 {
     state           = States.START;
     enterKeyColor   = enterKey.GetComponent <Image>().color;
     enterKeyColor.a = 0f;
     enterKey.GetComponent <Image>().color = enterKeyColor;
     player = GameObject.Find("Player");
     EnemySprite[] listOfEnemies = FindObjectsOfType <EnemySprite>();
     foreach (EnemySprite i in listOfEnemies)
     {
         if (i.ID == 7)
         {
             server = i;
         }
     }
 }
예제 #17
0
    private void Awake()
    {
        rb               = GetComponent <Rigidbody2D>();
        sGroup           = GetComponent <SortingGroup>();
        anim             = GetComponent <Animator>();
        sortingTransform = transform.Find("SortingTransform");
        top              = transform.Find("Top");
        idleState        = new IdleState(this);                 // Set enemy states
        aggressiveState  = new AggressiveState(this);
        patrolState      = new PatrolState(this);
        gotHitState      = new GotHitState(this);


        spritesTransform = transform.Find("Sprites");
        oriScale         = spritesTransform.localScale;
        colliders        = spritesTransform.GetComponentsInChildren <Collider2D>();
        Collider2D[] attackCol = colliders.Where(col => col.tag == "EnemyAttackBox").ToArray();
        attackState = new AttackState(this, GetComponent <Collider2D>(), attackCol);

        var spriteChilds = spritesTransform.GetComponentsInChildren <SpriteRenderer>();

        sprites = new EnemySprite[spriteChilds.Length];
        for (int i = 0; i < spriteChilds.Length; i++)
        {
            var _transform = spriteChilds[i].transform;
            var _sprite    = spriteChilds[i];
            var _color     = spriteChilds[i].color;
            sprites[i] = new EnemySprite(_transform, _sprite, _color);
        }

        _animMoveSpeed   = Animator.StringToHash("MoveSpeed");
        _animAttackSpeed = Animator.StringToHash("AttackSpeed");

        anim.SetFloat(_animMoveSpeed, stats.moveSpeed * 0.5f);
        overrideController = new AnimatorOverrideController();
        overrideController.runtimeAnimatorController = anim.runtimeAnimatorController;
        anim.runtimeAnimatorController = overrideController;
        overrideController["BaseWalk"] = walk;
        overrideController["BaseIdle"] = idle;
        if (death.Length > 0)
        {
            overrideController["BaseDeath"] = death[0];
        }
        layers                   = LayerMask.GetMask("StaticWall", "PlayerHitbox");
        stats.moveSpeed         += Random.Range(-0.2f, 0.2f);
        stats.minPathUpdateTime += Random.Range(-0.2f, 0.2f);
    }
예제 #18
0
파일: Bowser.cs 프로젝트: cuba-3/GameDesign
 public Bowser(ContentManager content, GraphicsDevice graphicsDevice)
 {
     Content           = content;
     BowserSpriteSheet = Content.Load <Texture2D>("Bowser");
     Sprite            = new EnemySprite(graphicsDevice, BowserSpriteSheet, 6, 17, OriginalLocation, 2, 1);
     Sprite.InitializeSprite(BowserSpriteSheet, graphicsDevice, 6, 17);
     Sprite.SwitchAnimation(2, 1);
     this.EnemyState = new StandardBowserState();
     GraphicsDevice  = graphicsDevice;
     Sprite          = BowserSpriteFactory.Instance.FactoryMethod(content, this, graphicsDevice);
     EnemyState      = new StandardBowserState();
     Random          = new Random();
     Delay           = Constants.ZERO;
     Health          = new HealthBar(content, graphicsDevice, this);
     Damage          = 9;
     isConsumed      = false;
 }
예제 #19
0
 // Update is called once per frame
 void Update()
 {
     rand = new System.Random();
     if (readyForBattle && player.anim.GetBool("isWalking"))
     {
         int x = rand.Next(100);
         if (x >= 0 && x < 2)   //2% chance for battle per frame
         {
             level          = (int)(GameControl.control.level * (rand.NextDouble() + 0.5) * 1.5f);
             atk            = (int)(((rand.NextDouble()) + 1) * 5 * level);
             def            = (int)(((rand.NextDouble()) + 1) * 2 * level);
             hp             = (int)(((rand.NextDouble()) + 1) * 30 * level);
             readyForBattle = false;
             sprite         = (EnemySprite)rand.Next(3);
             EnterBattleScene();
         }
     }
 }
예제 #20
0
 public KoopaTroopa(ContentManager content, GraphicsDevice graphicsDevice, bool red)
 {
     this.EnemyState = new StandardKoopaTroopaState();
     GreenKoopaSheet = content.Load <Texture2D>("GreenKoopaSheet");
     RedKoopaSheet   = content.Load <Texture2D>("RedKoopaSheet");
     if (red)
     {
         Sprite = new EnemySprite(graphicsDevice, RedKoopaSheet, 2, 2, new Vector2(1200, 738), Constants.ZERO, 2);
     }
     else
     {
         Sprite = new EnemySprite(graphicsDevice, GreenKoopaSheet, 2, 2, new Vector2(1200, 738), Constants.ZERO, 2);
     }
     Content        = content;
     GraphicsDevice = graphicsDevice;
     isConsumed     = false;
     activated      = true;
 }
예제 #21
0
    public bool collide(EnemySprite enemy)
    {
        Debug.Log("Collide: " + enemy.name);
        switch (enemy.name)
        {
        case "fish_swim":
            this.killPlayer();
            break;

        case "eel":
            this.killPlayer();
            break;

        case "jewel":
            Debug.Log("Money!");
            FSoundManager.PlaySound("pickup_jewel", 0.4f);
            PlayerState.SCORE++;
            return(true);
        }
        return(false);
    }
        public Queue <EnemySprite> CreateEnemies()
        {
            Queue <EnemySprite> allEnemies = new Queue <EnemySprite>();

            try
            {
                for (int i = 0; i < 10; i++)
                {
                    EnemySprite enemy = new EnemySprite("E" + 1, "enemy", new Vector2(0, 0), Helper.random.Next(5, 10));
                    enemy.Speed     = Helper.random.Next(5, 10);
                    enemy.IsVisible = false;
                    allEnemies.Enqueue(enemy);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error while creating Enemies : {0}", e.Message);
            }

            return(allEnemies);
        }
예제 #23
0
    public void update(EnemySprite target)
    {
        if (target.RIGHT)
        {
            target.dx     = Math.Min(target.MAX_SPEED, target.dx + target.ACCEL);
            target.scaleX = -1.0f;
        }
        else
        {
            target.dx     = Math.Max(target.MAX_SPEED * -1, target.dx - target.ACCEL);
            target.scaleX = 1.0f;
        }

        if (target.x > Futile.screen.halfWidth - 10.0f)
        {
            target.RIGHT = false;
        }
        else if (target.x < -Futile.screen.halfWidth + 10.0f)
        {
            target.RIGHT = true;
        }
    }
예제 #24
0
        /// <summary>
        /// Generates random enemy according to current level
        /// </summary>
        /// <param name="level">Current level of game</param>
        /// <returns>Random enemy ready to be placed on map</returns>
        private EnemySprite GenerateEnemy(int level)
        {
            var position = GenerateNewPosition();

            while (!IsPositionValid(position) && !IsPositionEmpty(position) && Math.Abs(position.X - Player.Position.X) < 3 && Math.Abs(position.Y - Player.Position.Y) < 3)
            {
                position = GenerateNewPosition();
            }

            Random      r             = new Random();
            int         randomMonster = (r.Next() % (level + 1)) % 4;
            EnemySprite monster       = null;

            switch (randomMonster)
            {
            case 0:
                monster = new NormalEnemySprite(_normalEnemyTexture, position, this);
                break;

            case 1:
                monster = new HunterEnemySprite(_hunterEnemyTexture, position, this);
                break;

            case 2:
                monster = new ShooterMonsterEnemySprite(_shooterEnemyTexture, position, this);
                break;

            case 3:
                monster = new TankMonsterEnemySprite(_tankEnemyTexture, position, this);
                break;
            }
            if (monster == null)
            {
                throw new ArgumentException("Could not generate monster");
            }
            return(monster);
        }
예제 #25
0
    //Load the Sprite by its type
    public EnemySprite LoadEnemySprite(Enemy.EnemyType _type)
    {
        EnemySprite temp = new EnemySprite();

        if (_type == Enemy.EnemyType.type1)
        {
            temp.type   = Enemy.EnemyType.type1;
            temp.sprite = Resources.Load <Sprite>("Sprites/e1");
        }

        else if (_type == Enemy.EnemyType.type2)
        {
            temp.type   = Enemy.EnemyType.type2;
            temp.sprite = Resources.Load <Sprite>("Sprites/e2");
        }

        else //(type == Enemy.EnemyType.type3)
        {
            temp.type   = Enemy.EnemyType.type3;
            temp.sprite = Resources.Load <Sprite>("Sprites/e3");
        }

        return(temp);
    }
예제 #26
0
 private void XnaPanelDragDrop(object sender, DragEventArgs e)
 {
     var enemy = (Enemy)e.Data.GetData(typeof(Enemy));
     var sprite = new EnemySprite(enemy);
     var p = this.xnaPanel.PointToClient(new Point(e.X, e.Y));
     sprite.X = p.X - (sprite.Width / 2);
     sprite.Y = p.Y - (sprite.Height / 2);
     this.xnaPanel.AddSprite(sprite);
 }
예제 #27
0
        public override void Update(GameTime gametime)
        {
            CheckCanMove();
            if (_state == BossState.MOVE)
            {
                movetimer += gametime.ElapsedGameTime.TotalSeconds;
                if (movetimer >= movetime)
                {
                    movetimer = 0.0f;
                    int rndnum = rnd.Next(0, 3);
                    switch (rndnum)
                    {
                    case 0:
                        _state = BossState.ATTACK;
                        break;

                    case 1:
                        changedir = true;
                        _state    = BossState.RUSH;
                        break;

                    case 2:
                        _state = BossState.SUPERATTACK;
                        break;
                    }
                }
            }
            if (_state == BossState.ATTACK)
            {
                attacktimer += gametime.ElapsedGameTime.TotalSeconds;
                if (attacktimer >= attacktime)
                {
                    attacktimer = 0.0f;
                    _state      = BossState.MOVE;
                }
            }
            else if (_state == BossState.RUSH)
            {
                rushtimer += gametime.ElapsedGameTime.TotalSeconds;
                if (rushtimer >= rushtime)
                {
                    rushtimer = 0.0f;
                    _state    = BossState.MOVE;
                }
            }
            else if (_state == BossState.SUPERATTACK)
            {
                supattacktimer += gametime.ElapsedGameTime.TotalSeconds;
                if (supattacktimer >= supattacktime)
                {
                    supattacktimer = 0.0f;
                    _state         = BossState.MOVE;
                }
            }

            switch (_state)
            {
            case BossState.MOVE:
                Move();
                break;

            case BossState.ATTACK:
                Attack(gametime);
                break;

            case BossState.RUSH:
                Rush();
                break;

            case BossState.SUPERATTACK:
                SuperAttack(gametime);
                break;
            }

            if (Health <= 0)
            {
                EnemySprite.IsLive = false;
            }

            _currentAnimation = _idleAniamtion;
            _currentAnimation.Update(gametime);
            EnemySprite.Update();
        }
예제 #28
0
 private void ButtonAddEnemyClick(object sender, EventArgs e)
 {
     var index = this.listBoxEnemies.SelectedIndex;
     if (index >= 0)
     {
         var sprite = new EnemySprite(Project.Data.Enemies[index + 1]);
         this.xnaPanel.AddSprite(sprite);
     }
     if (this.xnaPanel.Sprites.Count >= 12)
         this.buttonAddEnemy.Enabled = false;
 }
예제 #29
0
 void Start()
 {
     mySprite = LoadEnemySprite(type);
     enemySprites.Add(mySprite);
     enemySelector = GameObject.Find("Panel_EnemySelector").GetComponent <Animator>();
 }
예제 #30
0
 public void update(EnemySprite target)
 {
     //RXDebug.Log ("Staying");
 }
예제 #31
0
 public virtual void Update()
 {
     EnemySprite.Update();
     Enemy.gravityManagement.Update();
 }
예제 #32
0
    // Update is called once per frame
    void Update()
    {
        if (enemyC != -1)
        {
            Debug.Log("In combat: " + enemyC);
        }
        if (enviC != -1)
        {
            Debug.Log("In environment: " + enviC);
        }
        if (!enemyChosen)
        {
            EnemySprite[] currentEnemies = Object.FindObjectsOfType <EnemySprite>();
            foreach (EnemySprite e in currentEnemies)
            {
                e.opacity(0f);
                if (e.ID == enemyC)
                {
                    currentEnemy  = e;
                    enemyFound    = true;
                    announce.text = "You're up against: " + currentEnemy.linkedEnemy.Title;
                    if (currentEnemy.linkedEnemy.Type != "server")
                    {
                        enemyStat.text = "Attack 1: " + currentEnemy.linkedEnemy.Attack1Title + "\n" +
                                         "Damage: " + (currentEnemy.linkedEnemy.Attack1Damage - PersistentInventoryScript.instance.itemDefense / 5) + "\n" +
                                         "Attack 2: " + currentEnemy.linkedEnemy.Attack2Title + "\n" +
                                         "Damage: " + (currentEnemy.linkedEnemy.Attack2Damage - PersistentInventoryScript.instance.itemDefense / 5);
                    }
                    else
                    {
                        enemyStat.text = "Attack 1: " + currentEnemy.linkedEnemy.Attack1Title + "\n" +
                                         "Damage: ???\n" +
                                         "Attack 2: " + currentEnemy.linkedEnemy.Attack2Title + "\n" +
                                         "Damage: " + (currentEnemy.linkedEnemy.Attack2Damage - PersistentInventoryScript.instance.itemDefense / 5);
                    }
                    e.opacity(1f);
                }
            }
            if (!enemyFound)
            {
                currentEnemy = null;
            }
            else if (!enemyEntered)
            {
                currentEnemy.pleaseEnter = true;
                enemyEntered             = true;
            }
            enemyChosen = true;
        }

        if (!enviSet)
        {
            GetComponent <Environment>().changebg(enviC);
            enviSet = true;
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            SceneManager.LoadScene("Woonplaats");
        }
    }