Beispiel #1
0
 private void Awake()
 {
     enemyList.Add(this);
     enemyBase    = gameObject.GetComponent <Enemy_Base>();
     healthSystem = new HealthSystem(100);
     SetStateNormal();
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        GrabStdRefs();

        myE    = GetComponent <Enemy_Base>();
        target = ServiceLocator.instance.Player;

        oldPos = transform.position;
        newPos = target.position +
                 Vector3.forward * Random.Range(7, 40) +
                 Vector3.right * Random.Range(-33, 33) +
                 Vector3.up * Random.Range(5, 33);

        _tOffset = Random.Range(0.00f, 10.00f);

        shield = transform.Find("PeakyShield");

        SCG_EventManager.instance.Register <Event_EnemyDeath>(EnemyDeathHandler);
        SCG_EventManager.instance.Register <Event_DumpReg>(EnemyDeathHandler);

        damageInd = GetComponentInChildren <ParticleSystem>();

        _fsm = new SCG_FSM <Test_PeakyShooty>(this);
        _fsm.TransitionTo <Approach>();
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Add AI
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public static int Add_AI(Enemy_Base pEnemy)
    {
        // Find an Empty Slot in Lookup
        int iNewIndex = -1;

        for (int i = 0; i < sm_lEnemyLookup.Count; ++i)
        {
            if (sm_lEnemyLookup[i] == null)
            {
                iNewIndex = i;
                break;
            }
        }

        // If None Found, Create A New One
        if (iNewIndex == -1)
        {
            iNewIndex = sm_lEnemyLookup.Count;
            sm_lEnemyLookup.Add(iNewIndex, null);
        }

        // Insert Item
        EnemyInfo pEnemyInfo = new EnemyInfo();

        pEnemyInfo.goEnemyObject   = pEnemy.gameObject;
        pEnemyInfo.pEnemyInstance  = pEnemy;
        sm_lEnemyLookup[iNewIndex] = pEnemyInfo;

        // Increment Enemy Count
        sm_iEnemyCount += 1;

        // Return Enemy ID
        return(iNewIndex);
    }
Beispiel #4
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Derived Method: On Collision
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag.Contains("Enemy_"))
        {
            m_iClosestPlatform = GetClosestPlatform(collision.transform.position);

            GameObject goEnemy      = collision.gameObject;
            Enemy_Base pEnemyScript = goEnemy.GetComponent <Enemy_Base>();

            pEnemyScript.PlatformCollisionID = m_iPlatformCollisionBoxID;                               // Assign Collision Box ID
            AssignEnemyDirection(pEnemyScript);                                                         // Assign Direction

            switch (pEnemyScript.EnemyType)
            {
            case Enemy_Base.TypeOfEnemy.LACELING:
            {
                AssignDashTarget(goEnemy.GetComponent <Enemy_Laceling>());
                break;
            }

            case Enemy_Base.TypeOfEnemy.ROMLING:
            {
                AssignBreakableTarget(goEnemy.GetComponent <Enemy_Romling>());
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject bb = Resources.Load("DeadGolem_ParticleEffect") as GameObject;

        if (collision.transform.tag == "Bullet")
        {
            isGolemDead = true;
            speed       = 0f;
            animator.SetBool("Dead", true);

            Enemy_Base.RaiseEvent(score, ammoBonus);

            GameObject bloodPrefabInstance = Instantiate(bloodParticleSystemPrefab, transform.position, Quaternion.identity, transform.parent);
            //GameObject bloodPrefabInstance= Instantiate(bb, transform.position, Quaternion.identity,transform.parent);
            //gameObject.GetComponent<BoxCollider2D>().isTrigger = true;
            gameObject.GetComponent <BoxCollider2D>().enabled = false;
            Destroy(collision.gameObject);
            Destroy(bloodPrefabInstance, 1.5f);
            Destroy(gameObject, 2f);
        }
        if (collision.transform.tag == "Player")
        {
            speed = 0;
            if (player.GetComponent <Player>().isPlayerAlive)
            {
                animator.SetBool("CanAttack", true);
            }
            if (player.GetComponent <Player>().isPlayerAlive)
            {
                InvokeRepeating("callPlayerHitEvent", 0, 1.0f);
                Invoke("method", 2.5f);
            }
        }
    }
Beispiel #6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Blocker")
        {
            GameObject g = assets.Make(MyGameAsset.SFX, transform.position);
            g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_EnemyBulletHit);

            SCG_EventManager.instance.Fire(new Event_BonusPoints(1));
            SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(null, 0, transform.position, this));
        }
        else if (other.tag == "Enemy")
        {
            GameObject g = assets.Make(MyGameAsset.SFX, transform.position);
            g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_EnemyBulletHit);

            Enemy_Base e = other.gameObject.GetComponent <Enemy_Base>();
            if (e != null)
            {
                //Debug.Log("Hit!");
                SCG_EventManager.instance.Fire(new Event_BonusPoints(2));
                if (bounced)
                {
                    SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(e, gameModel.d_Guns_Damage * 3, transform.position, this));
                }
                else
                {
                    SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(e, gameModel.d_Guns_Damage, transform.position, this));
                }
            }
        }
    }
Beispiel #7
0
 public Event_PlayerRocketHit(Enemy_Base enemyHit, float damage, Vector3 where, Behavior_RocketsAlt rocket)
 {
     this.enemyHit  = enemyHit;
     damageTaken    = damage;
     location       = where;
     this.altRocket = rocket;
 }
Beispiel #8
0
 public Event_PlayerBulletHit(Enemy_Base enemyHit, float damage, Vector3 where, Behavior_Bullet bullet)
 {
     this.enemyHit    = enemyHit;
     enemyDamageTaken = damage;
     location         = where;
     this.bullet      = bullet;
 }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.tag == "Bullet")
        {
            if (OnArcherDeathEvent == null)
            {
                Debug.Log("Empty Event");
            }
            else
            {
                OnArcherDeathEvent();
            }

            //GetComponent<AudioSource>().Play();
            Enemy_Base.RaiseEvent(score, ammoBonus);
            float st = Time.time;
            isArcheralive = false;
            //GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f, Mathf.SmoothStep(0.0f, 1.0f, ((Time.time - st) / 5f)));
            GameObject bloodPrefabInstance = Instantiate(bloodParticleSystemPrefab, transform.position, Quaternion.identity, transform.parent);
            animator.SetBool("isDead", true);
            Destroy(collision.gameObject);
            Destroy(bloodPrefabInstance, 1.5f);
            Destroy(floatingBase, 2.0f);
            Destroy(gameObject, 2.0f);
        }
    }
Beispiel #10
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     collectableRef         = null;
     interactableRef        = null;
     enemy_Base             = null;
     isTouchingTrader       = false;
     isTouchingInteractable = false;
 }
Beispiel #11
0
 void Start()
 {
     GrabStdRefs();
     target = ServiceLocator.instance.Player;
     SCG_EventManager.instance.Register <Event_EnemyDeath>(EnemyDeathEventHandler);
     SCG_EventManager.instance.Register <Event_DumpReg>(EnemyDeathEventHandler);
     myE       = GetComponent <Enemy_Base>();
     damageInd = GetComponentInChildren <ParticleSystem>();
 }
Beispiel #12
0
 private void Start()
 {
     data          = GameManager.Instance.savedPlayerData.enemy;
     maxHealth     = data.maxHealth;
     health        = maxHealth;
     nameText.text = data.name;
     GetComponent <SpriteRenderer>().sprite = data.art;
     OnSetup?.Invoke(maxHealth);
 }
    void OnTriggerEnter(Collider other)
    {
        Enemy_Base e = other.gameObject.GetComponent <Enemy_Base>();

        if (e != null)
        {
            //Debug.Log("Rocket trigger entered");
            SCG_EventManager.instance.Fire(new Event_BonusPoints(103));
            SCG_EventManager.instance.Fire(new Event_PlayerRocketHit(e, gameModel.d_Rockets_Damage, transform.position, this));
        }
    }
Beispiel #14
0
    //Used to save data on an enemy encounter
    private void SavePlayerOnEnemy(Enemy_Base enemy, Vector2 enemyPos)
    {
        localPlayerData.enemy    = enemy;
        localPlayerData.health   = health;
        localPlayerData.enemyPos = enemyPos;

        GameManager.Instance.savedPlayerData = localPlayerData;
        GameManager.overworldPaused          = true;

        SceneManager.LoadScene("BattleScene", LoadSceneMode.Additive);
    }
Beispiel #15
0
    private void OnTriggerExit(Collider other)
    {
        if (!playModel.unaccessedStations.Contains(Stations.Lance) && (playModel.currentPlayerState == PlayerState.Alive || playModel.currentPlayerState == PlayerState.Respawning))
        {
            if (other.gameObject.tag == "Enemy")
            {
                Enemy_Base e = other.GetComponent <Enemy_Base>();

                SCG_EventManager.instance.Fire(new Event_LanceHit(e, other.transform.position, false));
            }
        }
    }
Beispiel #16
0
    private void Awake()
    {
        stats = GetComponent <Enemy_Base>();
        movementController = GetComponent <Enemy_Stipp_Movement>();
        animatorController = GetComponent <Enemy_Stipp_Animation>();

        //Visual
        animator = GetComponent <Animator>();

        //Base (Stores stats)
        enemyBase = GetComponent <Enemy_Base>();
        RefreshStats();
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag != "Enemy")
        {
            return;
        }

        Enemy_Base e = other.GetComponent <Enemy_Base>();

        if (e != null)
        {
            SCG_EventManager.instance.Fire(new Event_ExplosionBallHit(e, other.transform.position, false));
        }
    }
Beispiel #18
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Derived Method: On Impact
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private IEnumerator OnImpact(Enemy_Base enemy, Vector3 impactPosition)
    {
        // Show Half of the Animation first
        SpriteColour = Color.white;
        yield return(new WaitForSeconds(IMPACT_ANIMATION_TIME * 0.3f));

        // Now that we're halfway done, Hurt thy enemy
        enemy.IsFrozen = false;
        Enemy_Base.DeathType eDeath = ((Random.Range(0, 2) == 0) ? Enemy_Base.DeathType.BURNT : (Random.Range(0, 2) == 0 ? Enemy_Base.DeathType.CRUSHED : Enemy_Base.DeathType.ELECTROCUTED));
        enemy.ReduceHealth(m_iImpactDamage, eDeath, impactPosition);
        yield return(new WaitForSeconds(IMPACT_ANIMATION_TIME * 0.7f));

        m_ImpactTargetCollider = null;
        this.gameObject.SetActive(false);
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag != "Enemy")
        {
            return;
        }

        //Debug.Log("enemy in radius");

        Enemy_Base e = other.GetComponent <Enemy_Base>();

        if (e != null)
        {
            SCG_EventManager.instance.Fire(new Event_BonusPoints(12));
            SCG_EventManager.instance.Fire(new Event_ExplosionBallHit(e, other.transform.position, true));
        }
    }
Beispiel #20
0
    private void HandleAttack()
    {
        Vector2      dir;
        RaycastHit2D hit;

        //var dir = lastMoveDir;
        dir = new Vector2(player.player_Animation.animator.GetFloat("LastMoveX"), player.player_Animation.animator.GetFloat("LastMoveY"));
        hit = Physics2D.Raycast(transform.position, transform.TransformDirection(dir), attackRange, attackLayerMask);

        if (hit.collider != null && canAttack)
        {
            Debug.Log("Attacked");
            Enemy_Base enemy = hit.collider.GetComponent <Enemy_Base>();
            enemy.TakeDamage(1, "Player");
            canAttack = false;
            Invoke("ResetAttack", attackDelay);
        }
        //Debug.Log("Hitting: " + hit.collider?.name);
        Debug.DrawRay(transform.position, dir, Color.red, attackRange);
    }
Beispiel #21
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Derived Method: On Collision
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (!Impacted && collider.tag.Contains("Enemy"))
        {
            Enemy_Base enemy = collider.gameObject.GetComponent <Enemy_Base>();
            if (enemy.Hurtable && ImpactPossible(collider))
            {
                m_ImpactTargetCollider = collider;

                enemy.IsFrozen = true;                          // Also freeze it from moving
                Vector3 impactPosition = Position;
                Position.Set(enemy.Position);                   // Lock fireball impact animation to the current position of the enemy
                CollisionDetector = false;                      // Turn off the Collision Detector


                Impacted       = true;
                m_eAttackPhase = AttackPhase.IMPACT;
                StartCoroutine(OnImpact(enemy, impactPosition));
            }
        }
    }
Beispiel #22
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Assign Enemy Direction
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void AssignEnemyDirection(Enemy_Base a_EnemyInstance)
    {
        switch (m_PlatformGuides[m_iClosestPlatform].m_eDirectionType)
        {
        case PlatformInformation.MovementDirection.FACING:
        {
            a_EnemyInstance.SetFacingDirection(a_EnemyInstance.MovementDirectionFacing);
            break;
        }

        case PlatformInformation.MovementDirection.LEFT:
        {
            a_EnemyInstance.SetFacingDirection(Enemy_Base.MovementDirection.LEFT);
            break;
        }

        case PlatformInformation.MovementDirection.RIGHT:
        {
            a_EnemyInstance.SetFacingDirection(Enemy_Base.MovementDirection.RIGHT);
            break;
        }

        case PlatformInformation.MovementDirection.TOWARDS_PLAYER:
        {
            a_EnemyInstance.SetFacingDirection(Enemy_Base.MovementDirection.TOWARDS_PLAYER);
            break;
        }

        case PlatformInformation.MovementDirection.RANDOM:
        {
            a_EnemyInstance.SetFacingDirection(((Random.Range(0, 2) == 0) ? Enemy_Base.MovementDirection.LEFT : Enemy_Base.MovementDirection.RIGHT));
            break;
        }

        default:
        {
            break;
        }
        }
    }
Beispiel #23
0
    void Start()
    {
        GrabStdRefs();

        target = ServiceLocator.instance.Player;
        offset = Random.insideUnitSphere * 10;

        turnSpeedMin = turnSpeed * .8f;
        turnSpeedMax = turnSpeed * 1.2f;

        moveSpeedMin = moveSpeed * .8f;
        moveSpeedMax = moveSpeed * 1.2f;

        newUp = Vector3.Normalize(Random.insideUnitSphere);
        fired = true;

        transform.position = transform.position + Random.insideUnitSphere * 20;
        transform.rotation = Quaternion.LookRotation(Random.insideUnitSphere);

        myE = GetComponent <Enemy_Base>();
        SCG_EventManager.instance.Register <Event_EnemyDeath>(EventHandler);
        SCG_EventManager.instance.Register <Event_DumpReg>(EventHandler);
    }
Beispiel #24
0
    //Class is turned off when no TriggerCollision
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Collectable")
        {
            collectableRef = other.GetComponent <Collectable>();
            collectableRef.Collect(player);
        }
        if (other.tag == "Interactable")
        {
            interactableRef        = other.GetComponent <Interactable>();
            isTouchingInteractable = true;
        }

        else if (other.tag == "Enemy")
        {
            enemy_Base = other.GetComponent <Enemy_Base>();
            player.player_Actions.KnockedBack(enemy_Base.GetKnockbackAmount(), other.gameObject);
            player.TakeDamage(enemy_Base.GetCollsionDamage());
        }
        else if (other.tag == "NPC_Trader")
        {
            isTouchingTrader = true;
        }
    }
Beispiel #25
0
 public Event_ExplosionBallHit(Enemy_Base enemyHit, Vector3 where, bool tEFE)
 {
     this.enemyHit      = enemyHit;
     location           = where;
     trueEnterFalseExit = tEFE;
 }
Beispiel #26
0
 private void Start()
 {
     enemy_Base             = null;
     isTouchingTrader       = false;
     isTouchingInteractable = false;
 }
 public void RemoveBaseEnemies(Enemy_Base _enemy)
 {
     baseEnemies.Remove(_enemy);
 }
Beispiel #28
0
 void Start()
 {
     myE = GetComponent <Enemy_Base>();
     pS  = GetComponentInChildren <ParticleSystem>();
 }
 private void Awake()
 {
     enemy = GetComponentInParent <Enemy_Base>();
 }
 // Store all Base type Enemies
 public void AddBaseEnemies(Enemy_Base _enemy)
 {
     baseEnemies.Add(_enemy);
 }