// Start is called before the first frame update
    void Start()
    {
        manager       = GameObject.Find("EnemyManager");
        ManagerScript = manager.GetComponent <EnemyManagerScript>();
        playerObject  = GameObject.Find("Player");
        playerScript  = playerObject.GetComponent <PlayerScript>();
        float delay = Random.Range(2f, 10f);
        float rate  = Random.Range(2f, 8f);

        InvokeRepeating("Fire", delay, rate);
        int yposition = (int)transform.position.y;

        if (yposition % 2 == 0)
        {
            direction = -1;
        }
        else
        {
            direction = 1;
        }
        minDistance    = transform.position.x + minDistance;
        maxDistance    = transform.position.x + maxDistance - .5f;
        spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
        spedUp         = false;
    }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     rb            = GetComponent <Rigidbody2D>();
     manager       = GameObject.Find("EnemyManager");
     ManagerScript = manager.GetComponent <EnemyManagerScript>();
     StartCoroutine("Launch");
 }
예제 #3
0
 // Use this for initialization
 void Awake()
 {
     powerUp = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/PowerUp"));
     powerUp.SetActive(false);
     environment        = GameObject.Find("Environment");
     attributeShardList = new List <GameObject>();
     for (int i = 0; i < 10; i++)
     {
         attributeShard = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/AttributeShard"));
         attributeShard.transform.SetParent(this.transform);
         attributeShardList.Add(attributeShard);
         attributeShard.SetActive(false);
     }
     agent              = GetComponent <NavMeshAgent>();
     player             = GameObject.Find("Player");
     playerScript       = player.GetComponent <Player>();
     agent.destination  = player.transform.position;
     enemyManagerScript = GameObject.Find("EnemyManager").GetComponent <EnemyManagerScript>();
     rb      = GetComponent <Rigidbody>();
     hitstun = 1f;
     health  = 3;
     rend    = GetComponent <Renderer>();
     rend.material.shader = Shader.Find("_Color");
     healthColor          = new Color(.25f * health, .25f * health, .25f * health);
     rend.material.SetColor("_Color", healthColor);
     soundManager = GameObject.Find("SoundManager").GetComponent <SoundManager>();
 }
예제 #4
0
 // Use this for initialization
 private void Awake()
 {
     instance         = this;
     activeEnemies    = new LinkedList <EnemyScript>();
     survivors        = null;
     distanceComparer = new EnemyDistanceToGoalComparer();
     timeComparer     = new EnemyTimeToGoalComparer();
 }
예제 #5
0
 private void Awake()
 {
     enemyManagerScript = GameObject.FindGameObjectWithTag("EM").GetComponent <EnemyManagerScript>();
     if (enemyManagerScript == null)
     {
         Debug.LogError("No EnemyManagerScript found!");
     }
 }
예제 #6
0
 // Use this for initialization
 void Awake()
 {
     enemyManagerScript = GameObject.Find("EnemyManager").GetComponent <EnemyManagerScript>();
     start        = Time.time;
     secondLevel  = false;
     thirdLevel   = false;
     waveInterval = 6f;
 }
예제 #7
0
 // Start is called before the first frame update
 void Start()
 {
     rb            = GetComponent <Rigidbody2D>();
     animator      = this.GetComponent <Animator>();
     collider      = GetComponent <CircleCollider2D>();
     manager       = GameObject.Find("EnemyManager");
     ManagerScript = manager.GetComponent <EnemyManagerScript>();
     StartCoroutine("Launch");
 }
 // Start is called before the first frame update
 void Start()
 {
     manager          = GameObject.Find("EnemyManager");
     ManagerScript    = manager.GetComponent <EnemyManagerScript>();
     playerObject     = GameObject.Find("Player");
     playerScript     = playerObject.GetComponent <PlayerScript>();
     playerControlled = true;
     transform.parent = playerObject.transform;
     gameObject.tag   = "Ally";
 }
예제 #9
0
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();

        collider      = GetComponent <CircleCollider2D>();
        manager       = GameObject.Find("EnemyManager");
        ManagerScript = manager.GetComponent <EnemyManagerScript>();
        StartCoroutine("Explode");
        spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
    }
    void Awake()
    {
        if (Instance != null)
        {
            return;
        }

        Instance = this;

        activeEnemies = new List <Transform>();
    }
예제 #11
0
 private void Awake()
 {
     if (Instance == null) //if instance contains no data (when game starts) -> dont destroy
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject); //if instance already contains data -> destroy duplicant (dont create again)
     }
 }
예제 #12
0
    void Start()
    {
        transform       = GetComponent <Transform>();
        rigidBody       = GetComponent <Rigidbody2D>();
        audioSrc        = GetComponent <AudioSource>();
        playerTransform = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <Transform>();

        enemyManager = GameObject.FindObjectOfType <EnemyManagerScript>();

        currentCooldown = 0f;
        dead            = false;

        InitHp();
    }
예제 #13
0
    public void Reset()
    {
        ChangeScene();

        netrixiInParty = false;
        folkvarInParty = false;
        ivInParty      = false;

        barkeeperMad = false;
        EnemyManagerScript.barkeeperMadNextRound = false;

        CharacterManagerScript.ResetVariables();
        EnemyManagerScript.ClearMoves();
    }
예제 #14
0
    //Checks for a touch on the enemy and responds by deducting health
    void OnTouch()
    {
        //Raycast
        Ray          ray = Camera.main.ScreenPointToRay(m_touch);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity);

        //If there is a hit
        if (hit)
        {
            //Checkt the gameObject's tag
            if (hit.collider.gameObject.tag == "Enemy")
            {
                //Get access to the gameObject's enemyManager script
                enemyManager = hit.collider.gameObject.GetComponent <EnemyManagerScript>();
                // - health
                currentHealth = enemyManager.GetHealth();
                currentHealth--;
                //Set the new health
                enemyManager.SetHealth(currentHealth);


                //Check if enemy is dead
                if (enemyManager.GetHealth() <= 0)
                {
                    enemyManager.SetIsDead(true);
                }

                //If enemy is dead reset
                if (enemyManager.GetIsDead() == true)
                {
                    //Reset the enemies position
                    hit.collider.gameObject.transform.position = enemyManager.GetSpawnPos();
                    //Reset enemies health
                    enemyManager.ResetHealth();
                    //Set enemy to alive
                    enemyManager.SetIsDead(false);
                }
            }
        }
    }
예제 #15
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        instance = this;


        for (int i = 0; i < enemyINData.Count; i++)
        {
            enemyIn.Add(i);
        }

        for (int i = 0; i < enemyIn.Count; i++)
        {
            enemyDictionary.Add(i, enemyINData[i]);
        }
        //refers to all the scrptable enemy objects.
    }
예제 #16
0
 // Use this for initialization
 void Awake()
 {
     builder      = Object.FindObjectsOfType <Builder>()[0];
     enemyManager = Object.FindObjectsOfType <EnemyManagerScript>()[0];
 }
예제 #17
0
 private void Awake()
 {
     S = this;
 }
예제 #18
0
    public IEnumerator RunSimulation(int playerFirstAttack, int playerSecondAttack, string enemyFirstAttack, string enemySecondAttack, GameObject runner)
    {
        CombatManagerScript.netrixiAttacks = false;
        CombatManagerScript.folkvarAttacks = false;
        CombatManagerScript.ivAttacks      = false;


        // FIRST ATTACK
        yield return(new WaitForSecondsRealtime(moveDelay));

        // Check to see if any Main Characters move for their first attack
        CheckForPlayerMovement(playerFirstAttack, 1);
        // If any Main Characters did move for their first attack
        if (didPlayerMove1)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }

        // Check to see if any Enemy Characters move for their first attack
        CheckForEnemyMovement(enemyFirstAttack, 1);
        // If any Enemy Characters did move for their first attack
        if (didEnemyMove1)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }



        // Check to see what the player's first attack is
        if (!didPlayerMove1)
        {
            AttackScript.PlayerAttack(playerFirstAttack, 1);
            CombatManagerScript.playerAttacking1 = true;

            AttackScript.enemyAttack = !AttackScript.enemyAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack1Delay));
        }

        // Check to see what the enemy's first attack is
        if (!didEnemyMove1)
        {
            AttackScript.EnemyAttack(enemyFirstAttack, 1, enemyAttacker1);
            CombatManagerScript.enemyAttacking1 = true;

            AttackScript.playerAttack = !AttackScript.playerAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack1Delay));
        }



        // SECOND ATTACK

        // Check to see if any Main Characters move for their second attack
        CheckForPlayerMovement(playerSecondAttack, 2);
        // If any Main Characters did move for their second attack
        if (didPlayerMove2)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }

        // Check to see if any Enemy Characters move for their second attack
        CheckForEnemyMovement(enemySecondAttack, 2);
        // If any Enemy Characters did move for their second attack
        if (didEnemyMove2)
        {
            yield return(new WaitForSecondsRealtime(moveDelay));
        }



        // Check to see what the player's second attack is
        if (!didPlayerMove2)
        {
            AttackScript.PlayerAttack(playerSecondAttack, 2);
            CombatManagerScript.playerAttacking2 = true;

            AttackScript.enemyAttack = !AttackScript.enemyAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack2Delay));
        }

        // Check to see what the enemy's second attack is
        if (!didEnemyMove2)
        {
            AttackScript.EnemyAttack(enemySecondAttack, 2, enemyAttacker2);
            CombatManagerScript.enemyAttacking2 = true;

            AttackScript.playerAttack = !AttackScript.playerAttack;

            // Wait for attack animation to play
            yield return(new WaitForSecondsRealtime(attack2Delay));
        }



        // Reset variables once simulation is finished
        CombatManagerScript.firstAttack  = 0;
        CombatManagerScript.secondAttack = 0;

        NetrixiCombatScript.ResetNetrixiVariables();
        FolkvarCombatScript.ResetFolkvarVariables();
        IvCombatScript.ResetIvVariables();

        CombatManagerScript.roundNumber += 1;

        CombatManagerScript.playerAttacking1 = false;
        CombatManagerScript.playerAttacking2 = false;
        CombatManagerScript.enemyAttacking1  = false;
        CombatManagerScript.enemyAttacking2  = false;

        CombatManagerScript.target1Location = 0;
        CombatManagerScript.target2Location = 0;

        CharacterManagerScript.ResetVariables();
        EnemyManagerScript.ClearMoves();

        didPlayerMove1 = false;
        didPlayerMove2 = false;
        didEnemyMove1  = false;
        didEnemyMove2  = false;


        // If only one character is alive
        //if (CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.netrixiAttacks = true;
        //if (!CombatManagerScript.netrixiAlive && CombatManagerScript.folkvarAlive && !CombatManagerScript.ivAlive) CombatManagerScript.folkvarAttacks = true;
        //if (!CombatManagerScript.netrixiAlive && !CombatManagerScript.folkvarAlive && CombatManagerScript.ivAlive) CombatManagerScript.ivAttacks = true;


        Destroy(runner);
    }
예제 #19
0
 // Use this for initialization
 void Start()
 {
     //Access the enemy manager script
     enemyManager = gameObject.GetComponent <EnemyManagerScript>();
 }
예제 #20
0
    void DetermineNextCombat()
    {
        // Determine if the character has joined the party yet
        if (currentScene >= 2)
        {
            netrixiInParty = true;
        }
        if (currentScene >= 7)
        {
            folkvarInParty = true;
        }
        if (currentScene >= 12)
        {
            ivInParty = true;
        }

        switch (currentScene)
        {
        // Fighting a Pirate
        case 2:
            EnemyManagerScript.enemy1 = "Pirate";
            EnemyManagerScript.enemy2 = "null";
            EnemyManagerScript.enemy3 = "null";

            EnemyManagerScript.ChangeEnemyLocation(7, 0, 0);
            HealthManagerScript.StartingHealth(HealthValues.pirateHP, 0, 0);
            break;

        // Fighting Folkvar and his two Royal Knights
        case 4:
            // Change the Royal Knight to Melee or Ranged randomly
            if (randomIndex == 0)
            {
                EnemyManagerScript.enemy1 = "Folkvar";
                EnemyManagerScript.enemy2 = "Royal Knight Melee";
                EnemyManagerScript.enemy3 = "null";

                EnemyManagerScript.ChangeEnemyLocation(7, 8, 0);
                HealthManagerScript.StartingHealth(HealthValues.folkvarHP, HealthValues.knightMeleeHP, 0);
            }
            else if (randomIndex == 1 || randomIndex == 2)
            {
                EnemyManagerScript.enemy1 = "Folkvar";
                EnemyManagerScript.enemy2 = "Royal Knight Ranged";
                EnemyManagerScript.enemy3 = "null";

                EnemyManagerScript.ChangeEnemyLocation(7, 9, 0);
                HealthManagerScript.StartingHealth(HealthValues.folkvarHP, HealthValues.knightRangedHP, 0);
            }
            break;

        // Fighting Kaz and his two Skull Grunts
        case 7:
            EnemyManagerScript.enemy1 = "Skull Grunt Melee";
            EnemyManagerScript.enemy2 = "Skull Grunt Ranged";
            EnemyManagerScript.enemy3 = "Kaz 1";

            EnemyManagerScript.ChangeEnemyLocation(6, 8, 9);
            HealthManagerScript.StartingHealth(HealthValues.skullMeleeHP, HealthValues.skullRangedHP, HealthValues.kazHP);
            break;

        // Fighting the Tavern Brute
        case 10:
            EnemyManagerScript.enemy1 = "Tavern Brute";

            if (barkeeperMad)
            {
                EnemyManagerScript.enemy2 = "Barkeeper";
            }
            else
            {
                EnemyManagerScript.enemy2 = "null";
            }

            EnemyManagerScript.enemy3 = "null";

            EnemyManagerScript.ChangeEnemyLocation(6, 8, 0);
            HealthManagerScript.StartingHealth(HealthValues.bruteHP, HealthValues.barkeeperHP, 0);
            break;

        // Fighting the Gatekeeper
        case 12:
            EnemyManagerScript.enemy1 = "Royal Knight Melee";
            EnemyManagerScript.enemy2 = "Royal Knight Ranged";
            EnemyManagerScript.enemy3 = "Gatekeeper";

            EnemyManagerScript.ChangeEnemyLocation(6, 7, 10);
            HealthManagerScript.StartingHealth(HealthValues.knightMeleeHP, HealthValues.knightRangedHP, HealthValues.gatekeeperHP);
            break;

        // Fighting two Skull Grunts
        case 15:
            EnemyManagerScript.enemy1 = "Skull Grunt Melee";
            EnemyManagerScript.enemy2 = "Skull Grunt Ranged";
            EnemyManagerScript.enemy3 = "null";

            EnemyManagerScript.ChangeEnemyLocation(7, 9, 0);
            HealthManagerScript.StartingHealth(HealthValues.skullMeleeHP, HealthValues.skullRangedHP, 0);
            break;

        // Fighting Kaz and his two Skull Grunts
        case 17:
            EnemyManagerScript.enemy1 = "Skull Grunt Melee";
            EnemyManagerScript.enemy2 = "Skull Grunt Ranged";
            EnemyManagerScript.enemy3 = "Kaz 2";

            EnemyManagerScript.ChangeEnemyLocation(6, 8, 10);
            HealthManagerScript.StartingHealth(HealthValues.skullMeleeHP, HealthValues.skullRangedHP, HealthValues.kazHP);
            break;

        // Fighting two Royal Guards
        case 23:
            EnemyManagerScript.enemy1 = "Royal Guard 1";
            EnemyManagerScript.enemy2 = "Royal Guard 2";
            EnemyManagerScript.enemy3 = "null";

            EnemyManagerScript.ChangeEnemyLocation(7, 8, 0);
            HealthManagerScript.StartingHealth(HealthValues.royalGuardHP, HealthValues.royalGuardHP, 0);
            break;

        // Fighting the Skull King and his two Skull Grunts
        case 25:
            EnemyManagerScript.enemy1 = "Skull Grunt Melee";
            EnemyManagerScript.enemy2 = "Skull Grunt Ranged";
            EnemyManagerScript.enemy3 = "Skull King";

            EnemyManagerScript.ChangeEnemyLocation(7, 9, 10);
            HealthManagerScript.StartingHealth(HealthValues.skullMeleeHP, HealthValues.skullRangedHP, HealthValues.skullKingHP);
            break;

        // Fighting the Royal King and his two Royal Guards
        case 27:
            EnemyManagerScript.enemy1 = "Royal Guard 1";
            EnemyManagerScript.enemy2 = "Royal Guard 2";
            EnemyManagerScript.enemy3 = "Royal King";

            EnemyManagerScript.ChangeEnemyLocation(6, 7, 9);
            HealthManagerScript.StartingHealth(HealthValues.royalGuardHP, HealthValues.royalGuardHP, HealthValues.royalKingHP);
            break;
        }
    }
예제 #21
0
 // Start is called before the first frame update
 void Start()
 {
     manager       = GameObject.Find("EnemyManager");
     ManagerScript = manager.GetComponent <EnemyManagerScript>();
     active        = true;
 }
예제 #22
0
 // Use this for initialization
 void Awake()
 {
     builder = Object.FindObjectsOfType<Builder>()[0];
     enemyManager = Object.FindObjectsOfType<EnemyManagerScript>()[0];
 }