Example #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Renderer Rend;

        Rend = GetComponent <Renderer>();
        if (other.gameObject.tag == "Lava")
        {
            audio.PlayOneShot(LavaDeath);
            Rend.enabled = false;
            gameObject.GetComponent <SpriteTrail>().enabled = (false);
            StartCoroutine(GameOver());
        }
        else if (other.gameObject.tag == "Portal")
        {
            transform.position = PortalExit.position;
        }
        else if (other.gameObject.tag == "Spikes")
        {
            audio.PlayOneShot(SpikeDeath);
            Rend.enabled = false;
            BloodSplatter.SetActive(true);
            gameObject.GetComponent <SpriteTrail>().enabled = (false);
            StartCoroutine(GameOver());
        }
    }
Example #2
0
    void OnEntityDeath(Vector2 direction, string damageTag)
    {
        audioManager.PlayJukeboxAtPoint(clipDeath, transform.position, 0.75f);
        GameObject newBody = (GameObject)Instantiate(bodyPrefab, new Vector3(Mathf.Round(transform.position.x * 8) / 8 + 0.0625f, Mathf.Round(transform.position.y * 8) / 8 + 0.0625f, 0.5f), Quaternion.Euler(0, 0, 90 * Random.Range(0, 4)));

        newBody.GetComponent <SpriteRenderer>().sprite = bodies[Random.Range(0, bodies.Length)];

        gameManager.demons.Remove(entity);
        gameManager.UpdateScore();

        int forwardBloodSplats = Random.Range(15, 20);

        for (int a = 0; a < forwardBloodSplats; a++)
        {
            Quaternion    randomRotation          = Quaternion.Euler(0, 0, Random.Range(-20f, 20f));
            float         randomVelocityMagnitude = Random.Range(0.25f, 2f);
            GameObject    newBloodSplatter        = (GameObject)Instantiate(bloodSplatterPrefab, transform.position, randomRotation);
            BloodSplatter newBloodSplatterClass   = newBloodSplatter.GetComponent <BloodSplatter>();
            newBloodSplatterClass.velocity     = randomRotation * (direction * randomVelocityMagnitude * 75);
            newBloodSplatterClass.bgController = bgController;
            newBloodSplatterClass.waitDistance = Random.Range(0.5f, 2.5f);
            newBloodSplatterClass.fadeDistance = Random.Range(2f, 3f);
        }

        Destroy(gameObject);
    }
Example #3
0
 void Start()
 {
     audio = GetComponent <AudioSource>();
     BloodSplatter.SetActive(false);
     SkullDeath.SetActive(false);
     test = Mathf.Round(5.5f);
 }
 void Start()
 {
     for (int i = 0; i < PoolSize; i++)
     {
         BloodSplatter newProjectile = Instantiate(BloodPrefab, transform);
         newProjectile.gameObject.SetActive(false);
         _allBlood.Add(newProjectile);
     }
 }
    public void SpawnBloodSplatter(Vector3 position, Vector3 direction, float force, float length)
    {
        BloodSplatter blood = _allBlood.First();

        blood.transform.Rotate(Vector3.forward, Vector2.SignedAngle(Vector2.up, direction));
        blood.transform.position = position;
        blood.gameObject.SetActive(true);
        blood.Init(position, direction, force, length);
        _allBlood.Remove(blood);
        _allActiveBlood.Add(blood);
    }
Example #6
0
    public void OnDeath(Vector2 direction, string damageTag)
    {
        audioManager.PlayJukeboxAtPoint(clipDeath, transform.position, 1f);
        GameObject newBody = (GameObject)Instantiate(bodyPrefab, new Vector3(Mathf.Round(transform.position.x * 8) / 8, Mathf.Round(transform.position.y * 8) / 8, 0.5f), Quaternion.identity);

        healthCounter.UpdateLabel(entity.health);

        isDead = true;
        GetComponent <CircleCollider2D>().enabled = false;

        Collider2D[] blocksNearby = Physics2D.OverlapCircleAll(transform.position, 5f, blockLayermask);
        rigidbody.isKinematic = true;
        rigidbody.velocity    = Vector2.zero;
        feet.GetComponent <SpriteRenderer>().enabled = false;
        GetComponent <SpriteRenderer>().enabled      = false;

        foreach (Collider2D block in blocksNearby)
        {
            block.GetComponent <SpriteRenderer>().sprite = destroyedBlock;
            block.enabled = false;
            grid.GetNodeFromWorldPoint(block.transform.position).walkable = true;
            block.GetComponent <SpriteRenderer>().sortingOrder            = -50;
            block.transform.position += new Vector3(0, 0, 0.5f);
        }

        int forwardBloodSplats = Random.Range(90, 100);

        for (int a = 0; a < forwardBloodSplats; a++)
        {
            Quaternion    randomRotation          = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
            float         randomVelocityMagnitude = Random.Range(0.25f, 2f);
            GameObject    newBloodSplatter        = (GameObject)Instantiate(bloodSplatterPrefab, transform.position, randomRotation);
            BloodSplatter newBloodSplatterClass   = newBloodSplatter.GetComponent <BloodSplatter>();
            newBloodSplatterClass.velocity     = randomRotation * (Vector2.right * randomVelocityMagnitude * 75);
            newBloodSplatterClass.bgController = bgController;
            newBloodSplatterClass.waitDistance = Random.Range(0.5f, 2.5f);
            newBloodSplatterClass.fadeDistance = Random.Range(2f, 3f);
        }

        int flakCount = 64;

        for (int b = 0; b < flakCount; b++)
        {
            Quaternion randomRotation          = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
            float      randomVelocityMagnitude = Random.Range(1.75f, 2f);
            GameObject newFlak           = (GameObject)Instantiate(angelFlakPrefab, transform.position, randomRotation);
            Projectile newFlakProjectile = newFlak.GetComponent <Projectile>();
            newFlakProjectile.velocity  = randomRotation * (Vector2.right * randomVelocityMagnitude * 75);
            newFlakProjectile.ricochets = 100;
        }

        StartCoroutine(AfterDeath());
    }
    // POOL FUNCTIONALITY //

    public BloodSplatter GetObjectFromPool()
    {
        if (_bloodSplatters.Count == 0)
        {
            AddBloodSplattersToPool(10);
        }

        BloodSplatter bloodSplatter = _bloodSplatters.Pop();

        bloodSplatter.gameObject.SetActive(true);

        return(bloodSplatter);
    }
Example #8
0
    void Start()
    {
        maze = GameObject.FindWithTag("Main").GetComponent <MazeGenerator>();

        player = GameObject.FindWithTag("Player");

        soundEffectManager = GameObject.FindWithTag("Main").GetComponent <SoundEffectManager>();

        bloodSplatter = GameObject.FindWithTag("Main").GetComponent <BloodSplatter>();

        attackingCountDown = (float)random.NextDouble() * maximumAttackingCountDown;
        attackingRadius    = (float)random.NextDouble() * maximumAttackingRadius;
    }
Example #9
0
    void Start()
    {
        maze = GameObject.FindWithTag("Main").GetComponent <MazeGenerator>();

        player = GameObject.FindWithTag("Player");

        soundEffectManager = GameObject.FindWithTag("Main").GetComponent <SoundEffectManager>();

        bloodSplatter = GameObject.FindWithTag("Main").GetComponent <BloodSplatter>();

        debuffManager = GameObject.FindWithTag("Player").GetComponent <DebuffManager>();

        attackingRadius = minimumAttackingRadius + (float)random.NextDouble() * (maximumAttackingRadius - minimumAttackingRadius);
    }
    void Update()
    {
        for (int i = _allActiveBlood.Count - 1; i >= 0; i--)
        {
            BloodSplatter activeBlood = _allActiveBlood[i];

            if (!activeBlood.gameObject.activeSelf)
            {
                activeBlood.transform.rotation = Quaternion.identity;
                _allBlood.Add(activeBlood);
                _allActiveBlood.Remove(activeBlood);
            }
        }
    }
Example #11
0
        void OnTriggerEnter(Collider other)
        {
            if (!(other.attachedRigidbody.mass > Rb.mass * 5))
            {
                return;
            }

            if (BloodSplatterPrefab != null)
            {
                BloodSplatter newBloodSplatter = Instantiate(BloodSplatterPrefab);
                newBloodSplatter.transform.position = new Vector3(transform.position.x, 0.01f, transform.position.z);
            }

            Target.TrafficLight?.RemoveTraffic(this);
            Destroy(gameObject);
        }
Example #12
0
    void Start()
    {
        maze                 = GameObject.FindWithTag("Main").GetComponent <MazeGenerator>();
        lookAtPoint          = GameObject.FindWithTag("LookAtPoint");
        player               = GameObject.FindWithTag("Player");
        playerMentality      = player.GetComponent <Mentality>();
        playerCharacterMotor = player.GetComponent <CharacterMotor>();
        playerMouseLook      = player.GetComponent <MouseLook2>();

        cameraShaker = GameObject.FindWithTag("Main").GetComponent <CameraShaker>();

        soundEffectManager = GameObject.FindWithTag("Main").GetComponent <SoundEffectManager>();
        soundEffectManager.adjustSound();

        mainAudioSource = GameObject.FindWithTag("Main").GetComponent <AudioSource>();

        bloodSplatter = GameObject.FindWithTag("Main").GetComponent <BloodSplatter>();

        scoreboard = GameObject.FindWithTag("Main").GetComponent <Scoreboard>();

        countDown = GameObject.FindWithTag("Main").GetComponent <CountDown>();

        fadeOutAndFadeIn = Camera.main.GetComponent <FadeOutAndFadeIn>();

        virtualPlayer      = new GameObject();
        virtualPlayer.name = "virtual player";

        childrenRenderers = GetComponentsInChildren <Renderer>();
        sphereCollider    = GetComponent <SphereCollider>();

        npcState       = GetComponent <NPCState>();
        npcState.state = NPCState.MAKING_DECISION;

        isInsane       = false;
        isMoving       = false;
        isCameraMoving = false;

        fakeBossPositionDelta = new Vector2(0, 0);

        if (GameMode.mode == GameMode.ESCAPING)
        {
            player.GetComponent <Compass>().enabled = false;
        }
    }
Example #13
0
    public void OnDamage(Vector2 direction, string damageTag)
    {
        audioManager.PlayJukeboxAtPoint(clipPlayerHit, transform.position, 0.95f);

        healthCounter.UpdateLabel(entity.health);

        int forwardBloodSplats = Random.Range(25, 30);

        for (int a = 0; a < forwardBloodSplats; a++)
        {
            Quaternion    randomRotation          = Quaternion.Euler(0, 0, Random.Range(-20f, 20f));
            float         randomVelocityMagnitude = Random.Range(0.25f, 2f);
            GameObject    newBloodSplatter        = (GameObject)Instantiate(bloodSplatterPrefab, transform.position, randomRotation);
            BloodSplatter newBloodSplatterClass   = newBloodSplatter.GetComponent <BloodSplatter>();
            newBloodSplatterClass.velocity     = randomRotation * (direction * randomVelocityMagnitude * 75);
            newBloodSplatterClass.bgController = bgController;
            newBloodSplatterClass.waitDistance = Random.Range(0.5f, 2.5f);
            newBloodSplatterClass.fadeDistance = Random.Range(2f, 3f);
        }
    }
Example #14
0
    void Explode()
    {
        Collider2D[] blocksNearby = Physics2D.OverlapCircleAll(transform.position, 2.5f, blockLayermask);

        foreach (Collider2D block in blocksNearby)
        {
            block.GetComponent <SpriteRenderer>().sprite = destroyedBlock;
            block.enabled = false;
            pathfinding.grid.GetNodeFromWorldPoint(block.transform.position).walkable = true;
            block.GetComponent <SpriteRenderer>().sortingOrder = -50;
            block.transform.position += new Vector3(0, 0, 0.5f);
        }

        int forwardBloodSplats = Random.Range(55, 65);

        for (int a = 0; a < forwardBloodSplats; a++)
        {
            Quaternion    randomRotation          = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
            float         randomVelocityMagnitude = Random.Range(0.25f, 2f);
            GameObject    newBloodSplatter        = (GameObject)Instantiate(bloodSplatterPrefab, transform.position, randomRotation);
            BloodSplatter newBloodSplatterClass   = newBloodSplatter.GetComponent <BloodSplatter>();
            newBloodSplatterClass.velocity     = randomRotation * (Vector2.right * randomVelocityMagnitude * 75);
            newBloodSplatterClass.bgController = bgController;
            newBloodSplatterClass.waitDistance = Random.Range(0.5f, 2.5f);
            newBloodSplatterClass.fadeDistance = Random.Range(2f, 3f);
        }

        int flakCount = 32;

        for (int b = 0; b < flakCount; b++)
        {
            Quaternion randomRotation          = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
            float      randomVelocityMagnitude = Random.Range(1.75f, 2f);
            GameObject newFlak           = (GameObject)Instantiate(flakPrefab, transform.position, randomRotation);
            Projectile newFlakProjectile = newFlak.GetComponent <Projectile>();
            newFlakProjectile.velocity  = randomRotation * (Vector2.right * randomVelocityMagnitude * 35);
            newFlakProjectile.ricochets = 100;
        }
    }
Example #15
0
    IEnumerator BleedUpdate()
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(0.25f, 0.75f)));

            if (entity.health < 3)
            {
                int forwardBloodSplats = 50;
                for (int a = 0; a < forwardBloodSplats; a++)
                {
                    Quaternion    randomRotation          = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                    float         randomVelocityMagnitude = Random.Range(1.5f, 2f);
                    GameObject    newBloodSplatter        = (GameObject)Instantiate(bloodSplatterPrefab, transform.position, randomRotation);
                    BloodSplatter newBloodSplatterClass   = newBloodSplatter.GetComponent <BloodSplatter>();
                    newBloodSplatterClass.velocity     = randomRotation * (Vector2.right * randomVelocityMagnitude * 2);
                    newBloodSplatterClass.bgController = bgController;
                    newBloodSplatterClass.waitDistance = Random.Range(0.5f, 2.5f);
                    newBloodSplatterClass.fadeDistance = Random.Range(2f, 3f);
                }
            }
        }
    }
Example #16
0
 void Awake()
 {
     bloodsplatter = GameObject.FindWithTag("BloodParticleSystem").GetComponent <BloodSplatter>();
 }
    public void PlaceBloodSplatter(Vector3 position, Color bloodColor)
    {
        BloodSplatter bloodSplatter = GetObjectFromPool();

        bloodSplatter.SetBloodSplatter(position, Random.Range(0, 360), _bloodSplatterSprites[Random.Range(0, _bloodSplatterSprites.Count)], bloodColor);
    }
Example #18
0
 // Use this for initialization
 void Awake()
 {
     this.death  = false;
     this.health = maxHealth;
     blood       = gameObject.GetComponent <BloodSplatter>();
 }