Ejemplo n.º 1
0
    public void EndLevel()
    {
        // TODO: Chequeos de final de nivel
        PlayerIntegrity playerIntegrity = FindObjectOfType <PlayerIntegrity>();

        //
        if (victory == true)
        {
            // Chequeos de tiempo y vida restante
            float durationPerformance = DetermineDifficultyFactor(gameDuration, levelInfo.expectedDuration, 1.2f);
            float healthPerformance   = DetermineDifficultyFactor(playerIntegrity.CurrentHealth, gameManager.playerAttributes.maxHealth, 1);
            float attempsPerformance  = DetermineDifficultyFactor(gameManager.DefeatStreak, 3, 2);
            gameManager.difficultyFactor += durationPerformance + healthPerformance + attempsPerformance;
            // De momento esto
            gameManager.ReceiveExperience(enemiesDestroyed);
        }
        else
        {
            gameManager.DefeatStreak++;
            //if(gameManager.DefeatStreak > 5)
            //{
            //    float attempsPerformance = DetermineDifficultyFactor(gameManager.DefeatStreak, 3, 2);
            //    gameManager.difficultyFactor += attempsPerformance;
            //}
        }
        //
        finished            = true;
        robotControl.InPlay = false;

        //
        fade.direction = 1;
        fade.speed     = 0.5f;
    }
Ejemplo n.º 2
0
    //
    void SpawnBulletHole(Vector3 point, Vector3 normal, GameObject objectToParent)
    {
        //
        PlayerIntegrity playerIntegrity = objectToParent.GetComponent <PlayerIntegrity>();

        // Error control vago
        if (bulletHolePrefab == null || playerIntegrity != null)
        {
            return;
        }

        // Decidimos si crear agujero de bala o churrete de sangre
        EnemyCollider enemyCollider = objectToParent.GetComponent <EnemyCollider>();
        WeakPoint     weakPoint     = objectToParent.GetComponent <WeakPoint>();
        GameObject    prefabToUse   = (enemyCollider != null || weakPoint != null) ? bulletHoleBugPrefab : bulletHolePrefab;

        // Y lo creamos
        GameObject newBulletHole = Instantiate(prefabToUse, point, Quaternion.identity);

        newBulletHole.transform.rotation = Quaternion.LookRotation(newBulletHole.transform.forward, normal);

        // Lo movemos un pelin para evitar el z clipping
        newBulletHole.transform.position += newBulletHole.transform.up * 0.01f;
        newBulletHole.transform.SetParent(objectToParent.transform);
    }
Ejemplo n.º 3
0
 public static void Initiate(GameObject playerGO)
 {
     playerTransform = playerGO.transform;
     playerRb        = playerGO.GetComponent <Rigidbody>();
     playerIntegrity = playerGO.GetComponent <PlayerIntegrity>();
     playerControl   = playerGO.GetComponent <RobotControl>();
     isAlive         = true;
 }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     rb = GetComponent <Rigidbody>();
     //dustEmitterStatic.SetActive(true);
     currentParticleSystem = dustEmitterStatic;
     inputManager          = FindObjectOfType <InputManager>();
     gameManager           = FindObjectOfType <GameManager>();
     robotControl          = GetComponent <RobotControl>();
     audioSource           = GetComponent <AudioSource>();
     playerIntegrity       = GetComponent <PlayerIntegrity>();
     //
     StopDustEmitterParticleSystem(dustEmitterMovement);
     //
     transform.position = Vector3.up * idealDistanceFromFloor;
 }
Ejemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     robotControl      = FindObjectOfType <RobotControl>();
     mainCamera        = Camera.main;
     impactInfoManager = FindObjectOfType <ImpactInfoManager>();
     //cameraControl = mainCamera.GetComponent<SpringCamera>();
     cameraControl   = FindObjectOfType <SpringCamera>();
     gameManager     = FindObjectOfType <GameManager>();
     playerIntegrity = FindObjectOfType <PlayerIntegrity>();
     levelManager    = FindObjectOfType <ProvLevelManager>();
     enemyManager    = FindObjectOfType <EnemyManager>();
     bulletPool      = FindObjectOfType <BulletPool>();
     //
     damageIndicators = new List <DamageIndicator>(20);
     //
     radarDimensions = new Vector2(Screen.height * radarProportion, Screen.height * radarProportion);
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Check collsions with the walls
    /// </summary>
    /// <param name="collision"></param>
    public void CheckWallsCollision(Collision collision)
    {
        PlayerIntegrity possiblePlayerIntegrity = collision.collider.GetComponent <PlayerIntegrity>();

        Debug.Log("Possible player collision stay: " + (possiblePlayerIntegrity != null));

        if (possiblePlayerIntegrity != null)
        {
            wallsCollidingWithPlayer++;
        }

        if (wallsCollidingWithPlayer >= 4)
        {
            playerIntegrity.ReceiveEnvionmentalDamage(10);
        }
        //playerIntegrity.Die();
    }
Ejemplo n.º 7
0
    // TODO: Funciona, pero hay que revisar el modelado de la mandíbula
    private void CheckMawsCollision(Collision collision)
    {
        //
        if (mawStatus != MawStatus.Closing)
        {
            return;
        }
        //
        PlayerIntegrity robotControl = collision.collider.GetComponent <PlayerIntegrity>();

        if (collision.GetContact(0).thisCollider.tag == "Maw" && robotControl != null)
        {
            mawsCollidingPlayer++;
        }
        //
        if (mawsCollidingPlayer >= 2)
        {
            robotControl.Die();
        }
    }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        // Guardamos aqui los hijos para manejarlos con comodidad
        crushingwalls         = new Transform[transform.childCount];
        wallsOriginalPosition = new Vector3[transform.childCount];

        for (int i = 0; i < crushingwalls.Length; i++)
        {
            crushingwalls[i]         = transform.GetChild(i);
            wallsOriginalPosition[i] = crushingwalls[i].localPosition;
        }

        //
        initialWallY = crushingwalls[0].localPosition.y;
        closedWallY  = initialWallY / 2;

        //
        playerIntegrity = FindObjectOfType <PlayerIntegrity>();

        //
        audioSource = GetComponent <AudioSource>();
    }
Ejemplo n.º 9
0
    // Entrada de la boca
    private void OnTriggerEnter(Collider other)
    {
        // TODO: Chequear balas para primer entento
        Bullet bullet = other.GetComponent <Bullet>();

        if (bullet != null && currentState == WormStatus.Chasing && !firstBulletAttempAtMouth)
        {
            // Aquí sacaremos un mensaje de carol
            // TODO: Organizar mejor estas funciones
            //Debug.Log("Bullet shoot to mouth");
            firstBulletAttempAtMouth = true;
            carolHelp.TriggerIt(7, "Bullet shoot to mouth");
        }

        // Chequeamos que sea el player lo que colisiona
        PlayerIntegrity playerIntegrity = other.GetComponent <PlayerIntegrity>();

        //
        if (playerIntegrity != null)
        {
            //
            if (currentState == WormStatus.Stunned)
            {
                // Mandamos al player al interior del gusano
                PlayerReference.playerIntegrity.TranslationAllowed = true;
                // Después de permitir el movimiento
                MovePlayerToInterior();
                gigaWormInsides.PlayerOut = false;
                active = false;
                //
                if (!firstEntranceInMouth)
                {
                    firstEntranceInMouth = true;
                    carolHelp.TriggerIt(10, "Player entering mouth");
                }
            }
        }
    }
Ejemplo n.º 10
0
    //
    public void GenerateExplosion()
    {
        //
        if (exploding)
        {
            return;
        }
        else
        {
            exploding = true;
        }
        // Primero aplicamos la onda de choque
        // Vamos a hacer que este daño vaya contra la "estrucura"
        Collider[] affectedColliders = Physics.OverlapSphere(transform.position, shockWaveRange);
        //
        for (int i = 0; i < affectedColliders.Length; i++)
        {
            //
            Vector3 affectedColliderDirection = affectedColliders[i].transform.position - transform.position;
            float   receivedBlastForce        = explosionForce / (1 + Mathf.Pow(affectedColliderDirection.magnitude, 2));
            Vector3 blastForceWithDirection   = affectedColliderDirection.normalized * receivedBlastForce;
            //
            PlayerIntegrity playerIntegrity = affectedColliders[i].GetComponent <PlayerIntegrity>();
            if (playerIntegrity != null)
            {
                playerIntegrity.ReceiveBlastDamage(blastForceWithDirection);
            }
            //
            EnemyCollider enemyCollider = affectedColliders[i].GetComponent <EnemyCollider>();
            if (enemyCollider != null)
            {
                enemyCollider.ReceivePulseDamage(blastForceWithDirection);
            }
            // Después enemy consistencies
            EnemyConsistency enemyConsistency = affectedColliders[i].GetComponent <EnemyConsistency>();
            if (enemyConsistency == null)
            {
                enemyConsistency = affectedColliders[i].GetComponentInParent <EnemyConsistency>();
            }
            if (enemyConsistency != null)
            {
                enemyConsistency.ReceivePulseDamage(blastForceWithDirection);
            }
            //
            DestructibleTerrain destructibleTerrain = affectedColliders[i].GetComponent <DestructibleTerrain>();
            if (destructibleTerrain != null)
            {
                destructibleTerrain.ReceivePulseImpact(blastForceWithDirection);
            }
            // Aplicamos fuerza directa a los rigidbodies que no son el player ni los enemigos
            // Estos se lo gestionan en la funcióbn de recibir daño de explosión
            Rigidbody rigidbody = affectedColliders[i].GetComponent <Rigidbody>();
            if (rigidbody != null && enemyConsistency == null && playerIntegrity == null && rigidbody != proyectileRb)
            {
                rigidbody.AddForce(blastForceWithDirection / 1000);
            }
        }
        //
        if (generatesFragments)
        {
            GenerateFragments(fragmentsPerHeight, fragmentsPerWidth, 1 / 2);
        }
        //
        //GeneralFunctions.PlaySoundEffect(audioObjectManager, explosionClip);
        if (audioObjectManager != null)
        {
            audioObjectManager.CreateAudioObject(explosionClip, transform.position);
        }
        //
        //Destroy(gameObject);
        //proyectileRb.velocity = Vector3.zero;
        //bulletPool.ReturnBullet(gameObject);

        bulletScript.ReturnBulletToPool();
    }
Ejemplo n.º 11
0
    //
    protected void GenerateImpact(Collider collider, Vector3 hitPoint, Vector3 hitNormal, float dt = 0)
    {
        //
        transform.position = hitPoint;
        GameObject particlesToUse = impactParticlesPrefab;
        AudioClip  clipToUse      = null;

        // Chequeamos si ha impactado a un enemigo y aplicamos lo necesario
        EnemyCollider enemyCollider = collider.GetComponent <EnemyCollider>();

        if (enemyCollider != null)
        {
            enemyCollider.ReceiveBulletImpact(rb, hitPoint);
            particlesToUse = impactOnBugParticlesPrefab;
            clipToUse      = impactOnEnemy;
            // TODO: Buscar otro sitio donde ponerlo
            // Aquí no suena porque se destruye el objeto
            //GeneralFunctions.PlaySoundEffect(audioSource, impactOnEnemy);
            //bulletSoundManager.CreateAudioObject(impactOnEnemy, transform.position);
        }

        // Y el player, joputa
        PlayerIntegrity playerIntegrity = collider.GetComponent <PlayerIntegrity>();

        if (playerIntegrity != null)
        {
            clipToUse = impactOnPlayer;
            playerIntegrity.ReceiveImpact(transform.position, gameObject, rb, hitNormal);

            //GeneralFunctions.PlaySoundEffect(audioSource, impactOnPlayer);
            //bulletSoundManager.CreateAudioObject(impactOnPlayer, transform.position);
            //
            //Rigidbody playerRB = playerIntegrity.gameObject.GetComponent<Rigidbody>();
            //playerRB.AddForce(rb.velocity * rb.mass, ForceMode.Impulse);
        }

        // Weakpoints
        // TODO: Gestionarlos mejor
        WeakPoint weakPoint = collider.GetComponent <WeakPoint>();

        if (weakPoint != null)
        {
            clipToUse      = impactOnEnemy;
            particlesToUse = impactOnBugParticlesPrefab;
            weakPoint.ReceiveBulletImpact(rb, this);
        }

        // Efecto de sonido
        if (clipToUse != null)
        {
            bulletSoundManager.CreateAudioObject(clipToUse, transform.position, 0.1f);
        }

        // Partículas
        if (particlesToUse != null)
        {
            GameObject impactParticles = Instantiate(particlesToUse, hitPoint, Quaternion.identity);
            SpawnBulletHole(hitPoint, hitNormal, collider.gameObject);
            Destroy(impactParticles, 2);
        }

        // TODO: Ver por qué nos hacía falta esto
        // Si es explosiva gestionamos la destrucción ahí
        // Y si es player lo gestionams en player
        if (explosiveBullet == null && playerIntegrity == null)
        {
            //Debug.Log("Not explosive component, destroying object");
            // Destroy(gameObject);
            ReturnBulletToPool();
            // TODO: Hcaerlo mas limpio
            //if(dangerousEnough)
            //    bulletPool.RemoveDangerousBulletFromList(gameObject);
        }
    }