Exemple #1
0
    void Start()
    {
        // リロード時は処理をしない
        if (YamagenLib.PlayInstructor.instance.IsReload())
        {
            Destroy(gameObject);
        }

        // 演出中断のための入力
        var input = GetComponentInParent <IPlayerInput>();

        // ゴールへの参照
        m_goal = GameObject.Find("GoalEx").GetComponent <GoalDetector>();

        // ワールド座標で移動するので親をヌルヌル
        transform.parent = null;

        StartCoroutine(MoveCamera());

        // ジャンプボタンが押されたら演出中断
        input.OnJumpButtonObservable
        .Where(x => x == true)
        .TakeUntilDestroy(this)
        .Subscribe(_ =>
        {
            StopCoroutine(MoveCamera());
            StopCamera();
        });
    }
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        //改めて取得
        camera          = GameObject.Find("CameraRelation");
        middlePoint     = GameObject.Find("MiddlePoint");
        goal            = GameObject.Find("Goal");
        player          = GameObject.FindGameObjectWithTag("Player");
        playerRigidbody = GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody>();
        if (goal != null)
        {
            goalDetector = goal.GetComponent <GoalDetector>();
        }

        // 各シーンでの処理
        if (currentStageNum == startScene)
        {
            audioSource[0].PlayOneShot(titleSound);
            clearTime = new List <float> {
                0.0f, 0.0f, 0.0f
            };                                                // 時間をリセット
        }
        else if (currentStageNum == clearScene)
        {
            stage1ResultText = GameObject.Find("Stage1ResultText").GetComponent <Text>();
            stage2ResultText = GameObject.Find("Stage2ResultText").GetComponent <Text>();
            stage3ResultText = GameObject.Find("Stage3ResultText").GetComponent <Text>();
            endResultText    = GameObject.Find("EndResultText").GetComponent <Text>();

            // 各ステージのクリアタイムの合計を計算
            float totalTime = 0.0f;
            for (int i = 0; i < clearTime.Count; i++)
            {
                totalTime += clearTime[i];
            }
            // 各ステージと合計のタイムを表示
            stage1ResultText.text = "Stage1: " + timeShaping(clearTime[0]);
            stage2ResultText.text = "Stage2: " + timeShaping(clearTime[1]);
            stage3ResultText.text = "Stage3: " + timeShaping(clearTime[2]);
            endResultText.text    = "TotalTime: " + timeShaping(totalTime);
            // クリア時の効果音を流す
            for (int i = 0; i < gameClearSounds.Length; i++)
            {
                audioSource[0].PlayOneShot(gameClearSounds[i]);
            }
        }
        else // startSceneとclearScene以外ではBGMを流す
        {
            audioSource[1].Play(); // BGM
            measureTimeFlag = true; //このフラグがある時のみタイムを計測する
        }
    }
Exemple #3
0
    void Awake()
    {
        ball          = ballGO.GetComponent <Ball>();
        lPlayer       = lPlayerGO.GetComponent <PlayerController>();
        rPlayer       = rPlayerGO.GetComponent <PlayerController>();
        lGoalDetector = lGoalDetectorGO.GetComponent <GoalDetector>();
        rGoalDetector = rGoalDetectorGO.GetComponent <GoalDetector>();
        noticeText    = noticeGO.GetComponent <Text>();
        timerText     = timerGO.GetComponent <Text>();

        if (GameOptions.touchControls)
        {
            touchControlsGO.SetActive(true);
        }
        else
        {
            touchControlsGO.SetActive(false);
        }

        if (GameOptions.goalLimit == 1)
        {
            noticeText.text = "Golden Goal!";
        }
        else
        {
            noticeText.text = "First player to score " + GameOptions.goalLimit + " goals wins!";
        }
        noticeGO.SetActive(true);

        if (GameOptions.timeLimit == 0)
        {
            timedGame = false;
        }

        timeDelay      = resetTime + ball.kickoffDelay;
        Time.timeScale = 1;
        Invoke("StartUp", resetTime);

        if (GameOptions.items)
        {
            InvokeRepeating("SpawnItem", 1f, 1f);
        }
    }
Exemple #4
0
        private void mapComponent_SceneFinished(object sender, MapComponentEventArgs e)
        {
            SpriteRenderer currentTop = Owner.FindComponent <SpriteRenderer>(r => r.Name == "TopRenderer");

            goal += currentTop.Size.X;

            MapComponent mapComponent = Owner.FirstComponentOfType <MapComponent>();

            // Scenet loppuivat, kartta on suoritettu.
            if (!mapComponent.TryToScene())
            {
                return;
            }

            Console.WriteLine("Scene finished");

            // Uusien renderöijien alustus.
            SpriteRenderer nextTop = CreateRenderer("NextTop", e.Next.TopAssetName);

            nextTop.Position = new Vector2(goal, 0.0f);

            SpriteRenderer nextBottom = CreateRenderer("NextBottom", e.Next.BottomAssetName);

            nextBottom.Position = new Vector2(goal, nextTop.Size.Y);

            // Uusien seinien alustus.
            GameObject upper = CreateWall("NextUpperWall", new Vector2(nextBottom.Position.X, nextBottom.Position.Y + 70f), new Vector2(nextBottom.Size.X, 8f));
            GameObject lower = CreateWall("NextLowerWall", new Vector2(nextBottom.Position.X, nextBottom.Position.Y + nextBottom.Size.Y), new Vector2(nextBottom.Size.X, 8f));
            GameObject left  = CreateWall("NextLeftWall", new Vector2(nextBottom.Position.X - 8f, nextBottom.Position.Y), new Vector2(8f, nextBottom.Size.Y));
            GameObject right = CreateWall("NextRightWall", new Vector2(nextBottom.Position.X + nextBottom.Size.X, nextBottom.Position.Y), new Vector2(8f, nextBottom.Size.Y));

            // Tuhotaan vasen seinä jotta päästään liikkumaan.
            GameObject currentRight = Owner.Game.FindGameObject(g => g.Name == "RightWall");

            Owner.Game.World.RemoveBody(currentRight.Body);
            currentRight.Disable();

            // Disabloidaan lefti jotta päästään kävelemään läpi.
            Owner.Game.World.RemoveBody(left.Body);
            left.Disable();

#if DEBUG
            currentRight.Hide();
            left.Hide();
#endif

            GameObject   player       = Owner.Game.FindGameObject(g => g.Name.Contains("Player"));
            GoalDetector goalDetector = new GoalDetector(player, new Vector2(goal + currentTop.Size.X * 0.5f, 0.0f));

            player.AddComponent(goalDetector);

            goalDetector.AtGoal += goalDetector_AtGoal;
            goalDetector.Initialize();

            // TODO: debug.
            TextRenderer arrowRenderer = new TextRenderer(Owner)
            {
                Font        = Owner.Game.Content.Load <SpriteFont>("default"),
                Text        = "UNKLE GO HIER PLS =>",
                ScaleX      = 0.25f,
                ScaleY      = 0.25f,
                Y           = 150f,
                X           = nextTop.X - 200f,
                FollowOwner = false
            };

            Owner.AddComponent(nextTop);
            Owner.AddComponent(nextBottom);
            Owner.AddComponent(arrowRenderer);

            Owner.InitializeComponents();

            area = new Rectangle(area.X, area.Y, area.Width + (int)goal, area.Height);
        }
Exemple #5
0
        private void goalDetector_AtGoal(object sender, GameObjectComponentEventArgs e)
        {
            GameObject player = Owner.Game.FindGameObject(g => g.Name.Contains("Player"));

            GoalDetector goalDetector = player.FirstComponentOfType <GoalDetector>();

            player.RemoveComponent(goalDetector);

            goalDetector.AtGoal -= goalDetector_AtGoal;

            // Swapataan renderöijät.
            SpriteRenderer currentTop = Owner.FindComponent <SpriteRenderer>(r => r.Name == "TopRenderer");
            SpriteRenderer nextTop    = Owner.FindComponent <SpriteRenderer>(r => r.Name == "NextTop");

            SpriteRenderer currentBottom = Owner.FindComponent <SpriteRenderer>(r => r.Name == "BottomRenderer");
            SpriteRenderer nextBottom    = Owner.FindComponent <SpriteRenderer>(r => r.Name == "NextBottom");

            // Swapataan nimet.
            nextTop.Name    = currentTop.Name;
            nextBottom.Name = currentBottom.Name;

            TextRenderer arrowRenderer = Owner.FirstComponentOfType <TextRenderer>();

            // Poistetaan vanhat renderöijät ja nuolen piirtäjä.
            Owner.RemoveComponent(currentTop);
            Owner.RemoveComponent(currentBottom);
            Owner.RemoveComponent(arrowRenderer);

            // Swapataan seinät.
            GameObject upper = Owner.Game.FindGameObject(g => g.Name == "UpperWall");
            GameObject lower = Owner.Game.FindGameObject(g => g.Name == "LowerWall");
            GameObject left  = Owner.Game.FindGameObject(g => g.Name == "LeftWall");
            GameObject right = Owner.Game.FindGameObject(g => g.Name == "RightWall");

            // Tuhotaan vanhat seinät.
            upper.Destroy();
            lower.Destroy();
            left.Destroy();
            right.Destroy();

            GameObject nextUpper = Owner.Game.FindGameObject(g => g.Name == "NextUpperWall");
            GameObject nextLower = Owner.Game.FindGameObject(g => g.Name == "NextLowerWall");
            GameObject nextLeft  = Owner.Game.FindGameObject(g => g.Name == "NextLeftWall");
            GameObject nextRight = Owner.Game.FindGameObject(g => g.Name == "NextRightWall");

            // Swapataan nimet.
            nextUpper.Name = upper.Name;
            nextLower.Name = lower.Name;
            nextLeft.Name  = left.Name;
            nextRight.Name = right.Name;

            // Poistetaan text renderöijä.
            TextRenderer textRenderer = Owner.FirstComponentOfType <TextRenderer>();

            Owner.RemoveComponent(textRenderer);

            Owner.Game.World.CreateBody(nextLeft.Body, CollisionSettings.ObstacleCollisionGroup);
            nextLeft.Enable();

#if DEBUG
            nextLeft.Show();
#endif

            Console.WriteLine("at goal");

            Owner.FirstComponentOfType <MapComponent>().StartNextScene();

            area = new Rectangle(area.Width / 2, area.Y, area.Width / 2, area.Height);
        }