示例#1
0
    public void ChangeMoveStateToIdle()
    {
        Enemy.EnemyType enemyType = enemyInstance.GetEnemyType();
        moveState = MoveState.Idle;

        if (enemyType == Enemy.EnemyType.Smallest)
        {
            int diceResult = CalculateMoveDicesResult();
            SetMovement(diceResult);
        }
        else if (enemyType == Enemy.EnemyType.Middle)
        {
            if (makeCooldown == 0)
            {
                MakeSmallestEnemy();
                moveState    = MoveState.MakingEnemy;
                makeCooldown = 2;
            }
            else
            {
                moveState = MoveState.MakingComplete;
            }
            makeCooldown--;
        }
        else
        {
            //none.
        }

        Run.Coroutine(StartTurn());
    }
示例#2
0
 public void FreeSpawn(Enemy.EnemyType enemyType)
 {
     //libera el spawn para volver a usarse
     currentEnemyInSpawner = null;
     IsOccupied            = false;
     OnKilledEnemy(enemyType);
 }
示例#3
0
 private EnemyManager(Unit unitPrefab, Tile spawnTile, Enemy.EnemyType type, string enemyId)
 {
     this.unitPrefab = unitPrefab;
     this.spawnTile  = spawnTile;
     this.enemyType  = type;
     this.enemyId    = enemyId;
 }
示例#4
0
    void SpawnEnemy(Enemy.EnemyType enemyType)
    {
        GameObject enemyGameObject = SpawnVerticalObject(enemyMap[enemyType]);
        Enemy      enemy           = enemyGameObject.GetComponent <Enemy>();

        enemy.Type = enemyType;
    }
示例#5
0
    public Enemy setEnemyStats(Enemy.EnemyType enemyTypeTemp)
    {
        Enemy currentEnemy = new Enemy();

        currentEnemy.enemyTypeVal = enemyTypeTemp;

        raceBaseData baseData = new raceBaseData();

        switch (enemyTypeTemp)
        {
        case (Enemy.EnemyType.grey_rat):
            currentEnemy.enemyHeatlth           = baseData.grey_rat_health.Random;
            currentEnemy.enemyDamage            = baseData.grey_rat_base_damage.Random;
            currentEnemy.enemyExperienceGranted = baseData.grey_rat_experience_granted.Random;
            break;

        case (Enemy.EnemyType.warg):
            currentEnemy.enemyHeatlth           = baseData.warg_health.Random;
            currentEnemy.enemyDamage            = baseData.warg_base_damage.Random;
            currentEnemy.enemyExperienceGranted = baseData.warg_experience_granted.Random;
            break;

        case (Enemy.EnemyType.wolf):
            currentEnemy.enemyHeatlth           = baseData.wolf_health.Random;
            currentEnemy.enemyDamage            = baseData.wolf_base_damage.Random;
            currentEnemy.enemyExperienceGranted = baseData.wolf_experience_gained.Random;
            break;
        }

        return(currentEnemy);
    }
示例#6
0
    public void InstantiateEnemyByNetwork(string enemyId, int tileKey, Enemy.EnemyType type)
    {
        Tile startTile = TileManager.GetExistTile(tileKey);

        Camera.main.transform.position = new Vector3(
            startTile.transform.position.x,
            startTile.transform.position.y,
            Camera.main.transform.position.z);

        var summonEffect = EffectManager.Get().ShowEnemySpawnEffect(startTile.transform.position);

        var summon = Run.WaitSeconds(0.3f)
                     .ExecuteWhenDone(() => {
            EnemyManager enemyManager = EnemyManager.Create(enemyPrefab, startTile, type, enemyId);
            enemyManager.Init();
            enemies.Add(enemyId, enemyManager);
        });

        Run.Join(new List <Run> {
            summonEffect, summon
        })
        .ExecuteWhenDone(() => {
            if (Network.isServer)
            {
                Slinqable.Slinq(enemies.Values)
                .FirstOrNone((enemyManager) => enemyManager.GetMoveState() == EnemyManager.MoveState.MakingEnemy)
                .ForEach((enemyManager) => enemyManager.OnEnemyMakingEffectEnd());
            }
        });
    }
示例#7
0
    public static EnemyManager CreateInStart(Unit unitPrefab, string enemyId)
    {
        Tile startTile = TileManager.GetStartTile();

        Enemy.EnemyType type = Enemy.EnemyType.None;
        return(new EnemyManager(unitPrefab, startTile, type, enemyId));
    }
示例#8
0
    /// -------------------------------------------
    ///
    ///     Enemies
    ///
    /// -------------------------------------------

    public List <Enemy> GetEnemies(Enemy.EnemyType type, int amount)
    {
        // Make empty list
        List <Enemy> list = new List <Enemy>();

        // There are enough pending enemies to return
        foreach (Enemy enemy in _AvailiableEnemies)
        {
            // If it is a matching enemy type
            if (enemy._EnemyType == type)
            {
                list.Add(enemy);
            }

            if (list.Count > amount)
            {
                break;
            }
        }

        foreach (Enemy enemy in list)
        {
            enemy._CurrentState = Enemy.State.Active;

            _AvailiableEnemies.Remove(enemy);
            _ActiveEnemies.Add(enemy);
        }

        // Return list of enemies to use
        return(list);
    }
示例#9
0
    public Enemy randomEnemyGen(Enemy.EnemyType predefinedEnemy)
    {
        Enemy currentEnemy = new Enemy();

        currentEnemy = setEnemyStats(predefinedEnemy);

        return(currentEnemy);
    }
示例#10
0
 public void AddScore(Enemy.EnemyType type)
 {
     switch (type)
     {
     case Enemy.EnemyType.enemyBase:
         ModifyScore(scoreBaseEnemy);
         break;
     }
 }
示例#11
0
    /// <summary>
    /// Draws text above an object. Currently used to draw the enemyType, but can draw anything you pass in as second param.
    /// Create a new function to draw different objects above enemes
    /// </summary>
    /// <param name="gameObject">Target object we are drawing on top of </param>
    /// <param name="enemyType">should consider moving this to a different object, instead of enemyType</param>
    //[Conditional("DEBUG")]
    public static void DrawEnemyTypeAboveObject(GameObject gameObject, Enemy.EnemyType enemyType, int offsetX = 40, int offsetY = 40, int rectWidth = 90, int rectHeight = 40)
    {
        // Converts 3d space to 2d, to create a plane to draw text to
        var objectPos = Camera.main.WorldToScreenPoint(gameObject.transform.position);

        // BeginArea positioned in relation to my character
        GUILayout.BeginArea(new Rect((objectPos.x - offsetX), (Screen.height - objectPos.y) - offsetY, Screen.width, Screen.height));

        // Draw the text above the enemy
        GUI.Label(new Rect(gameObject.transform.position.x, gameObject.transform.position.y, rectWidth, rectHeight), enemyType.ToString());

        GUILayout.EndArea();
    }
    IEnumerator SpawnEnemyAfterDelay(float delay)
    {
        yield return(new WaitForSeconds(delay));

        int   runTimeLoopCount = runtimeChoices.runTimeLoopCount;
        Enemy enemy            = runtimeChoices.enemies[runTimeLoopCount - 1];

        Enemy.EnemyType enemyType = enemy.enemyType;

        Vector3 deltaVector = new Vector3(Random.Range(0, 60), 0, 0);

        GameObject     go;
        EnemyBehaviour enemyBehaviour;

        switch (enemyType)
        {
        case Enemy.EnemyType.None:
            go             = Instantiate(enemyPrefab, enemySpawnPos - deltaVector, Quaternion.identity);
            enemyBehaviour = go.GetComponent <EnemyBehaviour>();
            break;

        case Enemy.EnemyType.Agile:
            go             = Instantiate(agileEnemyPrefab, enemySpawnPos - deltaVector, Quaternion.identity);
            enemyBehaviour = go.GetComponent <AgileEnemy>();
            break;

        case Enemy.EnemyType.Orb:
            go             = Instantiate(orbEnemyPrefab, enemySpawnPos - deltaVector, Quaternion.identity);
            enemyBehaviour = go.GetComponent <OrbEnemy>();
            break;

        case Enemy.EnemyType.Splitter:
            //TODO: Make splitter:
            go             = Instantiate(splitterEnemyPrefab, enemySpawnPos - deltaVector, Quaternion.identity);
            enemyBehaviour = go.GetComponent <SplitterEnemy>();
            break;

        default:
            //Default is only here to ensure that enemyBehaviour is always assigned for future use in this method call.
            go             = Instantiate(enemyPrefab, enemySpawnPos - deltaVector, Quaternion.identity);
            enemyBehaviour = go.GetComponent <EnemyBehaviour>();
            break;
        }


        EnemyModifier[] modifiers = new EnemyModifier[] { runtimeChoices.enemyModifiers[runTimeLoopCount - 1] };
        enemyBehaviour.InitalizeEnemy(enemy, modifiers);        //take account for boss-amount of modifiers

        monsterSpawnedEvent.Raise();
    }
示例#13
0
    private IEnumerator SpawnEnemies()
    {
        int randomEnemyIndex = Random.Range(0, enemyTypes.Length);

        Enemy.EnemyType enemyToSpawn = enemyTypes[randomEnemyIndex];

        for (int i = 0; i < amountToSpawn; i++)
        {
            ObjectPooler.Instance.SpawnFromPool(enemyToSpawn.ToString(), transform.position, transform.rotation);
            yield return(new WaitForSeconds(spawnSpeed));
        }
        print("SPAWNING");
        yield return(new WaitForSeconds(timeBetweenSpawns));
        //StartCoroutine(SpawnEnemies());
    }
    //void TargetSwitch
    void SetDifferentTarget()
    {
        int temp = UnityEngine.Random.Range(0, 3); // One or two - Square or Triangle.

        switch (temp)
        {
        case 0:
            if (playerTarget == Enemy.EnemyType.Square)
            {
                SetDifferentTarget();
            }
            else
            {
                playerTarget = Enemy.EnemyType.Square;
            }
            break;

        case 1:
            if (playerTarget == Enemy.EnemyType.Triangle)
            {
                SetDifferentTarget();
            }
            else
            {
                playerTarget = Enemy.EnemyType.Triangle;
            }
            break;

        case 2:
            if (playerTarget == Enemy.EnemyType.Circle)
            {
                SetDifferentTarget();
            }
            else
            {
                playerTarget = Enemy.EnemyType.Circle;
            }
            break;

        //playerTarget = Enemy.EnemyType.Circle;
        default:
            break;
        }
        playerTargetUISpritesScript.SetDisplayTarget(playerTarget);

        // trigger blink trigger for targetpanel
        targetPanel_anim.SetTrigger("Blink");
    }
示例#15
0
    public void SetDisplayTarget(Enemy.EnemyType type)
    {
        switch (type)
        {
        case 0:     // square
            for (int i = 0; i < transform.childCount; i++)
            {
                if (i == 0)
                {
                    transform.GetChild(i).gameObject.SetActive(true);
                }
                else
                {
                    transform.GetChild(i).gameObject.SetActive(false);
                }
            }
            break;

        case (Enemy.EnemyType) 1:    // triangle
            for (int i = 0; i < transform.childCount; i++)
            {
                if (i == 1)
                {
                    transform.GetChild(i).gameObject.SetActive(true);
                }
                else
                {
                    transform.GetChild(i).gameObject.SetActive(false);
                }
            }
            break;

        case (Enemy.EnemyType) 2:
            for (int i = 0; i < transform.childCount; i++)
            {
                if (i == 2)
                {
                    transform.GetChild(i).gameObject.SetActive(true);
                }
                else
                {
                    transform.GetChild(i).gameObject.SetActive(false);
                }
            }
            break;
        }
    }
    public void Revive(EnemyBehaviour enemyToApplyTo)
    {
        FindObjectOfType <AudioList>().resurrection.Play();
        Enemy agent = enemyToApplyTo.agent;

        Enemy.EnemyType enemyType = agent.enemyType;
        Spawner         spawner   = FindObjectOfType <Spawner>();

        GameObject go;

        switch (enemyType)
        {
        case Enemy.EnemyType.Agile:
            go = Instantiate(spawner.agileEnemyPrefab, enemyToApplyTo.transform.position, Quaternion.identity);
            break;

        case Enemy.EnemyType.Orb:
            go = Instantiate(spawner.orbEnemyPrefab, enemyToApplyTo.transform.position, Quaternion.identity);
            break;

        case Enemy.EnemyType.Splitter:
            go = Instantiate(spawner.splitterEnemyPrefab, enemyToApplyTo.transform.position, Quaternion.identity);
            break;

        default:
            go = Instantiate(spawner.enemyPrefab, enemyToApplyTo.transform.position, Quaternion.identity);
            break;
        }

        EnemyBehaviour newEnemy = go.GetComponent <EnemyBehaviour>();

        newEnemy.name = name;
        newEnemy.spriteRenderer.sprite = agent.sprite;
        newEnemy.nameUI.SetText(enemyToApplyTo.name);

        newEnemy.nameUI = enemyToApplyTo.nameUI;

        newEnemy.currentHealth = agent.health;
        newEnemy.maxHealth     = newEnemy.currentHealth;
        newEnemy.healthBar.UpdateHPValues(newEnemy.currentHealth, newEnemy.maxHealth);

        EnemyModifier[] enemyModifiers = new EnemyModifier[0];

        newEnemy.InitalizeEnemy(agent, enemyModifiers);
    }
示例#17
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Enemy")
        {
            Enemy           enemy = collision.gameObject.GetComponent <Enemy>();
            Enemy.EnemyType type  = (Enemy.EnemyType)enemy.GetEnemyType();

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            if (type == Enemy.EnemyType.BOSS)
            {
                enemy.OnHit(100.0f, false, hitPoint);
            }
            else
            {
                enemy.OnHit(999999.0f, false, hitPoint);
            }
        }
    }
示例#18
0
    public void SpawnEnemy(Vector3 a_position, Enemy.EnemyType a_type)
    {
        GameObject enemy = null;

        for (int i = 0; i < m_pooledEnemies.Count; ++i)
        {
            if (m_pooledEnemies[i][0].m_type == a_type)
            {
                enemy = FindInactive(m_pooledEnemies[i]);
                break;
            }
        }

        if (enemy != null)
        {
            enemy.transform.position = a_position;
            enemy.gameObject.SetActive(true);
        }
    }
示例#19
0
    //タイプによって算出方法を分岐
    private void ScoreCululate(Enemy.EnemyType type)
    {
        switch (type)
        {
        case Enemy.EnemyType.SLOW:
            scoreManager.AddScore(20);
            //StartCoroutine(ChangeScore(10));
            break;

        case Enemy.EnemyType.FAST:
            scoreManager.AddScore(30);
            //StartCoroutine(ChangeScore(30));
            break;

        case Enemy.EnemyType.NPC:
            scoreManager.AddScore(-30);
            //StartCoroutine(ChangeScore(-30));
            break;
        }

        enemyManager.isDeadEnemy = false;
    }
示例#20
0
    // Game controller will call this function
    public void Spawn(Enemy.EnemyType toSpawn)
    {
        GameObject enemyToSpawn = new GameObject();

        switch (toSpawn)
        {
        case Enemy.EnemyType.StarShip:
            enemyToSpawn = prefabBank.starShip;
            break;

        case Enemy.EnemyType.Kamikaze:
            enemyToSpawn = prefabBank.kamikaze;
            break;

        case Enemy.EnemyType.Battleship:
            enemyToSpawn = prefabBank.battleship;
            break;

        default:
            break;
        }
        GameObject enemy = (GameObject)Instantiate(enemyToSpawn, transform.position, transform.rotation);
    }
示例#21
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);
    }
示例#22
0
 public static EnemyManager Create(Unit unitPrefab, Tile spawnTile, Enemy.EnemyType type, string enemyId)
 {
     return(new EnemyManager(unitPrefab, spawnTile, type, enemyId));
 }
示例#23
0
 public void addKilledEnemiesAmount(int i, Enemy.EnemyType type)
 {
     killedEnemiesAmount[type]++;
 }
示例#24
0
 public static void SpawnEnemies(Enemy.EnemyType enemyID, int enemyAmount, float spawnInterval)
 {
     OnSpawnEnemies?.Invoke(enemyID, enemyAmount, spawnInterval);
 }
示例#25
0
 private void ReceiveMakeNonetypeEnemy(string enemyId, int tileKey)
 {
     Enemy.EnemyType type = Enemy.EnemyType.None;
     GameManager.gameManagerInstance.InstantiateEnemyByNetwork(enemyId, tileKey, type);
 }
示例#26
0
 public EnemyInfo(int tileKey, Enemy.EnemyType type)
 {
     enemyPlaceTileKey = tileKey;
     enemyType         = type;
 }
示例#27
0
 private void AddScore(Enemy.EnemyType eType)
 {
     scoreManager.AddScore(eType);
     score.text = scoreManager.currentScore.ToString();
 }