コード例 #1
0
        //Old: public void AddEnemy(EnemyDestroyedAnimationListener enemyDAL)
        public void AddEnemy()
        {
            EnemyClass newEnemy = new EnemyClass(Content, random, screenWidth, (new SpriteBatch(GraphicsDevice)), spriteSheetLoader);

            //enemyDAL.Subscribe(newEnemy);
            enemies.Add(newEnemy);
        }
コード例 #2
0
    void CreateEnemy(EnemyClass enemyClass)
    {
        GameObject go;

        //GameObject go = Instantiate(enemyPrefab, pathAsset.way[0],Quaternion.identity);

        switch (enemyClass)
        {
        case EnemyClass.Big:
            go = Instantiate(BigEnemy);
            break;

        case EnemyClass.Medium:
            go = Instantiate(enemyPrefab);
            break;

        default:
            go = Instantiate(enemyPrefab);
            break;
        }
        if (enemyClass == EnemyClass.Medium)
        {
        }
        else
        {
        }

        go.GetComponent <Enemy_FindWayAndMove>().SetPath(pathAsset);
    }
コード例 #3
0
    public void MoneyValor(EnemyClass enemyType)
    {
        switch (enemyType)
        {
        case EnemyClass.Changeling:
            moneyToAdd = Random.Range(2, 7);
            break;

        case EnemyClass.Nach:
            moneyToAdd = Random.Range(2, 6);
            break;

        case EnemyClass.Bermonch:
            moneyToAdd = Random.Range(4, 11);
            break;

        case EnemyClass.Tatzel:
            moneyToAdd = Random.Range(3, 10);
            break;

        case EnemyClass.Neck:
            moneyToAdd = Random.Range(4, 12);
            break;

        default:
            moneyToAdd = Random.Range(15, 20);
            break;
        }
    }
コード例 #4
0
    // TODO - Still think this needs a look at
    // Should be just an 'object' with the class and its prefab
    // Shouldn't have to go and look for its prefab

    /* public GameObject GetRelevantModel(EnemyClass DesiredClass)
     * {
     *      Debug.Log("Getting relevent enemy model...");
     *      //If the list has a size and isn't null
     *      if(EnemyPrefabs != null && EnemyPrefabs.Count > 0)
     *      {
     *              Debug.Log("Enemy Prefabs exist");
     *              Debug.Log("Num of prefabs: " + EnemyPrefabs.Count);
     *
     *              // Pull the prefab from the List
     *              EnemyClass filteredClass = EnemyPrefabs.Class.Find(DesiredClass);
     *              if(filteredClass.length() != 0) {
     *                      return filteredClass.EnemyModel;
     *              }
     *              Debug.Log("Couldn't find enemy prefab for: " + DesiredClass);
     *      }
     *
     *      //Otherwise, done goofed
     *      return null;
     * } */

    public GameObject GetRelevantModel(EnemyClass DesiredClass)
    {
        //If the list has a size and isn't null
        if (EnemyPrefabs != null && EnemyPrefabs.Count > 0)
        {
            //For each pref
            for (int i = 0; i < EnemyPrefabs.Count; i++)
            {
                //
                if (EnemyPrefabs[i] != null)
                {
                    //If it matches
                    if (EnemyPrefabs[i].Class == DesiredClass)
                    {
                        //And exists
                        if (EnemyPrefabs[i].EnemyModel != null)
                        {
                            //Return the model
                            return(EnemyPrefabs[i].EnemyModel);
                        }
                    }
                }
            }
        }

        //Otherwise, done goofed
        return(null);
    }
コード例 #5
0
ファイル: DBManager.cs プロジェクト: w546296781/SimpleGame
    public EnemyClass GetEnemy(int id)
    {
        ConnectToDB("SimpleGame.db");

        EnemyClass enemy = new EnemyClass();

        enemy.id = id;

        dataReader =
            ExecuteQuery("SELECT Name, Attack, Defense, Speed, Life FROM Enemy WHERE ID = " + id + ";");
        while (dataReader.HasRows)
        {
            if (dataReader.Read())
            {
                enemy.name  = dataReader.GetString(0);
                enemy.atk   = dataReader.GetInt32(1);
                enemy.def   = dataReader.GetInt32(2);
                enemy.speed = dataReader.GetInt32(3);
                enemy.life  = dataReader.GetInt32(4);
            }
        }

        CloseConnection();

        return(enemy);
    }
コード例 #6
0
    void Start()
    {
        threatList = new List <PlayerThreat>();
        ec         = GetComponent <EnemyClass>();

        //szedjük össze a lehetséges célpontokat


        //Nexus
        int    viewId     = GameObject.FindGameObjectWithTag("Nexus").gameObject.transform.parent.gameObject.GetComponent <PhotonView>().ViewID;
        float  threat     = GameObject.FindGameObjectWithTag("Nexus").gameObject.transform.parent.gameObject.GetComponent <Nexus>().threat;
        string playerName = "Nexus";

        threatList.Add(new PlayerThreat(viewId, threat, playerName));

        //Játékosok
        GameObject[] targets = GameObject.FindGameObjectsWithTag("Player");
        for (int i = 0; i < targets.Length; i++)
        {
            viewId     = targets[i].GetComponent <PhotonView>().ViewID;
            threat     = 0;
            playerName = targets[i].GetComponent <PlayerClass>().PlayerName;
            PlayerThreat pt = new PlayerThreat(viewId, threat, playerName);
            threatList.Add(pt);
        }

        InvokeRepeating("ThreatFade", 1f, 1f);
    }
コード例 #7
0
    void Start()
    {
        var instance = new EnemyClass();

        instance.populateEnemies(1);
        Debug.Log(EnemyClass.Instance.levelOneSpawn[1]);
    }
コード例 #8
0
ファイル: DBManager.cs プロジェクト: w546296781/SimpleGame
    public List <EnemyClass> GetAllEnemy()
    {
        ConnectToDB("SimpleGame.db");

        List <EnemyClass> result = new List <EnemyClass>();

        dataReader =
            ExecuteQuery("SELECT Name, Attack, Defense, Speed, ID, Life FROM Enemy;");
        while (dataReader.HasRows)
        {
            if (dataReader.Read())
            {
                EnemyClass enemy = new EnemyClass();
                enemy.name  = dataReader.GetString(0);
                enemy.atk   = dataReader.GetInt32(1);
                enemy.def   = dataReader.GetInt32(2);
                enemy.speed = dataReader.GetInt32(3);
                enemy.id    = dataReader.GetInt32(4);
                enemy.life  = dataReader.GetInt32(5);
                result.Add(enemy);
            }
        }

        CloseConnection();

        return(result);
    }
コード例 #9
0
    // Trigger with stripes exit
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("TriggerStripe"))
        {
            switch (enemyClass)
            {
            case EnemyClass.Standard:
                canBeKilled = false;
                break;

            case EnemyClass.Drag:
                canBeDraged = false;
                numberOfStripePassed++;
                Debug.Log(numberOfStripePassed);
                if (numberOfStripePassed > 1 && DragedSate)
                {
                    RestoreEnemyMovement();
                }
                break;

            case EnemyClass.Swipe:
                if (isStandard)
                {
                    enemyClass = EnemyClass.Standard;
                }
                break;
            }
        }
    }
コード例 #10
0
        private static bool HeroHasMana(Hero hero, MethodInfo ability, EnemyClass enemy = null)
        {
            int currentMana = (int)hero.mana; //Check if the hero has mana for the ability

            if (enemy == null)                //If there is no enemy the ability is a void
            {
                ability.Invoke(hero, null);
            }
            else
            {
                ability.Invoke(hero, new object[] { enemy });
            }
            if (hero.mana < 0 && hero.mana >= -100) // If after being invoked the hero's mana is between 0 and -100 he doesn't have the mana for the ability
            {
                GameConsole.currentLog.Append("No mana for that ability \n");
                hero.mana = currentMana;
                return(false);
            }
            else if (hero.mana < -100)// If after being invoked the hero's level is not enough for the ability he loses 1000 mana temporarily
            {
                GameConsole.currentLog.Append("Need a higher level to use that ability \n");
                hero.mana = currentMana;
                return(false);
            }
            hero.mana = currentMana;
            return(true);
        }
コード例 #11
0
    //public static void PlayActiveSounds()
    //{
    //    instance.constantActiveGroup.audioMixer.SetFloat(ACTIVESOUND, instance.activeSoundVolume);
    //}

    public static void StopEnemySound(EnemyClass enemyClass)
    {
        if (instance == null)
        {
            return;
        }

        switch (enemyClass)
        {
        case EnemyClass.DesertSoldier:
            instance.desertSoldierSource.Stop();
            break;

        case EnemyClass.GreenAirplane:
            instance.greenAirplaneSource.Stop();
            break;

        case EnemyClass.GreyAirplane:
            instance.greyAirplaneSource.Stop();
            break;

        case EnemyClass.Soldier:
            instance.soldierSource.Stop();
            break;

        case EnemyClass.Stormtrooper:
            instance.stormtrooperSource.Stop();
            break;

        case EnemyClass.Tank:
            instance.tankSource.Stop();
            break;
        }
    }
コード例 #12
0
 // Use this for initialization
 void Awake()
 {
     gameManager = GameObject.Find("Main Camera").GetComponentInChildren <GameManager>();
     if (this.name == "Raft" || this.name == "Raft(Clone)")
     {
         this.name  = "Raft";
         enemyClass = EnemyData.CreateEnemy(0);
     }
     if (this.name == "Rowboat" || this.name == "Rowboat(Clone)")
     {
         this.name  = "Rowboat";
         enemyClass = EnemyData.CreateEnemy(1);
     }
     if (this.name == "Ship" || this.name == "Ship(Clone)")
     {
         this.name  = "Ship";
         enemyClass = EnemyData.CreateEnemy(2);
     }
     this.gameObject.name = this.enemyClass.Name;
     enemyNavScript       = this.GetComponent <EnemyNav>();
     Debug.Log("I am a " + this.name);
     health = this.enemyClass.Health;
     speed  = this.enemyClass.Speed;
     this.GetComponent <NavMeshAgent>().speed = speed;
     this.GetComponent <EnemyNav>().speed     = speed;
 }
コード例 #13
0
ファイル: GamePanel.cs プロジェクト: exdev/band-of-warriors
 public void OnMissionUpdate(EnemyClass _targetType, int _numToKill)
 {
     if (_numToKill < 0) _numToKill = 0;
     string iconName = _targetType.ToString().ToLower();
     missionTargetIcon.spanim.Play(iconName);
     missionInfoText.text = "to kill: " + _numToKill;
 }
コード例 #14
0
ファイル: PlayerClass.cs プロジェクト: Jou94/UnityFinder
    public void MeleeAttack(EnemyClass _enemyScript)
    {
        enemyScript = _enemyScript;
        int toHitDice = Random.Range(1, 20);

        Debug.Log((toHitDice + mAttack) + " to hit the goblin.");
        if (toHitDice == 20)
        {
            bool hit = enemyScript.toHit(toHitDice + mAttack);

            if (hit)
            {
                enemyScript.DealDamage((Random.Range(1, 8) + strenghtMod) * 2);
            }
            else
            {
                enemyScript.DealDamage(Random.Range(1, 8) + strenghtMod);
            }
        }

        else if (toHitDice == 1)
        {
            //FAIL
        }

        else
        {
            bool hit = enemyScript.toHit(toHitDice + mAttack);

            if (hit)
            {
                enemyScript.DealDamage(Random.Range(1, 8) + strenghtMod);
            }
        }
    }
コード例 #15
0
    public static bool EnemyAttack(PlayerAttack target, EnemyClass attacker)
    {
        float attack = attacker.GetAttack() - ((target.Defence + target.Armour) / 3);

        target.Health -= attack;
        return(target.Health <= 0);
    }
コード例 #16
0
        private void Start()
        {
            Enemy enemy = GetComponent <Enemy>();

            spriteRenderer = GetComponent <SpriteRenderer>();
            characterClass = enemy.characterClass;
            subSprites     = Resources.LoadAll <Sprite>("Characters/" + characterClass.ToString());
        }
コード例 #17
0
    // Use this for initialization
    void Start()
    {
        // m_someOtherScriptOnAnotherGameObject = GameObject.FindObjectOfType(typeof(Player)) as Player;
        PlayerScript = GameObject.Find("Player").GetComponent <Player>();
        EnemyClass Enemy = GetComponent <EnemyClass>();

        PlayerScript.GetHealth();
        Enemy.GetDamage();
    }
コード例 #18
0
    public void addEnemy(Utility.Coord _enemyCoords, string enemyName, Transform _enemyTransform)
    {
        enemyCoords = _enemyCoords;
        combatantNumber++;

        enemy          = GameObject.Find(enemyName);
        enemyScript    = enemy.GetComponent <EnemyClass>();
        enemyTransform = _enemyTransform;
    }
コード例 #19
0
 public void RemoveEnemyList(EnemyClass TargetEnemy)
 {
     if (!Enemys.Remove(TargetEnemy))
     {
         Debug.Log("Error Can't Remove EnemyClass!!");
         return;
     }
     AmountOfEnemy--;
 }
コード例 #20
0
 // Use this for initialization
 void Start()
 {
     cc = GetComponent <BoxCollider2D>();
     ps = GetComponent <PlayerScript>();
     bs = GetComponent <BottleScript>();
     ec = GetComponent <EnemyClass>();
     collision.reset();
     bounds.initRay(cc);
 }
コード例 #21
0
 public static bool AddToMaster(EnemyClass e)
 {
     if (instance == null)
     {
         Debug.LogWarning(e.name + " was not logged");
         return(false);
     }
     instance.enemies.Add(e);
     return(true);
 }
コード例 #22
0
        public void AttackTest()
        {
            EnemyClass enemyTest = new EnemyClass();


            int maxPower = 10000;

            enemyTest.Power = maxPower;
            Assert.AreEqual(5000, enemyTest.basicAttack(), 5000);
        }
コード例 #23
0
ファイル: FightHandler.cs プロジェクト: Kahl21/Grid-System
 static void CreateEnemies(int numberOfEnemiesToSpawn)
 {
     for (int i = 0; i < _enemiesToMake; i++)
     {
         Vector2   spawn        = GridHandler.GetSpawn(false);
         Character newCharacter = new EnemyClass("Enemy", (i + 1).ToString(), TeamType.ENEMY, spawn);
         GridHandler.PlaceEnemyOnBoard(newCharacter);
         _spawnedCharacters.Add(newCharacter);
     }
 }
コード例 #24
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            EnemyClass enemy  = other.gameObject.GetComponent <EnemyClass>();
            float      attack = Damage + _player.Weapon.Damage -
                                (enemy.GetArmor() + enemy.GetDefence());
            if (attack <= 0)
            {
                attack = 10;
            }

            if (!enemy.DecreaseHealth(attack))
            {
                List <int> spawnTable      = enemy.GetCurrencySpawnTable();
                int        spawnedCurrency = 0;
                int        randomInt       = Random.Range(0, 100);
                if (randomInt < 50)
                {
                    spawnedCurrency = spawnTable[0];
                }
                else if (randomInt < 75)
                {
                    spawnedCurrency = spawnTable[1];
                }
                else if (randomInt < 90)
                {
                    spawnedCurrency = spawnTable[2];
                }
                else if (randomInt < 96)
                {
                    spawnedCurrency = spawnTable[3];
                }
                else
                {
                    spawnedCurrency = spawnTable[4];
                }

                Debug.Log($"SPAWNED CURRENCY: {spawnedCurrency}");


                ClampToParent go = Instantiate(enemy.GetClampToParent(), enemy.GetCanvas(), false);
                go.StartPoint = enemy.GetGameObject().transform.position;
                TextMeshProUGUI tmp = go.gameObject.GetComponent <TextMeshProUGUI>();
                tmp.text = $"+{spawnedCurrency}";
                _player.gameObject.GetComponent <PlayerWallet>().ReceiveCoinsGG(spawnedCurrency);
                // Destroy(enemy.GetGameObject());
            }

            GameObject particles = Instantiate(Particles, null, false);
            particles.transform.position = transform.position;
            _mainCamera.Shake(CameraShakeMagnitude, CameraShakeDuration);
            StartCoroutine(DestroySelf());
        }
    }
コード例 #25
0
ファイル: DBManager.cs プロジェクト: w546296781/SimpleGame
    public void SaveEnemy(EnemyClass enemy)
    {
        ConnectToDB("SimpleGame.db");

        dbCommand             = dbConnection.CreateCommand();
        dbCommand.CommandText =
            "UPDATE Enemy SET Name = '" + enemy.name + "', Attack = " + enemy.atk + ", Defense = " + enemy.def + ", Speed = " + enemy.speed + ", Life = " + enemy.life + " WHERE ID = " + enemy.id;
        dbCommand.ExecuteNonQuery();

        CloseConnection();
    }
コード例 #26
0
ファイル: DBManager.cs プロジェクト: w546296781/SimpleGame
    public void CreateEnemy(EnemyClass enemy)
    {
        ConnectToDB("SimpleGame.db");

        dbCommand             = dbConnection.CreateCommand();
        dbCommand.CommandText =
            "INSERT INTO Enemy (ID, Name, Attack, Defense, Speed, Life) VALUES (" + enemy.id + ", '" + enemy.name + "', " + enemy.atk + ", " + enemy.def + ", " + enemy.speed + ", " + enemy.life + ")";
        dbCommand.ExecuteNonQuery();

        CloseConnection();
    }
コード例 #27
0
    public void PlaySound(EnemyClass eClass)
    {
        switch (eClass)
        {
        case EnemyClass.Enemy1: PlaySound(SoundType.Enemy1Attack); break;

        case EnemyClass.Enemy2: PlaySound(SoundType.Enemy2Attack); break;

        case EnemyClass.Enemy3: PlaySound(SoundType.Enemy3Attack); break;
        }
    }
コード例 #28
0
    private void OnTriggerEnter(Collider other)
    {
        //  COLLECTING BATTERY
        if (other.gameObject.tag == "batery")
        {
            // other.gameObject.GetType
            Destroy(other.gameObject);
        }

        // COLLECTING HEALTH MUSHROOM
        else if (other.gameObject.tag == "healthMushroom")
        {
            Debug.Log("Health:" + currentHealth.ToString());
            healthShroom = other.gameObject.GetComponent <HealthMushroomClass>();
            if (currentHealth < maxHealth - healthShroom.GetHealth())
            {
                currentHealth += healthShroom.GetHealth();
            }
            else
            {
                currentHealth = maxHealth;
            }
            healthText.text = "Health: " + currentHealth.ToString();

            Destroy(other.gameObject);
            Debug.Log("Health:" + currentHealth.ToString());
        }

        // COLLECTING POISON MUSHROOM
        else if (other.gameObject.tag == "poisonMushroom")
        {
            Debug.Log("Sanity:" + currentSanity.ToString());
            poisonShroom   = other.gameObject.GetComponent <PoisonMushroomClass>();
            currentSanity -= poisonShroom.GetPoison();
            if (currentSanity <= 0)
            {
                SceneManager.LoadScene(1);
            }
            sanityText.text = "Sanity: " + currentSanity.ToString();
            Destroy(other.gameObject);
            Debug.Log("Sanity:" + currentSanity.ToString());
        }

        // ENEMY CLLISION
        else if (other.gameObject.tag == "enemy")
        {
            Debug.Log("Damage dealt to player");
            enemy           = other.gameObject.GetComponent <EnemyClass>();
            currentHealth  -= enemy.GetDamege();
            healthText.text = "Health: " + currentHealth.ToString();
            Destroy(other.gameObject);
        }
    }
コード例 #29
0
 /// <summary>
 /// creates a wave which contains information about the number of enemies, their attack, their speed, and their currency value
 /// </summary>
 /// <param name="enemies">number of enemies the wave should spawn</param>
 /// <param name="health">amount of health the enemies will have</param>
 /// <param name="attack">attack value of the enemies</param>
 /// <param name="speed">speed value of the enemies</param>
 /// <param name="worth">currency value of the enemies</param>
 /// <param name="elementTypes">array of all types present in this wave</param>
 /// <param name="enemyClass">class that enemy should belong to</param>
 public Wave(int enemies, float health, float attack, float speed, float worth, ElementTypes[] elementTypes, EnemyClass enemyClass, int waveNumber)
 {
     this.enemies      = enemies;
     this.health       = health;
     this.attack       = attack;
     this.speed        = speed;
     this.worth        = worth;
     this.elementTypes = elementTypes;
     typeSpread        = elementTypes.Length / (float)enemies;
     this.enemyClass   = enemyClass;
     this.waveNumber   = waveNumber;
 }
コード例 #30
0
    public static Information[] GetRandomEnemies(int n)
    {
        //return an array with n enemies
        Information[] e = new Information[n];
        for (int i = 0; i < n; i++)
        {
            EnemyClass eC = (EnemyClass)UnityEngine.Random.Range(0, Enum.GetNames(typeof(EnemyClass)).Length - 1);
            e[i]        = GetInformation(eC);
            e[i].eClass = eC;
        }

        return(e);
    }
コード例 #31
0
    void Start()
    {
        HumanoidClass human = new HumanoidClass();
        HumanoidClass enemy = new EnemyClass();
        HumanoidClass orc   = new OrcClass();

        //Notice how each Humanoid variable contains
        //a reference to a different class in the
        //inheritance hierarchy, yet each of them
        //calls the Humanoid Yell() method.
        human.Yell();
        enemy.Yell();
        orc.Yell();
    }
コード例 #32
0
 //input EnemyClass, output Spawner for the enemy.
 public SpawnerEnemy GetSpawnerFromEnemyType(EnemyClass _enemyType)
 {
     if (_enemyType == EnemyClass.Slime) {
         return spawnerContainer.GetComponentInChildren<Spawner_Slime>();
     } else
     if (_enemyType == EnemyClass.Flymon) {
         return spawnerContainer.GetComponentInChildren<Spawner_Flymon>();
     } else
     if (_enemyType == EnemyClass.BigSlime || _enemyType == EnemyClass.FastSlime ) {
         return spawnerContainer.GetComponentInChildren<Spawner_BigSlime>();
     } else
     if (_enemyType == EnemyClass.Cubat) {
         return spawnerContainer.GetComponentInChildren<Spawner_Cubat>();
     } else {
         Debug.LogError("invalid enemy type, can't get spawner.");
         return null;
     }
 }
コード例 #33
0
ファイル: UnitManager.cs プロジェクト: JohnEz/TileBasedEngine
 void GiveEnemyAbilities(Unit u, EnemyClass e)
 {
     switch (e) {
     case EnemyClass.Goblin: u.myAbilities[0] = new Clobber(u, map, effectLibrary);
         break;
     case EnemyClass.GoblinAxeThrower: u.myAbilities[0] = new AxeThrow(u, map, effectLibrary);
         break;
     case EnemyClass.GoblinDrummer: u.myAbilities[0] = new BattleRhythem(u, map, effectLibrary);
         u.myAbilities[1] = new Inspire(u, map, effectLibrary);
         u.myAbilities[2] = new SonicWave(u, map, effectLibrary);
         break;
     case EnemyClass.GoblinShaman: u.myAbilities[0] = new HammerSlam(u, map, effectLibrary);
         u.myAbilities[1] = new FlamingAxe(u, map, effectLibrary);
         u.myAbilities[2] = new Combustion(u, map, effectLibrary);
         u.myAbilities[3] = new SpawnTotem(u, map, effectLibrary);
         break;
     case EnemyClass.EarthTotem: u.myAbilities[0] = new TotemSnare(u, map, effectLibrary);
         u.myAbilities[1] = new TotemShield(u, map, effectLibrary);
         break;
     case EnemyClass.FireTotem: u.myAbilities[0] = new TotemFireball(u, map, effectLibrary);
         u.myAbilities[1] = new TotemFlameShield(u, map, effectLibrary);
         break;
     case EnemyClass.WaterTotem: u.myAbilities[0] = new TotemHeal(u, map, effectLibrary);
         //u.myAbilities[1] = new TotemMist(u, map, effectLibrary);
         break;
     case EnemyClass.WindTotem: u.myAbilities[0] = new TotemCooldownReduction(u, map, effectLibrary);
         u.myAbilities[1] = new TotemPushBack(u, map, effectLibrary);
         break;
     }
 }
コード例 #34
0
ファイル: UnitManager.cs プロジェクト: JohnEz/TileBasedEngine
    public Unit spawnEnemy(int x, int y, EnemyClass e, bool isAtive = false)
    {
        //set starting position and spawn unit
        Vector3 pos = map.TileCoordToWorldCoord (x, y);
        pos = new Vector3(pos.x, pos.y, -2);
        GameObject go = (GameObject)Instantiate (enemyTypes [(int)e], pos, Quaternion.identity);

        Unit u 			= go.GetComponent<Unit> ();
        AIBehaviours ai = go.GetComponent<AIBehaviours> ();

        //set its starting values
        u.tileX = x;
        u.tileY = y;
        u.map = map;
        u.team = 2;
        u.ID = everyUnit.Count;
        u.uManager = this;
        u.hp = u.maxHP;
        u.mana = u.maxMana;
        ai.myMap = map;
        ai.myManager = this;
        ai.Initialise ();
        ++enemyCount;

        //add a shieldbar
        AddUnitUIElement (shieldBar, u);

        //add a manabar
        AddUnitUIElement (manaBar, u);
        AddUnitUIElement (manaText, u);

        //add a healthbar
        AddUnitUIElement (healthBar, u);
        AddUnitUIElement (hpText, u);

        //give the enemy their abilities
        GiveEnemyAbilities (u, e);

        //let the map know where the unit is
        map.GetNode (x, y).myUnit = u;

        // add to all the lists
        enemies [enemyCount] = go;	//enemy array
        everyUnit.Add(go);			//every unit

        if (isAtive) {
            activeUnits.Add(go);	 // list of currently active units
            u.isActive = true;
        }

        return u;
    }
コード例 #35
0
 public void OnEnemyKilled(EnemyClass _killedType)
 {
     if (currentLevel < levelInfos.Length) {
         EnemyClass targetType = levelInfos[currentLevel].targetEnemy;
         int targetNumber = levelInfos[currentLevel].targetKillNum;
         if ( _killedType == targetType || targetType == EnemyClass.AnyEnemy ) {
             currentKillNum += 1;
             Game.instance.theGamePanel.OnMissionUpdate(targetType,
                                                (targetNumber-currentKillNum));
             if (currentKillNum >= targetNumber) {
                 GoLevelUp();
             }
         }
     }
 }