FadeIn() публичный статический Метод

public static FadeIn ( float time = 2f ) : void
time float
Результат void
Пример #1
0
    //-------------------------------------------------------------------------
    //                        CLASS METHOD DEFINITIONS
    //-------------------------------------------------------------------------
    void Awake()
    {
        // position the again button
        AgainButton.SetScale(0.25f);
        ExitButton.SetScale(0.25f);

        float off = 50;

        Vector2 pos = new Vector2();
        pos.x = Screen.width/2.0f - (AgainButton.GetWidth() + ExitButton.GetWidth() + 50)/2.0f;
        pos.y = 40.0f;

        AgainButton.SetPosition(pos);

        // position the exit button

        pos.x = Screen.width/2.0f + (ExitButton.GetWidth())/2.0f;
        pos.y = 40.0f;

        ExitButton.SetPosition(pos);

        // set the fading parameters for the beginning fade in of the game
        // over screen
        fader_ = new Fader(0.0f, 3.0f, 3.0f);
        fader_.FadeIn();

        // set the initial update state to fade in
        update_ = fadeIn;
    }
Пример #2
0
    private IEnumerator LoadScene(int sceneIndex, string text = null)
    {
        Fader fader = FindObjectOfType <Fader>();

        if (text != null)
        {
            var restartMessage = GameObject.Find("RestartMessage").GetComponentInChildren <TextMeshProUGUI>();
            restartMessage.text = text;
        }

        DontDestroyOnLoad(gameObject);

        yield return(fader.FadeOut(fadeOutTime));

        yield return(SceneManager.LoadSceneAsync(sceneIndex));

        yield return(new WaitForSeconds(waitTime));

        yield return(fader.FadeIn(fadeInTime));
    }
Пример #3
0
        public static void EndDream(float fadeInSpeed = 5F)
        {
            if (!CurrentlyInDream)
            {
                return;
            }

            CurrentlyInDream = false;

            DreamCleanup();

            Payload.DreamEnded = true;

            AddGraphSquare(StaticityAccumulator, HappinessAccumulator);

            Fader.FadeIn(Color.black, fadeInSpeed, () =>
            {
                SceneManager.LoadScene("titlescreen");
                GameSettings.SetCursorViewState(true);
            });
        }
Пример #4
0
    public void Awake()
    {
        if (mFader == null)
        {
            mFader = FindObjectOfType <Fader>();
        }

        if (GlobalData.SaveExists())
        {
            mSaveExistsGroup.SetActive(true);
            mFirstTimeGroup.SetActive(false);
        }
        else
        {
            mSaveExistsGroup.SetActive(false);
            mFirstTimeGroup.SetActive(true);
        }

        mFader.FadeIn();
        playTitleTheme();
    }
Пример #5
0
    IEnumerator Transition()
    {
        DontDestroyOnLoad(gameObject);

        Fader         fader         = FindObjectOfType <Fader>();
        SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

        //remove player's control to escape of race condition
        Player playerMovement = GameObject.FindWithTag("Player").GetComponent <Player>();

        playerMovement.enabled = false;

        yield return(fader.FadeOut(fadeOutTime));

        savingWrapper.Save();

        yield return(SceneManager.LoadSceneAsync(nextScene));

        //remove player's control in a new scene
        Player newPlayerMovement = GameObject.FindWithTag("Player").GetComponent <Player>();

        newPlayerMovement.enabled = false;

        savingWrapper.Load();

        Portal otherPortal = GetOtherPortal();

        PlayerUpdate(otherPortal);

        savingWrapper.Save();

        yield return(new WaitForSeconds(fadeWaitTime));

        fader.FadeIn(fadeInTime);

        //return control
        newPlayerMovement.enabled = true;
        Destroy(gameObject);
    }
Пример #6
0
        /// <summary>
        /// Exits the dream without saving state.
        /// Used for quitting from pause menu.
        /// </summary>
        public static void ExitDream()
        {
            if (!CurrentlyInDream)
            {
                return;
            }

            CurrentlyInDream = false;

            DreamCleanup();

            Payload.ClearPayload();

            GameSettings.PauseGame(false);

            GameSettings.SetCursorViewState(true);

            Fader.FadeIn(Color.black, 1F, () =>
            {
                SceneManager.LoadScene("titlescreen");
                Fader.FadeOut(0.5F);
            });
        }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        btnFadeStart.onClick.AddListener(() => {
            // フェードカラーを指定
            Fader.SetFadeColor(Color.black);

            // ボタンが押されたら、フェードアウト ー> フェードイン
            Fader.FadeOut(1.0f, () => {
                Debug.Log("フェードアウト終了");
                // フェードアウトが終了したら、フェードイン
                Fader.FadeIn(1.0f, () => {
                    // フェードインが終了
                    Debug.Log("フェードイン終了");
                });
            });
        });


        btnSwitchScene.onClick.AddListener(() => {
            // ボタンが押されたら、フェードアウトして、次のシーンへ切り替える
            Fader.SwitchScene(NextScene);
        });
    }
Пример #8
0
    //-------------------------------------------------------------------------
    private void sceneIntro()
    {
        // update intro bg fader and fade the bg accordingly; UGLY
        introBgFader_.Update(Time.deltaTime);
        IntroBackground.renderer.material.color =
            new Color(0.0f, 0.0f, 0.0f, introBgFader_.GetAlpha());

        // if the time is greater then 8.0 sec start playing the intro
        // dialog
        if (time_ > 8.0f && !hasIntroDialogStarted_)
        {
            hasIntroDialogStarted_ = true;
            Color yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);

            string text1 = "You awaken with a start as the guard slams the cold iron bars shut.";
            string text2 = " He regards you with a look of pity and disgust.";

            DialogField.Display(text1, yellow, 0.0f, 5.0f);
            DialogField.Display(text2, yellow, 5.5f, 8.5f);

            // fade in bgm
            bgmFader_.FadeIn();
        }

        // fade in the actaul scene (fade out intro background)
        if (time_ > 14.0f)
        {
            introBgFader_.FadeOut();
        }

        // after 17 sec switch to guard dialog state
        if (time_ > 20.0f)
        {
            IntroBackground.SetActive(false);
            updateHandler_ = guardDialog;
        }
    }
    IEnumerator MainRoutine()
    {
        DialogueManager.Instance().StartDialogue(fadeDialogue);
        yield return(new WaitUntil(() => DialogueManager.Instance().canvasObj.activeSelf == false));


        objBlack.SetActive(false);
        fader.FadeIn();

        DialogueManager.Instance().StartDialogue(beforeDialogue);
        yield return(new WaitUntil(() => DialogueManager.Instance().canvasObj.activeSelf == false));

        objAfterCG.SetActive(true);
        DialogueManager.Instance().StartDialogue(afterDialogue);
        yield return(new WaitUntil(() => DialogueManager.Instance().canvasObj.activeSelf == false));


        fader.FadeOut();

        yield return(new WaitForSeconds(3.0f));

        SceneManager.LoadScene("Ending_Suicide");
        yield break;
    }
Пример #10
0
    // Fade the item indicator as appropriate
    void Update()
    {
        float dist = Vector3.Distance(transform.position, GameManager.Player.transform.position);

        if (dist < IndicatorFadeDistance)
        {
            if (dist > _midFadeDistance)
            {
                _itemIndicator.FadeIn(IndicatorFadeSpeed, false);
                _itemSign.FadeIn(IndicatorFadeSpeed, false);
            }
            else
            {
                Color currColor = _itemIndicator.GetComponent <Renderer>().material.color;
                float alpha     = 0.3f + 0.7f * ((dist - IndicatorFadeDistance2) / _midFadeDistance);
                _itemIndicator.GetComponent <Renderer>().material.color = new Color(currColor.r, currColor.g, currColor.b, Mathf.Max(alpha, 0.3f));
            }
        }
        else
        {
            _itemIndicator.FadeOut(IndicatorFadeSpeed, false);
            _itemSign.FadeOut(IndicatorFadeSpeed, false);
        }
    }
Пример #11
0
    IEnumerator CutScene()
    {
        Debug.Log("CutSceneStarted");
        var vrb = _victim.GetComponent <Rigidbody2D>();
        var prb = _player.GetComponent <Rigidbody2D>();

        _player.SendMessage("StartCutscene");

        _cam.SendMessage("ChangeTarget", _target);

        //Glue talks
        _source.PlayOneShot(_gueSound);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "A human, here in this realm?\nHow funny.", 0.1f)));

        yield return(new WaitForSeconds(1f));

        _source.PlayOneShot(_gueSound);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Your end is near, mortal.", 0.1f)));

        yield return(new WaitForSeconds(1f));

        _victim.SendMessage("DisplayText", "");
        //Glue attacks
        _music.SetActive(true);
        vrb.MovePosition(new Vector2(vrb.position.x - 0.95f, vrb.position.y));
        _source.PlayOneShot(_gueAttack);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahh!", 0.01f)));

        yield return(new WaitForSeconds(0.5f));

        //Cherry goes back
        _cam.SendMessage("ChangeTarget", _player.transform);
        prb.MovePosition(new Vector2(prb.position.x - 0.1f, prb.position.y));
        _player.SendMessage("DisplayText", "");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Yes, you are going to die here!", 0.05f)));

        yield return(new WaitForSeconds(1f));

        _victim.SendMessage("DisplayText", "");
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "No...no...", 0.15f)));

        yield return(new WaitForSeconds(1f));

        _isActive = true;
        //Decision Time
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Flee (Q)?\nFight (E)?")));

        while (!_isDecided)
        {
            yield return(null);
        }
        _music.SetActive(false);
        if (_choosedAttack)
        {
            //Cherry Attacks
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I don't want to die!!!", 0.01f)));

            prb.MovePosition(new Vector2(prb.position.x + 0.15f, prb.position.y));
            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Huah! Die! Die!", 0.01f)));

            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            //Mark as Human
            _victim.GetComponent <SpriteRenderer>().sprite = _markHuman;
            _player.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Wha..? Cher...?", 0.1f)));

            yield return(new WaitForSeconds(0.25f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Ahh..uhhu..", 0.1f)));

            yield return(new WaitForSeconds(0.25f));

            _victim.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Mark?!", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            //Mark to Bloody Glue
            _victim.SendMessage("DisplayText", "");
            _victim.GetComponent <SpriteRenderer>().sprite = _markGlue;
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahhhh! Die!", 0.1f)));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(new WaitForSeconds(0.5f));

            _source.PlayOneShot(_cherryOnMark);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(_flasherRed.Flash()));

            _player.SendMessage("DisplayText", "");
            //Fade Out
            //yield return new WaitForSeconds(0.5f);
            _source.PlayOneShot(_markScream);
            yield return(StartCoroutine(_faderRed.FadeOut()));

            _victim.GetComponent <SpriteRenderer>().sprite = _blood;
            vrb.MovePosition(new Vector2(vrb.position.x + 0.3f, vrb.position.y - 0.2f));
            yield return(new WaitForSeconds(3f));

            yield return(StartCoroutine(_faderRed.FadeIn()));

            // yield return StartCoroutine(_faderRed.FadeIn());
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "It's...it's over...?", 0.25f)));

            yield return(new WaitForSeconds(1f));

            yield return(StartCoroutine(_flasherWhite.Flash()));

            _player.SendMessage("DisplayText", "");
            Debug.Log("CutSceneEnded");
            _isActive = false;
            _player.SendMessage("EndCutscene");
            Destroy(gameObject);
        }
        else
        {
            //Cherry dies
            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I am scared.", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I want to run.", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "But my legs are frozen!", 0.01f)));

            yield return(new WaitForSeconds(0.5f));

            _player.SendMessage("DisplayText", "");
            yield return(StartCoroutine(CutsceneUtility.ShowText(_victim, "Muhaha", 0.1f)));

            yield return(new WaitForSeconds(0.5f));

            _victim.SendMessage("DisplayText", "");
            vrb.MovePosition(new Vector2(vrb.position.x - 0.15f, vrb.position.y));
            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahhh.")));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(_flasherRed.Flash()));

            _source.PlayOneShot(_gueAttack);
            yield return(StartCoroutine(_flasherRed.Flash()));

            yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Uhhh.")));

            _player.SendMessage("DisplayText", "");
            //Fade Out
            _source.PlayOneShot(_cherryScream);
            yield return(StartCoroutine(_faderRed.FadeOut()));

            _cam.SendMessage("ChangeTarget", _textScreen);
            yield return(new WaitForSeconds(2f));

            _endText.SetActive(true);
            yield return(StartCoroutine(_faderRed.FadeIn()));

            _restart = true;
        }
    }
Пример #12
0
 private void GoToOnePlayerMode()
 {
     Fader.FadeIn(2f, "CharacterSelect");
 }
Пример #13
0
 public IObservable <Unit> AnimateIn()
 {
     return(Fader.FadeIn().OnCompleteAsObservable());
 }
Пример #14
0
 void Start()
 {
     MainText.AddToDisplayQueue("Lost within the rainstorm, I search for a Guiding Light");
     MainText.DisplayText();
     Fader.FadeIn();
 }
Пример #15
0
    IEnumerator NextEventSetting()
    {
        // 열쇠가 안맞는 대사 출력
        DialogueManager.Instance().StartDialogue(dialogue1);
        yield return(new WaitUntil(() => DialogueManager.Instance().canvasObj.activeSelf == false));

        // 페이드 아웃
        fader.FadeOut();

        var n = FindObjectOfType <Note>();

        if (n)
        {
            n.RemoveAllMission();
        }

        yield return(new WaitForSeconds(1.0f));

        // 캐릭터 우측 동아리실로 좌표 이동
        playerCharacter.transform.position = new Vector3(63.7f, -7.0f, 0);
        // 우측방향, 앉기 세팅
        playerCharacter.transform.localScale = new Vector3(1, 1, 1);
        playerCharacter.GetComponent <CharacterMover>().myAnimator.SetBool("IsSit", true);
        FindObjectOfType <CameraSystem>().changeViewport();

        // 불+연기 세팅
        objEventFire.SetActive(true);

        // 지하 남자화장실 문 트리거 제거. 진압 트리거랑 겹치는 현상 대비
        //ToiletDoor.GetComponent<ToiletDoorInteraction>().enabled = false;
        Destroy(ToiletDoor.GetComponent <ToiletDoorInteraction>());
        Destroy(ToiletDoor.GetComponent <Collider2D>());
        //FireEx.GetComponent<FireExinguisher>().enabled = false;
        Destroy(FireEx.GetComponent <FireExinguisher>());
        FireEx.GetComponent <ItemSystem>().enabled = true;

        // 화재 발견 트리거 활성화
        objFireFocus.SetActive(true);

        // 화재 진압 트리거 활성화
        objFireFight.SetActive(true);

        // BGM 교체
        BGM.GetComponent <AudioSource>().clip = AlarmBGM;
        BGM.GetComponent <AudioSource>().Play();

        // 애니메이터 교체
        playerAnimator.runtimeAnimatorController = changeAnimator;



        yield return(new WaitForSeconds(2.0f));

        fader.FadeIn();


        // 뭔가 이상함을 느낀 대사
        DialogueManager.Instance().StartDialogue(dialogue2);
        yield return(new WaitUntil(() => DialogueManager.Instance().canvasObj.activeSelf == false));

        // 기립 상태
        playerCharacter.GetComponent <CharacterMover>().myAnimator.SetBool("IsSit", false);

        yield break;
    }
Пример #16
0
    private void UpdateVignettes()
    {
        // Turn the vignettes on as appropriate
        bool playerDead = GameManager.Player.IsDead;

        _hurtVignetteAlpha.On   = playerDead || _playerHeartBox.HitPoints != _playerHeartBox.MaxHitPoints;
        _searchVignetteAlpha.On = !playerDead && GameManager.AI.EnemiesSearching > 0 && GameManager.AI.EnemiesChasing == 0;
        _chaseVignetteAlpha.On  = !playerDead && GameManager.AI.EnemiesChasing > 0;

        // Don't anything extra if the player is dead
        if (playerDead)
        {
            return;
        }

        // try to flash if needed
        if ((GameManager.AI.EnemiesChasing > 0 || GameManager.AI.EnemiesSearching > 0))
        {
            float alpha         = _flashAlpha.GetComponent <Renderer>().material.color.a;
            float flashAlphaDir = 0;
            if (alpha >= 0.95f)
            {
                flashAlphaDir = -1;
            }
            else if (alpha <= 0.2)
            {
                flashAlphaDir = 1;
            }

            if (flashAlphaDir == 1 && !_hasFlashed)
            {
                _flashAlpha.On = true;
            }
            else if (flashAlphaDir == -1)
            {
                _flashAlpha.On = false;
                _hasFlashed    = true;
            }
        }
        if (GameManager.AI.EnemiesChasing == 0 && GameManager.AI.EnemiesSearching == 0)
        {
            _flashAlpha.On = false;
            if (_flashAlpha.GetComponent <Renderer>().material.color.a < 0.1f)
            {
                _hasFlashed = false;
            }
        }
        else if (_hasFlashed)
        {
            _flashAlpha.On = false;
        }

        bool canStealthKill = GameManager.Player is NewmanAnimator && ((NewmanAnimator)GameManager.Player).StealthKillable != null && GameManager.Inventory.CanWeaponStealthKill;
        bool vignetteActive = _stealthKillVignette.IsFadingIn || _stealthKillVignette.IsStaying;

        if (canStealthKill && !vignetteActive)
        {
            _stealthKillVignette.FadeIn();
            _stealthKillVignette1.FadeIn();
            _stealthKillVignette2.FadeIn();
        }
        else if (!canStealthKill && vignetteActive)
        {
            _stealthKillVignette.FadeOut();
            _stealthKillVignette1.FadeOut();
            _stealthKillVignette2.FadeOut();
        }
    }
Пример #17
0
    public static void SetPlanet(GameObject planet)
    {
        return;

        if (levelObjects == null)
        {
            levelObjects = new List <GameObject>();
        }

        if (planet != currentPlanet)
        {
            // Update planet reference
            currentPlanet = planet;

            // Clear old temp gameobjects
            foreach (GameObject obj in levelObjects)
            {
                if (obj != null)
                {
                    Destroy(obj);
                }
            }

            levelObjects.Clear();
            closest   = null;
            closestId = -1;

            if (currentPlanet != null)
            {
                currentWorld  = planet.name;
                startRotation = currentPlanet.transform.rotation.eulerAngles.y;
                rotation      = new Vector3(0, startRotation, 0);

                // Add a play button.
                //playLevel = (GameObject)Instantiate(Resources.Load("PlayLevel", typeof(GameObject)));
                //playLevel.transform.parent = currentPlanet.transform;
                //Vector3 playLevelPos = currentPlanet.transform.position;
                //playLevelPos.x += 2.0f;
                //playLevel.transform.position = playLevelPos;

                // Get world number
                Regex exp   = new Regex("World(?<world>.*)");
                Match match = exp.Match(currentWorld);
                int   world = 0;
                int.TryParse(match.Groups["world"].ToString(), out world);

                // Load new levels
                levels   = currentPlanet.GetComponent <Levels>();
                maxLevel = (SaveManager.save.worldUnlocked > world ? levels.levels.Length : -1);
                if (maxLevel < 0)
                {
                    maxLevel = SaveManager.save.levelUnlocked;
                }

                if (maxLevel > levels.levels.Length)
                {
                    maxLevel = levels.levels.Length;
                }

                // Get direction from planet to camera
                Vector3 camDir = currentPlanet.transform.position - Camera.main.transform.position;
                camDir.Normalize();

                // Create gameobjects to represent levels
                rotationStep = 360.0f / levels.levels.Length;
                Vector3 offset = Vector3.forward * currentPlanet.GetComponent <Collider>().bounds.extents.z * 1.1f;

                for (int i = 0; i < levels.levels.Length; ++i)
                {
                    if (levels.levels[i].world > SaveManager.save.worldUnlocked ||
                        (levels.levels[i].world == SaveManager.save.worldUnlocked &&
                         levels.levels[i].number > SaveManager.save.levelUnlocked))
                    {
                        continue;
                    }

                    // Rotate offset
                    float      thisRotation   = rotationStep * -i + INITIAL_ROTATION;
                    Quaternion thisQuaternion = Quaternion.Euler(0, thisRotation, 0);
                    Vector3    thisOffset     = thisQuaternion * offset;

                    // Create object
                    GameObject level = GameObject.CreatePrimitive(PrimitiveType.Plane);
                    level.AddComponent <Billboard>();
                    level.transform.rotation  *= Quaternion.Euler(90, 0, 0);
                    level.transform.localScale = 0.01f * Vector3.one;
                    level.tag = "Planet";
                    level.GetComponent <Renderer>().material = instance.levelMaterial;
                    levelObjects.Add(level);

                    // Initialise level object
                    level.name             = levels.levels[i].name;
                    level.transform.parent = currentPlanet.transform;
                    level.GetComponent <Renderer>().material.shader = Shader.Find("Transparent/Diffuse");
                    level.GetComponent <Renderer>().material.color  = new Color(1.0f, 1.0f, 1.0f, 0.1f);

                    // Fade object in
                    Fader fader = level.AddComponent <Fader>();
                    fader.fadeRate = 2.0f;
                    fader.FadeIn();

                    // Offset object around planet
                    level.transform.position = currentPlanet.transform.position - thisOffset;
                }
            }
        }
    }
Пример #18
0
 public void Onclick(string name)
 {
     SoundManager.PlayS(gameObject);
     Fader.FadeIn(2f, name);
 }
Пример #19
0
 void OnEnable()
 {
     fader.FadeIn();
     Camera.main.transform.localRotation = startCamPos.localRotation;
 }
Пример #20
0
        //TODO: Actually load from file
        public static State Load(string fileName, Fader fader)
        {
            fader.Timestep = 0.1f;
            fader.FadeIn();

            //disabled because otherwise it gets annoying to run the game while listening to music and stuff
            //Resource<Sound>.Get("BGM/HonorForAll", "mp3").IsLooped = true;
            //Resource<Sound>.Get("BGM/HonorForAll", "mp3").Play();

            string file = Path.Combine("Content/Maps/", fileName);
            var level = new LoadedLevel(new FileStream(file, FileMode.Open));

            var chunk = new Chunk(level.Width, level.Height);
            var camera = new Camera();

            var layers = level.Layers;
            var objectgroups = level.ObjectGroups;

            foreach (var layer in layers)
            {
                int[] tiles = layer.Value.Tiles;
                int z = int.Parse(layer.Key);

                for (int x = 0; x < chunk.Width; x++)
                    for (int y = 0; y < chunk.Height; y++)
                    {
                        Texture2D tex = Resource<Texture2D>.Get(level.Tileset.Image);

                        int id = tiles[x + y * chunk.Width];

                        //Texture coordinates

                        int tx = (int)(id * 32 / 1.5); //why does this work
                        int ty = 0;
                        //int tx = (id % (tex.Width / 32)) * 32;
                        //int ty = (id / (tex.Width / 32)) * 32;
                        int tw = 32;
                        int th = 32;

                        var tile = new Chunk.Tile(tex, tx, ty, tw, th);

                        Dictionary<string, string> properties;
                        if (level.Tileset.TileData.TryGetValue(id, out properties)) //If id isn't found, that means the tile id has no properties defined
                            foreach (var property in properties)
                                tile.AddProperty(property.Key, property.Value); //If id IS found, set all properties

                        tile.AddProperty("FrictionMultiplier", 1);

                        chunk.Set(x, y, z, tile);
                    }
            }

            Physical player = null; //This gets set down here

            foreach (var objectgroup in objectgroups)
            {
                var objects = objectgroup.Value.Entities;
                int z = int.Parse(objectgroup.Key); //TODO: Does this even work too?

                foreach (var obj in objects)
                {
                    string name = obj.Name;

                    bool isPassable = false;
                    bool isRamp = false;

                    if (obj.Properties != null)
                    {
                        isRamp = bool.Parse(obj.Properties["IsRamp"]);
                        isPassable = bool.Parse(obj.Properties["IsPassable"]);
                    }

                    int x = (int)(obj.Position.X / 32f) - 0; //This is...
                    int y = (int)(obj.Position.Y / 32f) - 1; //Pretty wonky.

                    if (isRamp) //If it's a ramp, we don't create an entity at all, but a tile!
                    {
                        Texture2D tex = Resource<Texture2D>.Get(level.Tileset.Image);

                        int id = obj.GID;

                        //Texture coordinates

                        int tx = (int)(id * 16); //why does this work
                        int ty = 0;
                        int tw = 32;
                        int th = 32;

                        var tile = new Chunk.Tile(tex, tx, ty, tw, th);

                        foreach (var property in obj.Properties)
                            tile.AddProperty(property.Key, property.Value);

                        chunk.Set(x, y, z, tile);
                    }
                    else
                    {
                        Physical entity;

                        if (name == "player.Start") //TODO: Maybe make these "hardcoded" entities a lookup table of prefabs?
                        {
                            entity = new Physical(Resource<Texture2D>.Get("debug-entity"), x, y, z);
                            player = entity;
                        }
                        else
                            entity = new Physical(Resource<Texture2D>.Get("debug-entity"), //TODO: Read texture from entity
                                                  x, y, z,
                                                  isPassable);

                        //TODO: For now, entities don't seem to have a way to set properties...

                        chunk.Add(entity);
                    }
                }
            }

            for (int i = 0; i < 0; i++) //LOOK AT ALL THOSE DUDES HAVING FUN
            {
                var otherDude = new Physical(Resource<Texture2D>.Get("debug-entity"), RandomHelper.Range(3, 16-3), RandomHelper.Range(3, 16-3), 0);

                float time = RandomHelper.Range();
                otherDude.Tick += f =>
                    {
                        time += f * 0.25f;
                        otherDude.Move((int)Math.Round(Math.Cos(time * Math.PI * 2)), (int)Math.Round(Math.Sin(time * Math.PI * 2)), 100 * f);
                    };

                chunk.Add(otherDude);
            }

            if (player == null)
                throw new Exception("Well, well, well. Looks like SOMEONE forgot to put a player.Start in the level. Have fun with all your NullReferenceExceptions down here.");

            player.Tick += dt =>
                {
                    var k = Keyboard.GetState();

                    var move = Vector2.Zero;

                    foreach (var i in k.GetPressedKeys())
                    {
                        switch (i)
                        {
                            case Keys.W:
                                move.Y = -1;
                                break;
                            case Keys.S:
                                move.Y = 1;
                                break;
                            case Keys.A:
                                move.X = -1;
                                break;
                            case Keys.D:
                                move.X = 1;
                                break;
                            case Keys.LeftShift:
                                Console.WriteLine(player.Depth);
                                break;
                        }
                    }

                    if (move != Vector2.Zero) player.Move((int)move.X, (int)move.Y, 200 * dt);

                    camera.Position = player.CenterPosition + Vector2.One / 2; //Add (0.5, 0.5) to player position so we don't get shakyness (it works trust me DON'T REMOVE IT)
                };

            chunk.Add(player);

            return new State(chunk, camera) { Player = player };
        }
    private IEnumerator EndGame()
    {
        yield return(fader.FadeIn(0.3f));

        gameOverCanvas.SetActive(true);
    }
Пример #22
0
    //-------------------------------------------------------------------------
    void Update()
    {
        // update time
        time_ += Time.deltaTime;

        // update the fader
        buttonFader_.Update(Time.deltaTime);
        backgFader_.Update(Time.deltaTime);
        musicFader_.Update(Time.deltaTime);

        // fade buttons in after ...
        if (time_ > 8.1f && !haveButtonsFadedIn_)
        {
            haveButtonsFadedIn_ = true;
            buttonFader_.FadeIn();
        }

        // if buttons are fully blended in set them clickable
        // otherwise set them non clickable
        if (StartButton.GetAlpha() == 1.0f)
        {
            StartButton.SetIsClickable(true);
        }

        // if buttons are fully blended in set them clickable
        // otherwise set them non clickable
        if (ExitButton.GetAlpha() == 1.0f)
        {
            ExitButton.SetIsClickable(true);
        }

        // if the start button was pressed (shallExitMM) and the background and
        // buttons are blended out load the intro
        if (BackgroundTex.GetAlpha() == 0.0f &&
            buttonFader_.GetAlpha() == 0.0f &&
            shallExitMM_
            )
        {
            // Load intro
            Application.LoadLevel(2);
        }

        // update alpha values of the gui elements
        BackgroundTex.SetAlpha(backgFader_.GetAlpha());
        StartButton.SetAlpha(buttonFader_.GetAlpha());
        ExitButton.SetAlpha(buttonFader_.GetAlpha());

        // update volume
        BackgroundMusic.SetVolume(musicFader_.GetAlpha());

        if (StartButton.IsPressed())
        {
            shallExitMM_ = true;
            StartButton.SetIsClickable(false);
            ExitButton.SetIsClickable(false);
            backgFader_.FadeOut();
            buttonFader_.FadeOut();
            musicFader_.FadeOut();
        }

        if (ExitButton.IsPressed())
        {
            Application.Quit();
        }
    }
Пример #23
0
 private void onActive()
 {
     fading = GetComponent <Fader>();
     fading.FadeIn();
 }
Пример #24
0
    private void KeyCtrl()
    {
        switch (mode)
        {
        case Mode.OnePlayer:
            if (blockManNames[0] == "nothing")
            {
                if (Dualshock4.LeftStick(0).x != 0 && keyTrigger[0] == false)
                {
                    if (Dualshock4.LeftStick(0).x > 0)
                    {
                        if (nowSelected[0] < buttons.Length - 1)
                        {
                            buttons[nowSelected[0]].Cancel();
                            buttons[nowSelected[0] + 1].Select(0, Color.red);
                            nowSelected[0] += 1;
                        }
                    }
                    else if (Dualshock4.LeftStick(0).x < 0)
                    {
                        if (nowSelected[0] > 0)
                        {
                            buttons[nowSelected[0]].Cancel();
                            buttons[nowSelected[0] - 1].Select(0, Color.red);
                            nowSelected[0] -= 1;
                        }
                    }
                    keyTrigger[0] = true;
                }
                else if (Dualshock4.LeftStick(0).x == 0)
                {
                    if (keyTrigger[0] == true)
                    {
                        keyTrigger[0] = false;
                    }
                }
                if (Dualshock4.CircleDown(0))
                {
                    blockManNames[0] = buttons[nowSelected[0]].blockManName;
                    buttons[nowSelected[0]].Decision(0, Color.red);
                }
            }
            break;

        case Mode.TwoPlayer:
            for (int i = 0; i < keyTrigger.Length; i++)
            {
                if (blockManNames[i] == "nothing")
                {
                    if (Dualshock4.LeftStick(i + 1).x != 0 && keyTrigger[i] == false)
                    {
                        if (Dualshock4.LeftStick(i + 1).x > 0)
                        {
                            if (nowSelected[i] < buttons.Length - 1)
                            {
                                if (buttons[nowSelected[i] + 1].selected != 0)
                                {
                                    if (nowSelected[i] + 2 <= buttons.Length - 1)
                                    {
                                        buttons[nowSelected[i]].Cancel();
                                        switch (i)
                                        {
                                        case 0:
                                            buttons[nowSelected[i] + 2].Select(i + 1, Color.red);
                                            break;

                                        case 1:
                                            buttons[nowSelected[i] + 2].Select(i + 1, Color.blue);
                                            break;
                                        }
                                        nowSelected[i] += 2;
                                    }
                                }
                                else
                                {
                                    buttons[nowSelected[i]].Cancel();
                                    switch (i)
                                    {
                                    case 0:
                                        buttons[nowSelected[i] + 1].Select(i + 1, Color.red);
                                        break;

                                    case 1:
                                        buttons[nowSelected[i] + 1].Select(i + 1, Color.blue);
                                        break;
                                    }
                                    nowSelected[i] += 1;
                                }
                            }
                        }
                        else if (Dualshock4.LeftStick(i + 1).x < 0)
                        {
                            if (nowSelected[i] > 0)
                            {
                                if (buttons[nowSelected[i] - 1].selected != 0)
                                {
                                    if (nowSelected[i] - 2 >= 0)
                                    {
                                        buttons[nowSelected[i]].Cancel();
                                        switch (i)
                                        {
                                        case 0:
                                            buttons[nowSelected[i] - 2].Select(i + 1, Color.red);
                                            break;

                                        case 1:
                                            buttons[nowSelected[i] - 2].Select(i + 1, Color.blue);
                                            break;
                                        }
                                        nowSelected[i] -= 2;
                                    }
                                }
                                else
                                {
                                    buttons[nowSelected[i]].Cancel();
                                    switch (i)
                                    {
                                    case 0:
                                        buttons[nowSelected[i] - 1].Select(i + 1, Color.red);
                                        break;

                                    case 1:
                                        buttons[nowSelected[i] - 1].Select(i + 1, Color.blue);
                                        break;
                                    }
                                    nowSelected[i] -= 1;
                                }
                            }
                        }
                        keyTrigger[i] = true;
                    }
                    else if (Dualshock4.LeftStick(i + 1).x == 0)
                    {
                        if (keyTrigger[i] == true)
                        {
                            keyTrigger[i] = false;
                        }
                    }
                    if (Dualshock4.CircleDown(i + 1))
                    {
                        blockManNames[i] = buttons[nowSelected[i]].blockManName;
                        switch (i)
                        {
                        case 0:
                            buttons[nowSelected[i]].Decision(i + 1, Color.red);
                            break;

                        case 1:
                            buttons[nowSelected[i]].Decision(i + 1, Color.blue);
                            break;
                        }
                    }
                }
            }
            break;
        }


        int num = 0;

        foreach (string name in blockManNames)
        {
            if (name != "nothing")
            {
                num += 1;
            }
        }
        if (num == blockManNames.Length)
        {
            nextText.SetActive(true);
            if (Dualshock4.OptionsDown(0))
            {
                switch (mode)
                {
                case Mode.OnePlayer:
                    nextSceneSingleton.NextScene1P(blockManNames[0]);
                    Fader.FadeIn(2f, "VsCOM");
                    break;

                case Mode.TwoPlayer:
                    nextSceneSingleton.NextScene2P(blockManNames[0], blockManNames[1]);
                    Fader.FadeIn(2f, "2P");
                    break;
                }
            }
        }
    }
Пример #25
0
    //private void Update()
    //{
    //    if (Input.GetKeyDown(KeyCode.Escape))
    //    {
    //        StopAllCoroutines();
    //        StartCoroutine(GoToMainMenu());
    //    }
    //}

    private IEnumerator GoToMainMenu()
    {
        yield return(_fader.FadeIn());

        _sceneChanger.ChangeScene("MainMenu");
    }
Пример #26
0
 private void GameStart()
 {
     audioSource.PlayOneShot(audioSource.clip);
     Fader.FadeIn(2f, "Main");
 }
Пример #27
0
    IEnumerator CutScene()
    {
        Debug.Log("CutSceneStarted");
        _player.SendMessage("StartCutscene");
        isActive = true;

        _player.transform.localScale = new Vector3(-1, 1, 1);
        yield return(new WaitForSeconds(0.5f));

        _cam.SendMessage("ChangeTarget", _target);
        yield return(new WaitForSeconds(2f));

        _cam.SendMessage("ChangeTarget", _player.transform);
        _player.transform.localScale = new Vector3(1, 1, 1);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "What was that?", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Did I see...him?", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Where am I, dawm it!", 0.1f)));

        yield return(new WaitForSeconds(0.5f));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ahh!")));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "My head still hurts...", 0.1f)));

        yield return(new WaitForSeconds(0.25f));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "!!")));

        _source.PlayOneShot(_headHurt);
        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(_flasherRed.Flash()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "I remember...")));

        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_player, "Ohnononono", 0.4f)));


        yield return(StartCoroutine(_fader.FadeOut()));

        _rainMusic.SetActive(false);
        _player.SendMessage("DisplayText", "");
        _cam.SendMessage("ChangeTarget", _textScreen.transform);
        yield return(new WaitForSeconds(1f));

        _music.SetActive(true);
        yield return(StartCoroutine(_fader.FadeIn()));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "Mark and I went out....\n" +
                                                             "We were going to party\n" +
                                                             "and party hard we did.\n" +
                                                             "I remember.\n" +
                                                             "Mark and I shared something.\n" +
                                                             "LSD? I'm not sure.\n", 0.15f)));

        yield return(new WaitForSeconds(2f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "But I know, I definitely know...\n" +
                                                             "That it is my head,\n" +
                                                             "messing with me...\n" +
                                                             "And that means...\n", 0.15f)));

        _music.SetActive(false);
        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "I killed Mark.", 0.5f)));

        yield return(new WaitForSeconds(2f));

        yield return(StartCoroutine(CutsceneUtility.ShowText(_textScreen, "My mind went blank.\n" +
                                                             "My mind tricked me,\n" +
                                                             "made me do the most monstrous\n" +
                                                             "thing a human being can do.\n" +
                                                             "To kill.\n" +
                                                             "I am a monster, forever.", 0.15f)));

        yield return(new WaitForSeconds(2f));

        _textScreen.SendMessage("DisplayText", "");
        _music.SetActive(false);
        _endMessage.SetActive(true);

        yield return(StartCoroutine(_flasherWhite.Flash()));

        Debug.Log("CutSceneEnded");
        isActive = false;
    }
Пример #28
0
    private IEnumerator ResetGameState()
    {
        yield return(StartCoroutine(fader.FadeIn()));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
Пример #29
0
 private void GoToTwoPlayerMode()
 {
     Fader.FadeIn(2f, "CharacterSelect2P");
 }
Пример #30
0
 //-------------------------------------------------------------------------
 //                          METHOD DEFINITIONS
 //-------------------------------------------------------------------------
 void Start()
 {
     musicFader_ = new Fader(0.0f, 10.0f, 4.0f);
     musicFader_.FadeIn();
     imseqFader_ = new Fader(1.0f, 0.0f, 4.0f);
 }
 private void MyForm_Load(object sender, EventArgs e)
 {
     Fader.FadeIn(this, Fader.FadeSpeed.Normal);
 }
Пример #32
0
 //-------------------------------------------------------------------------
 void Start()
 {
     fader.FadeIn();
 }
Пример #33
0
 private void Start()
 {
     fader.FadeIn();
 }