Пример #1
0
    public List <ItemEntry> GetItems(EnemyType type, bool isHero, int level)
    {
        string xpath = "";

        if (!isHero)
        {
            xpath = "/enemy/normal/level[" + level + "]";
        }
        else
        {
            xpath = "/enemy/hero/" + type.ToString();
        }

        XmlElement node = (XmlElement)xmlDoc.SelectSingleNode(xpath);

        if (node == null)
        {
            Debug.Log("On EnemyLootReader: " + type.ToString() + " not found");
            return(null);
        }
        XmlNodeList      itemnodes = node.SelectNodes("item");
        List <ItemEntry> items     = new List <ItemEntry>();

        for (int i = 0; i < itemnodes.Count; i++)
        {
            ItemEntry  itemEntry = new ItemEntry();
            XmlElement itemnode  = (XmlElement)itemnodes[i];
            itemEntry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(itemnode["type"].InnerXml);
            itemEntry.itemType    = GameEventHelper.getItemTypeFromString(itemEntry.primaryType, itemnode["typeEnum"].InnerXml);
            itemEntry.number      = int.Parse(itemnode["number"].InnerXml);
            itemEntry.posibility  = int.Parse(itemnode["posibility"].InnerXml);
            items.Add(itemEntry);
        }
        return(items);
    }
    public void UpdateDeadPanel(EnemyType enemyType)
    {
        if (gameManager == null)
        {
            gameManager = FindObjectOfType <GameManager>();
        }
        characterReader = gameManager.characterReader;
        skilldata       = characterReader.GetEnemySkillUI(enemyType.ToString());
        data            = characterReader.GetEnemyData(gameManager.enemyManager.getEnemyLevel(enemyType), enemyType.ToString());

        txtname.text  = enemyType.ToString();
        txtdata1.text = gameManager.enemyManager.getEnemyLevel(enemyType) + "\n" + data.HP + "\n" + data.attack + "\n" + data.defense;
        txtdata2.text = data.dexterity + "\n" + data.magicAttack + "\n" + data.magicDefense + "\n" + data.attackRange;

        string skilltext = "";

        for (int i = 0; i < skilldata.Count; i++)
        {
            var strb = new System.Text.StringBuilder(skilldata[i].description);
            for (int j = 0; skilldata[i].description.Length - letterPerLine * j > letterPerLine; j++)
            {
                strb.Insert((7 + letterPerLine) * j + letterPerLine, "\n\u3000\u3000\u3000\u3000\u3000\u3000");
            }
            skilldata[i].description = strb.ToString();
            skilltext += skilldata[i].name.PadRight(6, '\u3000') + skilldata[i].description + "\n";
        }
        skill.text = "<size=22>" + skilltext + "</size>";
    }
Пример #3
0
        public static Entity MakeEnemy(EnemyType enemyType, Vector2 position)
        {
            // Setup the base enemy entity
            var enemyEntity = new Entity("enemy"); // TODO: ("enemy-" + enemy.ToString()); ?

            enemyEntity.tag      = (int)Tag.Enemy;
            enemyEntity.position = position;
            enemyEntity.addComponent(new Mover());

            // Update these values to plug into default components
            int    hpValue = 0, strValue = 0, defValue = 0;
            string texturePath = "Graphics\\";

            // Enemy-unique setup
            switch (enemyType)
            {
            case EnemyType.Base:
                // TODO: Figure out what to do with this
                break;

            case EnemyType.Goomba:
                hpValue      = 47;
                texturePath += "Bomb";
                break;

            case EnemyType.Bat:
                hpValue      = 30;
                texturePath += "Bat";
                // ent.addComponent(new FlyingComponent());
                break;

            default:
                Debug.error("EnemyType not yet set up: {0}", enemyType.ToString());
                return(null);
            }

            // Health Component
            if (hpValue <= 0 || strValue <= 0 || defValue <= 0)
            {
                Debug.warn("Not all enemy stat values not set for type {0}", enemyType.ToString());
            }
            enemyEntity.addComponent(new CombatStats(hpValue, strValue, defValue));

            // Sprite Component
            if (String.Equals(texturePath, "Graphics\\"))
            {
                Debug.warn("Enemy texture path not set for type {0]", enemyType.ToString());
                texturePath += "DefaultEnemyGraphic";
            }
            Texture2D enemyTexture = Core.content.Load <Texture2D>(texturePath);

            enemyEntity.addComponent(new Sprite(enemyTexture));

            // Temporary addition(s)
            enemyEntity.addComponent(new PlayerMovementComponent());
            enemyEntity.addComponent(new CircleCollider());

            return(enemyEntity);
        }
Пример #4
0
    //For adding an enemy to a battle
    public void AddEnemy(EnemyType enemy)
    {
        //set index to be the length
        int index = _inBattle.Count;

        //Check if any enemies were killed, if so rest the index
        for (int i = 1; i < _inBattle.Count; i++)
        {
            if (_inBattle[i] == null)
            {
                index = i;
                break;
            }
        }

        if (index >= 5)
        {
            index = ReplaceWeakerEnemies();
        }

        Debug.Log("Index: " + index);
        Debug.Log("add enemy of type: " + enemy.ToString());

        //Instasiate the enmy of Type
        GameObject newE = Instantiate(Resources.Load("Enemies/" + enemy.ToString(), typeof(GameObject)) as GameObject, enemyPlacement[index], Quaternion.identity);

        if (index < _inBattle.Count)
        {
            if (_inBattle[index] != null)
            {
                Destroy(_inBattle[index].gameObject);
            }

            _inBattle[index] = newE;
            enemyList[index] = enemy;
        }
        else
        {
            _inBattle.Add(newE);
            enemyList.Add(enemy);
            _stats.enemyHealth.Add(0);
        }



        //Set enemy health
        _stats.enemyHealth[index] = newE.GetComponent <EnemyCombatBehaviour>().GetStartingHealth();
        enemyHealthBars[index].gameObject.SetActive(true);
        enemyHealthBars[index].value = 1;
        newE.GetComponent <EnemyCombatBehaviour>().healthSlider = enemyHealthBars[index];

        //Parent enemy
        newE.transform.parent = _enemyParent.transform;
        _battleEnd            = _inBattle.Count - 1;
        _battleStart          = 0;
    }
Пример #5
0
    public InitEnemyCount getSubWavelet()
    {
        InitEnemyCount enemies = new InitEnemyCount();

        enemies.name = currentEnemyType.ToString();
        enemies.c    = count;
        enemies.p    = path;

        return(enemies);
    }
    public void Activate(Vector3 startPosition)
    {
        this.gameObject.name    = $"{_enemyType.ToString()} - Active";
        this.transform.position = startPosition;

        _isAtCastle     = false;
        _attackCooldown = 0f;
        _currentHealth  = _maxHealth;

        IsActive = true;
        this.gameObject.SetActive(true);
    }
Пример #7
0
    public static Sprite getInfoButtonSprite(EnemyType type)
    {
        //unfortunately this has to be a separate image from what's actually used for the enemy prefab.
        Sprite s = Get.getSprite("GUI/Enemies/" + type.ToString() + "_info_button");

        if (s == null)
        {
            Debug.LogError("EnemyStore could not find an info button sprite for " + type.ToString() + "\n");
            return(Get.getSprite("GUI/Enemies/hint_info_button"));
        }
        return(s);
    }
Пример #8
0
    public static Sprite getEnemySprite(EnemyType type)
    {
        //unfortunately this has to be a separate image from what's actually used for the enemy prefab.
        Sprite s = Get.getSprite("GUI/Enemies/" + type.ToString());

        if (s != null)
        {
            return(s);
        }

        Debug.LogError("EnemyStore could not find a sprite for " + type.ToString() + "\n");
        return(Get.getSprite("GUI/Enemies/Soldier"));
    }
Пример #9
0
    public bool InitEnemyData(ref Enemy enemy, int level, EnemyType type)
    {
        if (enemy == null)
        {
            return(false);
        }

        CharacterData data = GetEnemyData(level, type.ToString());

        enemy.InitializeEnemy(type, type.ToString(), level, data.skillcounts,
                              data.attack, data.magicAttack, data.defense, data.magicDefense, data.HP, data.dexterity, data.attackRange, data.dropsoul);
        return(true);
    }
Пример #10
0
    public static EnemyPiece Spawn(int _posX, int _posY, int _health, GridType _movementType, EnemyType _unitType)
    {
        EnemyPiece curPiece = null;

        for (int i = 0; i < enemyPool.Count; i++)
        {
            if (enemyPool[i].IsAlive == false)
            {
                curPiece                    = enemyPool[i];
                curPiece.mbIsAlive          = true;
                curPiece.mSpriteRen.enabled = true;

                curPiece.mnPosX   = _posX;
                curPiece.mnPosY   = _posY;
                curPiece.mnHealth = _health;
                curPiece.SetMovementType(_movementType);
                curPiece.SetUnitType(_unitType);
                int spriteIndex = Array.IndexOf(enemySpriteNames, _unitType.ToString() + "_" + _movementType.ToString());
                curPiece.mSpriteRen.sprite = enemySprites[spriteIndex];

                DungeonManager.Instance.PlaceEnemy(curPiece, _posX, _posY);
                curPiece.transform.position = DungeonManager.Instance.GridPosToWorldPos(_posX, _posY);

                break;
            }
        }

        if (curPiece == null)
        {
            GameObject newEnemyPiece = (GameObject)Instantiate(GameManager.Instance.EnemyPrefab);

            curPiece                    = newEnemyPiece.GetComponent <EnemyPiece>();
            curPiece.mbIsAlive          = true;
            curPiece.mSpriteRen.enabled = true;

            curPiece.mnPosX   = _posX;
            curPiece.mnPosY   = _posY;
            curPiece.mnHealth = _health;
            curPiece.SetMovementType(_movementType);
            curPiece.SetUnitType(_unitType);
            int spriteIndex = Array.IndexOf(enemySpriteNames, _unitType.ToString() + "_" + _movementType.ToString());
            curPiece.mSpriteRen.sprite = enemySprites[spriteIndex];

            DungeonManager.Instance.PlaceEnemy(curPiece, _posX, _posY);
            curPiece.transform.position = DungeonManager.Instance.GridPosToWorldPos(_posX, _posY);
        }

        GameManager.Instance.EnemyList.Add(curPiece);

        return(curPiece);
    }
Пример #11
0
        protected override void LoadContent()
        {
            if (enemyType.ToString() == "slime" || enemyType.ToString() == "snail")
            {
                for (int i = 0; i < MAX_FRAME; i++)
                {
                    textures.Add(Game.Content.Load <Texture2D>($"Enemy\\{enemyType.ToString()}Walk{i + 1}"));
                }
            }
            else if (enemyType.ToString() == "fly")
            {
                for (int i = 0; i < MAX_FRAME; i++)
                {
                    textures.Add(Game.Content.Load <Texture2D>($"Enemy\\{enemyType.ToString()}Fly{i + 1}"));
                }
            }
            else if (enemyType.ToString() == "fish")
            {
                for (int i = 0; i < MAX_FRAME; i++)
                {
                    textures.Add(Game.Content.Load <Texture2D>($"Enemy\\{enemyType.ToString()}Swim{i + 1}"));
                }
            }
            else
            {
                for (int i = 0; i < MAX_FRAME; i++)
                {
                    textures.Add(Game.Content.Load <Texture2D>($"Enemy\\{enemyType.ToString()}{i + 1}"));
                }
            }

            bombSound   = Game.Content.Load <SoundEffect>("8bit_bomb_explosion");
            impactSound = Game.Content.Load <SoundEffect>("sfx_sounds_impact1");
            base.LoadContent();
        }
Пример #12
0
 public bool GetEnemyData(EnemyType index, out EnemyStruct enemyData) {
     if (enemyList.TryGetValue((int)index, out enemyData) == false) {
         Debug.LogWarning("not existed Data: " + index.ToString());
         return false;
     }
     return true;
 }
Пример #13
0
    public void UpdateAdventurer()
    {
        type = adventurerPage.adventurerList[adventurerPage.currentid];
        string name = type.ToString();

        skilldata   = characterReader.GetEnemySkillUI(name);
        description = characterReader.GetCharacterDescription(PawnType.Enemy, name);

        txtname.text = name;
        string skilltext = "";

        for (int i = 0; i < skilldata.Count; i++)
        {
            var strb = new System.Text.StringBuilder(skilldata[i].description);
            for (int j = 0; skilldata[i].description.Length - 18 * j > 18; j++)
            {
                strb.Insert(25 * j + 18, "\n\u3000\u3000\u3000\u3000\u3000\u3000");
            }
            skilldata[i].description = strb.ToString();
            skilltext += skilldata[i].name.PadRight(6, '\u3000') + skilldata[i].description + "\n";
        }
        skill.text = skilltext;
        story.text = description.story;
        race.text  = description.race;
        desc.text  = description.description;

        if ((sprite = Resources.Load("Image/character/" + name, typeof(Sprite)) as Sprite) != null)
        {
            image.sprite = sprite;
        }
    }
    public void AssignStats()
    {
        if (gameObject.CompareTag(CurrentEnemyType.ToString()))
        {
            if (CurrentEnemyType == EnemyType.Enemy1)
            {
                MaxHp = 50;
                Hp    = MaxHp;
                Debug.Log(Hp);
            }
            // instead of doing separated if blocks, you need to do if else for less code execution
            else if (CurrentEnemyType == EnemyType.Boss)
            {
                MaxHp = 500;
                Hp    = MaxHp;
                Debug.Log(Hp);
            }

            /*
             * More simplified way instead of the if else, if you assume that all your enemies except the boss have 50 hp.
             * MaxHp = CurrentEnemyType == EnemyType.Boss ? 500 : 50;
             * Hp = MaxHp;
             * Debug.Log(Hp);
             */
        }
    }
Пример #15
0
    public void CreateNewEnemy(EnemyType newbornType, Vector2 fatherPos)
    {
        needInstantiate = true;
        CurrentEnemysAlive++;

        for (i = 0; i < enemiesPools[(int)newbornType].Count; i++)
        {
            if (enemiesPools[(int)newbornType][i].activeInHierarchy == false)
            {
                enemiesPools[(int)newbornType][i].transform.position    = fatherPos;
                enemiesPools[(int)newbornType][i].transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
                enemiesPools[(int)newbornType][i].SetActive(true);
                needInstantiate = false;
                break;
            }
        }
        if (needInstantiate)
        {
            GameObject newborn = Instantiate(enemiesPrefabs[(int)newbornType]) as GameObject;
            newborn.transform.position    = fatherPos;
            newborn.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
            newborn.transform.SetParent(enemyPoolParty);
            newborn.name = newbornType.ToString();

            enemiesPools[(int)newbornType].Add(newborn);
        }
    }
Пример #16
0
    private void Start()
    {
        spells = GetComponent <CharacterAttacks>();

        if (enemyType.ToString() == "flying")
        {
            moving = true;
        }

        target = Player.instance.transform;

        combat         = GetComponent <CharacterCombat>();
        characterStats = GetComponent <CharacterStats>();

        startPos = transform.position;
    }
Пример #17
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("PlayerBullet"))
        {
            DoDeathExplosion();

            Sleep();


            Destroy(collision.gameObject);
            Destroy(gameObject);

            float dist = Vector2.Distance(playerController.GetLeftClickPlayerPos(), gameObject.transform.position);
            gm.EnemyKilled_AddOrRemoveRep(dist, myEnemyType.ToString());

            //Debug.Log("Player has killed : " + myEnemyType.ToString());
        }

        if (collision.gameObject.CompareTag("Player"))
        {
            Destroy(gameObject);
            playerStats.HurtPlayer();
            player.GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
            // maybe send an knockback to the player?

            // Maybe make the player invinable
        }
    }
Пример #18
0
        public GameObject SpawnEnemyFromPool(EnemyType enemyType, Vector3 position, Quaternion rotation)
        {
            if (!m_EnemyPoolDictionary.ContainsKey(enemyType))
            {
                Debug.LogWarning("Pool of " + enemyType + " dosen't exist.");
                return(null);
            }

            if (m_EnemyPoolDictionary[enemyType].Count == 0)
            {
                Debug.LogError(enemyType.ToString() + " pool is empty!");
                return(null);
            }

            GameObject objectToSpawn = m_EnemyPoolDictionary[enemyType].Dequeue();

            objectToSpawn.transform.position = position;
            objectToSpawn.transform.rotation = rotation;
            objectToSpawn.SetActive(true);

            PoolTracker poolTracker = AddPoolTrackerComponent(objectToSpawn, PoolType.EnemyType);

            poolTracker.EnemyType = enemyType;
            m_TrackedObject.Enqueue(poolTracker);

            return(objectToSpawn);
        }
        public override void Excute()
        {
            IEnemy enemy = null;

            switch (mEnemyType)
            {
            case EnemyType.Elf:
                enemy = FactoryManager.EnemyFactory.CreateCharacter <EnemyElf>(mWeaponType, mPosition) as IEnemy;
                break;

            case EnemyType.Ogre:
                enemy = FactoryManager.EnemyFactory.CreateCharacter <EnemyOgre>(mWeaponType, mPosition) as IEnemy;

                break;

            case EnemyType.Troll:
                enemy = FactoryManager.EnemyFactory.CreateCharacter <EnemyTroll>(mWeaponType, mPosition) as IEnemy;

                break;

            default:
                Debug.Log(GetType() + "/Excute()/ There is no one in EnemyType :" + mEnemyType.ToString());

                break;
            }

            PlayGameFacade.Instance.RemoveEnemyToCharactorSystem(enemy);
            SoldierCaptive captive = new SoldierCaptive(enemy);

            PlayGameFacade.Instance.AddSoldierToCharactorSystem(captive);
        }
Пример #20
0
    protected override void ChildrenExportToXML(XmlElement level_ele)
    {
        XmlDocument doc       = level_ele.OwnerDocument;
        XmlElement  enemy_ele = doc.CreateElement("EnemyInfo");

        level_ele.AppendChild(enemy_ele);

        enemy_ele.SetAttribute("enemyType", EnemyType.ToString());
        BuildInfo.ExportToXML(enemy_ele);

        XmlElement bonusGroupInfos_ele = doc.CreateElement("BonusGroupInfos");

        enemy_ele.AppendChild(bonusGroupInfos_ele);

        foreach (BonusGroup bg in BonusGroups)
        {
            bg.ExportToXML(bonusGroupInfos_ele);
        }

        CardPriority.ExportToXML(enemy_ele);

        XmlElement cardComboList_ele = doc.CreateElement("CardComboList");

        enemy_ele.AppendChild(cardComboList_ele);

        foreach (CardCombo cc in CardComboList)
        {
            cc.ExportToXML(cardComboList_ele);
        }
    }
Пример #21
0
 public enemyStats(EnemyType type)
 {
     this.enemy_type = type;
     this.defenses   = EnemyStore.getDefenses(type, true);
     this.mass       = EnemyStore.getMass(type);
     this.name       = type.ToString();
     this.inventory  = EnemyStore.getInventory(type);
 }
Пример #22
0
 /// <summary>
 /// Gets a string representation of this object.
 /// </summary>
 /// <returns>T string representation of this object.</returns>
 public override string ToString()
 {
     return("Enemy:" +
            " Type=" + EnemyType.ToString("x") +
            (Respawn ? "Respawns " : "") +
            " Palette=" + DifficultByteValue.ToString() +
            " Slot=" + SpriteSlot.ToString() +
            " ScreenPos=" + this.X.ToString() + "," + this.Y.ToString());
 }
Пример #23
0
 private static EnemyInfoJson GetEnemyInfo(EnemyType enemyType)
 {
     using (StreamReader r = new StreamReader("enemyInfo.json"))
     {
         var json = r.ReadToEnd();
         var info = JsonConvert.DeserializeObject <Dictionary <string, EnemyInfoJson> >(json);
         return(info[enemyType.ToString()]);
     }
 }
Пример #24
0
        public OptionEnemyEntry(Sprite spriteSheet, Vector2 position, EnemyType enemyType)
            : base(position)
        {
            squarePos.X += 30;

            this.position = position;
            displayText   = enemyType.ToString();
            optionSquare  = new OptionEnemySquare(spriteSheet, squarePos, enemyType);
        }
Пример #25
0
        private void SpawnRandomAsteroid(EnemyType eType)
        {
            int        color  = rand.Next(0, 4);
            EnemyColor eColor = EnemyColor.NONE;

            switch (color)
            {
            case 0:
                eColor = EnemyColor.RED;
                break;

            case 1:
                eColor = EnemyColor.BLUE;
                break;

            case 2:
                eColor = EnemyColor.GREEN;
                break;

            case 3:
                eColor = EnemyColor.PURPLE;
                break;

            case 4:
                eColor = EnemyColor.PINK;
                break;
            }
            Enemy enemy     = new Enemy(eType, enemyTextures[eType.ToString() + "_" + eColor.ToString()], eColor);
            int   direction = rand.Next(0, 3); // Generate a number 0 - 3 [0, 1, 2, 3] to determine what side to spawn on.

            switch (direction)
            {
            case 0:     // Top
                enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), 100);
                break;

            case 1:     // Bottom
                enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), ActionScreen.background.Height - 100);
                break;

            case 2:     // Left
                enemy.Position = new Vector2(100, rand.Next(100, ActionScreen.background.Height - 100));
                break;

            case 3:     // Right
                enemy.Position = new Vector2(rand.Next(ActionScreen.background.Width + 50, ActionScreen.background.Width - 50), rand.Next(-50, ActionScreen.background.Height + 50));
                break;
            }
            enemy.Velocity      += new Vector2(rand.Next(-enemy.Speed, enemy.Speed), rand.Next(-enemy.Speed, enemy.Speed));
            enemy.Transformation = Matrix.CreateTranslation(new Vector3(-enemy.Center, 0.0f)) *
                                   // Matrix.CreateScale(block.Scale) *  would go here
                                   Matrix.CreateRotationZ(enemy.Angle) *
                                   Matrix.CreateTranslation(new Vector3(enemy.Position, 0.0f));
            enemies.Add(enemy);
            ParticleManager.particleEffects["WarpIn"].Trigger(enemy.Position);
        }
Пример #26
0
    public void InitializeEnemy(EnemyType enemyType, string name, int level, int skillCounts,
                                int attack, int magicAttack, int defense, int magicDefense, int HP, int dexterity, int attackRange, int dropsoul)
    {
        this.enemyType = enemyType;
        Name           = enemyType.ToString();
        InitializePawn(PawnType.Enemy, name, level, attack, magicAttack, defense, magicDefense, HP, dexterity, attackRange);

        this.skillCounts = skillCounts;
        this.dropsoul    = dropsoul;
    }
Пример #27
0
    public BaseEnemy GetEnemyOfType(EnemyType enemyType)
    {
        IncrementGlobalEnemyCount(enemyType);
        var newObject = new GameObject();
        var newEnemy  = newObject.AddComponent <BaseEnemy>();

        newEnemy.EnemyType = enemyType;
        newEnemy.ID        = enemyType.ToString() + GlobalTypeCount[enemyType];
        return(newEnemy);
    }
Пример #28
0
    private float GetRegenerationRate(EnemyType enemyType)
    {
        switch (enemyType)
        {
        case EnemyType.BOUNTY:
            return(0.4f);

        default:
            throw new GameplayException("Enemy type not supported: " + enemyType.ToString());
        }
    }
    void OnTriggerEnter(Collider other)
    {
        switch (other.tag)
        {
        case "Node":
            if (partolling)
            {
                navMesh.SetDestination(navNodes[GetNewNode()].position);
                navMesh.Stop();
                anim.SetTrigger("Waiting");
                if (enemyType.ToString() == "Small")
                {
                    transform.GetChild(0).GetComponent <Animator>().SetTrigger("Waiting");
                    transform.GetChild(1).GetComponent <Animator>().SetTrigger("Waiting");
                    transform.GetChild(2).GetComponent <Animator>().SetTrigger("Waiting");
                    transform.GetChild(3).GetComponent <Animator>().SetTrigger("Waiting");
                    transform.GetChild(4).GetComponent <Animator>().SetTrigger("Waiting");
                    transform.GetChild(5).GetComponent <Animator>().SetTrigger("Waiting");
                }
                Invoke("Move", Random.Range(0, 2));
            }
            break;

        case "Enemy":
            if (other.GetComponent <EnemyController>().enemyType.ToString() != this.enemyType.ToString())
            {
                Destroy(this.gameObject);
            }
            break;

        case "Player":
            //switch case for audio and AI behavior
            if (!runningAway && player.GetComponent <MicInput>().playerVoice == runVoice)
            {
                ToRunState();
            }
            else if (!runningAway && !investigate && player.GetComponent <MicInput>().playerVoice == attractVoice)
            {
                ToInvestigateState(player.transform.position);
            }
            else if (enemySight.playerInSight && !runningAway)
            {
                ToChaseState();
            }

            break;

        case "AudioRange":
            break;
        }
    }
Пример #30
0
        public NPC(Texture2D texture, EnemyType type)
            : base(texture)
        {
            this.Type = type;
            this.Position = Constants.ENTITY_RIGHT_POSITION;
            this.AnimationController.Initialize(this.Position, new Vector2(12.0f, 8.0f), Constants.ENTITY_DEFAULT_TEXTURE);

            switch (this.Type)
            {
                case EnemyType.Zombie:
                case EnemyType.Ghoul:
                    base.AnimationController.StartFrame = 3.00f;
                    base.AnimationController.EndFrame = 220.25f;
                    base.AnimationController.DefaultFrameX = 73.75f;
                    break;
                case EnemyType.Skeleton:
                case EnemyType.Warrior:
                    base.AnimationController.StartFrame = 225.25f;
                    base.AnimationController.EndFrame = 440.5f;
                    base.AnimationController.DefaultFrameX = 295.0f;
                    break;
                case EnemyType.Butcher:
                case EnemyType.Mindless:
                    base.AnimationController.StartFrame = 442.5f;
                    base.AnimationController.EndFrame = 661.75f;
                    base.AnimationController.DefaultFrameX = 516.25f;
                    break;
                case EnemyType.Gladiator:
                case EnemyType.InfestedHuman:
                    base.AnimationController.StartFrame = 663.75f;
                    base.AnimationController.EndFrame = 883.00f;
                    base.AnimationController.DefaultFrameX = 737.50f;
                    break;
                default: throw new Exception("Invalid enemy type " + type.ToString() + "!");

            }
            switch (this.Type)
            {
                case EnemyType.Zombie:
                case EnemyType.Skeleton:
                case EnemyType.Butcher:
                case EnemyType.Gladiator:
                    this.AnimationController.DefaultFrameY = 194;
                    break;
                case EnemyType.Ghoul:
                case EnemyType.Warrior:
                case EnemyType.Mindless:
                case EnemyType.InfestedHuman:
                    this.AnimationController.DefaultFrameY = 582;
                    break;
            }
            this.AnimationController.CurrentFrame = new Vector2(this.AnimationController.StartFrame, 0.0f);
        }
Пример #31
0
 /// <summary>
 /// Returns Factory for provided enemyType.
 /// </summary>
 //TODO: неоптимальная логика, переделать. Должно вызываться только 1 раз.
 public EnemyFactory Get(EnemyType enemyType)
 {
     foreach (EnemyFactory factory in Factories)
     {
         if (factory.EnemyType == enemyType)
         {
             return(factory);
         }
     }
     Debug.LogError(name + " Has no EnemyFactory corresponding to provided " + enemyType.ToString() + " EnemyType");
     return(null);
 }
Пример #32
0
    public void Instantiate(BroWorldApplication application, GameObject prefab, EnemyType type)
    {
        // Model
        application.model.AddEnemy(_model);

        int id = _model.id;

        // View
        GameObject viewInstance = GameObject.Instantiate(prefab);
        viewInstance.name = type.ToString() + id;
        viewInstance.transform.parent = application.view.transform;
        _view = viewInstance.GetComponent<EnemyView>();

        // Controller
        GameObject controllerInstance = new GameObject(type.ToString() + "Controller" + id);
        _controller = controllerInstance.AddComponent<EnemyController>();
        _controller.enabled = false;
        _controller.EnemyModel = _model;
        _controller.EnemyView = _view;
        _controller.enabled = true;
        controllerInstance.transform.parent = application.controller.transform;
    }
Пример #33
0
 public InvalidEnemyException(EnemyType enemyType)
     : base("Invalid enemy type: " + enemyType.ToString())
 {
 }
Пример #34
0
 public static string GetTexture(EnemyType type)
 {
     return type.ToString("g");
 }
Пример #35
0
 private void SpawnRandomAsteroid(EnemyType eType)
 {
     int color = rand.Next(0, 4);
     EnemyColor eColor = EnemyColor.NONE;
     switch (color)
     {
         case 0:
             eColor = EnemyColor.RED;
             break;
         case 1:
             eColor = EnemyColor.BLUE;
             break;
         case 2:
             eColor = EnemyColor.GREEN;
             break;
         case 3:
             eColor = EnemyColor.PURPLE;
             break;
         case 4:
             eColor = EnemyColor.PINK;
             break;
     }
     Enemy enemy = new Enemy(eType, enemyTextures[eType.ToString() + "_" + eColor.ToString()], eColor);
     int direction = rand.Next(0, 3); // Generate a number 0 - 3 [0, 1, 2, 3] to determine what side to spawn on.
     switch (direction)
     {
         case 0: // Top
             enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), 100);
             break;
         case 1: // Bottom
             enemy.Position = new Vector2(rand.Next(100, ActionScreen.background.Width - 100), ActionScreen.background.Height - 100);
             break;
         case 2: // Left
             enemy.Position = new Vector2(100, rand.Next(100, ActionScreen.background.Height - 100));
             break;
         case 3: // Right
             enemy.Position = new Vector2(rand.Next(ActionScreen.background.Width + 50, ActionScreen.background.Width - 50), rand.Next(-50, ActionScreen.background.Height + 50));
             break;
     }
     enemy.Velocity += new Vector2(rand.Next(-enemy.Speed, enemy.Speed), rand.Next(-enemy.Speed, enemy.Speed));
     enemy.Transformation = Matrix.CreateTranslation(new Vector3(-enemy.Center, 0.0f)) *
         // Matrix.CreateScale(block.Scale) *  would go here
     Matrix.CreateRotationZ(enemy.Angle) *
     Matrix.CreateTranslation(new Vector3(enemy.Position, 0.0f));
     enemies.Add(enemy);
     ParticleManager.particleEffects["WarpIn"].Trigger(enemy.Position);
 }