コード例 #1
0
 public void SetImageTextFirstJumpFail()
 {
     SoundControllerScript.PlaySound("text");
     mario.textHolder.SetActive(true);
     mario.textHolder.GetComponent <SpriteRenderer>().sprite = textImagePostJumpFail1;
     StartCoroutine(mario.ClearTextAfterSeconds(6f));
 }
コード例 #2
0
    IEnumerator SpinJump()
    {
        SoundControllerScript.PlaySound("changing his clothes");
        float     jumpHeight     = 1.2f;
        float     jumpSpeed      = 2f;
        Mario     mario          = MarioController.Instance.mario;
        Transform marioTransform = mario.gameObject.transform;

        for (float t = 0.0f; t < jumpHeight; t += Time.deltaTime)
        {
            if (t > jumpHeight / 3 && hatRemoved == false)
            {
                RemoveHat();
            }
            if (t > jumpHeight / 1.5 && bodyRemoved == false)
            {
                RemoveBody();
            }
            flipCounter++;
            if (flipCounter > 3)
            {
                flipCounter = 0;
                flipped     = !flipped;
            }

            mario.skeletonSprite.GetComponent <SpriteRenderer>().flipX = flipped;
            mario.headSprite.GetComponent <SpriteRenderer>().flipX     = flipped;
            mario.bodySprite.GetComponent <SpriteRenderer>().flipX     = flipped;
            mario.feetSprite.GetComponent <SpriteRenderer>().flipX     = flipped;
            marioTransform.position += Vector3.up * jumpSpeed * Time.deltaTime;
            yield return(null);
        }
        MarioHasJumped();
    }
コード例 #3
0
    public void SetGameState(GameState state)
    {
        if (state == GameState.WelcomeScreen)
        {
            UIController.Instance.ShowTitleScreen();
        }
        if (state == GameState.DressupScreen)
        {
            //     TextController.Instance.ShowTextPanel(state);
            UIController.Instance.ShowDressUpScreen();
        }
        if (state == GameState.PowerupScreen)
        {
            UIController.Instance.ShowPowerUpScreen();
        }
        if (state == GameState.LevelOpen)
        {
            SoundControllerScript.PlaySound("background sound");
            MarioController.Instance.LoadMario();
            UIController.Instance.LoadLevel();
            DressController.Instance.LoadDressToCharacter();

            // Calls sequence start on finish:
            StartCoroutine(MoveMarioRight(5f, 1.7f, 0.7f));
        }
        //if (state == GameState.WalkedIn)
        //{
        //    StartCoroutine(PostWalkInDelay());
        //}
        //if (state == GameState.ClothesDropped)
        //{
        //    SoundControllerScript.PlaySound("changing his clothes");
        //    allowMovement = true;
        //}
        //if (state == GameState.JumpFailed)
        //{
        //    allowMovement = false;
        //    StartCoroutine(PostFailDelay());
        //}
        //if (state == GameState.MarioFreaks)
        //{
        //    MarioController.Instance.mario.MarioFreaks();
        //}
        //if (state == GameState.DoneFreaking)
        //{
        //    StartCoroutine(PostFreakDelay());

        //}
        //if (state == GameState.BadControls)
        //{
        //  MarioController.Instance.FlipControls();
        //    allowMovement = true;
        //}
        if (state == GameState.EndScreen)
        {
            SoundControllerScript.StopSound();
            UIController.Instance.LoadEndScreen();
        }
        currentGameState = state;
    }
コード例 #4
0
 public void SetGameState(GameState state)
 {
     if (state == GameState.WelcomeScreen)
     {
         SoundControllerScript.PlaySound("background sound");
         UIController.Instance.ShowTitleScreen();
     }
     if (state == GameState.DressupScreen)
     {
         //     TextController.Instance.ShowTextPanel(state);
         UIController.Instance.ShowDressUpScreen();
     }
     if (state == GameState.PowerupScreen)
     {
         UIController.Instance.ShowPowerUpScreen();
     }
     if (state == GameState.LevelOpen)
     {
         LevelController.Instance.LoadLevel();
     }
     if (state == GameState.WalkedIn)
     {
         StartCoroutine(PostWalkInDelay());
     }
     if (state == GameState.ClothesDropped)
     {
         SoundControllerScript.PlaySound("changing his clothes");
         allowMovement = true;
     }
     if (state == GameState.JumpFailed)
     {
         allowMovement = false;
         StartCoroutine(PostFailDelay());
     }
     if (state == GameState.MarioFreaks)
     {
         MarioController.Instance.misterMario.MarioFreaks();
     }
     if (state == GameState.DoneFreaking)
     {
         StartCoroutine(PostFreakDelay());
     }
     if (state == GameState.BadControls)
     {
         MarioController.Instance.FlipControls();
         allowMovement = true;
     }
     if (state == GameState.JumpedAround)
     {
         allowMovement = false;
         MarioController.Instance.misterMario.MarioWalksOff();
     }
     if (state == GameState.EndScreen)
     {
         UIController.Instance.LoadEndScreen();
     }
     currentGameState = state;
 }
コード例 #5
0
    void Start()
    {
        GameObject gameController = GameObject.Find("GameController");

        scoreKeeper = (ScoreKeeper)gameController.GetComponent(typeof(ScoreKeeper));
        GameObject soundControllerObj = GameObject.Find("SoundController");

        soundController = (SoundControllerScript)soundControllerObj.GetComponent(typeof(SoundControllerScript));
    }
コード例 #6
0
 // Start is called before the first frame update
 void Start()
 {
     mTransform      = GetComponent <Transform>();
     soundEvent      = FMODUnity.RuntimeManager.CreateInstance(sound);
     soundController = GameObject.Find("SoundController").GetComponent <SoundControllerScript>();
     bulbs           = new List <SpriteRenderer>();
     resetBulbs();
     createBulbs();
     StartCoroutine(SequenceSoundEmit());
     RandomizeBulbs();
 }
コード例 #7
0
    IEnumerator FadeBlackOut(float aValue, float aTime)
    {
        SoundControllerScript.PlaySound("FINAL sound - end scene beach");
        float alpha = blackPanel.GetComponent <Image>().color.a;

        for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
        {
            Color newColor = new Color(0, 0, 0, Mathf.Lerp(alpha, aValue, t));
            blackPanel.GetComponent <Image>().color = newColor;
            yield return(null);
        }
    }
コード例 #8
0
    // Use this for initialization
    void Awake()
    {
        if (instance)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }

        gameObject.AddComponent <AudioSource>();
        musicSource = gameObject.GetComponent <AudioSource>();

        SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
    }
コード例 #9
0
    private void Update()
    {
        if (Input.GetKeyDown("i") && titleScreenUpdated == false)
        {
            SoundControllerScript.PlaySound("mario-woohoo");
            buttonPressedI = true;
            UpdateTitleScreen();
        }
        else if (Input.GetKeyDown("l") && titleScreenUpdated == false)
        {
            buttonPressedL = true;
            UpdateTitleScreen();
        }
        if (titleScreenUpdated == true)
        {
            if (buttonPressedI == true)
            {
                if (Input.GetKeyDown("l"))
                {
                    ClearTitleScreen();
                }
            }
            if (buttonPressedL == true)
            {
                if (Input.GetKeyDown("i"))
                {
                    ClearTitleScreen();
                }
            }
        }

        if (Input.GetKeyDown("c"))
        {
            //   LoadEndScreen();
            //  TextController.Instance.CallCustomTextForSeconds("ooiiodssd that s ahshhds  dsajdsaj ", 6f);
            //  SoundControllerScript.StopSound();
        }
    }
コード例 #10
0
 public void SetImageTextSecondJumpFail()
 {
     SoundControllerScript.PlaySound("text");
     mario.textHolder.SetActive(true);
     mario.textHolder.GetComponent <SpriteRenderer>().sprite = textImagePostJumpFail2;
 }
コード例 #11
0
 public void SetImageTextPreSpin()
 {
     SoundControllerScript.PlaySound("text");
     mario.textHolder.SetActive(true);
     mario.textHolder.GetComponent <SpriteRenderer>().sprite = textImagePreSpin;
 }
コード例 #12
0
 void Awake ()
 {
     _currentTrack = 1;
     _instance = this;
 }
コード例 #13
0
 void GrabCoin()
 {
     hasCoin = true;
     UIController.Instance.coin.SetActive(false);
     SoundControllerScript.PlaySound("coin");
 }
コード例 #14
0
    void OnEnable()
    {
        GameObject soundControllerObj = GameObject.Find("SoundController");

        soundController = (SoundControllerScript)soundControllerObj.GetComponent(typeof(SoundControllerScript));
    }
コード例 #15
0
 public void CallCustomTextForSeconds(string str, float seconds)
 {
     SoundControllerScript.PlaySound("text");
     mario.SetCustomText(str);
     mario.StartCoroutine(mario.ClearTextAfterSeconds(seconds));
 }
コード例 #16
0
    private void Update()
    {
        float moveInput = 0;

        if (GameController.Instance.allowMovement == true)
        {
            if (controlsInverted == false)
            {
                moveInput = Input.GetAxisRaw("Horizontal");
            }
            else
            {
                moveInput = -Input.GetAxisRaw("Horizontal");
            }
        }


        if (moveInput < 0)
        {
            gameObject.GetComponent <Mario>().skeletonSprite.GetComponent <SpriteRenderer>().flipX = true;
            gameObject.GetComponent <Mario>().headSprite.flipX = true;
            gameObject.GetComponent <Mario>().bodySprite.flipX = true;
            gameObject.GetComponent <Mario>().feetSprite.flipX = true;
        }
        else
        {
            gameObject.GetComponent <Mario>().skeletonSprite.GetComponent <SpriteRenderer>().flipX = false;
            gameObject.GetComponent <Mario>().headSprite.flipX = false;
            gameObject.GetComponent <Mario>().bodySprite.flipX = false;
            gameObject.GetComponent <Mario>().feetSprite.flipX = false;
        }

        if (grounded)
        {
            velocity.y = 0;

            if (Input.GetButtonDown("Jump"))
            {
                if (GameController.Instance.allowMovement == true)
                {
                    SoundControllerScript.PlaySound("jump");
                    // Calculate the velocity required to achieve the target jump height.
                    if (jumpsLimited == true)
                    {
                        jumpHeight *= 0.8f;
                        MarioController.Instance.marioAI.CallTrigger(MarioAI.Trigger.JumpEverShorter);
                    }
                    velocity.y = Mathf.Sqrt(2 * jumpHeight * Mathf.Abs(Physics2D.gravity.y));
                }
            }
        }

        float acceleration = grounded ? walkAcceleration : airAcceleration;
        float deceleration = grounded ? groundDeceleration : 0;

        if (moveInput != 0)
        {
            velocity.x = Mathf.MoveTowards(velocity.x, speed * moveInput, acceleration * Time.deltaTime);
        }
        else
        {
            velocity.x = Mathf.MoveTowards(velocity.x, 0, deceleration * Time.deltaTime);
        }

        velocity.y += Physics2D.gravity.y * Time.deltaTime;

        // if no button pressed and grounded are both true then don't
        if ((moveInput == 0 && grounded) == false)
        {
            transform.Translate(velocity * Time.deltaTime);
        }


        grounded = false;

        // Retrieve all colliders we have intersected after velocity has been applied.
        Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, boxCollider.size, 0);

        foreach (Collider2D hit in hits)
        {
            // Ignore our own collider.
            if (hit == boxCollider)
            {
                continue;
            }

            ColliderDistance2D colliderDistance = hit.Distance(boxCollider);

            // Ensure that we are still overlapping this collider.
            // The overlap may no longer exist due to another intersected collider
            // pushing us out of this one.
            if (colliderDistance.isOverlapped)
            {
                transform.Translate(colliderDistance.pointA - colliderDistance.pointB);

                // If we intersect an object beneath us, set grounded to true.
                if (Vector2.Angle(colliderDistance.normal, Vector2.up) < 90 && velocity.y < 0)
                {
                    grounded = true;
                }
            }
        }
    }
コード例 #17
0
 void RemoveFeet()
 {
     SoundControllerScript.PlaySound("changing his clothes");
     feetRemoved = true;
     StartCoroutine(FlyFeet());
 }