Example #1
0
 void AddDebris(EnemyDebris debris)
 {
     if (!debrisInStorage.Contains(debris))
     {
         debrisInStorage.Add(debris);
     }
 }
Example #2
0
    // Start is called before the first frame update

    /*void Start () {
     *  StartCoroutine (Shooter ());
     * } */

    IEnumerator Shooter()
    {
        while (enabled)
        {
            // wait until not paused
            yield return(new WaitUntil(() => !GameManager.instance.paused));

            // wait for frequency
            yield return(new WaitForSeconds(Random.Range(frequency.x, frequency.y)));

            // Cheating
            shootingEvent.Invoke(this);
            yield return(new WaitForSeconds(0.45f));

            // spawn
            GameObject debris = Instantiate(debrisPrefabs[Random.Range(0, debrisPrefabs.Length)], transform);
            debris.transform.position = transform.position;
            debris.transform.SetParent(null);
            EnemyDebris component = debris.GetComponent <EnemyDebris> ();
            component.force     = Random.Range(force.x, force.y);
            component.damage    = Random.Range(damage.x, damage.y);
            component.direction = direction;
            if (component.allowPooling && !debrisInStorage.Contains(component))
            {
                component.debrisHitEvent.AddListener(AddToStorage);
            }
            ;
        }
    }
Example #3
0
 public void GetHurtByStuff(GameObject target, EnemyDebris hitter)
 {
     if (target == gameObject)
     {
         Hurt(hitter.damage);
     }
 }
Example #4
0
 public void PlayerHit(GameObject hit, EnemyDebris hitter)
 {
     if (hit == gameObject)
     {
         audioSource_self.Play();
         PlayerHit(hitter.damage);
     }
     ;
 }
    private void SetState(EnemyState newState)
    {
        //just in case we need to initialize something before setting the state...
        switch (newState)
        {
        case EnemyState.IDLE:
            break;

        case EnemyState.CHASING:
            AudioSource.PlayClipAtPoint(awakeClip, Camera.main.transform.position);
            break;

        case EnemyState.ATTACKING:
            nav.Stop();
            nextAttackTime = 0.0f;
            break;

        case EnemyState.DEAD:
            nav.Stop();
            //remove from living enemies array
            Utils.RemoveLivingEnemy(this.gameObject);
            spawner.UnManageEnemy(this.gameObject);

            //spawn the debris passing the material
            Material    skeletonMaterial      = this.GetComponentInChildren <SkinnedMeshRenderer>().material;
            GameObject  enemyDebrisGameObject = (GameObject)Instantiate(enemyDebris, this.transform.position, this.transform.rotation);
            EnemyDebris ed = enemyDebrisGameObject.GetComponent <EnemyDebris>();
            ed.Init(skeletonMaterial);

            //spawn the gold ingot
            Instantiate(goldIngot, this.transform.position, this.transform.rotation);

            //add experience to the player
            player.AddExperience(this.experience);

            DestroyImmediate(this.gameObject);
            return;
        }

        this.enemyState = newState;
    }
Example #6
0
 void AddToStorage(GameObject hit, EnemyDebris debris)
 {
     debris.debrisHitEvent.RemoveListener(AddToStorage);
     GameManager.instance.DelayedAction(2f, new System.Action(delegate { debris.ResetDebris(); debrisInStorage.Add(debris); }));
 }