Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        // Get Kessel
        if (GameObject.FindGameObjectWithTag("Kessel"))
        {
            kesselscript = Kessel.GetComponent <Extraleben_kessel>();
        }


        // Get ability scripts
        abilty_pushforce  = GetComponent <PushForce>();
        abilty_slowmotion = GetComponent <TimeManager>();

        // Get weapons

        weapon_deagle_gun        = weapon_deagle.GetComponent <Gun>();
        weapon_ar_gun            = weapon_ar.GetComponent <Gun>();
        weapon_shotgun_gun       = weapon_shotgun.GetComponent <Gun>();
        weapon_flammenwerfer_gun = weapon_flammenwerfer.GetComponent <Gun>();
        weapon_raketenwerfer_gun = weapon_raketenwerfer.GetComponent <Gun>();

        if (GameObject.FindGameObjectWithTag("Spawner"))
        {
            Spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <EnemySpawnerScript>();
        }


        LoadPlayer();

        maxhealth = health;

        healthBar.SetMaxHealth((int)maxhealth);
    }
Ejemplo n.º 2
0
    public virtual void Push(PushType _forceType, Vector3 _pushDirectionFlat, PushForce _force)
    {
        if (!isBumpable)
        {
            return;
        }
        RaycastHit i_hit;

        if (Physics.Raycast(GetCenterPosition(), _pushDirectionFlat, out i_hit, 1f, LayerMask.GetMask("Environment")))
        {
            return;
        }
        switch (_forceType)
        {
        case PushType.Light:
            PushLight(_pushDirectionFlat, _force);
            break;

        case PushType.Heavy:
            Vector3 forwardDirection = _pushDirectionFlat.normalized;
            transform.forward = forwardDirection;
            ChangePawnState("PushedHeavy", PushHeavy_C(_pushDirectionFlat, _force), CancelPush_C());
            break;
        }
    }
Ejemplo n.º 3
0
 public PushInfo(PushForce force1, Curve curve1, PushForce force2, Curve curve2, bool ignoreOtherForce = false,
                 bool expireOnGround = false)
 {
     this.ignoreOtherForce = ignoreOtherForce;
     this.expireOnGround   = expireOnGround;
     this.force1           = force1;
     this.curve1           = curve1;
     this.force2           = force2;
     this.curve2           = curve2;
 }
Ejemplo n.º 4
0
 public PushInfo(PushForce pushForce, Curve curve, bool ignoreOtherForce = false,
                 bool expireOnGround = false)
 {
     this.ignoreOtherForce = ignoreOtherForce;
     this.expireOnGround   = expireOnGround;
     force1 = pushForce;
     curve1 = curve;
     force2 = new PushForce();
     curve2 = Curve.empty;
 }
Ejemplo n.º 5
0
    private void PushLight(Vector3 _pushFlatDirection, PushForce _force)
    {
        float _pushDistance = 0;
        float _pushDuration = 0;
        float _pushHeight   = 0;

        switch (_force)
        {
        case PushForce.Force1:
            if (isPlayer)
            {
                _pushDistance = pushDatas.lightPushPlayerForce1Distance;
                _pushDuration = pushDatas.lightPushPlayerForce1Duration;
                _pushHeight   = pushDatas.lightPushPlayerForce1Height;
            }
            else
            {
                _pushDistance = pushDatas.lightPushForce1Distance;
                _pushDuration = pushDatas.lightPushForce1Duration;
                _pushHeight   = pushDatas.lightPushForce1Height;
            }
            break;

        case PushForce.Force2:
            if (isPlayer)
            {
                _pushDistance = pushDatas.lightPushPlayerForce2Distance;
                _pushDuration = pushDatas.lightPushPlayerForce2Duration;
                _pushHeight   = pushDatas.lightPushPlayerForce2Height;
            }
            else
            {
                _pushDistance = pushDatas.lightPushForce2Distance;
                _pushDuration = pushDatas.lightPushForce2Duration;
                _pushHeight   = pushDatas.lightPushForce2Height;
            }
            break;

        case PushForce.Force3:
            if (isPlayer)
            {
                _pushDistance = pushDatas.lightPushPlayerForce3Distance;
                _pushDuration = pushDatas.lightPushPlayerForce3Duration;
                _pushHeight   = pushDatas.lightPushPlayerForce3Height;
            }
            else
            {
                _pushDistance = pushDatas.lightPushForce3Distance;
                _pushDuration = pushDatas.lightPushForce3Duration;
                _pushHeight   = pushDatas.lightPushForce3Height;
            }
            break;
        }
        ChangePawnState("PushedLight", CustomLightPush_C(_pushFlatDirection, _pushDistance, _pushDuration, _pushHeight), CancelPush_C());
    }
Ejemplo n.º 6
0
    private IEnumerator PushHeavy_C(Vector3 _pushFlatDirection, PushForce _force)
    {
        float i_pushDistance = 0;
        float i_pushDuration = 0;
        float i_pushHeight   = 0;

        switch (_force)
        {
        case PushForce.Force1:
            if (isPlayer)
            {
                i_pushDistance = pushDatas.heavyPushPlayerForce1Distance;
                i_pushDuration = pushDatas.heavyPushPlayerForce1Duration;
                i_pushHeight   = pushDatas.heavyPushPlayerForce1Height;
            }
            else
            {
                i_pushDistance = pushDatas.heavyPushForce1Distance;
                i_pushDuration = pushDatas.heavyPushForce1Duration;
                i_pushHeight   = pushDatas.heavyPushForce1Height;
            }
            break;

        case PushForce.Force2:
            if (isPlayer)
            {
                i_pushDistance = pushDatas.heavyPushPlayerForce2Distance;
                i_pushDuration = pushDatas.heavyPushPlayerForce2Duration;
                i_pushHeight   = pushDatas.heavyPushPlayerForce2Height;
            }
            else
            {
                i_pushDistance = pushDatas.heavyPushForce2Distance;
                i_pushDuration = pushDatas.heavyPushForce2Duration;
                i_pushHeight   = pushDatas.heavyPushForce2Height;
            }
            break;

        case PushForce.Force3:
            if (isPlayer)
            {
                i_pushDistance = pushDatas.heavyPushPlayerForce3Distance;
                i_pushDuration = pushDatas.heavyPushPlayerForce3Duration;
                i_pushHeight   = pushDatas.heavyPushPlayerForce3Height;
            }
            else
            {
                i_pushDistance = pushDatas.heavyPushForce3Distance;
                i_pushDuration = pushDatas.heavyPushForce3Duration;
                i_pushHeight   = pushDatas.heavyPushForce3Height;
            }
            break;
        }
        animator.SetBool("PushedBool", true);

        DestroySpawnedAttackUtilities();

        FeedbackManager.SendFeedback("event.PlayerBeingHit", this, transform.position, transform.up, transform.up);
        moveState            = MoveState.Pushed;
        _pushFlatDirection.y = 0;
        _pushFlatDirection   = _pushFlatDirection.normalized * i_pushDistance;
        Vector3 moveDirection = _pushFlatDirection;

        moveDirection.y   = i_pushHeight;
        transform.forward = -moveDirection;
        Vector3 initialPosition = transform.position;
        Vector3 endPosition     = initialPosition + moveDirection;
        Vector3 moveOffset      = Vector3.zero;

        for (float i = 0f; i < i_pushDuration; i += Time.deltaTime)
        {
            transform.forward = -moveDirection;
            moveState         = MoveState.Pushed;
            moveOffset       += new Vector3(moveInput.x, 0, moveInput.z) * Time.deltaTime * pushDatas.heavyPushAirControlSpeed;
            Vector3 newPosition = Vector3.Lerp(initialPosition, endPosition, pushDatas.heavyPushSpeedCurve.Evaluate(i / i_pushDuration)) + moveOffset;

            //check of collision
            Collider hitCollider = CheckForCollision();
            if (hitCollider != null)
            {
                if (isPlayer)
                {
                    WallSplat(WallSplatForce.Light, transform.position - hitCollider.ClosestPoint(transform.position));
                }
                else
                {
                    WallSplat(WallSplatForce.Light, transform.position - hitCollider.ClosestPoint(transform.position));
                }
            }

            transform.position = newPosition;
            yield return(null);
        }
        moveState = MoveState.Idle;
        animator.SetBool("PushedBool", false);

        yield return(null);

        //----Custom code in child script---------
        HeavyPushAction();
    }