Example #1
0
    /// <summary>
    ///
    /// </summary>
    void CheckDefense()
    {
        //
        if (gameManager.playerAttributes.unlockedDefenseActions == 0)
        {
            return;
        }
        // De momento solo hacia arriba
        // Luego trabajaremos más direcciones
        if (inputManager.DefenseButton && actionCharging == ActionCharguing.None && gameManager.playerAttributes.unlockedDefenseActions > 0)
        {
            // DefenseMode
            actionCharging = ActionCharguing.Defense;
            // Chequeamos el tipo de defensa que utilizamos
            switch (defenseMode)
            {
            case DefenseMode.Spheric:
                sphericShield.SetActive(true);
                break;

            case DefenseMode.Front:
                // TODO: Crear escudo frontal
                frontShield.SetActive(true);
                break;
            }

            // De momento haremos que la carga empiece a tope en la defensa
            //chargedAmount = 1;
        }
        else if (inputManager.DefenseButton && actionCharging == ActionCharguing.Defense)
        {
            // Bajará con los impactos
            // Y se recargará con el tiempo
            chargedAmount += Time.deltaTime;
            chargedAmount  = Mathf.Clamp01(chargedAmount);
        }
        else if (chargedAmount > 0 && actionCharging == ActionCharguing.Defense)
        {
            chargedAmount  = 0;
            actionCharging = ActionCharguing.None;
            // A ver cual hay que desactivar
            switch (defenseMode)
            {
            case DefenseMode.Spheric:
                sphericShield.SetActive(false);
                break;

            case DefenseMode.Front:
                // TODO: Crear escudo frontal
                frontShield.SetActive(false);
                break;
            }
        }
    }
Example #2
0
    /// <summary>
    ///
    /// </summary>
    void CheckAndFire(float dt)
    {
        //
        if (gameManager.playerAttributes.unlockedAttackActions == 0)
        {
            return;
        }
        //
        if (inputManager.FireButton && actionCharging == ActionCharguing.None && gameManager.playerAttributes.unlockedAttackActions > 0)
        {
            actionCharging = ActionCharguing.Attack;
            switch (attackMode)
            {
            // Luego lo trabajamos
            // Poner "proyectil formándose"
            // O partículas del ataque de pulso
            case AttackMode.Pulse:
                releasingPulseEmitter.SetActive(false);
                chargingPulseEmitter.SetActive(true);
                GeneralFunctions.PlaySoundEffect(audioSource, loadingClip);
                break;

            case AttackMode.Canon:
                //chargingCanonProyectile.SetActive(false);
                GeneralFunctions.PlaySoundEffect(audioSource, loadingClip);
                break;
            }
        }
        else if (inputManager.FireButton && actionCharging == ActionCharguing.Attack)
        {
            //
            chargedAmount += dt;
            if (attackMode == AttackMode.RapidFire)
            {
                // TODO: Hacerlo un poco menos ñapa
                if (totalOverheat)
                {
                    chargedAmount -= dt;
                    return;
                }

                // TODO: Decidir si lo utilizamos o no
                // currentOverheat += dt;
                //
                if (currentOverheat <= gameManager.playerAttributes.maxOverheat)
                {
                    //
                    RapidFireAttack(dt);
                }
                else
                {
                    // Meteremos aqui el efecto de sobrecarga
                    totalOverheat   = true;
                    currentOverheat = gameManager.playerAttributes.maxOverheat;
                    GeneralFunctions.PlaySoundEffect(audioSource, overHeatClip);
                    actionCharging = ActionCharguing.None;
                }
                //
                chargedAmount = Mathf.Min(chargedAmount, 1);
            }
            else
            {
                //
                //chargedAmount += Time.deltaTime;
                //
                chargedAmount = Mathf.Min(chargedAmount, 1);
                //
                if (chargedAmount == 1 && audioSource.clip != loadingAtMaxClip)
                {
                    GeneralFunctions.PlaySoundEffect(audioSource, loadingAtMaxClip);
                }
            }
        }
        else if (chargedAmount > 0 && actionCharging == ActionCharguing.Attack) // Release shot
        {
            switch (attackMode)
            {
            case AttackMode.Pulse:
                chargingPulseEmitter.SetActive(false);
                releasingPulseEmitter.SetActive(true);
                // TODO: Revisar este get component
                ParticleSystem particleSystem = releasingPulseEmitter.GetComponent <ParticleSystem>();
                particleSystem.Play();
                //
                AlternativePulseAttack();
                //
                GeneralFunctions.PlaySoundEffect(audioSource, releasingPulseClip);
                break;

            case AttackMode.Canon:
                // TODO: Cambiarlo por complexity cuando lo tengamos claro
                //if(chargedAmount >= gameManager.canonMinCharge)
                //{
                //chargingCanonProyectile.SetActive(false);
                CharguedProyectileAttack(proyectileToUse, chargedProyectilePoint, dt);
                //
                GeneralFunctions.PlaySoundEffect(audioSource, releasingCanonClip);
                //}
                break;

            case AttackMode.RapidFire:
                //impactInfoManager.
                // Igual no hace falta poner nada
                break;
                // Ya haremos el resto
            }
            chargedAmount  = 0;
            actionCharging = ActionCharguing.None;
        }
    }
Example #3
0
    /// <summary>
    ///
    /// </summary>
    void AxisMotion(float dt)
    {
        // Primero pillamos el eje del joystick
        Vector2 movementAxis = inputManager.StickAxis;

        // TODO: Decidir si aplicar aqui el countdown del damping
        if (currentDamping != DampingType.TwoDimensional)
        {
            //
            not2dDCurrentDuration += dt;
            if (not2dDCurrentDuration > not2dDMaxDuration)
            {
                currentDamping        = DampingType.TwoDimensional;
                not2dDCurrentDuration = 0;
            }
        }

        //
        Vector3 directionZ = mainCamera.forward * movementAxis.y;
        Vector3 directionX = mainCamera.right * movementAxis.x;

        // First check sprint
        float   sprintMultiplier = 1;
        Vector3 currentUp        = Vector3.up;

        //
        if (gameManager.playerAttributes.unlockedSprintActions > 0)
        {
            RaycastHit adherencePoint;
            // TODO: Meter aqui el dash cuando otra habilidad está cargando
            if (inputManager.SprintButton && actionCharging != ActionCharguing.None && actionCharging != ActionCharguing.Sprint)
            {
                repulsor.RepulsorDash(directionX + directionZ);
            }
            //
            if (inputManager.SprintButton && actionCharging == ActionCharguing.None)
            {
                switch (sprintMode)
                {
                case SprintMode.Normal:
                    actionCharging = ActionCharguing.Sprint;
                    break;

                //case SprintMode.RepulsorDash:
                //    // TODO: Aquí haremos el impulso
                //    // Más abajo están los parámetros que necesitamos
                //    // Ahora pilla la velocidad en xz, probablemene quermos aplicarlo en la dirección del eje
                //    repulsor.RepulsorDash(directionX + directionZ);
                //    break;
                case SprintMode.Adherence:
                    // Let's check if there are a surface near
                    if (AdherenceCheck(out adherencePoint) != false)
                    {
                        // Trabajamos con el punto y la normal
                        //adherencePoint.normal
                        actionCharging = ActionCharguing.Sprint;
                        SetNewUp(adherencePoint.point, adherencePoint.normal);
                        currentUp     = adherencePoint.normal;
                        chargedAmount = 1;
                        adhering      = true;
                        //cameraControl.
                        Debug.Log("Adherence point found");
                    }
                    break;
                }
            }
            else if (inputManager.SprintButton && actionCharging == ActionCharguing.Sprint)
            {
                switch (sprintMode)
                {
                case SprintMode.Normal:
                    // De momento el multiplicador irá de 1 a 2
                    chargedAmount    += Time.deltaTime;
                    chargedAmount     = Mathf.Min(chargedAmount, gameManager.playerAttributes.maxCharge);
                    sprintMultiplier += chargedAmount;
                    break;

                case SprintMode.Adherence:
                    if (AdherenceCheck(out adherencePoint) != false)
                    {
                        // Trabajamos con el punto y la normal
                        //adherencePoint.normal
                        SetNewUp(adherencePoint.point, adherencePoint.normal);
                        currentUp = adherencePoint.normal;
                        Vector3 gravityForce   = Vector3.up * -rb.velocity.y;
                        Vector3 adherenceForce = -transform.up * 1;
                        rb.AddForce(gravityForce + adherenceForce, ForceMode.Impulse);
                        //chargedAmount = 1;
                        //cameraControl.
                        Debug.Log("Adherenring to something");
                    }
                    else
                    {
                        Debug.Log("Adherenrce lost");
                        chargedAmount  = 0;
                        actionCharging = ActionCharguing.None;
                        adhering       = false;
                    }

                    break;
                }
            }
            else if (chargedAmount > 0 && actionCharging == ActionCharguing.Sprint)
            {
                //
                if (sprintMode == SprintMode.Normal && chargedAmount < 0.2f)
                {
                    repulsor.RepulsorDash(directionX + directionZ);
                }
                //
                chargedAmount  = 0;
                actionCharging = ActionCharguing.None;
                adhering       = false;
            }
        }



        // The movement direction will depend on the current up
        directionZ = Vector3.ProjectOnPlane(directionZ, currentUp).normalized;
        directionX = Vector3.ProjectOnPlane(directionX, currentUp).normalized;

        // En estos casos el player estará encarado con el objetivo
        if (actionCharging == ActionCharguing.Attack ||
            (actionCharging == ActionCharguing.Defense && defenseMode == DefenseMode.Front) ||
            (actionCharging == ActionCharguing.Jump && jumpMode == JumpMode.Smash))
        {
            // Si no targetea al player
            // Osea un enemigo
            // Puesto aqui por si sacamos más casos (cinematicas por ejemplo)
            if (!cameraControl.TargetingPlayer)
            {
                //
                // TODO: Ajustar el stimated para que pille bien
                Vector3 pointToLook = EnemyAnalyzer.estimatedToHitPosition;
                transform.LookAt(pointToLook, currentUp);
            }
            else
            {
                //transform.LookAt(transform.position + cameraControl.transform.forward, currentUp);
                transform.rotation = mainCamera.rotation;
            }
        }
        else
        {
            // Para que ajuste la rotación poco a poco
            if ((directionX + directionZ).magnitude > Mathf.Epsilon)
            {
                currentRotationTime = 0;
                lastAxisXZ          = directionX + directionZ;
            }
            //
            objectiveRotation    = Quaternion.LookRotation(lastAxisXZ, currentUp);
            currentRotationTime += dt;
            transform.rotation   = Quaternion.Slerp(transform.rotation, objectiveRotation, currentRotationTime / rotationTime);

            //transform.LookAt(transform.position + directionX + directionZ, currentUp);
        }


        // TODO: Tener en cuenta velocity actual
        Vector3 forceDirection = (directionX + directionZ).normalized;

        rb.AddForce(forceDirection * gameManager.playerAttributes.movementForcePerSecond * sprintMultiplier * dt, ForceMode.Impulse);

        // And dampen de movement
        if (currentDamping == DampingType.TwoDimensional)
        {
            Vector3 currentVelocity = rb.velocity;
            currentVelocity.x *= 1 - (damping * dt);
            currentVelocity.z *= 1 - (damping * dt);
            rb.velocity        = currentVelocity;
        }
        else if (currentDamping == DampingType.ThreeDimensional)
        {
            //
            rb.velocity *= 1 - (damping * dt);
        }
    }
Example #4
0
    /// <summary>
    ///
    /// </summary>
    void JumpMotion()
    {
        // La primera se desbloquea en el repulsor
        if (gameManager.playerAttributes.unlockedJumpActions == 2 || jumpMode == JumpMode.RepulsorJump)
        {
            return;
        }
        // De momento solo hacia arriba
        // Luego trabajaremos más direcciones
        if (inputManager.JumpButton && actionCharging == ActionCharguing.None)
        {
            actionCharging = ActionCharguing.Jump;
            GeneralFunctions.PlaySoundEffect(audioSource, loadingClip);
        }
        else if (inputManager.JumpButton && actionCharging == ActionCharguing.Jump)
        {
            //
            chargedAmount += Time.deltaTime;
            chargedAmount  = Mathf.Clamp01(chargedAmount);
        }
        else if (chargedAmount > 0 && actionCharging == ActionCharguing.Jump)
        {
            // NOTA: Pensar si dejarle saltar en el aire
            // Chequeamos el tipo de salto seleccionado
            switch (jumpMode)
            {
            case JumpMode.ChargedJump:
                // En ese caso hacer que tenga menos impulso que haciéndolo desde el suelo
                float floorSupport = (repulsor.IsOnFloor) ? 1 : 0.5f;
                // Le damos un mínimo de base
                rb.AddForce(Vector3.up * (gameManager.playerAttributes.forcePerSecond.CurrentValue * chargedAmount * floorSupport),
                            ForceMode.Impulse);
                //
                GeneralFunctions.PlaySoundEffect(audioSource, releasingPulseClip);
                break;

            case JumpMode.Smash:
                // Le damos un mínimo de base
                // TODO: Añadir icono
                // TODO: Clacular bien la dirección
                // TODO: Aplicar más fuerza y probar
                Vector3 cameraForward = cameraControl.transform.forward;
                ChangeDampingType(DampingType.ThreeDimensional);
                Vector3 currentVelocity = rb.velocity;
                // Revisar: Podría ser el player.forward
                Vector3 desiredDirection = (!cameraControl.TargetingPlayer) ?
                                           (cameraControl.CurrentTarget.position - transform.position)
                        : cameraForward;
                // TODO: Revisar
                Vector3 compensatedDirection = (desiredDirection - currentVelocity).normalized;
                rb.AddForce(compensatedDirection * (gameManager.playerAttributes.forcePerSecond.CurrentValue * chargedAmount) * 10,
                            ForceMode.Impulse);
                //
                GeneralFunctions.PlaySoundEffect(audioSource, releasingPulseClip);
                break;
            }

            chargedAmount  = 0;
            actionCharging = ActionCharguing.None;
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        //
        if (!PlayerReference.isAlive)
        {
            return;
        }
        //
        float dt = Time.deltaTime;

        //
        timeFromLastChange += dt;

        // Chequeo para que no de error en cinemáticas
        if (robotControl == null)
        {
            return;
        }

        //
        ActionCharguing playerActionCharging = robotControl.CurrentActionCharging;

        chargeAmount = robotControl.ChargedAmount;

        // First check what posture is the current
        if (chargeAmount > 0 && previousChargeAmount == 0)
        {
            switch (playerActionCharging)
            {
            case ActionCharguing.Sprint:
                switch (robotControl.ActiveSprintMode)
                {
                case SprintMode.Normal:
                    currentShovelPosture = ShovelPostures.Sprint;
                    break;

                // TODO: Hacer el de adeherencia
                case SprintMode.Adherence:
                    currentShovelPosture = ShovelPostures.Adherence;
                    break;
                }

                break;

            case ActionCharguing.Jump:
                switch (robotControl.ActiveJumpMode)
                {
                case JumpMode.ChargedJump:
                    currentShovelPosture = ShovelPostures.Jump;
                    break;

                case JumpMode.Smash:
                    // TODO: Hacer el de smash
                    currentShovelPosture = ShovelPostures.Smash;
                    break;
                }

                break;

            case ActionCharguing.Attack:
                switch (robotControl.ActiveAttackMode)
                {
                case AttackMode.Pulse:
                    currentShovelPosture = ShovelPostures.PulseAttack;
                    break;

                case AttackMode.RapidFire:
                    currentShovelPosture = ShovelPostures.RapidFire;
                    break;

                case AttackMode.Canon:
                    currentShovelPosture = ShovelPostures.Canon;
                    break;

                case AttackMode.ParticleCascade:
                    currentShovelPosture = ShovelPostures.ParticleCascade;
                    break;
                }
                break;

            case ActionCharguing.Defense:
                switch (robotControl.ActiveDefenseMode)
                {
                case DefenseMode.Spheric:
                    currentShovelPosture = ShovelPostures.SphericDefense;
                    break;

                case DefenseMode.Front:
                    // TODO: Hacer el frontal
                    currentShovelPosture = ShovelPostures.FrontalDefense;
                    break;
                }
                break;
            }
            timeFromLastChange = 0;
        }
        else if (chargeAmount == 0)
        {
            currentShovelPosture = ShovelPostures.Original;
        }

        //
        previousChargeAmount = chargeAmount;

        //
        Transform[] shovelFrom = new Transform[4];
        shovelFrom = shovelsPositions[(int)previousShovelPosture];

        //
        Transform[] shovelTo = new Transform[4];
        shovelTo = shovelsPositions[(int)currentShovelPosture];

        //
        for (int i = 0; i < shovels.Length; i++)
        {
            //
            shovels[i].localRotation = Quaternion.Slerp(shovelFrom[i].localRotation, shovelTo[i].localRotation, timeFromLastChange / timeLerping);
            shovels[i].localPosition = Vector3.Lerp(shovelFrom[i].localPosition, shovelTo[i].localPosition, timeFromLastChange / timeLerping);
            //
            shovels[i].GetChild(0).localRotation =
                Quaternion.Slerp(shovelFrom[i].GetChild(0).localRotation, shovelTo[i].GetChild(0).localRotation, timeFromLastChange / timeLerping);
            shovels[i].GetChild(0).localPosition =
                Vector3.Lerp(shovelFrom[i].GetChild(0).localPosition, shovelTo[i].GetChild(0).localPosition, timeFromLastChange / timeLerping);
        }
    }