Exemplo n.º 1
0
    IEnumerator CreateEnemyWave() //depending on chosed parameters generating enemies and defining their parameters
    {
        for (int i = 0; i < count; i++)
        {
            GameObject newEnemy;
            newEnemy = Instantiate(enemy, enemy.transform.position, Quaternion.identity);
            FollowThePath followComponent = newEnemy.GetComponent <FollowThePath>();
            followComponent.path           = pathPoints;
            followComponent.speed          = speed;
            followComponent.rotationByPath = rotationByPath;
            followComponent.loop           = Loop;
            followComponent.SetPath();
            //Enemy enemyComponent = newEnemy.GetComponent<Enemy>();
            //newEnemy.SetActive(true);
            yield return(new WaitForSeconds(timeBetween));
        }
        if (testMode)       //if testMode is activated, waiting for 3 sec and re-generating the wave
        {
            yield return(new WaitForSeconds(3));

            StartCoroutine(CreateEnemyWave());
        }
        else if (!Loop)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
    IEnumerator CreateEnemyWave()
    {
        for (int i = 0; i < count; i++)
        {
            GameObject newEnemy;
            newEnemy = Instantiate(enemy, enemy.transform.position, Quaternion.identity);
            FollowThePath followComponent = newEnemy.GetComponent <FollowThePath>();
            followComponent.path           = pathPoints;
            followComponent.speed          = speed;
            followComponent.rotationByPath = rotationByPath;
            followComponent.loop           = Loop;
            followComponent.SetPath();
            // Enemy enemyComponent = newEnemy.GetComponent<Enemy>();
            // enemyComponent.shotChance = shooting.shotChance;
            // enemyComponent.shotTimeMin = shooting.shotTimeMin;
            // enemyComponent.shotTimeMax = shooting.shotTimeMax;
            // newEnemy.SetActive(true);
            yield return(new WaitForSeconds(timeBetween));
        }
        if (testMode)
        {
            yield return(new WaitForSeconds(3));

            StartCoroutine(CreateEnemyWave());
        }
        else if (!Loop)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 3
0
    public void assignScripts()
    {
        inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <Inventory>();
        player    = GameObject.FindGameObjectWithTag("Player").GetComponent <AstronautMovement>();

        if (GameObject.FindGameObjectWithTag("IceGollem") != null)
        {
            iceGolem = GameObject.FindGameObjectWithTag("IceGollem").GetComponent <IceGolemScript>();
        }



        if (GameObject.FindGameObjectWithTag("Gollem") != null)
        {
            lavaGolem = GameObject.FindGameObjectWithTag("Gollem").GetComponent <FollowThePath>();
        }

        if (GameObject.FindGameObjectWithTag("MineralGollem") != null)
        {
            mineralGolem = GameObject.FindGameObjectWithTag("MineralGollem").GetComponent <MineralGolemScript>();
        }

        if (GameObject.FindGameObjectWithTag("FinalBoss") != null)
        {
            finalBoss = GameObject.FindGameObjectWithTag("FinalBoss").GetComponent <FinalBossMovement>();
        }
    }
Exemplo n.º 4
0
    private static void moveActor(float speed = 5f, bool backward = false)
    {
        FollowThePath curActor = playerInTurnActor();

        curActor.setSpeed(speed);
        curActor.setDirection(backward);
        curActor.moveAllowed = true;
        turnLock             = true;
    }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        speed = initialSpeed;

        if (hasBounds)
        {
            currentRotationZ = transform.rotation.eulerAngles.z;
        }

        followThePath = GetComponent <FollowThePath>();
    }
Exemplo n.º 6
0
    public static void Save(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string path = Application.persistentDataPath + "/player.save";

        FileStream stream = new FileStream(path, FileMode.Create);

        Data data = new Data(player, iceGolem, lavaGolem, mineralGolem, finalBoss, items);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemplo n.º 7
0
    IEnumerator CreateEnemyWave()
    {
        //Создаём цикл который зависит от кол-ва врагов в волне.
        for (int i = 0; i < count_in_Wave; i++)
        {
            // Создаём врага
            GameObject new_enemy = Instantiate(obj_Enemy, obj_Enemy.transform.position, Quaternion.identity);


            //Получаем компонент FollowThePath который висит на созданном враге.
            follow_Component = new_enemy.GetComponent <FollowThePath>();

            // Через ссылку передадим точки пути по которым должен перемещаться враг
            follow_Component.path_Points = path_Points;

            //Через ссылку передадим скорость с которой должен перемещаться враг
            follow_Component.speed_Enemy = speed_Enemy;

            //Через ссылку передадим значение логической переменной. Если true - движемся бесконечно, если false - уничтожаем врага в конце пути.
            follow_Component.is_Return = is_return;

            //Получим ссылку на компонент MoveEnemy который висит на созданном враге.
            enemy_Component_Script = new_enemy.GetComponent <MoveEnemy>();

            //Через ссылку передадим врагу шанс выстрела.
            enemy_Component_Script.shot_Chance = shottingSettings.shot_Chance;

            //Через ссылку передадим врагу интервал через который будет происходить выстрел
            enemy_Component_Script.shot_Time_Min = shottingSettings.shot_Timer_Min;
            enemy_Component_Script.shot_Time_Max = shottingSettings.shot_Timer_Max;

            new_enemy.SetActive(true);

            //Делаем задержку после которой продолжаем выполнения кода и создаём нового врага
            yield return(new WaitForSeconds(time_Spawn));
        }
        // Cоздаём условия( если логическая переменная для теста имеет значение true ждём 5 секунд и запускаем волну)
        if (is_Test_Wave)
        {
            yield return(new WaitForSeconds(5f));

            StartCoroutine(CreateEnemyWave());
        }

        //Если значение false уничтожаем врага в конце пути.
        if (!is_Test_Wave)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// Субпрограмма для создания врагов в волне
 /// </summary>
 /// <returns></returns>
 IEnumerator CreateEnemyWave()
 {
     Debug.Log(count_in_Wave);
     for (int i = 0; i < count_in_Wave; i++)
     {
         GameObject new_enemy = Instantiate(obj_Enemy, obj_Enemy.transform.position, Quaternion.identity);
         new_enemy.transform.SetParent(parentEnemyWave.transform);
         _update = IGameManager.Instance.updateEnemy; // Улучшаем характеристики
         new_enemy.GetComponent <Enemy>().UpAttributes(_update.UpHealth, _update.UpDamage, _update.UpSpeed, _update.UpGold);
         follow_Component             = new_enemy.GetComponent <FollowThePath>();
         follow_Component.path_Points = path_Points;
         yield return(new WaitForSeconds(time_Spawn));
     }
     IGameManager.Instance.IncrementUpAttributes(); // Увеличваем характеристики
     Destroy(gameObject);                           // Уничтожаем волну (чтоб не захламлят редактор)
 }
Exemplo n.º 9
0
    IEnumerator CreateEnemyWave()
    {
        //Ceate enemies...
        for (int i = 0; i < count_in_Wave; i++)
        {
            // Create an instance of the prefab obj_Enemy in the obj_Enemy position and without rotation.
            GameObject new_enemy = Instantiate(obj_Enemy, obj_Enemy.transform.position, Quaternion.identity);

            // Try and find an FollowThePath script on the gameobject new_enemy.
            follow_Component = new_enemy.GetComponent <FollowThePath>();
            // Specify the path that will move the new_enemy
            follow_Component.path_Points = path_Points;
            // Specify the speed with which the new enemy will move
            follow_Component.speed_Enemy = speed_Enemy;
            //Destroy the surviving enemies at the end of the path or send them to the beginning of the path.
            follow_Component.is_return = is_return;

            // Try and find an Enemy script on the gameobject new_enemy.
            enemy_Component_Script = new_enemy.GetComponent <Enemy>();
            // Specify shot chance a new enemy.
            enemy_Component_Script.shot_Chance = shooting_Settings.shot_Chance;
            // Specify time interval within which the shot occurs.
            enemy_Component_Script.shot_Time_Min = shooting_Settings.shot_Time_Min;
            enemy_Component_Script.shot_Time_Max = shooting_Settings.shot_Time_Max;

            new_enemy.SetActive(true);
            // Every time_Spawn seconds
            yield return(new WaitForSeconds(time_Spawn));
        }
        // If wave test
        if (is_Test_Wave)
        {
            //Infinitely generate the current wave every 5 seconds
            yield return(new WaitForSeconds(5f));

            StartCoroutine(CreateEnemyWave());
        }

        // If is_return = false destroy the enemy at the end of the path
        if (!is_return)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 10
0
    IEnumerator CreateEnemyWawe()
    {
        for (int i = 0; i < count_in_Wave; i++)
        {
            //создадим экзепляр врага и поместим его в переменну
            GameObject new_Enemy = Instantiate(obj_Enemy, obj_Enemy.transform.position, Quaternion.identity);
            //получим ссылку на компонент FollowThePath который на созданном враге должен появиться
            follow_Component = new_Enemy.GetComponent <FollowThePath>();
            //через ссылку перередадим точки пути по которым должен перемещаться враг
            follow_Component.path_Points = path_Points;
            //также передадим скорость с которой он должен перемещаться
            follow_Component.speed_Enemy = speed_Enemy;
            // значение логической переменной также передаем (должен ли враг быть уничтожен в конце пути)
            follow_Component.is_return = is_return;

            //получим ссылку на компонент Enemy, который висит на созданном враге
            _enemy_Component_Script = new_Enemy.GetComponent <Enemy>();
            //через эту ссылку передадим врагу шанс выстрела
            _enemy_Component_Script.shoot_Chance = shooting_Setting.shoot_Chance;
            //передаем интервал внутри которого будет происходить выстрел
            _enemy_Component_Script.shoot_Time_Min = shooting_Setting.shoot_Time_Min;
            _enemy_Component_Script.shoot_Time_Max = shooting_Setting.shoot_Time_Max;

            new_Enemy.SetActive(true);
            //задержка перед созданием нового врага
            yield return(new WaitForSeconds(time_Spawn));
        }

        //ели переменная для теста активна - ждем пять секунд и запускаем волну
        if (is_Test)
        {
            //бесконечная генерация волн
            yield return(new WaitForSeconds(5f));

            StartCoroutine(CreateEnemyWawe());
        }

        if (!is_return)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 11
0
 IEnumerator CreateEnemyWave() //depending on chosed parameters generating enemies and defining their parameters
 {
     for (int i = 0; i < count; i++)
     {
         GameObject newEnemy;
         newEnemy = (GameObject)Instantiate(enemy, enemy.transform.position, Quaternion.identity);
         FollowThePath followComponent = newEnemy.GetComponent <FollowThePath>();
         Enemy         e = newEnemy.GetComponent <Enemy>();
         e.health                       = health;
         followComponent.path           = pathPoints;
         followComponent.speed          = speed;
         followComponent.rotationByPath = rotationByPath;
         followComponent.loop           = Loop;
         followComponent.SetPath();
         newEnemy.SetActive(true);
         yield return(new WaitForSeconds(timeBetween));
     }
     if (Loop)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 12
0
    public Data(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
    {
        health = player.health;
        oxygen = player.oxygen;


        if (items.Count > 0)
        {
            Debug.Log("Entered");
            tags = new int[items.Count];
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].tag != "Untagged")
                {
                    string tag = items[i].tag;
                    Debug.Log(tag);
                    tags[i] = int.Parse(tag);
                }
            }
        }

        if (iceGolem != null)
        {
            positionIceGolem = new float[3];



            positionIceGolem[0] = iceGolem.transform.position.x;
            positionIceGolem[1] = iceGolem.transform.position.y;
            positionIceGolem[2] = iceGolem.transform.position.z;

            iceGolemHealth = iceGolem.health;
        }
        else
        {
            iceGolemAlive = false;
        }

        if (lavaGolem != null)
        {
            lavaGolemHealth = lavaGolem.health;

            positionLavaGolem = new float[3];

            positionLavaGolem[0] = lavaGolem.transform.position.x;
            positionLavaGolem[1] = lavaGolem.transform.position.y;
            positionLavaGolem[2] = lavaGolem.transform.position.z;
        }
        else
        {
            lavaGolemAlive = false;
        }

        if (mineralGolem != null)
        {
            mineralGolemHealth = mineralGolem.health;

            positionMineralGolem = new float[3];

            positionMineralGolem[0] = mineralGolem.transform.position.x;
            positionMineralGolem[1] = mineralGolem.transform.position.y;
            positionMineralGolem[2] = mineralGolem.transform.position.z;
        }
        else
        {
            mineralGolemAlive = false;
        }

        if (finalBoss != null)
        {
            finalBossHealth = finalBoss.health;

            positionFinalBoss = new float[3];

            positionFinalBoss[0] = finalBoss.transform.position.x;
            positionFinalBoss[1] = finalBoss.transform.position.y;
            positionFinalBoss[2] = finalBoss.transform.position.z;
        }
        else
        {
            finalBossAlive = false;
        }



        positionPlayer = new float[3];



        positionPlayer[0] = player.transform.position.x;
        positionPlayer[1] = player.transform.position.y;
        positionPlayer[2] = player.transform.position.z;
    }
Exemplo n.º 13
0
 private void Save(AstronautMovement player, IceGolemScript iceGolem, FollowThePath lavaGolem, MineralGolemScript mineralGolem, FinalBossMovement finalBoss, List <GameObject> items)
 {
     SaveSystem.Save(player, iceGolem, lavaGolem, mineralGolem, finalBoss, items);
     hasSaved = true;
 }