private void CheckWallHits()
    {
        wallHit = WallHit.None;

        if (grounded) // don't check for walls when grounded
        {
            return;
        }

        var hits = rb2d.Cast(Vector2.left, contactFilter, hitBuffer, 0.1f);

        for (int i = 0; i < hits; i++)
        {
            if (hitBuffer[i].normal.y == 0)
            {
                wallHit = WallHit.Left;
                return;
            }
        }

        hits = rb2d.Cast(Vector2.right, contactFilter, hitBuffer, 0.1f);

        for (int i = 0; i < hits; i++)
        {
            if (hitBuffer[i].normal.y == 0)
            {
                wallHit = WallHit.Right;
                return;
            }
        }
    }
Exemplo n.º 2
0
    private void Awake()
    {
        _toggles         = ObjectsLibrary.Find("ImageCheatSheet/ObjectSelected/Shape").GetComponentsInChildren <Toggle>();
        _currentWallType = WallsUtils.Walltype.WC; // TODO Set null

        Transform wallObjectProperties = WallObjectProperties.Find("ImageCheatSheet/Properties");
        Transform wallObjectContent    = WallObjectProperties.Find("ImageCheatSheet/ObjectSelected");

        _wallObjectId = wallObjectProperties.Find("Id").gameObject;
        _time         = wallObjectProperties.Find("Time").gameObject;
        // _backgroundImage = wallObjectContent.Find("Shape/ImageBackground").gameObject;
        _shapeImage = wallObjectContent.Find("Shape/ImageBackground/WallImage").gameObject;
        _dodgeImage = wallObjectContent.Find("Dodge/ImageBackground").gameObject;

        _coinImageBackground = wallObjectContent.Find("Coin/ImageBackground").gameObject;
        _coinImage           = wallObjectContent.Find("Coin/ImageBackground/Image").gameObject;

        _currentTab = wallObjectContent.Find("Shape").gameObject;
        _currentTab.SetActive(true);

        WallShape   = new WallShape();
        WallHit     = new WallHit();
        WallDodge   = new WallDodge();
        WallCoin    = new Coin();
        WallCustom  = new WallCustom();
        CurrentWall = WallShape;
    }
Exemplo n.º 3
0
    public int GetPositionOfCharToChange(WallsUtils.Walltype wallType, string name)
    {
        switch (wallType)
        {
        case WallsUtils.Walltype.NONE:
            break;

        case WallsUtils.Walltype.WP:
            return(WallShape.GetPositionOfCharToChange(name));

        case WallsUtils.Walltype.WA:
            break;

        case WallsUtils.Walltype.WH:
            return(WallHit.GetPositionOfCharToChange(name));

        case WallsUtils.Walltype.WC:
            break;

        case WallsUtils.Walltype.CN:
            break;

        case WallsUtils.Walltype.EV:
            break;

        default:
            break;
        }

        return(-1);
    }
Exemplo n.º 4
0
    private void RpcBackWallHit(int backWallHitPosition)
    {
        backWallHits[(PlayerPosition)backWallHitPosition]++;
        WallHit?.Invoke((PlayerPosition)backWallHitPosition);

        if (backWallHits[(PlayerPosition)backWallHitPosition] >= backWallMaxHits)
        {
            backWallHits[PlayerPosition.Top]    = 0;
            backWallHits[PlayerPosition.Bottom] = 0;
            currentScore[(PlayerPosition)backWallHitPosition] += scoreIncrease;

            ScoreIncreased?.Invoke(currentScore, (PlayerPosition)backWallHitPosition);


            if (currentScore.Values.ToList().TrueForAll(x => x == killerPointScore))
            {
                //Handle Killer Point
            }
            if (currentScore[(PlayerPosition)backWallHitPosition] >= winningScore)
            {
                StartCoroutine(HandleGameOver((PlayerPosition)backWallHitPosition));
            }
            ballSpawner.DestroyCurrentBall();

            //TODO: Handle ball spawning
            if (!gameOver)
            {
                scoreAnimator.UpdateScores(EvaluateScore(currentScore[PlayerPosition.Bottom]),
                                           EvaluateScore(currentScore[PlayerPosition.Top]),
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Bottom,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Bottom,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Top,
                                           (PlayerPosition)backWallHitPosition == PlayerPosition.Top);
                StartCoroutine(scoreTransition.Animate(Camera.main.GetComponent <AnalogGlitch>()));
                scoreAnimator.MoveScores();
                StartCoroutine(ballSpawner.WaitBeforeBallSpawn(ballSpawner.longSpawnTime));
            }
        }
    }
Exemplo n.º 5
0
    private void changeHitIcons() // TODO set in hit class
    {
        Image[] hitImages = _currentTab.gameObject.GetComponent <Transform>().Find("Hit Icons").gameObject.GetComponentsInChildren <Image>();

        List <int> validHits = WallHit.GetValidHits(WallHit.Id);

        for (int i = 0; i < hitImages.Length; i++)
        {
            Image   image = hitImages[i];
            Color32 color = image.color;
            if (validHits.IndexOf(i) >= 0)
            {
                color.a     = 255;
                image.color = color;
            }
            else
            {
                color.a     = 75;
                image.color = color;
            }
        }
    }
    private void DoWall(float x)
    {
        if (grounded)
        {
            instantStick = false;
            animator.SetBool(Hang, false);
            wallStickCounter = 0;
            return;
        }

        if (wallHit == WallHit.None)
        {
            // no walls in sight, disregard everything
            slidingOnWall = false;
            animator.SetBool(Hang, false);
            return;
        }

        // touching wall

        // sliding on wall: touching wall AND not pressing away from wall for over 0.1 sec
        var pressingAwayFromWall = (wallHit == WallHit.Left && x > 0 || wallHit == WallHit.Right && x < 0);

        if (pressingAwayFromWall)
        {
            // start timer to detach
            wallStickCounter -= Time.deltaTime;

            slidingOnWall = wallStickCounter > 0;
        }
        else
        {
            // reset time to detach
            wallStickCounter = wallStickTime;
            slidingOnWall    = true;
        }

        // horizontal movement

        if (slidingOnWall)
        {
            horizontalVelocity = 0;
        }

        // vertical movement
        if (slidingOnWall)
        {
            if (velocity.y <= 0 || instantStick)
            {
                velocity.y = wallGrabSlideSpeed;
                noGravity  = true;

                animator.SetBool(Hang, true);
            }

            if (Input.GetButtonDown("Jump"))
            {
                wallStickCounter = 0;
                slidingOnWall    = false;
                noGravity        = false;

                velocity.y         = jumpTakeOffSpeed;
                horizontalVelocity = wallHit == WallHit.Left ? moveSpeed : -moveSpeed;

                directionFreezeCounter = directionFreezeTime;
                directionFreeze        = new Vector2(horizontalVelocity, walljumpSpeed.y);
                directionFreezeY       = false;
                directionFreezeGravity = 0;

                instantStick = true;

                wallHit = WallHit.None; // to prevent user from grabbing wall again before frame has updated
            }
        }
    }