Пример #1
0
 //// Public API
 public void SetEnemyAttributes(Vector3 spawnPoint, EnemyAttributes attributes)
 {
     _isActive = true;
     this.transform.position = spawnPoint;
     InsertAIAgent();
     UnpackEnemyAttributes(attributes);
 }
 public override void Start()
 {
     enemyStats = GetComponent <EnemyAttributes> ();
     master     = GetComponent <EnemyAIMaster> ();
     setProjectile(projectile);
     started = true;
 }
Пример #3
0
    //// Private methods
    void UnpackEnemyAttributes(EnemyAttributes attributes)
    {
        _totalLife = _currentLife = attributes.life;
        _lifeBar.SetUp(_totalLife);

        _aiAgent.speed = attributes.speed;
    }
 // Use this for initialization
 void Start()
 {
     enemy = GetComponent<EnemyAttributes>();
     player = GameObject.FindGameObjectWithTag("Player").transform;
     state = State.Patrol;
     patrol = GetComponent<Patrol>();
 }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     EA         = transform.parent.GetComponent <EnemyAttributes>();
     EB         = transform.parent.GetComponent <EnemyBehaviour>();
     NextAttack = 0;
     Attacking  = false;
 }
Пример #6
0
        /// <summary>
        /// Initializes references to ReferenceManager and other managers, list of renderers and
        /// their materials for HitFlash(), and spawns the spawn particle emitter.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            player            = reference.shipLookTarget;
            enemyAttributes   = reference.enemyAttributes;
            waveManager       = reference.waveManager;
            scoringSystem     = reference.scoringSystem;
            objectPoolManager = reference.objectPoolManager;

            renderers = new List <Renderer>();
            materials = new List <Material>();

            foreach (Renderer r in gameObject.GetComponentsInChildren <Renderer>())
            {
                if (r.gameObject.CompareTag("Emitter") ||
                    r.transform.parent.CompareTag("Emitter"))
                {
                    continue;
                }

                renderers.Add(r);
                materials.Add(r.material);
            }
        }
Пример #7
0
    void Start()
    {
        thisWaveEnemyData = Instantiate(enemyData);

        thisWaveEnemyAttributes = ThisWaveEnemyData.EnemyAttributes;

        gameplayUiController = GameInstance.Instance.gameplayUiController;
    }
Пример #8
0
    public GameObject SpawnEnemyAt(Vector3 position, EnemyAttributes attributes)
    {
        GameObject enemy = _pool.GetInstance();

        enemy.GetComponent <EnemyBehaviour>().SetEnemyAttributes(position, attributes);
        enemy.GetComponent <Renderer>().material.color = attributes.color;
        return(enemy);
    }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     EnemyStats = GetComponent <EnemyAttributes> ();
     //EnemyMove = GetComponent<EnemyMovement> ();
     EnemyRigid = GetComponent <Rigidbody2D> ();
     master     = GetComponent <EnemyAIMaster> ();
     //projSpawner = GetComponent<EnemyProjectileSpawner> ();
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     //Initialise variables
     EA     = GetComponent <EnemyAttributes>();
     Player = GameObject.FindGameObjectWithTag("Player");
     GC     = GameObject.FindGameObjectWithTag("GameController");
     target = Player;
 }
Пример #11
0
    void Awake()
    {
        PlayerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        PlayerHealth    = PlayerTransform.GetComponent <PlayerAttributes>();
        EnemyMeshAgent  = GetComponent <UnityEngine.AI.NavMeshAgent>();
        EnemyAttributes = GetComponent <EnemyAttributes>();

        PlayerDictionary = new Dictionary <GameObject, float>();
    }
Пример #12
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        EnemyAttributes enemy = hitInfo.GetComponent <EnemyAttributes>();

        if (enemy != null)
        {
            Destroy(gameObject);
            FindObjectOfType <GameManager>().EndGame();
        }
    }
Пример #13
0
    private void Awake()
    {
        EnemyAttributes = GetComponent <EnemyAttributes>();
        EnemyAttributes.SetManager(this);

        EnemyAudioManager = GetComponentInChildren <EnemyAudioManager>();
        EnemyAudioManager.SetManager(this);

        EnemyMovement = GetComponent <EnemyMovement>();
        EnemyMovement.SetManager(this);
    }
Пример #14
0
 public void dealDamage(EnemyAttributes enemy)
 {
     if (!attackCooldown)
     {
         GetComponent <Animator>().SetTrigger("punch");
         StartCoroutine(activateAttackCooldown());
         //Debug.Log("punch");
         int damageToDeal = melee;
         enemy.takeDamage(melee);
     }
 }
Пример #15
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        EnemyAttributes enemy = hitInfo.GetComponent <EnemyAttributes>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Destroy(gameObject);
            GameObject bulletEffect = Instantiate(bulletExplosion, transform.position, transform.rotation);
            Destroy(bulletEffect, 1);
        }
    }
Пример #16
0
    public GameObject npc; //for testing

    void Awake()
    {
        // Get gamemanager
        gameManager     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
        inventory       = GetComponent <Inventory>();
        skills          = GetComponent <Skills>();
        perkAttributes  = GetComponent <PerkAttributes>();
        toolbelt        = GetComponent <Toolbelt>();
        enemyAttributes = GetComponent <EnemyAttributes>();
        thirst          = 100;
        hunger          = 100;
    }
Пример #17
0
    void Spawn(int enemyNumber, Vector3 spawn, SpawnTypes mode, EnemyAttributes attributes)
    {
        switch (mode)
        {
        case SpawnTypes.DelayedIndianLine:
            _gameManager.StartCoroutine(SpawnDelayedSingleEnemy(spawn, 1, enemyNumber, attributes));
            break;

        case SpawnTypes.LineGroup:
            SpawnEnemyLineGroup(spawn, enemyNumber, attributes);
            break;
        }
    }
Пример #18
0
    void SpawnEnemyLineGroup(Vector3 initialPosition, int newEnemies, EnemyAttributes attributes)
    {
        if (newEnemies > 0)
        {
            int poolAvailableElements = _enemySystem.GetAvailableElements();

            if (newEnemies > poolAvailableElements)
            {
                _enemySystem.EnlargePoolSize(newEnemies - poolAvailableElements);
            }

            PositionEnemyLine(initialPosition, newEnemies, attributes);
        }
    }
Пример #19
0
    void PositionEnemyLine(Vector3 initialPosition, int enemyNumber, EnemyAttributes attributes)
    {
        int enemiesSpawned = 0;

        Vector3 spawnPoint;

        Vector3 destiny = _gameManager.Core.transform.position;
        Vector3 diff    = initialPosition - destiny;

        while (enemiesSpawned < enemyNumber)
        {
            float modifier = (enemiesSpawned % 2 == 0 ? -1 : 1) * enemiesSpawned;

            if (diff.x == 0)
            {
                float modHorizontal = diff.z > 0 ? 1 : (diff.z == 0 ? 0 : -1);
                spawnPoint = new Vector3(initialPosition.x + modifier * modHorizontal, 0, initialPosition.z);
            }
            else
            {
                if (diff.z == 0)
                {
                    float modVertical = diff.x > 0 ? 1 : (diff.x == 0 ? 0 : -1);
                    spawnPoint = new Vector3(initialPosition.x, 0, initialPosition.z + modifier * modVertical);
                }
                else
                {
                    if (Mathf.Sign(diff.z) == Mathf.Sign(diff.x))
                    {
                        spawnPoint = new Vector3((initialPosition.x + modifier), 0, (initialPosition.z + -modifier));
                    }
                    else
                    {
                        spawnPoint = new Vector3((initialPosition.x + modifier), 0, (initialPosition.z + modifier));
                    }
                }
            }
            try{
                _enemySystem.SpawnEnemyAt(spawnPoint, attributes);
                enemiesSpawned++;
            }catch (System.Exception) {
                CheckAvailablePoolSize(enemyNumber - enemiesSpawned);
            }
        }
    }
Пример #20
0
    // PLAYER
    public IEnumerator attackEnemy(EnemyAttributes enemy, bool player)
    {
        EnemyAttributes playerEnemy       = gameManager.getPlayerBehavior().transform.GetComponent <EnemyAttributes>();
        Vector3         hitGroundPosition = gameManager.getPlayerBehavior().getHitGround();

        //Debug.Log("start attacking");
        if (!playerEnemy.getIsAttackingEnemy() && enemy != this)
        {
            playerEnemy.setIsAttackigEnemy(true);
            playerEnemy.lookAtTargetEnemy(enemy);

            while (playerEnemy.getIsAttackingEnemy())
            {
                if (hitGroundPosition != gameManager.getPlayerBehavior().getHitGround())
                {
                    //Debug.Log("not attacking anymore because player clicked elsewhere");
                    enemy.setMobIndicator(false);
                    enemy.setHealthbar(false);
                    enemy.setAllIndicatorsFallsAndActivate("red");
                    break;
                }
                if (enemy == null)
                {
                    break;
                }
                else
                {
                    enemy.setHealthbar(true);
                    enemy.setMobIndicator(true);
                    enemy.setAllIndicatorsFallsAndActivate("yellow");
                    //Debug.Log("attacking enemy running");
                }

                if (!playerEnemy.getAttackCooldown())
                {
                    playerEnemy.dealDamage(enemy);
                }
                yield return(null);
            }
            //Debug.Log("end attacking");
            playerEnemy.setIsAttackigEnemy(false);
        }
    }
Пример #21
0
    void SpawnEnemy(EnemyAttributes e, Vector3 l)
    {
        e.bonus.BonusSetter();
        BasicEnemy basicEnemy = _spawner.basicEnemyPool.GetObject();

        basicEnemy.UnitDefiner(e.myType);
        basicEnemy.SetPowerAmount(e.power).SetHealth(e.health).SetCooldown(e.maxCooldown).SetSpawner(_spawner).SetSetinelAmount(e.sentinelAmount).BonusSetter(e.bonus.bonus).SetPointAmount(e.pointAmount).SetLocation(l);
        basicEnemy.movementOptions.Clear();
        basicEnemy.behaviour = e.behaviour.Clone();
        basicEnemy.behaviour.TargetSetter(basicEnemy._model.transform.position);

        if (e.sentinelAmount > 0)
        {
            basicEnemy.SentinelSpawn();
        }

        if (e.behaviour.changeMovementWrappers.Length > 0)
        {
            basicEnemy.StartCoroutine(basicEnemy.ChangeMovement(e.movementTimeToChange, e.behaviour.changeMovementWrappers));
        }
    }
Пример #22
0
    // THIS ONE IS FOR PLAYER
    public IEnumerator walkToEnemy(EnemyAttributes enemy)
    {
        bool            walkingToEnemy    = true;
        EnemyAttributes player            = this;
        Vector3         hitGroundPosition = gameManager.getPlayerBehavior().getHitGround();


        while (walkingToEnemy)
        {
            enemy.setMobIndicator(true);
            enemy.setAllIndicatorsFallsAndActivate("yellow");
            //Debug.Log("player WALKINMG to enemy");

            if (hitGroundPosition != gameManager.getPlayerBehavior().getHitGround())
            {
                //Debug.Log("new walking position");
                enemy.setMobIndicator(false);
                enemy.setAllIndicatorsFallsAndActivate("red");
                break;
            }

            if (Vector3.Distance(gameManager.getPlayerBehavior().getPlayerPosition(), enemy.getPosition()) < player.getAttackRange())
            {
                //Debug.Log("clsoe enough");
                stopMovement();
                player.setCurrentTarget(enemy);
                StartCoroutine(attackEnemy(enemy, true));

                break;
            }
            else
            {
                player.getNavMeshAgent().SetDestination(enemy.getPosition());
            }
            yield return(null);
        }
    }
Пример #23
0
    public IEnumerator attackEnemy(EnemyAttributes enemy)
    {
        if (!attackingEnemy)
        {
            attackingEnemy = true;
            lookAtTargetEnemy(enemy);

            while (attackingEnemy)
            {
                //Debug.Log("attacking enemy running");

                if (Vector3.Distance(this.transform.position, enemy.getPosition()) > attackRange)
                {
                    //Debug.Log("Lost target, or distance to high to attack");
                    //enemy.setHealthbar(false);
                    break;
                }

                if (enemy == null)
                {
                    stopMovement();
                    //Debug.Log("Current target is null");
                    setHealthbar(false);
                    break;
                }
                else
                {
                    //enemy.setHealthbar(true);
                }

                this.dealDamage(enemy);
                yield return(null);
            }
            attackingEnemy = false;
        }
    }
Пример #24
0
    public IEnumerator walkToClosestEnemy()
    {
        if (!walkingToClosestEnemy)
        {
            walkingToClosestEnemy = true;
            EnemyAttributes enemy = getClosestEnemyInRange();

            while (walkingToClosestEnemy)
            {
                enemy = getClosestEnemyInRange();

                if (enemy == null || !enemiesInRange.Contains(enemy))
                {
                    //Debug.Log("No enemy found");
                    stopMovement();
                    break;
                }

                if (Vector3.Distance(this.getPosition(), enemy.getPosition()) < attackRange)
                {
                    //Debug.Log("clsoe enough");
                    setCurrentTarget(enemy);
                    StartCoroutine(attackEnemy(enemy));
                    break;
                }
                else
                {
                    agent.SetDestination(enemy.getPosition());
                }

                yield return(null);
            }
            stopMovement();
            walkingToClosestEnemy = false;
        }
    }
Пример #25
0
 public void setCurrentTarget(EnemyAttributes enemy)
 {
     currentTarget = enemy;
 }
Пример #26
0
 /// <summary>
 /// Loads skill attributes from datamined data.
 /// </summary>
 // Id has been manually deduced from the datamined data. It's used to connect the attack to datamined information.
 public void LoadAttributes(int id, EnemyAttributes attributes)
 {
     if (attributes == null || attributes.Weapons == null)
     return;
       if (attributes.Weapons.Main != null && attributes.Weapons.Main.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Main.Skills)
     {
       if (skill.id == id)
       {
     LoadFromSkillPalette(skill);
     Weapon = "main";
       }
     }
       }
       if (attributes.Weapons.Offhand != null && attributes.Weapons.Offhand.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Offhand.Skills)
     {
       if (skill.id == id)
       {
     LoadFromSkillPalette(skill);
     Weapon = "off";
       }
     }
       }
       if (attributes.Weapons.Underwater != null && attributes.Weapons.Underwater.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Underwater.Skills)
     {
       if (skill.id == id)
       {
     LoadFromSkillPalette(skill);
     Weapon = "water";
       }
     }
       }
 }
Пример #27
0
 public void lookAtTargetEnemy(EnemyAttributes enemy)
 {
     transform.LookAt(new Vector3(enemy.transform.position.x, 0, enemy.transform.position.z));
 }
Пример #28
0
 /***********************************************************************************************
 * LoadAttributes / 2015-10-02 / Wethospu                                                       *
 *                                                                                              *
 * Loads skill attributes from datamined data.                                                  *
 *                                                                                              *
 * id: Id of the skill.                                                                         *
 * attributes: Attributes for the base enemy.                                                   *
 *                                                                                              *
 ***********************************************************************************************/
 public void LoadAttributes(int id, EnemyAttributes attributes)
 {
     if (attributes == null || attributes.Weapons == null)
     return;
       if (attributes.Weapons.Main != null && attributes.Weapons.Main.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Main.Skills)
     {
       if (skill.id == id)
       {
     _minimumRange = skill.MinimumRange;
     _maximumRange = skill.MaxRange;
     _requiredLevel = skill.LevelRequirement;
     _internalCooldown = skill.Cooldown;
     _weapon = "main";
     if (skill.Tags != null)
       _coefficient = skill.Tags.Coefficient;
       }
     }
       }
       if (attributes.Weapons.Offhand != null && attributes.Weapons.Offhand.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Offhand.Skills)
     {
       if (skill.id == id)
       {
     _minimumRange = skill.MinimumRange;
     _maximumRange = skill.MaxRange;
     _requiredLevel = skill.LevelRequirement;
     _internalCooldown = skill.Cooldown;
     _weapon = "off";
     if (skill.Tags != null)
       _coefficient = skill.Tags.Coefficient;
       }
     }
       }
       if (attributes.Weapons.Underwater != null && attributes.Weapons.Underwater.Skills != null)
       {
     foreach (var skill in attributes.Weapons.Underwater.Skills)
     {
       if (skill.id == id)
       {
     _minimumRange = skill.MinimumRange;
     _maximumRange = skill.MaxRange;
     _requiredLevel = skill.LevelRequirement;
     _internalCooldown = skill.Cooldown;
     _weapon = "water";
     if (skill.Tags != null)
       _coefficient = skill.Tags.Coefficient;
       }
     }
       }
 }
Пример #29
0
 // Start is called before the first frame update
 void Start()
 {
     player           = GameObject.FindGameObjectWithTag("Player");
     attributes       = this.gameObject.GetComponent <EnemyAttributes>();
     playerAttributes = player.GetComponent <PlayerAttributes>();
 }
Пример #30
0
 public void addEnemyToEnemyInRange(EnemyAttributes enemy)
 {
     enemiesInRange.Add(enemy);
 }
Пример #31
0
 public void updateHealthbar(EnemyAttributes enemy)
 {
     enemy.transform.Find("Healthbar").GetComponent <Healthbar>().updateHealthBar();
 }
Пример #32
0
 public void removeEnemyFromEnemyInRange(EnemyAttributes enemy)
 {
     enemiesInRange.Remove(enemy);
 }
Пример #33
0
    // Use this for initialization
    void Start()
    {
        EnemyStats = GetComponent <EnemyAttributes> ();
        anim       = GetComponent <Animator> ();
        //projSpawner.setProjectile (weaponList[currWeap]);

        spawnList = new EnemyProjectileSpawner[spawnSeq.Length];
        EnemyProjectileSpawner[] allSpawners = GetComponents <EnemyProjectileSpawner> ();
        for (int i = 0; i < allSpawners.Length; i++)
        {
            allSpawners [i].enabled = false;
        }

        for (int i = 0; i < spawnList.Length; i++)
        {
            for (int x = 0; x < allSpawners.Length; x++)
            {
                if (spawnSeq[i].Equals(allSpawners[x].label))
                {
                    spawnList [i] = allSpawners [x];
                    //spawnList [i].enabled = true;
                    //Debug.Log (allSpawners [x].label);
                    break;
                }
            }
        }
        spawnList [0].enabled = true;

        moveList = new EnemyMovement[moveSeq.Length];
        EnemyMovement[] allMoves = GetComponents <EnemyMovement> ();
        for (int i = 0; i < allMoves.Length; i++)
        {
            allMoves [i].master = this;
        }

        for (int i = 0; i < allMoves.Length; i++)
        {
            allMoves [i].enabled = false;
        }

        for (int i = 0; i < moveList.Length; i++)
        {
            for (int x = 0; x < allMoves.Length; x++)
            {
                if (moveSeq[i].Equals(allMoves[x].label))
                {
                    moveList [i] = allMoves [x];
                    //moveList [i].enabled = true;
                    //Debug.Log (allMoves [x].label);
                    break;
                }
            }
        }
        if (GetComponent <SpriteRenderer> ().flipX)
        {
            GetComponent <SpriteRenderer> ().flipX = false;
            moveList [0].xdir = -1;
        }
        moveList [0].switchTo();
        moveList [0].enabled = true;
        for (int x = 0; x < allMoves.Length; x++)
        {
            if (aggromove.Equals(allMoves[x].label))
            {
                aMove = allMoves [x];
                //moveList [i].enabled = true;
                //Debug.Log (allMoves [x].label);
                break;
            }
        }
    }
Пример #34
0
    void Start()
    {
        enemy = GetComponent<EnemyAttributes>();
        fsm = GetComponent<FiniteStateMachine>();

        StartCoroutine(SetWayPoints());
        //print (tile.transform.position);
    }