コード例 #1
0
    public void SmashGround(bool isSmall)
    {
        float       range        = isSmall? _playerData.SmallSmashRange : _playerData.BigSmashRange;
        ShakePreset currentShake = isSmall? _smallSmashShake : _bigSmashShake;

        Shaker.ShakeAll(currentShake);
        _playerData.ActionController.SmashEffect.transform.position = _playerData.ActionController.Transf.position - Vector3.up * 0.8f;
        _playerData.ActionController.SmashEffect.SetActive(true);
        _playerData.ActionController.SmashEffect.GetComponent <Renderer>().sharedMaterial.SetFloat("Timer", -0.44f);
        Vector3 playerPos = _playerData.ActionController.Transf.position;

        //check all the enemies in the area
        foreach (KillEnemy enemy in KillEnemy.EnemiesList)
        {
            if ((enemy.transform.position.y > playerPos.y - 1f && enemy.transform.position.y < playerPos.y + 1f) && Vector3.Distance(playerPos, enemy.transform.position) <= range)
            {
                RaycastHit hit;

                if (Physics.Raycast(playerPos, (enemy.transform.position - playerPos).normalized, out hit, Mathf.Infinity) && hit.transform.gameObject == enemy.gameObject)
                {
                    enemy.GetComponent <Enemy>().OnHit(10);
                }
            }
        }
    }
コード例 #2
0
 private void ShakeCamera(ShakePreset sPreset)
 {
     if (sPreset != null)
     {
         Shaker.ShakeAll(sPreset);
     }
 }
コード例 #3
0
 public void GameWin(string winner)
 {
     AudioManager.instance.Play("VikingHorn", 1f, 1f, false);
     Shaker.ShakeAll(explosionShakePreset);
     Shaker.ShakeAll(bigExplosionShakePreset);
     gameController.EndGame(winner);
 }
コード例 #4
0
    private void IsGrounded()
    {
        RaycastHit raycastHit;

        bool lastState = _playerData.isGrounded;

        Physics.SphereCast(transform.position, _capsuleCollider.radius - 0.2f, Vector3.down, out raycastHit, (_capsuleCollider.height) * 0.60f, _groundCheckLayerMask);

        _playerData.isGrounded = raycastHit.collider == null ? false : true;
        Anim.SetBool("OnAir", !_playerData.isGrounded);

        if (_playerData.isGrounded == false)
        {
            Transf.rotation = Quaternion.Euler(0, Transf.rotation.eulerAngles.y, 0);
        }

        //Set the jumped flag
        if (_playerData.isGrounded == true && lastState == false)
        {
            _playerData.Jumped = false;
            _landParticle1.gameObject.transform.position = _playerData.ActionController.Transf.position - Vector3.up * 0.8f;
            _landParticle2.gameObject.transform.position = _playerData.ActionController.Transf.position - Vector3.up * 0.8f;
            _landParticle1.Play();
            _landParticle2.Play();
            Shaker.ShakeAll(_landShake);
        }
    }
コード例 #5
0
ファイル: Goal.cs プロジェクト: moocow17/Valhalla-Ball
    IEnumerator GoalShake()
    {
        Shaker.ShakeAll(explosionShakePreset);

        yield return(new WaitForSeconds(2.4f));

        Shaker.ShakeAll(bigExplosionShakePreset);
    }
コード例 #6
0
 public virtual void TakeDamage(float dmg)
 {
     currentHealth -= dmg;
     if (currentHealth <= 0)
     {
         _audioManger.PlaySound(clip);
         gameObject.SetActive(false);
     }
     Shaker.ShakeAll(shakePreset);
 }
コード例 #7
0
ファイル: ShakeButton.cs プロジェクト: Sogekeeper/ZODZ3
 public void UIToggleShake(bool enabled)
 {
     if (shakeInstance == null)
     {
         shakeInstance = Shaker.ShakeAll(shakePreset);
     }
     else
     {
         shakeInstance.Stop(shakePreset.FadeOut, true);
         shakeInstance = null;
     }
 }
コード例 #8
0
    public override void DestroyObject()
    {
        Shaker.ShakeAll(shakePreset);
        if (explosionParticlesPrefab != null)
        {
            ParticleSystem.MainModule explosion = Instantiate(explosionParticlesPrefab, transform.position, Quaternion.identity)
                                                  .GetComponent <ParticleSystem>().main;

            //explosion.startColor = currentColor;
        }
        LevelManager.instance.CountDestroyedObjective();
        Destroy(gameObject);
    }
コード例 #9
0
ファイル: EntityStats.cs プロジェクト: Reraduragon/ZODZ3
 public void FallCallbackDamage()
 {
     if (anim)
     {
         anim.Play("Fall");
     }
     if (onFallDamageShake)
     {
         Shaker.ShakeAll(onFallDamageShake);
     }
     TakeDamage((int)(totalLife.Value * 0.10f));
     if (!recoverFall)
     {
         Die();
     }
 }
コード例 #10
0
ファイル: DamageSource.cs プロジェクト: Sogekeeper/ZODZ3
    private void OnTriggerEnter2D(Collider2D other)
    {
        EntityStats entityStats = other.GetComponent <EntityStats>();

        if (entityStats && EntityRuntimeSet.DetectArrayOverlap(hostileTo, entityStats.myEntitySets) &&
            entityStats != owner)
        {
            OnHitEntity?.Invoke();
            if (onHitShake)
            {
                //Debug.Log("Shaking");
                Shaker.ShakeAll(onHitShake);
            }
            if (onHitSound)
            {
                EazySoundManager.PlaySound(onHitSound, 0.13f);
            }
            ApplyDamage(entityStats);
            if (owner != null)
            {
                owner.ChangeMana(manaReplenishAmount);
            }
        }
    }
コード例 #11
0
ファイル: Mover.cs プロジェクト: moocow17/Valhalla-Ball
    void Attack()//hits in front of the player; any other players in the colliders in the Hitbox gameobject will die
    {
        Collider2D currentPlayerPolygonCollider = gameObject.FindComponentInChildWithTag <PolygonCollider2D>("Hitbox");
        Collider2D currentPlayerCircleCollider  = gameObject.FindComponentInChildWithTag <CircleCollider2D>("Hitbox");

        //ATTACK ANIMATION/EFFECT
        hitParticles = Instantiate(hitPrefab, transform.position + (transform.right * hitPointDistance), transform.rotation) as GameObject;

        //ATTACK SOUND
        float randomPitch = UnityEngine.Random.Range(0.7f, 1.3f);

        AudioManager.instance.Play("GravityHammer1", 1f, randomPitch, false);

        //SHAKE CAMERA
        Shaker.ShakeAll(hitShakePreset);

        //DETECT ALL OTHER PLAYERS THAT ARE HIT
        //get player colliders hit by the polygon hit collider stored as a list
        List <Collider2D> hitPlayersFromPolygonCollider = new List <Collider2D>();
        LayerMask         playerLayerMask     = LayerMask.GetMask("Player");
        ContactFilter2D   playerContactFilter = new ContactFilter2D();

        playerContactFilter.SetLayerMask(playerLayerMask);//With this, the overlap collider will only detect colliders that have the "Player" layer on it, including the controlled player
        int polygonColliderCount = currentPlayerPolygonCollider.OverlapCollider(playerContactFilter, hitPlayersFromPolygonCollider);

        //get player colliders hit by the circle hit collider stored as a list
        List <Collider2D> hitPlayersFromCircleCollider = new List <Collider2D>();
        int circleColliderCount = currentPlayerCircleCollider.OverlapCollider(playerContactFilter, hitPlayersFromCircleCollider);

        //get union of the above lists
        IEnumerable <Collider2D> unionOfHitBoxLists = hitPlayersFromPolygonCollider.Union(hitPlayersFromCircleCollider);

        //KILL THE HIT PLAYERS (except the player that did the hit)
        foreach (Collider2D playerCollider in unionOfHitBoxLists)
        {
            //disattach balls from players who are about to die
            Collider2D ballsCollider = Helper.FindComponentInChildWithTag <Collider2D>(playerCollider.gameObject, "Ball");
            if (ballsCollider != null)
            {
                ballsCollider.attachedRigidbody.isKinematic = false;
                ballsCollider.enabled          = true;
                ballsCollider.transform.parent = null;
                Mover playerMover = (Mover)playerCollider.gameObject.GetComponent(typeof(Mover));
                playerMover.hasBall = false;
            }
            //kill the players
            if (playerCollider.gameObject.GetComponent <Mover>().playerIndex != this.playerIndex) //playerCollider.name != this.gameObject.name)
            {
                /*Vector2 direction = (playerCollider.transform.position - transform.position)*10000; //intended to shoot the player off the edge really fast like in advance wars so they could explode off the edge like in smash bros; couldnt get it to work
                 * playerCollider.attachedRigidbody.AddForceAtPosition(direction, transform.position);*/
                KillPlayer(playerCollider.gameObject);
            }
        }

        //GET ALL BALLS THAT WILL BE HIT
        //get ball colliders hit by the polygon hit collider stored as a list
        List <Collider2D> hitBallsFromPolygonCollider = new List <Collider2D>();
        LayerMask         ballLayerMask     = LayerMask.GetMask("Ball");
        ContactFilter2D   ballContactFilter = new ContactFilter2D();

        ballContactFilter.SetLayerMask(ballLayerMask);//With this, the overlap collider will only detect colliders that have the "Ball" layer on it
        int polygonBallColliderCount = currentPlayerPolygonCollider.OverlapCollider(ballContactFilter, hitBallsFromPolygonCollider);

        //get player colliders hit by the circle hit collider stored as a list
        List <Collider2D> hitBallsFromCircleCollider = new List <Collider2D>();
        int circleBallColliderCount = currentPlayerCircleCollider.OverlapCollider(ballContactFilter, hitBallsFromCircleCollider);

        //get union of the above lists
        IEnumerable <Collider2D> unionOfBallHitBoxLists = hitBallsFromPolygonCollider.Union(hitBallsFromCircleCollider);

        //SEND FORCES OUTWARDS TO AFFECT BALL
        foreach (Collider2D ballCollider in unionOfBallHitBoxLists)
        {
            Vector2 direction = (ballCollider.transform.position - currentPlayerCircleCollider.transform.position);
            ballCollider.attachedRigidbody.AddForce(direction.normalized * hitStrengthMultiplier);
        }

        //COMMENCE ATTACK FREEZE - PREVENTS PLAYER FROM DOING ANYTHING ELSE UNTIL FREEZETIME IS OVER
        hitFreezeTime = Time.time + hitFreezeTimeIncrement;
    }
コード例 #12
0
 public static void PlayShake(Shake shake)
 {
     //Debug.Log(shake);
     Shaker.ShakeAll(GetShakePreset(shake));
 }