Ejemplo n.º 1
0
    public IEnumerator SetEnemiesTurn()
    {
        GetAllEnemies();
        for (int i = 0; i < numberEnemies; i++)
        {
            // Starts all enemies turn
            EnemyBaseClass enemyBaseScript = allEnemiesInScene[i].GetComponent <EnemyBaseClass>();
            cameraControllerSCR.SnapToPosition(enemyBaseScript.GetPos());

            //camera shows enemy actions
            yield return(new WaitForSeconds(enemyWaitTime));

            enemyBaseScript.StartEnemiesTurn();
            yield return(new WaitForSeconds(0.01f));

            cameraControllerSCR.SnapToPosition(enemyBaseScript.GetPos());

            yield return(new WaitForSeconds(enemyWaitTime));
        }

        cameraControllerSCR.SnapToPosition(GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>().GetPos());

        yield return(new WaitForSeconds(enemyWaitTime));

        //Back to players turn
        PlayerScript.actionsPerTurn = PlayerScript.maxActionsPerTurn;
        gridManagerSCR.SetCurrentGameState(GridSystemManager.EGameState.EPlayerMove);
        gridManagerSCR.ChangeTurn(true);
        gridManagerSCR.IncrPower(1);
        gridManagerSCR.SetGroundMaterial();
    }
    public void PlayerFinalAttackCalculation(EnemyBaseClass enemy)
    {
        float finalAttackProbability = _weaponSuccessShotProbability - _enemyDodgeChance;
        float diceRoll = Random.Range(0.0f, 1.0f);
        bool  success  = (diceRoll <= finalAttackProbability);

        if (success)
        {
            int finalDamage = _weaponCalculatedBaseDamage + _playerDamageModifier - _enemyArmorNormal - _enemyArmorBlindage;
            _finalDamage = finalDamage;
            float finalCriticalProbability = _weaponCriticalChance + _playerCriticalChanceModifier;
            _finalCriticalProbability = finalCriticalProbability;
            float diceRoll02 = Random.Range(0.0f, 1.0f);
            bool  success02  = (diceRoll02 <= finalCriticalProbability);

            if (success02)
            {
                finalDamage  = (finalDamage * ((int)(_weaponCriticalDamage + _playerCriticalDamageModifier)));
                _finalDamage = finalDamage;
                Debug.Log("Critical Shot Success!!!");
            }
        }
        else
        {
            Debug.Log("Shot MISSED!!!");
            _finalDamage = 0;
        }

        Debug.Log("Calculated Critical Chance = " + _finalCriticalProbability);
        Debug.Log("FINAL DAMAGE ON ENEMY = " + _finalDamage);

        enemy.ApplyDamage(_finalDamage);

        ResetCalculaterVariables();
    }
    public void ActivateMouseToAttack()
    {
        //if(Input.GetMouseButtonDown(0))
        //{
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            EnemyBaseClass enemyPlaceHolder = hit.collider.GetComponent <EnemyBaseClass>();
            if (enemyPlaceHolder)
            {
                foreach (var enemy in _listOfScannedEnemies)
                {
                    if (enemy == enemyPlaceHolder)
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            Attack(enemy);
                        }
                        else
                        {
                            ShowProbability(enemy);
                        }
                    }
                }
            }
        }
        //}
    }
    private void Update()
    {
        // Update the timers for the enemy spawning template
        foreach (SpawningTemplate spawn in listOfEnemies)
        {
            // have we spawned all enemies?
            if (!spawn.SpawnedAllEnemies())
            {
                // is it time to spawn
                if (spawn.UpdateTimer())
                {
                    // Fetch enemy
                    GameObject newEnemy = ObjectPooler.Instance.FetchGO(spawn.enemyToSpawn.name);
                    // Attach SpawnZone and Reset the Enemy before anything
                    //newEnemy.GetComponent<EnemyBaseClass>().ResetEnemy(spawn.spawningZone, spawn.GetRandomPositionFromZone());

                    EnemyBaseClass baseClass = newEnemy.GetComponent <EnemyBaseClass>();
                    if (baseClass == null)
                    {
                        baseClass = newEnemy.GetComponentInChildren <EnemyBaseClass>();
                    }

                    baseClass.ResetEnemy(spawn.spawningZone, spawn.GetRandomPositionFromZone());
                }
            }
        }
    }
    public void ScanForEnemies()
    {
        if (_listOfScannedEnemies.Count > 0)
        {
            foreach (var enemy in _listOfScannedEnemies)
            {
                enemy.canBeAttacked = false;
            }
        }
        _listOfScannedEnemies.Clear();

        foreach (var item in GridManager.instance.listOfSelectableTiles)
        {
            RaycastHit hit;
            if (Physics.Raycast(item.transform.position, Vector3.up, out hit, 1))
            {
                EnemyBaseClass enemyPlaceHolder = hit.collider.GetComponent <EnemyBaseClass>();
                if (enemyPlaceHolder)
                {
                    _listOfScannedEnemies.Add(enemyPlaceHolder);
                    enemyPlaceHolder.canBeAttacked = true;
                }
            }
        }
    }
Ejemplo n.º 6
0
    public virtual void EnemyStopMotion(GameObject bully)
    {
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        bullyBaseClass_.m_RigidBody.velocity = new Vector3(0, 0, 0); //freeze position
        bullyBaseClass_.m_EnemyInMotion      = false;                //set bool that prevents movement in the update
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log(other.gameObject.name);
        if (other.gameObject.layer == LayerMask.NameToLayer("ProjWithGround") && other.gameObject.tag == "Enemy")
        {
            // Hit by enemy
            EnemyBaseClass  enemy   = other.gameObject.GetComponentInParent <EnemyBaseClass>();
            EnemyAttackType enemyat = enemy.GetCurrentAttackType();
            switch (enemyat)
            {
            case EnemyAttackType.DRAGONSTALET: TakeDamage(enemy.damage); break;

            case EnemyAttackType.BLOODYSHINGLER_NORMAL: TakeDamage(enemy.damage); break;

            case EnemyAttackType.BLOODYSHINGLER_DASH: TakeDamage(enemy.GetComponent <PT2Script>().dartDamage); break;

            case EnemyAttackType.APES_NORMAL: TakeDamage(enemy.damage); break;

            case EnemyAttackType.APES_DASH: TakeDamage(enemy.GetComponent <AWScript>().Dash); break;

            case EnemyAttackType.APES_ATTACK: TakeDamage(enemy.GetComponent <AWScript>().Attack); break;

            case EnemyAttackType.APES_ROCK: TakeDamage(enemy.GetComponent <AWScript>().Rock); break;

            case EnemyAttackType.APES_SHAKE: TakeDamage(enemy.GetComponent <AWScript>().Shake); break;
            }
        }
    }
Ejemplo n.º 8
0
    void SpawnEnemy()
    {
        if (currentEnemyBag.Count == 0)
        {
            ShuffleAndReplenishBag(enemyPrefabBag, currentEnemyBag);
        }

        EnemyBaseClass newEnemy = currentEnemyBag[0];

        currentEnemyBag.RemoveAt(0);

        //If there is already an inactive enemy of the same type, active it and jump out
        for (int i = 0; i < inactiveEnemies.Count; i++)
        {
            if (inactiveEnemies [i].GetType() == newEnemy.GetType())
            {
                newEnemy = inactiveEnemies [i];
                activeEnemies.Add(newEnemy);
                inactiveEnemies.RemoveAt(i);
                newEnemy.Reset();
                return;
            }
        }

        //If we make it through the for loop, that means we need to make a new enemy of that type
        GameObject newEnemyObj = (GameObject)Instantiate(newEnemy.gameObject);

        //This is a bit weird, but we want to change what this is pointing to from the prefab to the new instance
        newEnemy = newEnemyObj.GetComponent <EnemyBaseClass>();

        allEnemies.Add(newEnemy);
        activeEnemies.Add(newEnemy);
//		newEnemy.Reset (); //probably don't want this, should just use Awake
    }
Ejemplo n.º 9
0
    public virtual void EnemyAttack(GameObject bully)
    {
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        int attackSelector = Random.Range(0, 100);

        bullyBaseClass_.EnemyStopMotion(bully);

        //	m_EnemyInMotion = false; //prevent continued motion of the bully
        if (attackSelector <= m_AttackPunchOdds)      //If attack selector is less than the odds of punching
        {
            bullyBaseClass_.EnemyAttackPunch(bully);  //PAWNCH
        }
        else if (attackSelector <= m_AttackKickOdds)  //not less than Punch odds, so check if less than kick odds
        {
            bullyBaseClass_.EnemyAttackKick(bully);   //Kick
        }
        else if (attackSelector >= m_AttackKickOdds)  //must be greater than kick odds by now so Unique Attack is called
        {
            bullyBaseClass_.EnemyAttackUnique(bully); //
        }

        else if (attackSelector >= m_AttackKickOdds)  //must be greater than kick odds by now so Unique Attack is called
        {
            bullyBaseClass_.EnemyAttackUnique(bully); //
        }
    }
Ejemplo n.º 10
0
    private void OnCollisionEnter2D(Collision2D hit)
    {
        if (gameObject.tag == "PlayerWeapon" && hit.gameObject.CompareTag("Player"))
        {
            return;
        }

        GetComponent <Collider2D>().isTrigger = true;
        transform.parent = hit.gameObject.transform;
        rb.velocity      = Vector2.zero;

        if (hit.gameObject.CompareTag("Player") || hit.gameObject.CompareTag("Enemy"))
        {
            Rigidbody2D rb = hit.transform.GetComponent <Rigidbody2D>();
            hit.transform.GetComponent <HealthManager>().TakeDamage(attackDamage);

            if (hit.gameObject.CompareTag("Enemy"))
            {
                EnemyBaseClass ebc = rb.GetComponent <EnemyBaseClass>();
                ebc.ChangeState(EnemyState.stagger);
                ebc.ChangeState(EnemyState.idle, knockbackTime);
            }
            Vector2 direction = hit.transform.position - transform.position;
            rb.AddForce(direction.normalized * knockbackStrength, ForceMode2D.Impulse);
        }
    }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     gameManager    = GameObject.Find("gameManager");
     player         = GameObject.Find("gameManager").GetComponent <GameStateHandler>().player;
     enemyBaseClass = GetComponent <EnemyBaseClass>();
     baseSpeed      = 0.8f;
     actualSpeed    = baseSpeed;
 }
    public override void onApply(EnemyBaseClass newEnemy)
    {
        base.onApply(newEnemy);

        // Set Position
        transform.position = enemyClass.GetFeetPosition();
        // Buff the enemy
        enemyClass.ModifyDefense(2);
    }
 public void ShowProbability(EnemyBaseClass enemy)
 {
     transform.LookAt(enemy.transform);
     weaponInstanceBelt[_currentWeaponIndex].GetComponent <WeaponBaseClass>().GatherWeaponAttackStats((CharacterStats)this, enemy);
     CombatCalculatorManager.instance.GatherEnemyDefenseStats(enemy);
     CombatCalculatorManager.instance.GatherPlayerAttackStats((CharacterStats)this);
     CombatCalculatorManager.instance.DisplayShotChance();//(weaponInstanceBelt[_currentWeaponIndex].GetComponent<WeaponBaseClass>());
     enemy.ShowProbability();
 }
    public override void onApply(EnemyBaseClass newEnemy)
    {
        base.onApply(newEnemy);

        // Set Position
        transform.position = enemyClass.GetFeetPosition();
        // Reset Damage Timer
        ResetDamageTimer();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Track which enemy we need to deal the damage
        if (collision.gameObject.tag == "Enemy")
        {
            StayEnemies.Add(collision.gameObject, Time.time);
            return;
        }

        if (collision.gameObject.name == "AttackCollider")
        {
            ElectricHand eh = collision.gameObject.GetComponent <ElectricHand>();
            if (eh.getElectricHand())
            {
                // touched by electric.
                Debug.Log("Electric touch");
                // do the exposion here
                for (int index = 0; index < StayEnemies.Count; index++)
                {
                    var        item           = StayEnemies.ElementAt(index);
                    GameObject go             = item.Key;
                    float      nextDamageTime = item.Value;

                    EnemyBaseClass enemy = go.GetComponent <EnemyBaseClass>();
                    // if the enemy already dead remove from the list
                    if (enemy.GetCurrentHP() <= 0)
                    {
                        StayEnemies.Remove(go);
                    }

                    int damage = GetActualDamage();
                    enemy.ModifyHealth(-damage);
                }


                gameObject.SetActive(false);

                isElectric = true;
                eh.setElectricHand(false);
            }
        }

        if (Time.time > expiredExpandTime)
        {
            return;
        }
        if (collision.gameObject.GetComponent <IceMissile>() != null)
        {
            receivedIce = true;
        }
        else if (collision.gameObject.GetComponent <FlameProjectile>() != null)
        {
            receivedFire = true;
        }
    }
    public void GatherWeaponAttackStats(CharacterStats character, EnemyBaseClass enemy)//(CharacterCombat character, EnemyBaseClass enemy)
    {
        transform.LookAt(enemy.transform);
        Ray ray = new Ray(weaponFirePoint.transform.position, transform.forward * 100);           //enemy.transform.position);//Input.mousePosition);

        Debug.DrawRay(weaponFirePoint.transform.position, transform.forward * 100, Color.red, 2); //enemy.transform.position, Color.red, 1);//Input.mousePosition, Color.red, 1);

        RaycastHit[] hits;
        hits = Physics.RaycastAll(ray, Vector3.Distance(this.transform.position, enemy.transform.position));//Mathf.Infinity);//enemy.transform.position.magnitude);



        ////Reset Odds
        //successShotProbability = 1;
        //damagePenalty = 1.0f;

        foreach (var hit in hits)
        {
            TileModifier cover = hit.collider.GetComponent <TileModifier>();
            if (cover && cover.isCover)
            {
                if (cover.isHalfCover)
                {
                    //Debug.Log("Hit HALF Cover");
                    successShotProbability -= cover.halfCoverPenalty;
                    isHalfCover             = true;
                }
                else if (cover.isFullCover) //&& !isCoverComputed)
                {
                    //Debug.Log("Hit FULL Cover");
                    successShotProbability -= cover.fullCoverPenalty;
                    isFullCover             = true;
                }
            }
            EnemyBaseClass enemyclass = hit.collider.GetComponent <EnemyBaseClass>();
            if (enemyclass)
            {
                //Debug.Log("Hit Enemy!!!");
                distanceFromTarget = Vector3.Distance(character.transform.position, enemy.transform.position);
                //Debug.Log("Distance From The Target: " + distanceFromTarget);
                if (optimalRange + 1 >= distanceFromTarget && optimalRange - 1 <= distanceFromTarget)//
                {
                    damagePenalty          -= 0f;
                    successShotProbability -= 0f;
                }
                else
                {
                    damagePenalty          -= 0.2f;
                    successShotProbability -= .1f;
                }
                CalculateBaseDamage();
            }
        }
    }
Ejemplo n.º 17
0
    public virtual void EnemyUpdate(GameObject bully)
    {
        bullyRigidbody_ = bully.GetComponent <Rigidbody>();
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        //Debug.Log(bully.name);
        if (bully.name != "FattestBully" && bully.name != "KingBully" && bully.name != "RefereeBully" && bully.name != "QueenBully")
        {
            Vector3 enemyPos = new Vector3(bullyRigidbody_.position.x, bullyRigidbody_.position.y, bullyRigidbody_.position.z);
            bully.GetComponent <BullyScript>().m_UniqueAttackHolder.GetComponent <UniqueAttackScript>().UpdateUATKs(bully);           //Update Enemy Projectiles on screen

            m_PlayerPos = new Vector3(m_Player.GetComponent <Rigidbody>().position.x, m_Player.GetComponent <Rigidbody>().position.y, m_Player.GetComponent <Rigidbody>().position.z);


            GetPlayerInfo(bully);

            {
                // bullyBaseClass_.ChasePlayer(m_PlayerPos, enemyPos, bully);
                if (bullyBaseClass_.m_NavAgent != null)
                {
                    bullyBaseClass_.m_NavAgent.SetDestination(m_Player.transform.position);
                }

                //Animation
                if (bullyBaseClass_.m_AnimationLength > 0) //if animating, subtract Delta.Time
                {
                    bullyBaseClass_.m_AnimationLength -= Time.deltaTime;
                }
                if (bullyBaseClass_.m_AttackTimer > 0 && bullyBaseClass_.m_AnimationLength <= 0) //if the enemy isn't cooled down, and is not animating
                {
                    bullyBaseClass_.m_AttackTimer -= Time.deltaTime;
                }
                if (bullyBaseClass_.m_AttackTimer <= 0 && bullyBaseClass_.m_BullyAnimator.GetBool("IsPunch") == false && bullyBaseClass_.m_BullyAnimator.GetBool("IsKick") == false && bullyBaseClass_.m_BullyAnimator.GetBool("IsUnique") == false) //If the enemy is cooled down, and is not animating
                {
                    bullyBaseClass_.m_AttackTimer = 0;
                    EnemyAttack(bully);
                }

                if (bullyBaseClass_.m_AnimationLength <= 0)
                {
                    bullyBaseClass_.m_AnimationLength = 0;
                    bullyBaseClass_.m_BullyAnimator.SetBool("IsPunch", false);
                    bullyBaseClass_.m_BullyAnimator.SetBool("IsKick", false);
                    bullyBaseClass_.m_BullyAnimator.SetBool("IsUnique", false);
                    bullyBaseClass_.m_EnemyInMotion = true;
                }
            }
        }
        else
        {
        }
    }
Ejemplo n.º 18
0
    public virtual void TurnAround(GameObject bully)
    {
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        bullyBaseClass_.m_VelocityX      *= -1; //turn the enemy around
        bullyBaseClass_.m_EnemyGoingLeft *= -1; //tell the enemy it has turned around

        //Brandon's code to fip the animation,,, flips the x
        Vector3 theScale = transform.localScale;

        theScale.x          *= -1;
        transform.localScale = theScale;
    }
Ejemplo n.º 19
0
 // Function to add or reapply a Status Effect
 // Key should be the name of the prefab
 public bool AddEffect(string key, BaseStatusEffect newEffect, EnemyBaseClass newOwner)
 {
     // If status effect is already in, then reset and return
     if (activeStatus.ContainsKey(key))
     {
         activeStatus[key].onReApply();
         newEffect.gameObject.SetActive(false);
         return(false);
     }
     // Not in dictionary, so add
     activeStatus.Add(key, newEffect);
     // call onApply as we just added it
     newEffect.onApply(newOwner);
     return(true);
 }
Ejemplo n.º 20
0
    public virtual void InitEnemy(Vector3 spawnPos, Vector3 zOffSet_, GameObject newBully)
    {
        bullyBaseClass_ = newBully.GetComponent <EnemyBaseClass>();

        // bullyBaseClass_.changeTrackCountdown = m_ChangeTrackTimer;

        bullyBaseClass_.m_Player    = GameObject.FindGameObjectWithTag("Player");
        bullyBaseClass_.m_PlayerPos = new Vector2(m_Player.GetComponent <Rigidbody>().position.x, m_Player.GetComponent <Rigidbody>().position.y);

        bullyBaseClass_.m_InitialXY     = spawnPos;
        bullyBaseClass_.m_isIdle        = true;
        bullyBaseClass_.m_BullyAnimator = newBully.GetComponent <Animator>();

        //
    }
    public void Attack(EnemyBaseClass enemy)
    {
        //Debug.Log("The Enemy " + enemy.name + " is Being Attacked By " + this.gameObject.name + " Using " + _weaponClass);
        transform.LookAt(enemy.transform);
        weaponInstanceBelt[_currentWeaponIndex].GetComponent <WeaponBaseClass>().GatherWeaponAttackStats((CharacterStats)this, enemy);
        CombatCalculatorManager.instance.GatherEnemyDefenseStats(enemy);
        CombatCalculatorManager.instance.GatherPlayerAttackStats((CharacterStats)this);
        CombatCalculatorManager.instance.PlayerFinalAttackCalculation(enemy);



        this.GetComponent <CharacterStats>().actionPoints--;
        if (this.GetComponent <CharacterStats>().actionPoints <= 0)
        {
            TurnManager.instance.PlayerCharacterActionDepleted((CharacterStats)this);
        }
    }
Ejemplo n.º 22
0
    public void PlayerMeeleAttackCalled(LayerMask hitLayers, Transform attackPoint, int attackDamage, float attackRange, float knockbackStrength, float knockbackTime)
    {
        Collider2D[] hitRegistered = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, hitLayers);

        foreach (Collider2D hit in hitRegistered)
        {
            //print("hit " + enemy.name);
            hit.GetComponent <HealthManager>().TakeDamage(attackDamage);
            Rigidbody2D rb = hit.GetComponent <Rigidbody2D>();

            if (rb != null)
            {
                EnemyBaseClass ebc = rb.GetComponent <EnemyBaseClass>();
                ebc.ChangeState(EnemyState.stagger);
                Vector2 direction = hit.transform.position - transform.position;
                rb.AddForce(direction.normalized * knockbackStrength, ForceMode2D.Impulse);
                ebc.ChangeState(EnemyState.idle, knockbackTime);
            }
        }
    }
    public override void onApply(EnemyBaseClass newEnemy)
    {
        base.onApply(newEnemy);
        // Reactivate Collider for ownself
        GetComponent <Collider2D>().enabled = true;
        // Disable the Enemy's collider and rigidbody
        enemyClass.gameObject.GetComponent <Collider2D>().enabled      = false;
        enemyClass.gameObject.GetComponent <Rigidbody2D>().isKinematic = true;
        enemyClass.SetAnimatorSpeed(0.0f);
        // parent the enemy
        //enemyClass.gameObject.transform.parent = transform;

        // Class Specific
        if (newEnemy.gameObject.GetComponent <SquirrelWolf>())
        {
            newEnemy.gameObject.GetComponent <SquirrelWolf>().SetFrozen(true);
        }
        // Reset Status Effects Data
        isMoving = false;
    }
Ejemplo n.º 24
0
    public void Damage(float givenDamage)
    {
        //mainEnemy = GameObject.FindGameObjectWithTag("EnemyMain");
        mainEnemy = transform.root.gameObject;

        if(mainEnemy.tag == "TutorialEnemy"){
            GameObject tutorialSpwaner = GameObject.FindGameObjectWithTag("TutorialSpawner");
            TutorialEnemy tutorialSpawnClass = tutorialSpwaner.GetComponent<TutorialEnemy>();
            tutorialSpawnClass.respawn = true;
            Destroy(tutorialSpawnClass.currentEnemy);

        }
        else{

            enemyMainHealth = mainEnemy.GetComponent<EnemyBaseClass>();
            calculatedDamage = givenDamage * damageModifier;
            int roundedDamage = Mathf.CeilToInt(calculatedDamage);
            enemyMainHealth.Health(roundedDamage);
        }
    }
Ejemplo n.º 25
0
    public virtual void EnemyIdle(GameObject bully, Vector3 enemyPos)
    {
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        //float differenceThenNow = bullyBaseClass_.m_InitialXY.x - enemyPos.x;
        float pointB = m_MaxDist;
        float pointA = bullyBaseClass_.m_InitialXY.x + 1;

        //moving right and has passed pointA
        if (enemyPos.x >= pointA && bullyBaseClass_.m_EnemyGoingLeft == -1)
        {
            enemyPos.x = pointA;
            bullyBaseClass_.TurnAround(bully);
        }
        //moving left and has passed point B
        if (enemyPos.x <= pointB && bullyBaseClass_.m_EnemyGoingLeft == 1)
        {
            bullyBaseClass_.TurnAround(bully);
        }
        DetectPlayer(m_Player.transform.position, bully);
    }
Ejemplo n.º 26
0
    /*
     *  public virtual void ChasePlayer(Vector3 playerPos, Vector3 enemyPos, GameObject bully)
     *  {
     *  bullyBaseClass_ = bully.GetComponent<EnemyBaseClass>();
     *
     *          for (int i = 0; i < Physics2D.AllLayers; ++i )
     *          {
     *                  string LayerName = LayerMask.LayerToName(i);
     *                  if(LayerName == "ActiveBully")
     *                  {
     *                          bully.layer = i;
     *                  }
     *          }
     *          float curEnemyXPOS = enemyPos.x;
     *          float lineOfSight;
     *  if (bullyBaseClass_.m_IsABoss)
     *          {
     *                  lineOfSight = bully.GetComponent<BossBaseClass>().m_AttackDist;
     *          }
     *          else
     *          {
     *                  lineOfSight = bully.GetComponent<BullyScript>().m_AttackDist;
     *          }
     *
     *
     *          if (playerPos.x > curEnemyXPOS)//if the player is on the right
     *          {
     *                  //if the player is less to the right than the currentposition of the enemy's line of sight
     *                  if (playerPos.x < enemyPos.x + lineOfSight)
     *                  {
     *                          EnemyStopMotion(bully);
     *                  }
     *                  else
     *                  {
     *                          EnemyMove(bully);
     *                  }
     *          }
     *          else //the player is on the left
     *          {
     *                  //if the player is less to the left than the enemy's pos - it's line of sight
     *                  if (playerPos.x > enemyPos.x - lineOfSight)
     *                  {
     *                          //EnemyStopMotion(bully);
     *                  }
     *                  else
     *                  {
     *                          EnemyMove(bully);
     *                  }
     *          }
     *
     *          //If the enemy is to the left of the player and if the enemy is moving to the right
     *  if (enemyPos.x < playerPos.x && bullyBaseClass_.m_VelocityX < 0)
     *          {
     *      bullyBaseClass_.TurnAround(bully); //correct movement direction
     *          }
     *          //If the enemy is to the right, and moving left
     *  if (enemyPos.x > playerPos.x && bullyBaseClass_.m_VelocityX > 0)
     *          {
     *      bullyBaseClass_.TurnAround(bully); //correct movement direction
     *          }
     *  }*/

    public virtual void DetectPlayer(Vector3 playerPos, GameObject bully)
    {
        bullyBaseClass_ = bully.GetComponent <EnemyBaseClass>();

        Vector3 differenceInDistance = new Vector3(bully.transform.position.x, bully.transform.position.y, bully.transform.position.z) - playerPos; //get the difference between the two entities
        float   forwardDetectionX    = bully.transform.position.x - bullyBaseClass_.m_DetectionDist;                                                //x position player has to reach or pass for the enemy to wake up

        //e - p = differenceInDistance
        //difference in distance == a line between the two p_____e
        //if this "line" is shorter than the bully's forwardDetection aka "Line Of Sight" (while the player is to the left) -|____e____|+
        //or if the "line" is shorter than (player is inside the line) the bully's ForwardDetectionX (while the player is to the right)
        if (differenceInDistance.x <= forwardDetectionX || differenceInDistance.x <= -forwardDetectionX)
        {
            bullyBaseClass_.m_isIdle = false;//then the enemy is no longer Idle
        }

        if (differenceInDistance.x <= forwardDetectionX) //if the player is within the detection "range" of a bully
        {
            bullyBaseClass_.m_isIdle = false;            //then the enemy is no longer Idle
        }
    }
Ejemplo n.º 27
0
    private void BasicAttack(GameObject attackObject)
    {
        FMODUnity.RuntimeManager.PlayOneShotAttached(attackHitEvent, this.gameObject);
        RaycastHit hit;

        if (Physics.Raycast(transform.position, Vector3.right, out hit, 8.0f, attackLayerMask))
        {
            EnemyBaseClass enemyScript = hit.transform.GetComponent <EnemyBaseClass>();
            Debug.Log(hit.transform.gameObject);
            enemyScript.TakeDamage(GetComponent <BoyClass>().attackDamage);
        }
        //GameObject attackObject = RayCaster(raycastPos.transform.position, Vector2.right, 8f);
        Debug.Log(attackObject);
        if (attackObject != null)
        {
            if (attackObject.tag == "Monster")
            {
                EnemyBaseClass _enemyScript = attackObject.GetComponent <EnemyBaseClass>();
                int            _damage      = GetComponent <BoyClass>().attackDamage;
                _enemyScript.TakeDamage(_damage);
            }
        }
    }
Ejemplo n.º 28
0
    public void showInstrucitons()
    {
        if (stageOfTutorial == 2)
        {
            StartCoroutine(showTextToForDuration(tutorialMessage[1]));
        }

        if (stageOfTutorial == 4)
        {
            StartCoroutine(showTextToForDuration(tutorialMessage[2]));
        }

        if (stageOfTutorial == 5)
        {
            checkpoints[3].SetActive(false);
            StartCoroutine(showTextToForDuration(tutorialMessage[3]));
            // Spawning enemy

            Vector3 startPos     = new Vector3(SIZEOFBOX_X, -SIZEOFBOX_Y, 0.0f);
            Vector3 endPos       = new Vector3(-SIZEOFBOX_X, SIZEOFBOX_Y, 0.0f);
            int     tip          = 1;
            float   colliderSize = 0.08f;
            Sprite  imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy1");

            if (tutorialEnemy == null)
            {
                tutorialEnemy = (GameObject)Instantiate(enemyPrefab, startPos, Quaternion.identity);
            }
            //else {
            //    tutorialEnemy.transform.position = startPos;
            //}

            GameObject trail1 = tutorialEnemy.transform.FindChild("Trail1").gameObject;
            trail1.SetActive(false);
            tutorialEnemy.transform.position = startPos;
            trail1.SetActive(true);

            tutorialEnemy.GetComponent <SpriteRenderer>().sprite   = imageOfEnemy;
            tutorialEnemy.GetComponent <CircleCollider2D>().radius = colliderSize;
            tutorialEnemy.name = "EnemyTutorial";

            rotateEnemy(tutorialEnemy.transform, endPos);

            tutorialEnemyData = new EnemyBaseClass((byte)tip, startPos, endPos);
        }

        if (stageOfTutorial == 6)
        {
            StartCoroutine(showTextToForDuration(tutorialMessage[4]));

            Vector3 startPos     = new Vector3(SIZEOFBOX_X / 2, -SIZEOFBOX_Y, 0.0f);
            Vector3 endPos       = new Vector3(-SIZEOFBOX_X / 2, SIZEOFBOX_Y, 0.0f);
            int     tip          = 2;
            float   colliderSize = 0.13f;
            Sprite  imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy2");

            GameObject trail1 = tutorialEnemy.transform.FindChild("Trail1").gameObject;
            trail1.SetActive(false);
            tutorialEnemy.transform.position = startPos;
            trail1.SetActive(true);

            tutorialEnemy.GetComponent <SpriteRenderer>().sprite   = imageOfEnemy;
            tutorialEnemy.GetComponent <CircleCollider2D>().radius = colliderSize;
            tutorialEnemy.name = "EnemyTutorial";

            //rotateEnemy(tutorialEnemy.transform, endPos);
            tutorialEnemy.transform.rotation = new Quaternion();

            tutorialEnemyData = new EnemyCurveClass((byte)tip, startPos, endPos, Time.time, center, SIZEOFBOX_X, SIZEOFBOX_Y);
        }

        if (stageOfTutorial == 7)
        {
            StartCoroutine(showTextToForDuration(tutorialMessage[5]));

            Vector3 startPos     = new Vector3(SIZEOFBOX_X / 2, -SIZEOFBOX_Y, 0.0f);
            Vector3 endPos       = new Vector3(-SIZEOFBOX_X / 2, SIZEOFBOX_Y, 0.0f);
            int     tip          = 3;
            float   colliderSize = 0.14f;
            Sprite  imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy3");


            GameObject trail1 = tutorialEnemy.transform.FindChild("Trail1").gameObject;
            trail1.SetActive(false);
            tutorialEnemy.transform.position = startPos;
            trail1.SetActive(true);

            tutorialEnemy.GetComponent <SpriteRenderer>().sprite   = imageOfEnemy;
            tutorialEnemy.GetComponent <CircleCollider2D>().radius = colliderSize;
            tutorialEnemy.name = "EnemyTutorial";

            //rotateEnemy(tutorialEnemy.transform, GameObject.Find("Player").transform.position);
            tutorialEnemy.transform.rotation = new Quaternion();

            tutorialEnemyData = new EnemyShootClass((byte)tip, startPos, endPos, Time.time, center, SIZEOFBOX_X, SIZEOFBOX_Y, Random.Range(3f, 6f), Random.Range(0f, 5f));
            ((EnemyShootClass)tutorialEnemyData).setShooter(tutorialEnemy.transform);
        }

        if (stageOfTutorial == 8)
        {
            StartCoroutine(showTextToForDuration(tutorialMessage[6]));
        }
    }
 public void GatherEnemyDefenseStats(EnemyBaseClass enemyRef)
 {
     _enemyArmorNormal   = enemyRef.armorNormal;   //
     _enemyArmorBlindage = enemyRef.armorBlindage; //
     _enemyDodgeChance   = enemyRef.dodgeChance;   //
 }
 public virtual void onApply(EnemyBaseClass newEnemy)
 {
     enemyClass  = newEnemy;
     effectTimer = effectDuration;
 }
Ejemplo n.º 31
0
    private void createEnemy(int index, int tip)
    {
        // Seeting of object
        float scaleOfEnemy = 2f;
        int   whichSite    = Random.Range(1, 5);

        Vector3 startPos;
        Vector3 endPos;

        switch (whichSite)
        {
        case 1:
            startPos = new Vector3(SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            endPos   = new Vector3(-SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            break;

        case 2:
            startPos = new Vector3(Random.Range(-SIZEOFBOX_X, SIZEOFBOX_X), SIZEOFBOX_Y, 0.0f);
            endPos   = new Vector3(Random.Range(-SIZEOFBOX_X, SIZEOFBOX_X), -SIZEOFBOX_Y, 0.0f);
            break;

        case 3:
            startPos = new Vector3(Random.Range(-SIZEOFBOX_X, SIZEOFBOX_X), -SIZEOFBOX_Y, 0.0f);
            endPos   = new Vector3(Random.Range(-SIZEOFBOX_X, SIZEOFBOX_X), SIZEOFBOX_Y, 0.0f);
            break;

        case 4:
            startPos = new Vector3(-SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            endPos   = new Vector3(SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            break;

        default:
            startPos = new Vector3(SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            endPos   = new Vector3(-SIZEOFBOX_X, Random.Range(-SIZEOFBOX_Y, SIZEOFBOX_Y), 0.0f);
            break;
        }

        //Vector3 orientationOfEnemy = Vector3.RotateTowards(startPos, endPos, 0.0f, 0.0f);

        // Spawning on scene
        float          colliderSize = 1f;
        GameObject     result;
        EnemyBaseClass temp         = new EnemyBaseClass((byte)tip, startPos, endPos);
        Sprite         imageOfEnemy = new Sprite();

        if (tip == 1 || tip == 4)
        {
            temp         = new EnemyBaseClass((byte)tip, startPos, endPos);
            imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy1");
            colliderSize = 0.08f;
        }
        else if (tip == 2)
        {
            temp         = new EnemyCurveClass((byte)tip, startPos, endPos, Time.time, playerPos, SIZEOFBOX_X, SIZEOFBOX_Y); // TODO: Get user position
            imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy2");
            colliderSize = 0.13f;
        }
        else if (tip == 3)
        {
            temp         = new EnemyShootClass((byte)tip, startPos, endPos, Time.time, playerPos, SIZEOFBOX_X, SIZEOFBOX_Y, Random.Range(3f, 6f), Random.Range(0f, 5f)); // TODO: Get user position
            imageOfEnemy = (Sprite)Resources.Load <Sprite>("enemy3");
            colliderSize = 0.14f;
        }

        if (allEnemies[index] == null)
        {
            result = (GameObject)Instantiate(enemyPrefab, startPos, Quaternion.identity);
            //result.transform.rotation = Quaternion.Euler(0, 0, 90);
            rotateEnemy(result.transform, endPos);
            //result.transform.LookAt(playerPos);
            enemiesData[index] = temp;
        }
        else
        {
            result = allEnemies[index];
            GameObject trail1 = result.transform.FindChild("Trail1").gameObject;
            trail1.SetActive(false);
            result.transform.position = startPos;
            trail1.SetActive(true);
            rotateEnemy(result.transform, endPos);
            //result.transform.rotation = Quaternion.identity;
            //result.transform.rotation = Quaternion.Euler(0, 0, 90);
            //result.transform.LookAt(playerPos);
            enemiesData[index] = temp;
        }
        // Image of enemy
        result.GetComponent <SpriteRenderer>().sprite   = imageOfEnemy;
        result.GetComponent <CircleCollider2D>().radius = colliderSize;
        result.transform.localScale = new Vector3(scaleOfEnemy, scaleOfEnemy, 1);  // Setting scale of star
        result.name = "Enemy" + index.ToString();

        if (tip == 3)
        {
            ((EnemyShootClass)temp).setShooter(result.transform);
        }

        allEnemies[index] = result;
    }